From: Kai Moritz Date: Sun, 2 Jun 2024 09:10:21 +0000 (+0200) Subject: top10: 1.2.1 - Added expectations for the final state in the last message X-Git-Tag: top10-1.2.1~12 X-Git-Url: http://juplo.de/gitweb/?a=commitdiff_plain;h=33639a3c8ae1ce028d3a273d8d28e9c2472e2a2b;p=demos%2Fkafka%2Fwordcount top10: 1.2.1 - Added expectations for the final state in the last message --- diff --git a/src/test/java/de/juplo/kafka/wordcount/top10/TestData.java b/src/test/java/de/juplo/kafka/wordcount/top10/TestData.java index eb30298..008cdde 100644 --- a/src/test/java/de/juplo/kafka/wordcount/top10/TestData.java +++ b/src/test/java/de/juplo/kafka/wordcount/top10/TestData.java @@ -73,6 +73,12 @@ class TestData assertRankingEqualsRankingFromLastMessage(KLAUS, store.get(KLAUS)); } + static void assertExpectedLastMessagesForUsers(MultiValueMap receivedMessages) + { + assertRankingEqualsRankingFromLastMessage(PETER, getLastMessageFor(PETER, receivedMessages)); + assertRankingEqualsRankingFromLastMessage(KLAUS, getLastMessageFor(KLAUS, receivedMessages)); + } + static void assertRankingEqualsRankingFromLastMessage(User user, Ranking ranking) { assertThat(ranking).isEqualTo(getLastMessageFor(user)); diff --git a/src/test/java/de/juplo/kafka/wordcount/top10/Top10ApplicationIT.java b/src/test/java/de/juplo/kafka/wordcount/top10/Top10ApplicationIT.java index d55048d..d27a9d1 100644 --- a/src/test/java/de/juplo/kafka/wordcount/top10/Top10ApplicationIT.java +++ b/src/test/java/de/juplo/kafka/wordcount/top10/Top10ApplicationIT.java @@ -107,6 +107,15 @@ public class Top10ApplicationIT .untilAsserted(() -> TestData.assertExpectedMessages(consumer.getReceivedMessages())); } + @DisplayName("Await the expected final output messages") + @Test + public void testAwaitExpectedLastMessagesForUsers() + { + await("Expected final output messages") + .atMost(Duration.ofSeconds(5)) + .untilAsserted(() -> TestData.assertExpectedLastMessagesForUsers(consumer.getReceivedMessages())); + } + static class Consumer { diff --git a/src/test/java/de/juplo/kafka/wordcount/top10/Top10StreamProcessorTopologyTest.java b/src/test/java/de/juplo/kafka/wordcount/top10/Top10StreamProcessorTopologyTest.java index 1becd65..200b6f4 100644 --- a/src/test/java/de/juplo/kafka/wordcount/top10/Top10StreamProcessorTopologyTest.java +++ b/src/test/java/de/juplo/kafka/wordcount/top10/Top10StreamProcessorTopologyTest.java @@ -98,6 +98,8 @@ public class Top10StreamProcessorTopologyTest TestData.assertExpectedMessages(receivedMessages); + TestData.assertExpectedLastMessagesForUsers(receivedMessages); + KeyValueStore store = testDriver.getKeyValueStore(STORE_NAME); TestData.assertExpectedState(store); }