await("Expected messages")
.atMost(Duration.ofSeconds(10))
- .untilAsserted(() -> TestData.assertExpectedMessages(consumer.getReceivedMessages()));
+ .untilAsserted(() -> consumer.enforceAssertion(TestData.expectedMessagesAssertion()));
}
received.add(word, counter);
}
- synchronized MultiValueMap<TestOutputWord, TestOutputWordCounter> getReceivedMessages()
+ synchronized void enforceAssertion(
+ java.util.function.Consumer<MultiValueMap<TestOutputWord, TestOutputWordCounter>> assertion)
{
- return received;
+ assertion.accept(received);
}
}
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(