splitter: 1.2.0 - A domain-class (``User``) is used as key
[demos/kafka/wordcount] / src / test / java / de / juplo / kafka / wordcount / splitter / TestData.java
index feedb1e..f89b099 100644 (file)
@@ -1,7 +1,9 @@
 package de.juplo.kafka.wordcount.splitter;
 
+import de.juplo.kafka.wordcount.counter.TestOutputUser;
 import de.juplo.kafka.wordcount.counter.TestOutputWord;
 import de.juplo.kafka.wordcount.recorder.TestInputRecording;
+import de.juplo.kafka.wordcount.recorder.TestInputUser;
 import org.apache.kafka.streams.KeyValue;
 import org.springframework.util.LinkedMultiValueMap;
 import org.springframework.util.MultiValueMap;
@@ -15,29 +17,29 @@ import static org.awaitility.Awaitility.await;
 
 public class TestData
 {
-       static final String PETER = "peter";
-       static final String KLAUS = "klaus";
+       static final TestInputUser PETER = TestInputUser.of("peter");
+       static final TestInputUser KLAUS = TestInputUser.of("klaus");
 
 
-       static final Stream<KeyValue<String, TestInputRecording>> getInputMessages()
+       static final Stream<KeyValue<TestInputUser, TestInputRecording>> getInputMessages()
        {
                return Stream.of(INPUT_MESSAGES);
        }
 
-       private static final KeyValue<String, TestInputRecording>[] INPUT_MESSAGES = new KeyValue[]
+       private static final KeyValue<TestInputUser, TestInputRecording>[] INPUT_MESSAGES = new KeyValue[]
        {
                        new KeyValue<>(
                                        PETER,
-                                       TestInputRecording.of(PETER, "Hallo Welt!")),
+                                       TestInputRecording.of(PETER.getUser(), "Hallo Welt!")),
                        new KeyValue<>(
                                        KLAUS,
-                                       TestInputRecording.of(KLAUS, "Müsch gäb's auch!")),
+                                       TestInputRecording.of(KLAUS.getUser(), "Müsch gäb's auch!")),
                        new KeyValue<>(
                                        PETER,
-                                       TestInputRecording.of(PETER, "Boäh, echt! ß mal nä Nümmäh!")),
+                                       TestInputRecording.of(PETER.getUser(), "Boäh, echt! ß mal nä Nümmäh!")),
        };
 
-       static void assertExpectedMessages(MultiValueMap<String, TestOutputWord> receivedMessages)
+       static void assertExpectedMessages(MultiValueMap<TestOutputUser, TestOutputWord> receivedMessages)
        {
                await("Received expected messages")
                                .atMost(Duration.ofSeconds(5))
@@ -45,49 +47,49 @@ public class TestData
                                                assertThat(receivedMessages.get(user)).containsExactlyElementsOf(word)));
        }
 
-       private static final KeyValue<String, TestOutputWord>[] EXPECTED_MESSAGES = new KeyValue[]
+       private static final KeyValue<TestOutputUser, TestOutputWord>[] EXPECTED_MESSAGES = new KeyValue[]
        {
                        KeyValue.pair(
-                                       "peter",
-                                       TestOutputWord.of("peter", "Hallo")),
+                                       TestOutputUser.of(PETER.getUser()),
+                                       TestOutputWord.of(PETER.getUser(), "Hallo")),
                        KeyValue.pair(
-                                       "peter",
-                                       TestOutputWord.of("peter", "Welt")),
+                                       TestOutputUser.of(PETER.getUser()),
+                                       TestOutputWord.of(PETER.getUser(), "Welt")),
                        KeyValue.pair(
-                                       "klaus",
-                                       TestOutputWord.of("klaus", "Müsch")),
+                                       TestOutputUser.of(KLAUS.getUser()),
+                                       TestOutputWord.of(KLAUS.getUser(), "Müsch")),
                        KeyValue.pair(
-                                       "klaus",
-                                       TestOutputWord.of("klaus", "gäb")),
+                                       TestOutputUser.of(KLAUS.getUser()),
+                                       TestOutputWord.of(KLAUS.getUser(), "gäb")),
                        KeyValue.pair(
-                                       "klaus",
-                                       TestOutputWord.of("klaus", "s")),
+                                       TestOutputUser.of(KLAUS.getUser()),
+                                       TestOutputWord.of(KLAUS.getUser(), "s")),
                        KeyValue.pair(
-                                       "klaus",
-                                       TestOutputWord.of("klaus", "auch")),
+                                       TestOutputUser.of(KLAUS.getUser()),
+                                       TestOutputWord.of(KLAUS.getUser(), "auch")),
                        KeyValue.pair(
-                                       "peter",
-                                       TestOutputWord.of("peter", "Boäh")),
+                                       TestOutputUser.of(PETER.getUser()),
+                                       TestOutputWord.of(PETER.getUser(), "Boäh")),
                        KeyValue.pair(
-                                       "peter",
-                                       TestOutputWord.of("peter", "echt")),
+                                       TestOutputUser.of(PETER.getUser()),
+                                       TestOutputWord.of(PETER.getUser(), "echt")),
                        KeyValue.pair(
-                                       "peter",
-                                       TestOutputWord.of("peter", "ß")),
+                                       TestOutputUser.of(PETER.getUser()),
+                                       TestOutputWord.of(PETER.getUser(), "ß")),
                        KeyValue.pair(
-                                       "peter",
-                                       TestOutputWord.of("peter", "mal")),
+                                       TestOutputUser.of(PETER.getUser()),
+                                       TestOutputWord.of(PETER.getUser(), "mal")),
                        KeyValue.pair(
-                                       "peter",
-                                       TestOutputWord.of("peter", "nä")),
+                                       TestOutputUser.of(PETER.getUser()),
+                                       TestOutputWord.of(PETER.getUser(), "nä")),
                        KeyValue.pair(
-                                       "peter",
-                                       TestOutputWord.of("peter", "Nümmäh")),
+                                       TestOutputUser.of(PETER.getUser()),
+                                       TestOutputWord.of(PETER.getUser(), "Nümmäh")),
        };
 
-       static MultiValueMap<String, TestOutputWord> expectedMessages()
+       static MultiValueMap<TestOutputUser, TestOutputWord> expectedMessages()
        {
-               MultiValueMap<String, TestOutputWord> expectedMessages = new LinkedMultiValueMap<>();
+               MultiValueMap<TestOutputUser, TestOutputWord> expectedMessages = new LinkedMultiValueMap<>();
                Stream
                                .of(EXPECTED_MESSAGES)
                                .forEach(keyValue -> expectedMessages.add(keyValue.key, keyValue.value));