counter: 1.2.15 - Refined `TestData.writeInputData(..)`
authorKai Moritz <kai@juplo.de>
Mon, 27 May 2024 19:53:26 +0000 (21:53 +0200)
committerKai Moritz <kai@juplo.de>
Sat, 8 Jun 2024 11:33:30 +0000 (13:33 +0200)
src/test/java/de/juplo/kafka/wordcount/counter/TestData.java

index 1687a33..ea33cb0 100644 (file)
@@ -19,41 +19,26 @@ class TestData
 {
        static void writeInputData(BiConsumer<String, Word> consumer)
        {
-               consumer.accept(
-                               "peter",
-                               Word.of("peter","Hallo"));
-               consumer.accept(
-                               "klaus",
-                               Word.of("klaus","Müsch"));
-               consumer.accept(
-                               "peter",
-                               Word.of("peter","Welt"));
-               consumer.accept(
-                               "klaus",
-                               Word.of("klaus","Müsch"));
-               consumer.accept(
-                               "klaus",
-                               Word.of("klaus","s"));
-               consumer.accept(
-                               "peter",
-                               Word.of("peter","Boäh"));
-               consumer.accept(
-                               "peter",
-                               Word.of("peter","Welt"));
-               consumer.accept(
-                               "peter",
-                               Word.of("peter","Boäh"));
-               consumer.accept(
-                               "klaus",
-                               Word.of("klaus","s"));
-               consumer.accept(
-                               "peter",
-                               Word.of("peter","Boäh"));
-               consumer.accept(
-                               "klaus",
-                               Word.of("klaus","s"));
+               Stream
+                               .of(inputMessagesArray)
+                               .forEach(word -> consumer.accept(word.getUser(), word));
        }
 
+       static Word[] inputMessagesArray = new Word[]
+       {
+                       Word.of("peter","Hallo"),
+                       Word.of("klaus","Müsch"),
+                       Word.of("peter","Welt"),
+                       Word.of("klaus","Müsch"),
+                       Word.of("klaus","s"),
+                       Word.of("peter","Boäh"),
+                       Word.of("peter","Welt"),
+                       Word.of("peter","Boäh"),
+                       Word.of("klaus","s"),
+                       Word.of("peter","Boäh"),
+                       Word.of("klaus","s"),
+       };
+
        static void assertExpectedResult(MultiValueMap<Word, WordCounter> receivedMessages)
        {
                expectedMessages.forEach(