1 package de.juplo.kafka.chat.backend;
3 import org.junit.jupiter.api.DisplayName;
4 import org.junit.jupiter.api.Test;
5 import org.springframework.beans.factory.annotation.Autowired;
6 import org.springframework.boot.test.web.server.LocalServerPort;
7 import org.springframework.http.MediaType;
8 import org.springframework.test.web.reactive.server.WebTestClient;
9 import org.testcontainers.shaded.org.awaitility.Awaitility;
11 import java.time.Duration;
14 public abstract class AbstractConfigurationIT
19 WebTestClient webTestClient;
22 @DisplayName("The app starts, the data is restored and accessible")
27 .atMost(Duration.ofSeconds(15))
32 .uri("http://localhost:{port}/actuator/health", port)
34 .expectStatus().isOk()
35 .expectBody().jsonPath("$.status").isEqualTo("UP");
38 .uri("http://localhost:{port}/list", port)
39 .accept(MediaType.APPLICATION_JSON)
41 .expectStatus().isOk()
43 .jsonPath("$.length()").isEqualTo(1)
44 .jsonPath("$[0].name").isEqualTo("FOO");
47 .uri("http://localhost:{port}/5c73531c-6fc4-426c-adcb-afc5c140a0f7", port)
48 .accept(MediaType.APPLICATION_JSON)
50 .expectStatus().isOk()
51 .expectBody().jsonPath("$.name").isEqualTo("FOO");
54 .uri("http://localhost:{port}/5c73531c-6fc4-426c-adcb-afc5c140a0f7/ute/1", port)
55 .accept(MediaType.APPLICATION_JSON)
57 .expectStatus().isOk()
58 .expectBody().jsonPath("$.text").isEqualTo("Ich bin Ute...");
61 .uri("http://localhost:{port}/5c73531c-6fc4-426c-adcb-afc5c140a0f7/peter/1", port)
62 .accept(MediaType.APPLICATION_JSON)
64 .expectStatus().isOk()
65 .expectBody().jsonPath("$.text").isEqualTo("Hallo, ich heiße Peter!");
68 .uri("http://localhost:{port}/97cca12a-af72-11ed-9b9e-f78fa16794ac/otto/66", port)
69 .contentType(MediaType.TEXT_PLAIN)
70 .accept(MediaType.APPLICATION_JSON)
71 .bodyValue("The devil rules route 66")
73 .expectStatus().isNotFound();
76 .uri("http://localhost:{port}/97cca12a-af72-11ed-9b9e-f78fa16794ac/otto/66", port)
77 .accept(MediaType.APPLICATION_JSON)
79 .expectStatus().isNotFound();