stats: 1.0.0 - Added a test that asserts, that foreign stats are ignored
authorKai Moritz <kai@juplo.de>
Tue, 25 Jun 2024 04:23:33 +0000 (06:23 +0200)
committerKai Moritz <kai@juplo.de>
Tue, 25 Jun 2024 16:35:28 +0000 (18:35 +0200)
src/main/java/de/juplo/kafka/wordcount/stats/StatisticsType.java [new file with mode: 0644]
src/test/java/de/juplo/kafka/wordcount/stats/TestData.java

diff --git a/src/main/java/de/juplo/kafka/wordcount/stats/StatisticsType.java b/src/main/java/de/juplo/kafka/wordcount/stats/StatisticsType.java
new file mode 100644 (file)
index 0000000..c8f6e09
--- /dev/null
@@ -0,0 +1,7 @@
+package de.juplo.kafka.wordcount.stats;
+
+public enum StatisticsType
+{
+  POPULAR,
+  SPEAKERS
+}
index 1603619..28dfe71 100644 (file)
@@ -10,14 +10,14 @@ import java.util.Arrays;
 import java.util.function.Function;
 import java.util.stream.Stream;
 
-import static de.juplo.kafka.wordcount.stats.StatsStreamProcessor.STATS_TYPE;
 import static org.assertj.core.api.Assertions.assertThat;
 
 
 class TestData
 {
-       static final TestUser PETER = TestUser.of(STATS_TYPE, "peter");
-       static final TestUser KLAUS = TestUser.of(STATS_TYPE, "klaus");
+       static final TestUser PETER = TestUser.of(StatisticsType.POPULAR.name(), "peter");
+       static final TestUser KLAUS = TestUser.of(StatisticsType.POPULAR.name(), "klaus");
+       static final TestUser OTHER_CHANNEL = TestUser.of("COUNTER", "klaus");
 
        static final Stream<KeyValue<TestUser, TestRanking>> getTop10Messages()
        {
@@ -80,6 +80,10 @@ class TestData
                                        PETER,
                                        TestRanking.of(
                                                        TestEntry.of("Hallo", 1l))),
+                       KeyValue.pair( // BOOM!
+                                       OTHER_CHANNEL,
+                                       TestRanking.of(
+                                                       TestEntry.of("Müsch", 1l))),
                        KeyValue.pair( // 1
                                        KLAUS,
                                        TestRanking.of(
@@ -121,6 +125,11 @@ class TestData
                                        TestRanking.of(
                                                        TestEntry.of("Müsch", 2l),
                                                        TestEntry.of("s", 2l))),
+                       KeyValue.pair( // BOOM!
+                                       KLAUS,
+                                       TestRanking.of(
+                                                       TestEntry.of("Müsch", 2l),
+                                                       TestEntry.of("s", 2l))),
                        KeyValue.pair( // 9
                                        PETER,
                                        TestRanking.of(