WIP:test: `*ConfigurationIT` asserts, if restored messages can be seen
[demos/kafka/chat] / src / test / java / de / juplo / kafka / chat / backend / AbstractConfigurationIT.java
index 3e0efd3..451690b 100644 (file)
@@ -23,10 +23,10 @@ import java.time.Duration;
 import java.util.List;
 import java.util.UUID;
 import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.random.RandomGenerator;
 
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.hamcrest.Matchers.endsWith;
-import static pl.rzrz.assertj.reactor.Assertions.assertThat;
 
 
 @Slf4j
@@ -251,44 +251,16 @@ public abstract class AbstractConfigurationIT
   }
 
   @Test
-  @DisplayName("Restored messages can be seen, when listening to restored chat-room")
-  void testListenToRestoredChatRoomYieldsRestoredMessages()
-  {
-    Awaitility
-        .await()
-        .atMost(Duration.ofSeconds(15))
-        .untilAsserted(() ->
-        {
-          Flux<MessageTo> result = webTestClient
-              .get()
-              .uri(
-                  "http://localhost:{port}/{chatRoomId}/listen",
-                  port,
-                  EXISTING_CHATROOM)
-              .accept(MediaType.TEXT_EVENT_STREAM)
-              .exchange()
-              .expectStatus().isOk()
-              .returnResult(MessageTo.class)
-              .getResponseBody();
-
-          List<MessageTo> messages = result
-              .take(expectedExistingMessages.length)
-              .collectList()
-              .block();
-          assertThat(messages).containsExactly(expectedExistingMessages);
-        });
-  }
-
-  @Test
-  @DisplayName("Newly send messages can be seen, when listening to restored chat-room")
-  void testListenToRestoredChatRoomYieldsAddedMessages()
+  @DisplayName("Only newly send messages can be seen, when listening to restored chat-room")
+  void testListenToRestoredChatRoomYieldsOnlyNewlyAddedMessages()
   {
     MessageTo sentMessage = webTestClient
         .put()
         .uri(
-            "http://localhost:{port}/{chatRoomId}/nerd/7",
+            "http://localhost:{port}/{chatRoomId}/nerd/{messageId}",
             port,
-            EXISTING_CHATROOM)
+            EXISTING_CHATROOM,
+            RandomGenerator.getDefault().nextInt())
         .contentType(MediaType.TEXT_PLAIN)
         .accept(MediaType.APPLICATION_JSON)
         .bodyValue("Hello world!")