static void assertExpectedState(ReadOnlyKeyValueStore<User, Ranking> store)
{
- assertThat(store.get(EXPECTED_MESSAGES[9].key)).isEqualTo(EXPECTED_MESSAGES[9].value);
- assertThat(store.get(EXPECTED_MESSAGES[10].key)).isEqualTo(EXPECTED_MESSAGES[10].value);
+ assertRankingEqualsRankingFromLastMessage(PETER, store.get(PETER));
+ assertRankingEqualsRankingFromLastMessage(KLAUS, store.get(KLAUS));
+ }
+
+ static void assertRankingEqualsRankingFromLastMessage(User user, Ranking ranking)
+ {
+ assertThat(ranking).isEqualTo(getLastMessageFor(user));
+ }
+
+ static Ranking getLastMessageFor(User user)
+ {
+ return getLastMessageFor(user, expectedMessages());
+ }
+
+ static Ranking getLastMessageFor(User user, MultiValueMap<User, Ranking> messagesForUsers)
+ {
+ return messagesForUsers
+ .get(user)
+ .stream()
+ .reduce(null, (left, right) -> right);
}
static KeyValue<User, Ranking>[] EXPECTED_MESSAGES = new KeyValue[]