Browse Source

add createGameTest to ServerAppTest

feat-serverGameRepresentation
Steffen Nitschke 4 years ago
parent
commit
40aa492aae
  1. 19
      fh.fd.ci.server/src/test/java/de/fd/fh/ServerAppTest.java

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

@ -3,6 +3,7 @@ package de.fd.fh;
import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonProcessingException;
import de.fd.fh.server.ApiTestUtils; import de.fd.fh.server.ApiTestUtils;
import de.fd.fh.server.access.web.AccessController; import de.fd.fh.server.access.web.AccessController;
import de.fd.fh.server.game.web.GameController;
import de.fd.fh.server.user.web.UserController; import de.fd.fh.server.user.web.UserController;
import de.fd.fh.shared.Utils; import de.fd.fh.shared.Utils;
import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.AfterAll;
@ -26,11 +27,12 @@ class ServerAppTest
{ {
private static UserController userController = mock(UserController.class); private static UserController userController = mock(UserController.class);
private static AccessController accessController = mock(AccessController.class); private static AccessController accessController = mock(AccessController.class);
private static GameController gameController = mock(GameController.class);
@BeforeAll @BeforeAll
static void before() static void before()
{ {
ServerApp.initController(accessController, userController);
ServerApp.initController(accessController, userController, gameController);
ServerApp.main(null); ServerApp.main(null);
awaitInitialization(); awaitInitialization();
@ -163,4 +165,19 @@ class ServerAppTest
assertEquals(200, res.getStatus()); assertEquals(200, res.getStatus());
then(userController).should().getUser(any(), any()); then(userController).should().getUser(any(), any());
} }
@Test
void testCreateGame() throws IOException
{
when(gameController.createGame(any(), any())).thenReturn(mock(Response.class));
final String url = "/games";
ApiTestUtils.TestResponse<String> res = new ApiTestUtils<String>()
.request("POST", url, null, null, String.class);
assertNotNull(res);
assertEquals(200, res.getStatus());
then(gameController).should().createGame(any(), any());
}
} }
Loading…
Cancel
Save