e6fd95a9db61904c8389e9e09ed5301d7a4ddc9e
[demos/kafka/chat] / src / test / java / de / juplo / kafka / chat / backend / AbstractConfigurationWithShardingIT.java
1 package de.juplo.kafka.chat.backend;
2
3 import org.junit.jupiter.api.DisplayName;
4 import org.junit.jupiter.api.Test;
5 import org.springframework.http.MediaType;
6 import org.testcontainers.shaded.org.awaitility.Awaitility;
7
8 import java.time.Duration;
9
10
11 public abstract class AbstractConfigurationWithShardingIT extends AbstractConfigurationIT
12 {
13   @Test
14   @DisplayName("A PUT-message for a not owned shard yields 404 - NOT FOUND")
15   void testNotFoundForPutMessageToAChatRoomInNotOwnedShard()
16   {
17     String otherChatRoomId = "4e7246a6-29ae-43ea-b56f-669c3481ac19";
18
19     Awaitility
20         .await()
21         .atMost(Duration.ofSeconds(15))
22         .untilAsserted(() ->
23           webTestClient
24               .put()
25               .uri(
26                   "http://localhost:{port}/{chatRoomId}/otto/66",
27                   port,
28                   otherChatRoomId)
29               .contentType(MediaType.TEXT_PLAIN)
30               .accept(MediaType.APPLICATION_JSON)
31               .bodyValue("The devil rules route 66")
32               .exchange()
33               .expectStatus().isNotFound());
34   }
35 }