From 8d0426539d69616900f4d6ef19e52d50b497f57f Mon Sep 17 00:00:00 2001 From: Kai Moritz Date: Sat, 8 Jun 2024 12:26:10 +0200 Subject: [PATCH] counter: 1.2.15 - Inlined the asserting ``Consumer``s --- .../wordcount/counter/CounterApplicationIT.java | 9 ++++++--- .../juplo/kafka/wordcount/counter/TestData.java | 16 ---------------- 2 files changed, 6 insertions(+), 19 deletions(-) diff --git a/src/test/java/de/juplo/kafka/wordcount/counter/CounterApplicationIT.java b/src/test/java/de/juplo/kafka/wordcount/counter/CounterApplicationIT.java index a53ffc8..9995ce7 100644 --- a/src/test/java/de/juplo/kafka/wordcount/counter/CounterApplicationIT.java +++ b/src/test/java/de/juplo/kafka/wordcount/counter/CounterApplicationIT.java @@ -91,7 +91,8 @@ public class CounterApplicationIT { await("Expected number of messages") .atMost(Duration.ofSeconds(5)) - .untilAsserted(() -> consumer.enforceAssertion(TestData.expectedNumberOfMessagesForWordAssertion())); + .untilAsserted(() -> consumer.enforceAssertion( + receivedMessages -> TestData.assertExpectedNumberOfMessagesForWord(receivedMessages))); } @DisplayName("Await the expected output messages") @@ -100,7 +101,8 @@ public class CounterApplicationIT { await("Expected messages") .atMost(Duration.ofSeconds(10)) - .untilAsserted(() -> consumer.enforceAssertion(TestData.expectedMessagesAssertion())); + .untilAsserted(() -> consumer.enforceAssertion( + receivedMessages -> TestData.assertExpectedMessages(receivedMessages))); } @DisplayName("Await the expected final output messages") @@ -109,7 +111,8 @@ public class CounterApplicationIT { await("Expected final output messages") .atMost(Duration.ofSeconds(5)) - .untilAsserted(() -> consumer.enforceAssertion(TestData.expectedLastMessagesForWordAssertion())); + .untilAsserted(() -> consumer.enforceAssertion( + receivedMessages -> TestData.assertExpectedLastMessagesForWord(receivedMessages))); } @DisplayName("Await the expected state in the state-store") 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 4e431e1..7446db6 100644 --- a/src/test/java/de/juplo/kafka/wordcount/counter/TestData.java +++ b/src/test/java/de/juplo/kafka/wordcount/counter/TestData.java @@ -8,7 +8,6 @@ import org.apache.kafka.streams.state.ReadOnlyKeyValueStore; import org.springframework.util.LinkedMultiValueMap; import org.springframework.util.MultiValueMap; -import java.util.function.Consumer; import java.util.stream.Stream; import static org.assertj.core.api.Assertions.assertThat; @@ -73,11 +72,6 @@ class TestData return Stream.of(TestData.INPUT_MESSAGES); } - static Consumer> expectedMessagesAssertion() - { - return receivedMessages -> assertExpectedMessages(receivedMessages); - } - static void assertExpectedMessages(MultiValueMap receivedMessages) { expectedMessages().forEach( @@ -86,11 +80,6 @@ class TestData .containsExactlyElementsOf(counter)); } - static Consumer> expectedNumberOfMessagesForWordAssertion() - { - return receivedMessages -> assertExpectedNumberOfMessagesForWord(receivedMessages); - } - static void assertExpectedNumberOfMessagesForWord(MultiValueMap receivedMessages) { assertThat(countMessagesForWord(PETER_HALLO, receivedMessages)); @@ -105,11 +94,6 @@ class TestData return messagesForUsers.get(word).size(); } - static Consumer> expectedLastMessagesForWordAssertion() - { - return receivedMessages -> assertExpectedLastMessagesForWord(receivedMessages); - } - static void assertExpectedState(ReadOnlyKeyValueStore store) { assertWordCountEqualsWordCountFromLastMessage(PETER_HALLO, store.get(wordOf(PETER_HALLO))); -- 2.20.1