Browse Source

extract getCompleteUser routing to ServerApp

chore-betterServerTestCoverage
Steffen Nitschke 4 years ago
parent
commit
d586c064fc
  1. 1
      fh.fd.ci.server/src/main/java/de/fd/fh/ServerApp.java
  2. 1
      fh.fd.ci.server/src/main/java/de/fd/fh/server/user/web/UserController.java
  3. 15
      fh.fd.ci.server/src/test/java/de/fd/fh/ServerAppTest.java

1
fh.fd.ci.server/src/main/java/de/fd/fh/ServerApp.java

@ -47,6 +47,7 @@ public class ServerApp
delete("/accounts/:player_id", accessController::deletePlayer); delete("/accounts/:player_id", accessController::deletePlayer);
post("/users", userController::updateUser); post("/users", userController::updateUser);
get("/users", userController::getCompleteUser);
get("/hello", (req, res) -> "Hello World"); get("/hello", (req, res) -> "Hello World");

1
fh.fd.ci.server/src/main/java/de/fd/fh/server/user/web/UserController.java

@ -92,7 +92,6 @@ public class UserController
public UserController(final UserService service) public UserController(final UserService service)
{ {
this.service = service; this.service = service;
post("/users", this::getCompleteUser);
get("/users/:user_id", this::getUser); get("/users/:user_id", this::getUser);
} }

15
fh.fd.ci.server/src/test/java/de/fd/fh/ServerAppTest.java

@ -133,4 +133,19 @@ class ServerAppTest
assertEquals(200, res.getStatus()); assertEquals(200, res.getStatus());
then(userController).should().updateUser(any(), any()); then(userController).should().updateUser(any(), any());
} }
@Test
void getPlayers() throws JsonProcessingException
{
when(userController.getCompleteUser(any(), any())).thenReturn(mock(Response.class));
String url = "/users";
ApiTestUtils.TestResponse<String> res = new ApiTestUtils<String>()
.request("GET", url, null, null, String.class);
assertNotNull(res);
assertEquals(200, res.getStatus());
then(userController).should().getCompleteUser(any(), any());
}
} }
Loading…
Cancel
Save