SystemConfig extends MapConfig { public Optional<String> getSystemFactory(String systemName) { if (systemName == null) { return Optional.empty(); } String systemFactory = String.format(SYSTEM_FACTORY_FORMAT, systemName); String value = get(systemFactory, null); return (StringUtils.isBlank(value)) ? Optional.empty() : Optional.of(value); } SystemConfig(Config config); Optional<String> getSystemFactory(String systemName); List<String> getSystemNames(); Map<String, SystemAdmin> getSystemAdmins(String adminLabel); Map<String, SystemAdmin> getSystemAdmins(); SystemAdmin getSystemAdmin(String systemName, String adminLabel); SystemAdmin getSystemAdmin(String systemName); Map<String, SystemFactory> getSystemFactories(); Config getDefaultStreamProperties(String systemName); String getSystemOffsetDefault(String systemName); Optional<String> getSystemKeySerde(String systemName); Optional<String> getSystemMsgSerde(String systemName); boolean deleteCommittedMessages(String systemName); static final String SYSTEM_ID_PREFIX; static final String SYSTEM_FACTORY_FORMAT; static final String SYSTEM_DEFAULT_STREAMS_PREFIX_FORMAT; }
@Test public void testGetSystemFactory() { Map<String, String> map = new HashMap<>(); map.put(MOCK_SYSTEM_FACTORY_NAME1, MOCK_SYSTEM_FACTORY_CLASSNAME1); SystemConfig systemConfig = new SystemConfig(new MapConfig(map)); assertEquals(MOCK_SYSTEM_FACTORY_CLASSNAME1, systemConfig.getSystemFactory(MOCK_SYSTEM_NAME1).get()); }
@Test public void testGetSystemFactoryEmptyClassName() { Map<String, String> map = new HashMap<>(); map.put(MOCK_SYSTEM_FACTORY_NAME1, ""); map.put(MOCK_SYSTEM_FACTORY_NAME2, " "); SystemConfig systemConfig = new SystemConfig(new MapConfig(map)); assertFalse(systemConfig.getSystemFactory(MOCK_SYSTEM_NAME1).isPresent()); assertFalse(systemConfig.getSystemFactory(MOCK_SYSTEM_NAME2).isPresent()); }