From c9663d885810c20447e31d48f1d5b3de3b90e229 Mon Sep 17 00:00:00 2001 From: Kai Moritz Date: Sun, 2 Jun 2024 13:44:28 +0200 Subject: [PATCH] splitter: 1.2.0 - `TestData.assertExpectedResult(..)` --- .../kafka/wordcount/splitter/TestData.java | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/test/java/de/juplo/kafka/wordcount/splitter/TestData.java b/src/test/java/de/juplo/kafka/wordcount/splitter/TestData.java index 2af8644..e2bf9cc 100644 --- a/src/test/java/de/juplo/kafka/wordcount/splitter/TestData.java +++ b/src/test/java/de/juplo/kafka/wordcount/splitter/TestData.java @@ -41,15 +41,14 @@ public class TestData static void assertExpectedMessages(MultiValueMap receivedMessages) { - MultiValueMap expected = new LinkedMultiValueMap<>(); - expectedMessages.forEach(keyValue -> expected.add(keyValue.key, keyValue.value)); await("Received expected messages") .atMost(Duration.ofSeconds(5)) - .untilAsserted(() -> expected.forEach((user, word) -> + .untilAsserted(() -> expectedMessages().forEach((user, word) -> assertThat(receivedMessages.get(user)).containsExactlyElementsOf(word))); } - static Stream> expectedMessages = Stream.of( + static final KeyValue[] EXPECTED_MESSAGES = new KeyValue[] + { KeyValue.pair( "peter", TestWord.of("peter", "Hallo")), @@ -85,5 +84,15 @@ public class TestData TestWord.of("peter", "nä")), KeyValue.pair( "peter", - TestWord.of("peter", "Nümmäh"))); + TestWord.of("peter", "Nümmäh")), + }; + + static MultiValueMap expectedMessages() + { + MultiValueMap expectedMessages = new LinkedMultiValueMap<>(); + Stream + .of(EXPECTED_MESSAGES) + .forEach(keyValue -> expectedMessages.add(keyValue.key, keyValue.value)); + return expectedMessages; + } } -- 2.20.1