From: Kai Moritz Date: Sun, 2 Jun 2024 16:36:26 +0000 (+0200) Subject: splitter: 1.2.0 - Renamed classes for test-input/-output -- ALIGN X-Git-Tag: splitter-1.2.0~4 X-Git-Url: http://juplo.de/gitweb/?a=commitdiff_plain;h=47ed803476f547b79439b510d409c81d7d85db53;p=demos%2Fkafka%2Fwordcount splitter: 1.2.0 - Renamed classes for test-input/-output -- ALIGN --- diff --git a/src/test/java/de/juplo/kafka/wordcount/counter/TestOutputWord.java b/src/test/java/de/juplo/kafka/wordcount/counter/TestOutputWord.java index 0453671..7dcc66a 100644 --- a/src/test/java/de/juplo/kafka/wordcount/counter/TestOutputWord.java +++ b/src/test/java/de/juplo/kafka/wordcount/counter/TestOutputWord.java @@ -8,7 +8,7 @@ import lombok.NoArgsConstructor; @Data @NoArgsConstructor @AllArgsConstructor(staticName = "of") -public class TestWord +public class TestOutputWord { String user; String word; diff --git a/src/test/java/de/juplo/kafka/wordcount/recorder/TestInputRecording.java b/src/test/java/de/juplo/kafka/wordcount/recorder/TestInputRecording.java index 2d09896..a62b1b4 100644 --- a/src/test/java/de/juplo/kafka/wordcount/recorder/TestInputRecording.java +++ b/src/test/java/de/juplo/kafka/wordcount/recorder/TestInputRecording.java @@ -8,7 +8,7 @@ import lombok.NoArgsConstructor; @Data @NoArgsConstructor @AllArgsConstructor(staticName = "of") -public class TestRecording +public class TestInputRecording { String user; String sentence; diff --git a/src/test/java/de/juplo/kafka/wordcount/splitter/SplitterApplicationIT.java b/src/test/java/de/juplo/kafka/wordcount/splitter/SplitterApplicationIT.java index b91af13..891a435 100644 --- a/src/test/java/de/juplo/kafka/wordcount/splitter/SplitterApplicationIT.java +++ b/src/test/java/de/juplo/kafka/wordcount/splitter/SplitterApplicationIT.java @@ -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 kafkaTemplate) + @Autowired KafkaTemplate kafkaTemplate) { TestData .getInputMessages() @@ -59,7 +59,7 @@ public class SplitterApplicationIT { try { - SendResult result = kafkaTemplate.send(TOPIC_IN, kv.key, kv.value).get(); + SendResult 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 received = new LinkedMultiValueMap<>(); + private final MultiValueMap 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 getReceivedMessages() + synchronized MultiValueMap getReceivedMessages() { return received; } diff --git a/src/test/java/de/juplo/kafka/wordcount/splitter/TestData.java b/src/test/java/de/juplo/kafka/wordcount/splitter/TestData.java index a3f7575..feedb1e 100644 --- a/src/test/java/de/juplo/kafka/wordcount/splitter/TestData.java +++ b/src/test/java/de/juplo/kafka/wordcount/splitter/TestData.java @@ -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> getInputMessages() + static final Stream> getInputMessages() { return Stream.of(INPUT_MESSAGES); } - private static final KeyValue[] INPUT_MESSAGES = new KeyValue[] + private static final KeyValue[] 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 receivedMessages) + static void assertExpectedMessages(MultiValueMap 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[] EXPECTED_MESSAGES = new KeyValue[] + private static final KeyValue[] 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 expectedMessages() + static MultiValueMap expectedMessages() { - MultiValueMap expectedMessages = new LinkedMultiValueMap<>(); + MultiValueMap expectedMessages = new LinkedMultiValueMap<>(); Stream .of(EXPECTED_MESSAGES) .forEach(keyValue -> expectedMessages.add(keyValue.key, keyValue.value));