From f502218a12fe5ca72fcc15898ef942daa7c20224 Mon Sep 17 00:00:00 2001 From: Kai Moritz Date: Tue, 14 May 2024 23:42:07 +0200 Subject: [PATCH] WIP --- .../juplo/kafka/wordcount/top10/Ranking.java | 7 ++- .../juplo/kafka/wordcount/top10/TestData.java | 55 ++++++++++++++++++- 2 files changed, 60 insertions(+), 2 deletions(-) diff --git a/src/main/java/de/juplo/kafka/wordcount/top10/Ranking.java b/src/main/java/de/juplo/kafka/wordcount/top10/Ranking.java index cc08f4b..1d64a57 100644 --- a/src/main/java/de/juplo/kafka/wordcount/top10/Ranking.java +++ b/src/main/java/de/juplo/kafka/wordcount/top10/Ranking.java @@ -7,7 +7,7 @@ import java.util.LinkedList; import java.util.List; -@AllArgsConstructor(staticName = "of") +@AllArgsConstructor(access = AccessLevel.PRIVATE) @NoArgsConstructor @Data public class Ranking @@ -50,4 +50,9 @@ public class Ranking } } } + + public static Ranking of(Entry... entries) + { + return new Ranking(entries); + } } diff --git a/src/test/java/de/juplo/kafka/wordcount/top10/TestData.java b/src/test/java/de/juplo/kafka/wordcount/top10/TestData.java index fd18d26..fb030e3 100644 --- a/src/test/java/de/juplo/kafka/wordcount/top10/TestData.java +++ b/src/test/java/de/juplo/kafka/wordcount/top10/TestData.java @@ -77,7 +77,60 @@ class TestData { KeyValue.pair( "peter", - Ranking.of("peter","Hallo",1)), + Ranking.of( + Entry.of("Hallo", 1l))), + KeyValue.pair( + "klaus", + Ranking.of( + Entry.of("Müsch", 1l))), + KeyValue.pair( + "peter", + Ranking.of( + Entry.of("Hallo", 1l), + Entry.of("Welt", 1l))), + KeyValue.pair( + "klaus", + Ranking.of( + Entry.of("Müsch", 2l))), + KeyValue.pair( + "klaus", + Ranking.of( + Entry.of("Müsch", 2l), + Entry.of("s", 1l))), + KeyValue.pair( + "peter", + Ranking.of( + Entry.of("Hallo", 1l), + Entry.of("Welt", 1l), + Entry.of("Boäh", 1l))), + KeyValue.pair( + "peter", + Ranking.of( + Entry.of("Welt", 2l), + Entry.of("Hallo", 1l), + Entry.of("Boäh", 1l))), + KeyValue.pair( + "peter", + Ranking.of( + Entry.of("Welt", 2l), + Entry.of("Boäh", 2l), + Entry.of("Hallo", 1l))), + KeyValue.pair( + "klaus", + Ranking.of( + Entry.of("Müsch", 2l), + Entry.of("s", 2l))), + KeyValue.pair( + "peter", + Ranking.of( + Entry.of("Boäh", 3l), + Entry.of("Welt", 2l), + Entry.of("Hallo", 1l))), + KeyValue.pair( + "klaus", + Ranking.of( + Entry.of("s", 3l), + Entry.of("Müsch", 2l))), }; static Map convertToMap(Properties properties) -- 2.20.1