From: Kai Moritz Date: Wed, 11 Jan 2023 20:41:46 +0000 (+0100) Subject: refactor: refined the endpoint-uri's X-Git-Tag: wip-sharding~38 X-Git-Url: http://juplo.de/gitweb/?a=commitdiff_plain;h=8adc14c2abeacb3605b0638afa95b1e4eea9e087;p=demos%2Fkafka%2Fchat refactor: refined the endpoint-uri's --- diff --git a/src/main/java/de/juplo/kafka/chat/backend/api/ChatBackendController.java b/src/main/java/de/juplo/kafka/chat/backend/api/ChatBackendController.java index 3b8fc842..d0d27634 100644 --- a/src/main/java/de/juplo/kafka/chat/backend/api/ChatBackendController.java +++ b/src/main/java/de/juplo/kafka/chat/backend/api/ChatBackendController.java @@ -32,7 +32,7 @@ public class ChatBackendController return chatHome.getChatRooms().map(chatroom -> ChatRoomTo.from(chatroom)); } - @GetMapping("list/{chatroomId}") + @GetMapping("{chatroomId}/list") public Flux list(@PathVariable UUID chatroomId) { return chatHome @@ -42,13 +42,13 @@ public class ChatBackendController .map(MessageTo::from)); } - @GetMapping("get/{chatroomId}") + @GetMapping("{chatroomId}") public Mono get(@PathVariable UUID chatroomId) { return chatHome.getChatRoom(chatroomId).map(chatroom -> ChatRoomTo.from(chatroom)); } - @PutMapping("put/{chatroomId}/{username}/{messageId}") + @PutMapping("{chatroomId}/{username}/{messageId}") public Mono put( @PathVariable UUID chatroomId, @PathVariable String username, @@ -76,7 +76,7 @@ public class ChatBackendController .map(message -> MessageTo.from(message)); } - @GetMapping("get/{chatroomId}/{username}/{messageId}") + @GetMapping("{chatroomId}/{username}/{messageId}") public Mono get( @PathVariable UUID chatroomId, @PathVariable String username, @@ -99,7 +99,7 @@ public class ChatBackendController .map(message -> MessageTo.from(message)); } - @GetMapping(path = "listen/{chatroomId}") + @GetMapping(path = "{chatroomId}/listen") public Flux> listen(@PathVariable UUID chatroomId) { return chatHome diff --git a/src/test/java/de/juplo/kafka/chat/backend/api/ChatBackendControllerTest.java b/src/test/java/de/juplo/kafka/chat/backend/api/ChatBackendControllerTest.java index eeaf5ee8..403c9d52 100644 --- a/src/test/java/de/juplo/kafka/chat/backend/api/ChatBackendControllerTest.java +++ b/src/test/java/de/juplo/kafka/chat/backend/api/ChatBackendControllerTest.java @@ -41,7 +41,7 @@ public class ChatBackendControllerTest // When WebTestClient.ResponseSpec responseSpec = client .get() - .uri("/list/{chatroomId}", chatroomId) + .uri("/{chatroomId}/list", chatroomId) .accept(MediaType.APPLICATION_JSON) .exchange(); @@ -61,7 +61,7 @@ public class ChatBackendControllerTest // When WebTestClient.ResponseSpec responseSpec = client .get() - .uri("/get/{chatroomId}", chatroomId) + .uri("/{chatroomId}", chatroomId) .accept(MediaType.APPLICATION_JSON) .exchange(); @@ -83,7 +83,7 @@ public class ChatBackendControllerTest WebTestClient.ResponseSpec responseSpec = client .put() .uri( - "/put/{chatroomId}/{username}/{messageId}", + "/{chatroomId}/{username}/{messageId}", chatroomId, username, messageId) @@ -109,7 +109,7 @@ public class ChatBackendControllerTest WebTestClient.ResponseSpec responseSpec = client .get() .uri( - "/get/{chatroomId}/{username}/{messageId}", + "/{chatroomId}/{username}/{messageId}", chatroomId, username, messageId) @@ -131,7 +131,7 @@ public class ChatBackendControllerTest // 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(); @@ -185,7 +185,7 @@ public class ChatBackendControllerTest client .put() .uri( - "/put/{chatroomId}/{username}/{messageId}", + "/{chatroomId}/{username}/{messageId}", chatroomId, user, messageId) @@ -232,7 +232,7 @@ public class ChatBackendControllerTest client .put() .uri( - "/put/{chatroomId}/{username}/{messageId}", + "/{chatroomId}/{username}/{messageId}", chatroomId, user, messageId)