feat: Prepared the application for sharding
[demos/kafka/chat] / src / test / java / de / juplo / kafka / chat / backend / api / ChatBackendControllerTest.java
index eeaf5ee..b3504d2 100644 (file)
@@ -36,12 +36,12 @@ public class ChatBackendControllerTest
   {
     // Given
     UUID chatroomId = UUID.randomUUID();
-    when(chatHomeService.getChatRoom(any(UUID.class))).thenReturn(Mono.empty());
+    when(chatHomeService.getChatRoom(anyInt(), any(UUID.class))).thenReturn(Mono.empty());
 
     // When
     WebTestClient.ResponseSpec responseSpec = client
         .get()
-        .uri("/list/{chatroomId}", chatroomId)
+        .uri("/{chatroomId}/list", chatroomId)
         .accept(MediaType.APPLICATION_JSON)
         .exchange();
 
@@ -56,12 +56,12 @@ public class ChatBackendControllerTest
   {
     // Given
     UUID chatroomId = UUID.randomUUID();
-    when(chatHomeService.getChatRoom(any(UUID.class))).thenReturn(Mono.empty());
+    when(chatHomeService.getChatRoom(anyInt(), any(UUID.class))).thenReturn(Mono.empty());
 
     // When
     WebTestClient.ResponseSpec responseSpec = client
         .get()
-        .uri("/get/{chatroomId}", chatroomId)
+        .uri("/{chatroomId}", chatroomId)
         .accept(MediaType.APPLICATION_JSON)
         .exchange();
 
@@ -77,13 +77,13 @@ public class ChatBackendControllerTest
     UUID chatroomId = UUID.randomUUID();
     String username = "foo";
     Long messageId = 66l;
-    when(chatHomeService.getChatRoom(any(UUID.class))).thenReturn(Mono.empty());
+    when(chatHomeService.getChatRoom(anyInt(), any(UUID.class))).thenReturn(Mono.empty());
 
     // When
     WebTestClient.ResponseSpec responseSpec = client
         .put()
         .uri(
-            "/put/{chatroomId}/{username}/{messageId}",
+            "/{chatroomId}/{username}/{messageId}",
             chatroomId,
             username,
             messageId)
@@ -103,13 +103,13 @@ public class ChatBackendControllerTest
     UUID chatroomId = UUID.randomUUID();
     String username = "foo";
     Long messageId = 66l;
-    when(chatHomeService.getChatRoom(any(UUID.class))).thenReturn(Mono.empty());
+    when(chatHomeService.getChatRoom(anyInt(), any(UUID.class))).thenReturn(Mono.empty());
 
     // When
     WebTestClient.ResponseSpec responseSpec = client
         .get()
         .uri(
-            "/get/{chatroomId}/{username}/{messageId}",
+            "/{chatroomId}/{username}/{messageId}",
             chatroomId,
             username,
             messageId)
@@ -126,12 +126,12 @@ public class ChatBackendControllerTest
   {
     // Given
     UUID chatroomId = UUID.randomUUID();
-    when(chatHomeService.getChatRoom(any(UUID.class))).thenReturn(Mono.empty());
+    when(chatHomeService.getChatRoom(anyInt(), any(UUID.class))).thenReturn(Mono.empty());
 
     // When
     WebTestClient.ResponseSpec responseSpec = client
         .get()
-        .uri("/listen/{chatroomId}", chatroomId)
+        .uri("/{chatroomId}/listen", chatroomId)
         // .accept(MediaType.TEXT_EVENT_STREAM, MediaType.APPLICATION_JSON) << TODO: Does not work!
         .exchange();
 
@@ -167,9 +167,10 @@ public class ChatBackendControllerTest
     ChatRoom chatRoom = new ChatRoom(
         chatroomId,
         "Test-ChatRoom",
+        0,
         Clock.systemDefaultZone(),
         chatRoomService, 8);
-    when(chatHomeService.getChatRoom(any(UUID.class))).thenReturn(Mono.just(chatRoom));
+    when(chatHomeService.getChatRoom(anyInt(), any(UUID.class))).thenReturn(Mono.just(chatRoom));
     Message existingMessage = new Message(
         key,
         serialNumberExistingMessage,
@@ -185,7 +186,7 @@ public class ChatBackendControllerTest
     client
         .put()
         .uri(
-            "/put/{chatroomId}/{username}/{messageId}",
+            "/{chatroomId}/{username}/{messageId}",
             chatroomId,
             user,
             messageId)
@@ -218,9 +219,10 @@ public class ChatBackendControllerTest
     ChatRoom chatRoom = new ChatRoom(
         chatroomId,
         "Test-ChatRoom",
+        0,
         Clock.systemDefaultZone(),
         chatRoomService, 8);
-    when(chatHomeService.getChatRoom(any(UUID.class)))
+    when(chatHomeService.getChatRoom(anyInt(), any(UUID.class)))
         .thenReturn(Mono.just(chatRoom));
     when(chatRoomService.getMessage(any(Message.MessageKey.class)))
         .thenReturn(Mono.empty());
@@ -232,7 +234,7 @@ public class ChatBackendControllerTest
     client
         .put()
         .uri(
-            "/put/{chatroomId}/{username}/{messageId}",
+            "/{chatroomId}/{username}/{messageId}",
             chatroomId,
             user,
             messageId)