Browse Source

extract update user routing to ServerApp

chore-betterServerTestCoverage
Steffen Nitschke 4 years ago
parent
commit
3e507d3fe1
  1. 1
      fh.fd.ci.server/src/main/java/de/fd/fh/ServerApp.java
  2. 2
      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

@ -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");

2
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);
}
}

15
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<String> res = new ApiTestUtils<String>()
.request("POST", url, null, null, String.class);
assertNotNull(res);
assertEquals(200, res.getStatus());
then(userController).should().updateUser(any(), any());
}
}
Loading…
Cancel
Save