From f08dc87a018fb2cd84de1a274c20fb9f4487b7a0 Mon Sep 17 00:00:00 2001 From: Kai Moritz Date: Mon, 27 May 2024 21:53:26 +0200 Subject: [PATCH] counter: 1.2.15 - Refined `TestData.writeInputData(..)` --- .../kafka/wordcount/counter/TestData.java | 51 +++++++------------ 1 file changed, 18 insertions(+), 33 deletions(-) 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 1687a33..ea33cb0 100644 --- a/src/test/java/de/juplo/kafka/wordcount/counter/TestData.java +++ b/src/test/java/de/juplo/kafka/wordcount/counter/TestData.java @@ -19,41 +19,26 @@ class TestData { static void writeInputData(BiConsumer 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 receivedMessages) { expectedMessages.forEach( -- 2.20.1