</parent>
<groupId>de.juplo.kafka.wordcount</groupId>
<artifactId>top10</artifactId>
- <version>1.1.2</version>
+ <version>1.1.3</version>
<name>Wordcount-Top-10</name>
<description>Top-10 stream-processor of the multi-user wordcount-example</description>
<properties>
.isThrownBy(() -> ranking.add(Entry.of(entry.getWord(), entry.getCounter() - 1))));
}
+ @DisplayName("Identical rankings are considered equal")
+ @ParameterizedTest
+ @MethodSource("validRankingsProvider")
+ public void testIdenticalRankingsAreConsideredEaqual(List<Entry> entryList)
+ {
+ assertThat(Ranking.of(toArray(entryList))).isEqualTo(Ranking.of(toArray(entryList)));
+ }
+
+ @DisplayName("Two empty rankings are considered equal")
+ @Test
+ public void testTwoEmptyRankingsAreConsideredEaqual()
+ {
+ assertThat(Ranking.of()).isEqualTo(Ranking.of());
+ }
+
+ @DisplayName("A changed ranking is not considered equal to its unchanged counter-part")
+ @ParameterizedTest
+ @MethodSource("validRankingsProvider")
+ public void testChangedRankingsDoNotEaqualUnchangedOne(List<Entry> entryList)
+ {
+ Ranking changed = Ranking.of(toArray(entryList));
+ changed.add(Entry.of("devilish", 666l));
+ assertThat(changed).isNotEqualTo(Ranking.of(toArray(entryList)));
+ }
+
+ @DisplayName("Rankigs are considered equal, if only the order of words with the same count differ")
+ @Test
+ public void testRankingWithDifferentOrderForSameCountAreEqual()
+ {
+ assertThat(
+ Ranking.of(
+ Entry.of("a1",10l),
+ Entry.of("a2",10l),
+ Entry.of("b1", 9l),
+ Entry.of("b2",9l),
+ Entry.of("c1", 8l),
+ Entry.of("c2", 8l)))
+ .isEqualTo(Ranking.of(
+ Entry.of("a2",10l),
+ Entry.of("a1",10l),
+ Entry.of("b2", 9l),
+ Entry.of("b1",9l),
+ Entry.of("c2", 8l),
+ Entry.of("c1", 8l)));
+ }
+
Entry[] toArray(List<Entry> entryList)
{