SystemConfig extends MapConfig { public Optional<String> getSystemKeySerde(String systemName) { return getSystemDefaultStreamProperty(systemName, StreamConfig.KEY_SERDE); } 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 testGetSystemKeySerde() { String system1KeySerde = "system1-key-serde"; String defaultStreamPrefixSystem1 = buildDefaultStreamPropertiesPrefix(MOCK_SYSTEM_NAME1); Config config = new MapConfig(ImmutableMap.of(defaultStreamPrefixSystem1 + StreamConfig.KEY_SERDE, system1KeySerde)); SystemConfig systemConfig = new SystemConfig(config); assertEquals(system1KeySerde, systemConfig.getSystemKeySerde(MOCK_SYSTEM_NAME1).get()); config = new MapConfig( ImmutableMap.of(String.format(SystemConfig.SYSTEM_ID_PREFIX, MOCK_SYSTEM_NAME1) + StreamConfig.KEY_SERDE, system1KeySerde)); systemConfig = new SystemConfig(config); assertEquals(system1KeySerde, systemConfig.getSystemKeySerde(MOCK_SYSTEM_NAME1).get()); config = new MapConfig(ImmutableMap.of( defaultStreamPrefixSystem1 + StreamConfig.KEY_SERDE, "", String.format(SystemConfig.SYSTEM_ID_PREFIX, MOCK_SYSTEM_NAME1) + StreamConfig.KEY_SERDE, system1KeySerde)); systemConfig = new SystemConfig(config); assertEquals(system1KeySerde, systemConfig.getSystemKeySerde(MOCK_SYSTEM_NAME1).get()); config = new MapConfig( ImmutableMap.of(String.format(SystemConfig.SYSTEM_ID_PREFIX, MOCK_SYSTEM_NAME1) + StreamConfig.KEY_SERDE, "")); systemConfig = new SystemConfig(config); assertFalse(systemConfig.getSystemKeySerde(MOCK_SYSTEM_NAME1).isPresent()); config = new MapConfig(); systemConfig = new SystemConfig(config); assertFalse(systemConfig.getSystemKeySerde(MOCK_SYSTEM_NAME1).isPresent()); }