splitter: 1.2.0 - Renamed classes for test-input/-output -- ALIGN
authorKai Moritz <kai@juplo.de>
Sun, 2 Jun 2024 16:36:26 +0000 (18:36 +0200)
committerKai Moritz <kai@juplo.de>
Mon, 3 Jun 2024 07:34:40 +0000 (09:34 +0200)
src/test/java/de/juplo/kafka/wordcount/counter/TestOutputWord.java
src/test/java/de/juplo/kafka/wordcount/recorder/TestInputRecording.java
src/test/java/de/juplo/kafka/wordcount/splitter/SplitterApplicationIT.java
src/test/java/de/juplo/kafka/wordcount/splitter/TestData.java

index 0453671..7dcc66a 100644 (file)
@@ -8,7 +8,7 @@ import lombok.NoArgsConstructor;
 @Data
 @NoArgsConstructor
 @AllArgsConstructor(staticName = "of")
-public class TestWord
+public class TestOutputWord
 {
   String user;
   String word;
index 2d09896..a62b1b4 100644 (file)
@@ -8,7 +8,7 @@ import lombok.NoArgsConstructor;
 @Data
 @NoArgsConstructor
 @AllArgsConstructor(staticName = "of")
-public class TestRecording
+public class TestInputRecording
 {
   String user;
   String sentence;
index b91af13..891a435 100644 (file)
@@ -1,7 +1,7 @@
 package de.juplo.kafka.wordcount.splitter;
 
-import de.juplo.kafka.wordcount.counter.TestWord;
-import de.juplo.kafka.wordcount.recorder.TestRecording;
+import de.juplo.kafka.wordcount.counter.TestOutputWord;
+import de.juplo.kafka.wordcount.recorder.TestInputRecording;
 import lombok.extern.slf4j.Slf4j;
 import org.junit.jupiter.api.BeforeAll;
 import org.junit.jupiter.api.Test;
@@ -51,7 +51,7 @@ public class SplitterApplicationIT
 
        @BeforeAll
        public static void testSendMessage(
-                       @Autowired KafkaTemplate<String, TestRecording> kafkaTemplate)
+                       @Autowired KafkaTemplate<String, TestInputRecording> kafkaTemplate)
        {
                TestData
                                .getInputMessages()
@@ -59,7 +59,7 @@ public class SplitterApplicationIT
                                {
                                        try
                                        {
-                                               SendResult<String, TestRecording> result = kafkaTemplate.send(TOPIC_IN, kv.key, kv.value).get();
+                                               SendResult<String, TestInputRecording> result = kafkaTemplate.send(TOPIC_IN, kv.key, kv.value).get();
                                                log.info(
                                                                "Sent: {}={}, partition={}, offset={}",
                                                                result.getProducerRecord().key(),
@@ -87,18 +87,18 @@ public class SplitterApplicationIT
 
        static class Consumer
        {
-               private final MultiValueMap<String, TestWord> received = new LinkedMultiValueMap<>();
+               private final MultiValueMap<String, TestOutputWord> received = new LinkedMultiValueMap<>();
 
                @KafkaListener(groupId = "TEST", topics = TOPIC_OUT)
                public synchronized void receive(
                                @Header(KafkaHeaders.RECEIVED_KEY) String key,
-                               @Payload TestWord value)
+                               @Payload TestOutputWord value)
                {
                        log.debug("Received message: {}={}", key, value);
                        received.add(key, value);
                }
 
-               synchronized MultiValueMap<String, TestWord> getReceivedMessages()
+               synchronized MultiValueMap<String, TestOutputWord> getReceivedMessages()
                {
                        return received;
                }
index a3f7575..feedb1e 100644 (file)
@@ -1,7 +1,7 @@
 package de.juplo.kafka.wordcount.splitter;
 
-import de.juplo.kafka.wordcount.counter.TestWord;
-import de.juplo.kafka.wordcount.recorder.TestRecording;
+import de.juplo.kafka.wordcount.counter.TestOutputWord;
+import de.juplo.kafka.wordcount.recorder.TestInputRecording;
 import org.apache.kafka.streams.KeyValue;
 import org.springframework.util.LinkedMultiValueMap;
 import org.springframework.util.MultiValueMap;
@@ -19,25 +19,25 @@ public class TestData
        static final String KLAUS = "klaus";
 
 
-       static final Stream<KeyValue<String, TestRecording>> getInputMessages()
+       static final Stream<KeyValue<String, TestInputRecording>> getInputMessages()
        {
                return Stream.of(INPUT_MESSAGES);
        }
 
-       private static final KeyValue<String, TestRecording>[] INPUT_MESSAGES = new KeyValue[]
+       private static final KeyValue<String, TestInputRecording>[] INPUT_MESSAGES = new KeyValue[]
        {
                        new KeyValue<>(
                                        PETER,
-                                       TestRecording.of(PETER, "Hallo Welt!")),
+                                       TestInputRecording.of(PETER, "Hallo Welt!")),
                        new KeyValue<>(
                                        KLAUS,
-                                       TestRecording.of(KLAUS, "Müsch gäb's auch!")),
+                                       TestInputRecording.of(KLAUS, "Müsch gäb's auch!")),
                        new KeyValue<>(
                                        PETER,
-                                       TestRecording.of(PETER, "Boäh, echt! ß mal nä Nümmäh!")),
+                                       TestInputRecording.of(PETER, "Boäh, echt! ß mal nä Nümmäh!")),
        };
 
-       static void assertExpectedMessages(MultiValueMap<String, TestWord> receivedMessages)
+       static void assertExpectedMessages(MultiValueMap<String, TestOutputWord> receivedMessages)
        {
                await("Received expected messages")
                                .atMost(Duration.ofSeconds(5))
@@ -45,49 +45,49 @@ public class TestData
                                                assertThat(receivedMessages.get(user)).containsExactlyElementsOf(word)));
        }
 
-       private static final KeyValue<String, TestWord>[] EXPECTED_MESSAGES = new KeyValue[]
+       private static final KeyValue<String, TestOutputWord>[] EXPECTED_MESSAGES = new KeyValue[]
        {
                        KeyValue.pair(
                                        "peter",
-                                       TestWord.of("peter", "Hallo")),
+                                       TestOutputWord.of("peter", "Hallo")),
                        KeyValue.pair(
                                        "peter",
-                                       TestWord.of("peter", "Welt")),
+                                       TestOutputWord.of("peter", "Welt")),
                        KeyValue.pair(
                                        "klaus",
-                                       TestWord.of("klaus", "Müsch")),
+                                       TestOutputWord.of("klaus", "Müsch")),
                        KeyValue.pair(
                                        "klaus",
-                                       TestWord.of("klaus", "gäb")),
+                                       TestOutputWord.of("klaus", "gäb")),
                        KeyValue.pair(
                                        "klaus",
-                                       TestWord.of("klaus", "s")),
+                                       TestOutputWord.of("klaus", "s")),
                        KeyValue.pair(
                                        "klaus",
-                                       TestWord.of("klaus", "auch")),
+                                       TestOutputWord.of("klaus", "auch")),
                        KeyValue.pair(
                                        "peter",
-                                       TestWord.of("peter", "Boäh")),
+                                       TestOutputWord.of("peter", "Boäh")),
                        KeyValue.pair(
                                        "peter",
-                                       TestWord.of("peter", "echt")),
+                                       TestOutputWord.of("peter", "echt")),
                        KeyValue.pair(
                                        "peter",
-                                       TestWord.of("peter", "ß")),
+                                       TestOutputWord.of("peter", "ß")),
                        KeyValue.pair(
                                        "peter",
-                                       TestWord.of("peter", "mal")),
+                                       TestOutputWord.of("peter", "mal")),
                        KeyValue.pair(
                                        "peter",
-                                       TestWord.of("peter", "nä")),
+                                       TestOutputWord.of("peter", "nä")),
                        KeyValue.pair(
                                        "peter",
-                                       TestWord.of("peter", "Nümmäh")),
+                                       TestOutputWord.of("peter", "Nümmäh")),
        };
 
-       static MultiValueMap<String, TestWord> expectedMessages()
+       static MultiValueMap<String, TestOutputWord> expectedMessages()
        {
-               MultiValueMap<String, TestWord> expectedMessages = new LinkedMultiValueMap<>();
+               MultiValueMap<String, TestOutputWord> expectedMessages = new LinkedMultiValueMap<>();
                Stream
                                .of(EXPECTED_MESSAGES)
                                .forEach(keyValue -> expectedMessages.add(keyValue.key, keyValue.value));