From: Kai Moritz Date: Sun, 2 Jun 2024 11:44:28 +0000 (+0200) Subject: splitter: 1.2.0 - `TestData.assertExpectedResult(..)` X-Git-Tag: splitter-1.2.0~8 X-Git-Url: http://juplo.de/gitweb/?a=commitdiff_plain;h=c9663d885810c20447e31d48f1d5b3de3b90e229;p=demos%2Fkafka%2Fwordcount splitter: 1.2.0 - `TestData.assertExpectedResult(..)` --- 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; + } }