static void assertExpectedMessages(MultiValueMap<String, TestWord> receivedMessages)
{
- MultiValueMap<String, TestWord> expected = new LinkedMultiValueMap<>();
- expectedMessages.forEach(keyValue -> expected.add(keyValue.key, keyValue.value));
await("Received expected messages")
.atMost(Duration.ofSeconds(5))
- .untilAsserted(() -> expected.forEach((user, word) ->
+ .untilAsserted(() -> expectedMessages().forEach((user, word) ->
assertThat(receivedMessages.get(user)).containsExactlyElementsOf(word)));
}
- static Stream<KeyValue<String, TestWord>> expectedMessages = Stream.of(
+ static final KeyValue<String, TestWord>[] EXPECTED_MESSAGES = new KeyValue[]
+ {
KeyValue.pair(
"peter",
TestWord.of("peter", "Hallo")),
TestWord.of("peter", "nä")),
KeyValue.pair(
"peter",
- TestWord.of("peter", "Nümmäh")));
+ TestWord.of("peter", "Nümmäh")),
+ };
+
+ static MultiValueMap<String, TestWord> expectedMessages()
+ {
+ MultiValueMap<String, TestWord> expectedMessages = new LinkedMultiValueMap<>();
+ Stream
+ .of(EXPECTED_MESSAGES)
+ .forEach(keyValue -> expectedMessages.add(keyValue.key, keyValue.value));
+ return expectedMessages;
+ }
}