SystemConfig extends MapConfig { public Map<String, SystemFactory> getSystemFactories() { Map<String, SystemFactory> systemFactories = getSystemNames().stream().collect(Collectors.toMap( systemName -> systemName, systemName -> { String systemFactoryClassName = getSystemFactory(systemName).orElseThrow(() -> new SamzaException( String.format("A stream uses system %s, which is missing from the configuration.", systemName))); return ReflectionUtil.getObj(systemFactoryClassName, SystemFactory.class); })); return systemFactories; } 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 testGetSystemFactories() { Map<String, String> map = ImmutableMap.of(MOCK_SYSTEM_FACTORY_NAME1, MockSystemFactory.class.getName()); SystemConfig systemConfig = new SystemConfig(new MapConfig(map)); Map<String, SystemFactory> actual = systemConfig.getSystemFactories(); assertEquals(actual.size(), 1); assertTrue(actual.get(MOCK_SYSTEM_NAME1) instanceof MockSystemFactory); }