counter: 1.2.12 - Renamed `WordCount` into `WordCounter` -- ALIGN
[demos/kafka/wordcount] / src / test / java / de / juplo / kafka / wordcount / counter / CounterApplicationIT.java
index 158c6ae..5a3507a 100644 (file)
@@ -5,6 +5,7 @@ import lombok.extern.slf4j.Slf4j;
 import org.apache.kafka.clients.consumer.ConsumerConfig;
 import org.apache.kafka.clients.consumer.ConsumerRecord;
 import org.apache.kafka.clients.producer.ProducerConfig;
+import org.apache.kafka.streams.KeyValue;
 import org.apache.kafka.streams.state.KeyValueBytesStoreSupplier;
 import org.apache.kafka.streams.state.Stores;
 import org.junit.jupiter.api.BeforeEach;
@@ -26,9 +27,9 @@ import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
 import java.util.Properties;
-import java.util.stream.Collectors;
 
 import static de.juplo.kafka.wordcount.counter.CounterApplicationIT.*;
+import static de.juplo.kafka.wordcount.counter.TestData.convertToMap;
 import static org.awaitility.Awaitility.*;
 
 
@@ -75,16 +76,16 @@ public class CounterApplicationIT
        @RequiredArgsConstructor
        static class Consumer
        {
-               private final List<Message> received = new LinkedList<>();
+               private final List<KeyValue<Word, WordCounter>> received = new LinkedList<>();
 
                @KafkaListener(groupId = "TEST", topics = TOPIC_OUT)
-               public synchronized void receive(ConsumerRecord<Word, WordCount> record)
+               public synchronized void receive(ConsumerRecord<Word, WordCounter> record)
                {
                        log.debug("Received message: {}", record);
-                       received.add(Message.of(record.key(),record.value()));
+                       received.add(KeyValue.pair(record.key(),record.value()));
                }
 
-               synchronized List<Message> getReceivedMessages()
+               synchronized List<KeyValue<Word, WordCounter>> getReceivedMessages()
                {
                        return received;
                }
@@ -96,14 +97,7 @@ public class CounterApplicationIT
                @Bean
                ProducerFactory<?, ?> producerFactory(Properties streamProcessorProperties)
                {
-                       Map<String, Object> propertyMap = streamProcessorProperties
-                                       .entrySet()
-                                       .stream()
-                                       .collect(
-                                                       Collectors.toMap(
-                                                                       entry -> (String)entry.getKey(),
-                                                                       entry -> entry.getValue()
-                                                       ));
+                       Map<String, Object> propertyMap = convertToMap(streamProcessorProperties);
 
                        propertyMap.put(
                                        ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG,
@@ -119,14 +113,7 @@ public class CounterApplicationIT
                ConcurrentKafkaListenerContainerFactory<?, ?> kafkaListenerContainerFactory(
                                Properties streamProcessorProperties)
                {
-                       Map<String, Object> propertyMap = streamProcessorProperties
-                                       .entrySet()
-                                       .stream()
-                                       .collect(
-                                                       Collectors.toMap(
-                                                                       entry -> (String)entry.getKey(),
-                                                                       entry -> entry.getValue()
-                                                       ));
+                       Map<String, Object> propertyMap = convertToMap(streamProcessorProperties);
 
                        propertyMap.put(
                                        ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG,