assertRankingEqualsRankingFromLastMessage(KLAUS, store.get(KLAUS));
}
+ static void assertExpectedNumberOfMessagesForUsers(MultiValueMap<User, Ranking> receivedMessages)
+ {
+ assertThat(countMessagesForUser(PETER, receivedMessages));
+ assertThat(countMessagesForUser(KLAUS, receivedMessages));
+ }
+
+ static int countMessagesForUser(User user, MultiValueMap<User, Ranking> messagesForUsers)
+ {
+ return messagesForUsers.get(user).size();
+ }
+
+
static void assertExpectedLastMessagesForUsers(MultiValueMap<User, Ranking> receivedMessages)
{
assertRankingEqualsRankingFromLastMessage(PETER, getLastMessageFor(PETER, receivedMessages));
.untilAsserted(() -> TestData.assertExpectedMessages(consumer.getReceivedMessages()));
}
+ @DisplayName("Await the expected number of messages")
+ @Test
+ public void testAwaitExpectedNumberOfMessagesForUsers()
+ {
+ await("Expected number of messages")
+ .atMost(Duration.ofSeconds(5))
+ .untilAsserted(() -> TestData.assertExpectedNumberOfMessagesForUsers(consumer.getReceivedMessages()));
+ }
+
@DisplayName("Await the expected final output messages")
@Test
public void testAwaitExpectedLastMessagesForUsers()
TestData.assertExpectedMessages(receivedMessages);
+ TestData.assertExpectedNumberOfMessagesForUsers(receivedMessages);
TestData.assertExpectedLastMessagesForUsers(receivedMessages);
KeyValueStore<User, Ranking> store = testDriver.getKeyValueStore(STORE_NAME);