splitter: 1.2.0 - Refined `TestData` clearified concerns
authorKai Moritz <kai@juplo.de>
Sun, 2 Jun 2024 16:03:15 +0000 (18:03 +0200)
committerKai Moritz <kai@juplo.de>
Mon, 3 Jun 2024 07:34:40 +0000 (09:34 +0200)
src/test/java/de/juplo/kafka/wordcount/splitter/SplitterApplicationIT.java
src/test/java/de/juplo/kafka/wordcount/splitter/TestData.java

index 743c06e..b91af13 100644 (file)
@@ -20,7 +20,6 @@ import org.springframework.util.LinkedMultiValueMap;
 import org.springframework.util.MultiValueMap;
 
 import java.time.Duration;
-import java.util.stream.Stream;
 
 import static de.juplo.kafka.wordcount.splitter.SplitterApplicationIT.TOPIC_IN;
 import static de.juplo.kafka.wordcount.splitter.SplitterApplicationIT.TOPIC_OUT;
@@ -54,8 +53,8 @@ public class SplitterApplicationIT
        public static void testSendMessage(
                        @Autowired KafkaTemplate<String, TestRecording> kafkaTemplate)
        {
-               Stream
-                               .of(TestData.INPUT_MESSAGES)
+               TestData
+                               .getInputMessages()
                                .forEach(kv ->
                                {
                                        try
index 8c343d5..a3f7575 100644 (file)
@@ -19,7 +19,12 @@ public class TestData
        static final String KLAUS = "klaus";
 
 
-       static final KeyValue<String, TestRecording>[] INPUT_MESSAGES = new KeyValue[]
+       static final Stream<KeyValue<String, TestRecording>> getInputMessages()
+       {
+               return Stream.of(INPUT_MESSAGES);
+       }
+
+       private static final KeyValue<String, TestRecording>[] INPUT_MESSAGES = new KeyValue[]
        {
                        new KeyValue<>(
                                        PETER,
@@ -40,7 +45,7 @@ public class TestData
                                                assertThat(receivedMessages.get(user)).containsExactlyElementsOf(word)));
        }
 
-       static final KeyValue<String, TestWord>[] EXPECTED_MESSAGES = new KeyValue[]
+       private static final KeyValue<String, TestWord>[] EXPECTED_MESSAGES = new KeyValue[]
        {
                        KeyValue.pair(
                                        "peter",