counter: 1.3.0 - Fixed possible NPE in `Counter10ApplicationIT`
[demos/kafka/wordcount] / src / test / java / de / juplo / kafka / wordcount / counter / TestData.java
index 7446db6..1ecfdbd 100644 (file)
@@ -1,5 +1,6 @@
 package de.juplo.kafka.wordcount.counter;
 
+import de.juplo.kafka.wordcount.splitter.TestInputUser;
 import de.juplo.kafka.wordcount.splitter.TestInputWord;
 import de.juplo.kafka.wordcount.top10.TestOutputWord;
 import de.juplo.kafka.wordcount.top10.TestOutputWordCounter;
@@ -30,44 +31,44 @@ class TestData
        static final TestOutputWord KLAUS_MÜSCH = TestOutputWord.of(KLAUS, WORD_MÜSCH);
        static final TestOutputWord KLAUS_S = TestOutputWord.of(KLAUS, WORD_S);
 
-       private static final KeyValue<String, TestInputWord>[] INPUT_MESSAGES = new KeyValue[]
+       private static final KeyValue<TestInputUser, TestInputWord>[] INPUT_MESSAGES = new KeyValue[]
        {
                        new KeyValue<>(
-                                       PETER,
+                                       TestInputUser.of(PETER),
                                        TestInputWord.of(PETER, WORD_HALLO)),
                        new KeyValue<>(
-                                       KLAUS,
+                                       TestInputUser.of(KLAUS),
                                        TestInputWord.of(KLAUS, WORD_MÜSCH)),
                        new KeyValue<>(
-                                       PETER,
+                                       TestInputUser.of(PETER),
                                        TestInputWord.of(PETER, WORD_WELT)),
                        new KeyValue<>(
-                                       KLAUS,
+                                       TestInputUser.of(KLAUS),
                                        TestInputWord.of(KLAUS, WORD_MÜSCH)),
                        new KeyValue<>(
-                                       KLAUS,
+                                       TestInputUser.of(KLAUS),
                                        TestInputWord.of(KLAUS, WORD_S)),
                        new KeyValue<>(
-                                       PETER,
+                                       TestInputUser.of(PETER),
                                        TestInputWord.of(PETER, WORD_BOÄH)),
                        new KeyValue<>(
-                                       PETER,
+                                       TestInputUser.of(PETER),
                                        TestInputWord.of(PETER, WORD_WELT)),
                        new KeyValue<>(
-                                       PETER,
+                                       TestInputUser.of(PETER),
                                        TestInputWord.of(PETER, WORD_BOÄH)),
                        new KeyValue<>(
-                                       KLAUS,
+                                       TestInputUser.of(KLAUS),
                                        TestInputWord.of(KLAUS, WORD_S)),
                        new KeyValue<>(
-                                       PETER,
+                                       TestInputUser.of(PETER),
                                        TestInputWord.of(PETER, WORD_BOÄH)),
                        new KeyValue<>(
-                                       KLAUS,
+                                       TestInputUser.of(KLAUS),
                                        TestInputWord.of(KLAUS, WORD_S)),
        };
 
-       static Stream<KeyValue<String, TestInputWord>> getInputMessages()
+       static Stream<KeyValue<TestInputUser, TestInputWord>> getInputMessages()
        {
                return Stream.of(TestData.INPUT_MESSAGES);
        }
@@ -91,7 +92,9 @@ class TestData
 
        private static int countMessagesForWord(TestOutputWord word, MultiValueMap<TestOutputWord, TestOutputWordCounter> messagesForUsers)
        {
-               return messagesForUsers.get(word).size();
+               return messagesForUsers.get(word) == null
+                               ? 0
+                               : messagesForUsers.get(word).size();
        }
 
        static void assertExpectedState(ReadOnlyKeyValueStore<Word, Long> store)