counter: 1.2.12 - Renamed `WordCount` into `WordCounter` -- ALIGN counter-1.2.12
authorKai Moritz <kai@juplo.de>
Tue, 14 May 2024 19:54:28 +0000 (21:54 +0200)
committerKai Moritz <kai@juplo.de>
Tue, 14 May 2024 20:37:41 +0000 (22:37 +0200)
src/main/java/de/juplo/kafka/wordcount/counter/CounterStreamProcessor.java
src/main/java/de/juplo/kafka/wordcount/counter/WordCounter.java
src/test/java/de/juplo/kafka/wordcount/counter/CounterApplicationIT.java
src/test/java/de/juplo/kafka/wordcount/counter/CounterStreamProcessorTopologyTest.java
src/test/java/de/juplo/kafka/wordcount/counter/TestData.java

index 3dd8c0f..b1343a7 100644 (file)
@@ -50,7 +50,7 @@ public class CounterStreamProcessor
                                .groupByKey()
                                .count(Materialized.as(storeSupplier))
                                .toStream()
-                               .map((word, count) -> new KeyValue<>(word, WordCount.of(word, count)))
+                               .map((word, counter) -> new KeyValue<>(word, WordCounter.of(word, counter)))
                                .to(outputTopic);
 
                Topology topology = builder.build();
index 958f9b7..1334e5b 100644 (file)
@@ -8,14 +8,14 @@ import lombok.NoArgsConstructor;
 @Data
 @NoArgsConstructor
 @AllArgsConstructor(staticName = "of")
-public class WordCount
+public class WordCounter
 {
   String user;
   String word;
-  long count;
+  long counter;
 
-  public static WordCount of(Word word, long count)
+  public static WordCounter of(Word word, long counter)
   {
-    return new WordCount(word.getUser(), word.getWord(), count);
+    return new WordCounter(word.getUser(), word.getWord(), counter);
   }
 }
index e0f4672..5a3507a 100644 (file)
@@ -76,16 +76,16 @@ public class CounterApplicationIT
        @RequiredArgsConstructor
        static class Consumer
        {
-               private final List<KeyValue<Word, WordCount>> received = new LinkedList<>();
+               private final List<KeyValue<Word, WordCounter>> received = new LinkedList<>();
 
                @KafkaListener(groupId = "TEST", topics = TOPIC_OUT)
-               public synchronized void receive(ConsumerRecord<Word, WordCount> record)
+               public synchronized void receive(ConsumerRecord<Word, WordCounter> record)
                {
                        log.debug("Received message: {}", record);
                        received.add(KeyValue.pair(record.key(),record.value()));
                }
 
-               synchronized List<KeyValue<Word, WordCount>> getReceivedMessages()
+               synchronized List<KeyValue<Word, WordCounter>> getReceivedMessages()
                {
                        return received;
                }
index 159123b..b785dfa 100644 (file)
@@ -45,14 +45,14 @@ public class CounterStreamProcessorTopologyTest
         (JsonSerializer<String>)keySerde.serializer(),
         (JsonSerializer<Word>)valueSerde.serializer());
 
-    TestOutputTopic<Word, WordCount> out = testDriver.createOutputTopic(
+    TestOutputTopic<Word, WordCounter> out = testDriver.createOutputTopic(
         OUT,
         (JsonDeserializer<Word>)keySerde.deserializer(),
-        (JsonDeserializer<WordCount>)valueSerde.deserializer());
+        (JsonDeserializer<WordCounter>)valueSerde.deserializer());
 
     TestData.writeInputData((key, value) -> in.pipeInput(key, value));
 
-    List<KeyValue<Word,WordCount>> receivedMessages = out
+    List<KeyValue<Word, WordCounter>> receivedMessages = out
         .readRecordsToList()
         .stream()
         .map(record -> KeyValue.pair(record.key(), record.value()))
index c1dd45a..43e1919 100644 (file)
@@ -50,7 +50,7 @@ class TestData
                                Word.of("klaus","s"));
        }
 
-       static void assertExpectedResult(List<KeyValue<Word, WordCount>> receivedMessages)
+       static void assertExpectedResult(List<KeyValue<Word, WordCounter>> receivedMessages)
        {
                assertThat(receivedMessages).hasSize(11);
                assertThat(receivedMessages).containsSubsequence(
@@ -71,41 +71,41 @@ class TestData
                                expectedMessages[9]); // Boäh
        }
 
-       static KeyValue<Word,WordCount>[] expectedMessages = new KeyValue[]
+       static KeyValue<Word, WordCounter>[] expectedMessages = new KeyValue[]
        {
                        KeyValue.pair(
                                        Word.of("peter","Hallo"),
-                                       WordCount.of("peter","Hallo",1)),
+                                       WordCounter.of("peter","Hallo",1)),
                        KeyValue.pair(
                                        Word.of("klaus","Müsch"),
-                                       WordCount.of("klaus","Müsch",1)),
+                                       WordCounter.of("klaus","Müsch",1)),
                        KeyValue.pair(
                                        Word.of("peter","Welt"),
-                                       WordCount.of("peter","Welt",1)),
+                                       WordCounter.of("peter","Welt",1)),
                        KeyValue.pair(
                                        Word.of("klaus","Müsch"),
-                                       WordCount.of("klaus","Müsch",2)),
+                                       WordCounter.of("klaus","Müsch",2)),
                        KeyValue.pair(
                                        Word.of("klaus","s"),
-                                       WordCount.of("klaus","s",1)),
+                                       WordCounter.of("klaus","s",1)),
                        KeyValue.pair(
                                        Word.of("peter","Boäh"),
-                                       WordCount.of("peter","Boäh",1)),
+                                       WordCounter.of("peter","Boäh",1)),
                        KeyValue.pair(
                                        Word.of("peter","Welt"),
-                                       WordCount.of("peter","Welt",2)),
+                                       WordCounter.of("peter","Welt",2)),
                        KeyValue.pair(
                                        Word.of("peter","Boäh"),
-                                       WordCount.of("peter","Boäh",2)),
+                                       WordCounter.of("peter","Boäh",2)),
                        KeyValue.pair(
                                        Word.of("klaus","s"),
-                                       WordCount.of("klaus","s",2)),
+                                       WordCounter.of("klaus","s",2)),
                        KeyValue.pair(
                                        Word.of("peter","Boäh"),
-                                       WordCount.of("peter","Boäh",3)),
+                                       WordCounter.of("peter","Boäh",3)),
                        KeyValue.pair(
                                        Word.of("klaus","s"),
-                                       WordCount.of("klaus","s",3)),
+                                       WordCounter.of("klaus","s",3)),
        };
 
        static Map<String, Object> convertToMap(Properties properties)