counter: 1.2.15 - Inlined the asserting ``Consumer``s counter-1.2.15
authorKai Moritz <kai@juplo.de>
Sat, 8 Jun 2024 10:26:10 +0000 (12:26 +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/CounterApplicationIT.java
src/test/java/de/juplo/kafka/wordcount/counter/TestData.java

index a53ffc8..9995ce7 100644 (file)
@@ -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")
index 4e431e1..7446db6 100644 (file)
@@ -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<MultiValueMap<TestOutputWord, TestOutputWordCounter>> expectedMessagesAssertion()
-       {
-               return receivedMessages -> assertExpectedMessages(receivedMessages);
-       }
-
        static void assertExpectedMessages(MultiValueMap<TestOutputWord, TestOutputWordCounter> receivedMessages)
        {
                expectedMessages().forEach(
@@ -86,11 +80,6 @@ class TestData
                                                                .containsExactlyElementsOf(counter));
        }
 
-       static Consumer<MultiValueMap<TestOutputWord, TestOutputWordCounter>> expectedNumberOfMessagesForWordAssertion()
-       {
-               return receivedMessages -> assertExpectedNumberOfMessagesForWord(receivedMessages);
-       }
-
        static void assertExpectedNumberOfMessagesForWord(MultiValueMap<TestOutputWord, TestOutputWordCounter> receivedMessages)
        {
                assertThat(countMessagesForWord(PETER_HALLO, receivedMessages));
@@ -105,11 +94,6 @@ class TestData
                return messagesForUsers.get(word).size();
        }
 
-       static Consumer<MultiValueMap<TestOutputWord, TestOutputWordCounter>> expectedLastMessagesForWordAssertion()
-       {
-               return receivedMessages -> assertExpectedLastMessagesForWord(receivedMessages);
-       }
-
        static void assertExpectedState(ReadOnlyKeyValueStore<Word, Long> store)
        {
                assertWordCountEqualsWordCountFromLastMessage(PETER_HALLO, store.get(wordOf(PETER_HALLO)));