From 57f1bf70ba6fb4dbcafd8c6837fdac82557347ca Mon Sep 17 00:00:00 2001 From: Kai Moritz Date: Wed, 11 Jan 2023 21:41:46 +0100 Subject: [PATCH] refactor: refined the endpoint-uri's --- .../chat/backend/api/ChatBackendController.java | 10 +++++----- .../backend/api/ChatBackendControllerTest.java | 14 +++++++------- 2 files changed, 12 insertions(+), 12 deletions(-) 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) -- 2.20.1