From: Kai Moritz Date: Tue, 25 Jun 2024 04:23:33 +0000 (+0200) Subject: stats: 1.0.0 - Added a test that asserts, that foreign stats are ignored X-Git-Tag: stats-1.0.0~1 X-Git-Url: http://juplo.de/gitweb/?a=commitdiff_plain;h=8e5112c52f657efa2ba7265b2e5c4b59a048cf4f;p=demos%2Fkafka%2Fwordcount stats: 1.0.0 - Added a test that asserts, that foreign stats are ignored --- 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 index 0000000..c8f6e09 --- /dev/null +++ b/src/main/java/de/juplo/kafka/wordcount/stats/StatisticsType.java @@ -0,0 +1,7 @@ +package de.juplo.kafka.wordcount.stats; + +public enum StatisticsType +{ + POPULAR, + SPEAKERS +} diff --git a/src/test/java/de/juplo/kafka/wordcount/stats/TestData.java b/src/test/java/de/juplo/kafka/wordcount/stats/TestData.java index 1603619..28dfe71 100644 --- a/src/test/java/de/juplo/kafka/wordcount/stats/TestData.java +++ b/src/test/java/de/juplo/kafka/wordcount/stats/TestData.java @@ -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> 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(