WIP rebase--2023-09-14--22-59
authorKai Moritz <kai@juplo.de>
Wed, 13 Sep 2023 22:15:22 +0000 (00:15 +0200)
committerKai Moritz <kai@juplo.de>
Wed, 13 Sep 2023 22:15:22 +0000 (00:15 +0200)
src/test/java/de/juplo/kafka/chat/backend/implementation/kafka/KafkaChatHomeServiceTest.java

index 33b4144..781781b 100644 (file)
@@ -18,9 +18,12 @@ import org.springframework.context.annotation.Import;
 import org.springframework.kafka.core.KafkaTemplate;
 import org.springframework.kafka.support.SendResult;
 import org.springframework.kafka.test.context.EmbeddedKafka;
+import org.testcontainers.shaded.org.awaitility.Awaitility;
 
 import java.time.Clock;
+import java.time.Duration;
 import java.util.List;
+import java.util.UUID;
 
 import static de.juplo.kafka.chat.backend.domain.ChatHomeServiceWithShardsTest.NUM_SHARDS;
 import static de.juplo.kafka.chat.backend.implementation.kafka.KafkaChatHomeServiceTest.DATA_TOPIC;
@@ -59,10 +62,19 @@ public class KafkaChatHomeServiceTest extends ChatHomeServiceWithShardsTest
   static class KafkaChatHomeTestConfiguration
   {
     @Bean
-    KafkaServicesApplicationRunner.WorkAssignor workAssignor(DataChannel dataChannel)
+    KafkaServicesApplicationRunner.WorkAssignor workAssignor(
+        InfoChannel infoChannel,
+        DataChannel dataChannel)
     {
       return consumer ->
       {
+        // TODO: Darauf warten, dass der Chat-Room erzeugt wurde!
+        Awaitility
+            .await()
+            .atMost(Duration.ofSeconds(10))
+            .until(() -> infoChannel
+                .getChatRoomInfo(UUID.fromString("5c73531c-6fc4-426c-adcb-afc5c140a0f7"))
+                .block() != null);
         List<TopicPartition> assignedPartitions =
             List.of(new TopicPartition(DATA_TOPIC, 2));
         consumer.assign(assignedPartitions);