test: HandoverIT-POC - splitted up code into smaller classes -- ALIGN
[demos/kafka/chat] / src / test / java / de / juplo / kafka / chat / backend / HandoverIT.java
index f384f7e..b22166f 100644 (file)
@@ -37,7 +37,6 @@ import java.util.stream.IntStream;
 public abstract class AbstractHandoverIT
 {
   static final ImagePullPolicy NEVER_PULL = imageName -> false;
-  static final ParameterizedTypeReference<ServerSentEvent<String>> SSE_TYPE = new ParameterizedTypeReference<>() {};
 
 
   @Test
@@ -61,70 +60,6 @@ public abstract class AbstractHandoverIT
         .block();
   }
 
-  Mono<ChatRoomInfoTo> createChatRoom(String name)
-  {
-    return webClient
-        .post()
-        .uri("/create")
-        .contentType(MediaType.TEXT_PLAIN)
-        .bodyValue(name)
-        .accept(MediaType.APPLICATION_JSON)
-        .exchangeToMono(response ->
-        {
-          if (response.statusCode().equals(HttpStatus.OK))
-          {
-            return response.bodyToMono(ChatRoomInfoTo.class);
-          }
-          else
-          {
-            return response.createError();
-          }
-        });
-  }
-
-  Mono<MessageTo> sendMessage(
-      ChatRoomInfoTo chatRoom,
-      User user,
-      String message)
-  {
-    return webClient
-        .put()
-        .uri(
-            "/{chatRoomId}/{username}/{serial}",
-            chatRoom.getId(),
-            user.getName(),
-            user.nextSerial())
-        .contentType(MediaType.TEXT_PLAIN)
-        .accept(MediaType.APPLICATION_JSON)
-        .bodyValue(message)
-        .exchangeToMono(response ->
-        {
-          if (response.statusCode().equals(HttpStatus.OK))
-          {
-            return response.bodyToMono(MessageTo.class);
-          }
-          else
-          {
-            return response.createError();
-          }
-        });
-  }
-
-  Flux<ServerSentEvent<String>> receiveMessages(ChatRoomInfoTo chatRoom)
-  {
-    return webClient
-        .get()
-        .uri(
-            "/{chatRoomId}/listen",
-            chatRoom.getId())
-        .accept(MediaType.TEXT_EVENT_STREAM)
-        .retrieve()
-        .bodyToFlux(SSE_TYPE);
-  }
-
-
-  WebClient webClient;
-
 
   abstract void setUpExtra() throws IOException, InterruptedException;
 
@@ -137,9 +72,6 @@ public abstract class AbstractHandoverIT
     // backend2.start();
     // backend3.start();
 
-    Integer port = haproxy.getMappedPort(8400);
-    webClient = WebClient.create("http://localhost:" + port);
-
     Awaitility
         .await()
         .atMost(Duration.ofMinutes(10))
@@ -173,7 +105,8 @@ public abstract class AbstractHandoverIT
     Awaitility
         .await()
         .atMost(Duration.ofMinutes(10))
-        .until(() -> webClient
+        .until(() -> WebClient
+            .create("http://localhost:" + haproxy.getMappedPort(8400))
             .get()
             .uri("/actuator/health")
             .exchangeToMono(response ->