SerializerConfig extends MapConfig { public List<String> getSerdeNames() { List<String> results = new ArrayList<String>(); Config subConfig = subset(String.format(SERIALIZER_PREFIX, ""), true); for (String key : subConfig.keySet()) { if (key.endsWith(".class")) { results.add(key.replace(".class", "")); } } return results; } SerializerConfig(Config config); static String getPredefinedSerdeFactoryName(String serdeName); Optional<String> getSerdeFactoryClass(String name); List<String> getSerdeNames(); static final Logger LOGGER; static final String SERIALIZER_PREFIX; static final String SERDE_FACTORY_CLASS; static final String SERIALIZED_INSTANCE_SUFFIX; static final String SERDE_SERIALIZED_INSTANCE; }
@Test public void testGetSerdeNames() { String otherSerdeName = "otherSerdeName"; String serdeClassName = "my.class.serde.name"; Config config = new MapConfig( ImmutableMap.of(String.format(SerializerConfig.SERDE_FACTORY_CLASS, SERDE_NAME), serdeClassName, String.format(SerializerConfig.SERDE_FACTORY_CLASS, otherSerdeName), serdeClassName)); List<String> serdeNames = new SerializerConfig(config).getSerdeNames(); ImmutableSet<String> expectedSerdeNames = ImmutableSet.of(SERDE_NAME, otherSerdeName); assertEquals(expectedSerdeNames.size(), serdeNames.size()); assertEquals(expectedSerdeNames, ImmutableSet.copyOf(serdeNames)); }