### Question:
GroupTopicExtractor implements Function<T, String> { @Override public String apply(T t) { return topicsByGroup.get(groupExtractor.apply(t)); } GroupTopicExtractor(GroupExtractor<T> groupExtractor, Map<?, String> topicsByGroup); @Override String apply(T t);  }### Answer:
@Test public void topicCanBeExtractedFromGrouping() { TestData data = TestData.create(); GroupExtractor<TestData> groupExtractor = new FieldValueGroupExtractor<>("data1"); Function<TestData, String> topicExtractor = new GroupTopicExtractor<>(groupExtractor, Collections.singletonMap(data.getData1(), "TOPIC")); assertEquals("TOPIC", topicExtractor.apply(data)); }