From 3a18c26e5eab2d0e18139b0e76e4d93e08fc4036 Mon Sep 17 00:00:00 2001 From: Kai Moritz Date: Fri, 15 Sep 2023 13:28:27 +0200 Subject: [PATCH] VORTASTEN --- .../chat/backend/KafkaConfigurationIT.java | 2 ++ .../kafka/KafkaChatHomeServiceTest.java | 2 ++ .../implementation/kafka/KafkaTestUtils.java | 21 ++++++++++--------- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/src/test/java/de/juplo/kafka/chat/backend/KafkaConfigurationIT.java b/src/test/java/de/juplo/kafka/chat/backend/KafkaConfigurationIT.java index 04caad66..ee9ab92f 100644 --- a/src/test/java/de/juplo/kafka/chat/backend/KafkaConfigurationIT.java +++ b/src/test/java/de/juplo/kafka/chat/backend/KafkaConfigurationIT.java @@ -54,6 +54,8 @@ class KafkaConfigurationIT extends AbstractConfigurationWithShardingIT { KafkaTestUtils.sendAndLoadStoredData( messageTemplate, + INFO_TOPIC, + DATA_TOPIC, consumerTaskRunner); } diff --git a/src/test/java/de/juplo/kafka/chat/backend/implementation/kafka/KafkaChatHomeServiceTest.java b/src/test/java/de/juplo/kafka/chat/backend/implementation/kafka/KafkaChatHomeServiceTest.java index 33d26003..394ba1b3 100644 --- a/src/test/java/de/juplo/kafka/chat/backend/implementation/kafka/KafkaChatHomeServiceTest.java +++ b/src/test/java/de/juplo/kafka/chat/backend/implementation/kafka/KafkaChatHomeServiceTest.java @@ -49,6 +49,8 @@ public class KafkaChatHomeServiceTest extends ChatHomeServiceWithShardsTest { KafkaTestUtils.sendAndLoadStoredData( messageTemplate, + INFO_TOPIC, + DATA_TOPIC, consumerTaskRunner); } diff --git a/src/test/java/de/juplo/kafka/chat/backend/implementation/kafka/KafkaTestUtils.java b/src/test/java/de/juplo/kafka/chat/backend/implementation/kafka/KafkaTestUtils.java index e19473b3..7ba713db 100644 --- a/src/test/java/de/juplo/kafka/chat/backend/implementation/kafka/KafkaTestUtils.java +++ b/src/test/java/de/juplo/kafka/chat/backend/implementation/kafka/KafkaTestUtils.java @@ -14,9 +14,6 @@ import org.springframework.kafka.support.SendResult; import java.time.Clock; import java.util.List; -import static de.juplo.kafka.chat.backend.implementation.kafka.KafkaChatHomeServiceTest.DATA_TOPIC; -import static de.juplo.kafka.chat.backend.implementation.kafka.KafkaChatHomeServiceTest.INFO_TOPIC; - @Slf4j public class KafkaTestUtils @@ -27,12 +24,14 @@ public class KafkaTestUtils static class KafkaTestConfiguration { @Bean - WorkAssignor dataChannelWorkAssignor(DataChannel dataChannel) + WorkAssignor dataChannelWorkAssignor( + ChatBackendProperties properties, + DataChannel dataChannel) { return consumer -> { List assignedPartitions = - List.of(new TopicPartition(DATA_TOPIC, 2)); + List.of(new TopicPartition(properties.getKafka().getInfoChannelTopic(), 2)); consumer.assign(assignedPartitions); dataChannel.onPartitionsAssigned(assignedPartitions); }; @@ -48,13 +47,15 @@ public class KafkaTestUtils public static void sendAndLoadStoredData( KafkaTemplate messageTemplate, + String infoTopic, + String dataTopic, ConsumerTaskRunner consumerTaskRunner) { - send(messageTemplate, INFO_TOPIC, "5c73531c-6fc4-426c-adcb-afc5c140a0f7","{ \"id\": \"5c73531c-6fc4-426c-adcb-afc5c140a0f7\", \"shard\": 2, \"name\": \"FOO\" }", "event_chatroom_created"); - send(messageTemplate, DATA_TOPIC, "5c73531c-6fc4-426c-adcb-afc5c140a0f7","{ \"id\" : 1, \"user\" : \"peter\", \"text\" : \"Hallo, ich heiße Peter!\" }", "event_chatmessage_received"); - send(messageTemplate, DATA_TOPIC, "5c73531c-6fc4-426c-adcb-afc5c140a0f7","{ \"id\" : 1, \"user\" : \"ute\", \"text\" : \"Ich bin Ute...\" }", "event_chatmessage_received"); - send(messageTemplate, DATA_TOPIC, "5c73531c-6fc4-426c-adcb-afc5c140a0f7","{ \"id\" : 2, \"user\" : \"peter\", \"text\" : \"Willst du mit mir gehen?\" }", "event_chatmessage_received"); - send(messageTemplate, DATA_TOPIC, "5c73531c-6fc4-426c-adcb-afc5c140a0f7","{ \"id\" : 1, \"user\" : \"klaus\", \"text\" : \"Ja? Nein? Vielleicht??\" }", "event_chatmessage_received"); + send(messageTemplate, infoTopic, "5c73531c-6fc4-426c-adcb-afc5c140a0f7","{ \"id\": \"5c73531c-6fc4-426c-adcb-afc5c140a0f7\", \"shard\": 2, \"name\": \"FOO\" }", "event_chatroom_created"); + send(messageTemplate, dataTopic, "5c73531c-6fc4-426c-adcb-afc5c140a0f7","{ \"id\" : 1, \"user\" : \"peter\", \"text\" : \"Hallo, ich heiße Peter!\" }", "event_chatmessage_received"); + send(messageTemplate, dataTopic, "5c73531c-6fc4-426c-adcb-afc5c140a0f7","{ \"id\" : 1, \"user\" : \"ute\", \"text\" : \"Ich bin Ute...\" }", "event_chatmessage_received"); + send(messageTemplate, dataTopic, "5c73531c-6fc4-426c-adcb-afc5c140a0f7","{ \"id\" : 2, \"user\" : \"peter\", \"text\" : \"Willst du mit mir gehen?\" }", "event_chatmessage_received"); + send(messageTemplate, dataTopic, "5c73531c-6fc4-426c-adcb-afc5c140a0f7","{ \"id\" : 1, \"user\" : \"klaus\", \"text\" : \"Ja? Nein? Vielleicht??\" }", "event_chatmessage_received"); consumerTaskRunner.run(); } -- 2.20.1