From 3e507d3fe1efea94bb1548c7be9daa23c7487f17 Mon Sep 17 00:00:00 2001 From: Steffen Nitschke Date: Sun, 31 Jan 2021 03:57:50 +0100 Subject: [PATCH] extract update user routing to ServerApp --- .../src/main/java/de/fd/fh/ServerApp.java | 1 + .../de/fd/fh/server/user/web/UserController.java | 2 -- .../src/test/java/de/fd/fh/ServerAppTest.java | 15 +++++++++++++++ 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/fh.fd.ci.server/src/main/java/de/fd/fh/ServerApp.java b/fh.fd.ci.server/src/main/java/de/fd/fh/ServerApp.java index 8ff3fbb..62dfd47 100644 --- a/fh.fd.ci.server/src/main/java/de/fd/fh/ServerApp.java +++ b/fh.fd.ci.server/src/main/java/de/fd/fh/ServerApp.java @@ -46,6 +46,7 @@ public class ServerApp post("/accounts/logout", accessController::logout); delete("/accounts/:player_id", accessController::deletePlayer); + post("/users", userController::updateUser); get("/hello", (req, res) -> "Hello World"); diff --git a/fh.fd.ci.server/src/main/java/de/fd/fh/server/user/web/UserController.java b/fh.fd.ci.server/src/main/java/de/fd/fh/server/user/web/UserController.java index 4ddeb91..016475b 100644 --- a/fh.fd.ci.server/src/main/java/de/fd/fh/server/user/web/UserController.java +++ b/fh.fd.ci.server/src/main/java/de/fd/fh/server/user/web/UserController.java @@ -94,8 +94,6 @@ public class UserController this.service = service; post("/users", this::getCompleteUser); - get("/users", this::updateUser); - get("/users/:user_id", this::getUser); } } diff --git a/fh.fd.ci.server/src/test/java/de/fd/fh/ServerAppTest.java b/fh.fd.ci.server/src/test/java/de/fd/fh/ServerAppTest.java index a848d18..962bf54 100644 --- a/fh.fd.ci.server/src/test/java/de/fd/fh/ServerAppTest.java +++ b/fh.fd.ci.server/src/test/java/de/fd/fh/ServerAppTest.java @@ -118,4 +118,19 @@ class ServerAppTest assertEquals(200, res.getStatus()); then(accessController).should().deletePlayer(any(), any()); } + + @Test + void updateUser() throws IOException + { + when(userController.updateUser(any(), any())).thenReturn(mock(Response.class)); + + String url = "/users"; + + ApiTestUtils.TestResponse res = new ApiTestUtils() + .request("POST", url, null, null, String.class); + + assertNotNull(res); + assertEquals(200, res.getStatus()); + then(userController).should().updateUser(any(), any()); + } } \ No newline at end of file