X-Git-Url: https://juplo.de/gitweb/?a=blobdiff_plain;f=src%2Ftest%2Fjava%2Fde%2Fjuplo%2Fkafka%2Fwordcount%2Fcounter%2FTestData.java;h=43e1919b585c446a45832f081cecb275a0dd40ea;hb=35943a021ac4b25fad29861ecc083b6974ea2732;hp=5798fc3d437355c1fe75df2fa0e9ee84da25c786;hpb=4e10b6e106409b2884fcef67f7a5ded0581bc35f;p=demos%2Fkafka%2Fwordcount diff --git a/src/test/java/de/juplo/kafka/wordcount/counter/TestData.java b/src/test/java/de/juplo/kafka/wordcount/counter/TestData.java index 5798fc3..43e1919 100644 --- a/src/test/java/de/juplo/kafka/wordcount/counter/TestData.java +++ b/src/test/java/de/juplo/kafka/wordcount/counter/TestData.java @@ -3,7 +3,10 @@ package de.juplo.kafka.wordcount.counter; import org.apache.kafka.streams.KeyValue; import java.util.List; +import java.util.Map; +import java.util.Properties; import java.util.function.BiConsumer; +import java.util.stream.Collectors; import static org.assertj.core.api.Assertions.assertThat; @@ -47,7 +50,7 @@ class TestData Word.of("klaus","s")); } - static void assertExpectedResult(List> receivedMessages) + static void assertExpectedResult(List> receivedMessages) { assertThat(receivedMessages).hasSize(11); assertThat(receivedMessages).containsSubsequence( @@ -68,40 +71,52 @@ class TestData expectedMessages[9]); // Boäh } - static KeyValue[] expectedMessages = new KeyValue[] + static KeyValue[] expectedMessages = new KeyValue[] { KeyValue.pair( Word.of("peter","Hallo"), - WordCount.of("peter","Hallo",1)), + WordCounter.of("peter","Hallo",1)), KeyValue.pair( Word.of("klaus","Müsch"), - WordCount.of("klaus","Müsch",1)), + WordCounter.of("klaus","Müsch",1)), KeyValue.pair( Word.of("peter","Welt"), - WordCount.of("peter","Welt",1)), + WordCounter.of("peter","Welt",1)), KeyValue.pair( Word.of("klaus","Müsch"), - WordCount.of("klaus","Müsch",2)), + WordCounter.of("klaus","Müsch",2)), KeyValue.pair( Word.of("klaus","s"), - WordCount.of("klaus","s",1)), + WordCounter.of("klaus","s",1)), KeyValue.pair( Word.of("peter","Boäh"), - WordCount.of("peter","Boäh",1)), + WordCounter.of("peter","Boäh",1)), KeyValue.pair( Word.of("peter","Welt"), - WordCount.of("peter","Welt",2)), + WordCounter.of("peter","Welt",2)), KeyValue.pair( Word.of("peter","Boäh"), - WordCount.of("peter","Boäh",2)), + WordCounter.of("peter","Boäh",2)), KeyValue.pair( Word.of("klaus","s"), - WordCount.of("klaus","s",2)), + WordCounter.of("klaus","s",2)), KeyValue.pair( Word.of("peter","Boäh"), - WordCount.of("peter","Boäh",3)), + WordCounter.of("peter","Boäh",3)), KeyValue.pair( Word.of("klaus","s"), - WordCount.of("klaus","s",3)), + WordCounter.of("klaus","s",3)), }; + + static Map convertToMap(Properties properties) + { + return properties + .entrySet() + .stream() + .collect( + Collectors.toMap( + entry -> (String)entry.getKey(), + entry -> entry.getValue() + )); + } }