{
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")
{
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")
{
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")
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;
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(
.containsExactlyElementsOf(counter));
}
- static Consumer<MultiValueMap<TestOutputWord, TestOutputWordCounter>> expectedNumberOfMessagesForWordAssertion()
- {
- return receivedMessages -> assertExpectedNumberOfMessagesForWord(receivedMessages);
- }
-
static void assertExpectedNumberOfMessagesForWord(MultiValueMap<TestOutputWord, TestOutputWordCounter> receivedMessages)
{
assertThat(countMessagesForWord(PETER_HALLO, receivedMessages));
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)));