|
@ -0,0 +1,43 @@ |
|
|
|
|
|
package de.fd.fh.server.game.web; |
|
|
|
|
|
|
|
|
|
|
|
import de.fd.fh.server.access.AccessToken; |
|
|
|
|
|
import de.fd.fh.server.game.GameId; |
|
|
|
|
|
import de.fd.fh.server.game.GameService; |
|
|
|
|
|
import org.junit.jupiter.api.BeforeEach; |
|
|
|
|
|
import org.junit.jupiter.api.Test; |
|
|
|
|
|
import org.mockito.Mock; |
|
|
|
|
|
import org.mockito.MockitoAnnotations; |
|
|
|
|
|
import spark.Request; |
|
|
|
|
|
import spark.Response; |
|
|
|
|
|
import spark.Session; |
|
|
|
|
|
|
|
|
|
|
|
import static org.mockito.ArgumentMatchers.any; |
|
|
|
|
|
import static org.mockito.Mockito.when; |
|
|
|
|
|
|
|
|
|
|
|
public class GameControllerTest |
|
|
|
|
|
{ |
|
|
|
|
|
@Mock |
|
|
|
|
|
Request request; |
|
|
|
|
|
@Mock |
|
|
|
|
|
Response response; |
|
|
|
|
|
@Mock |
|
|
|
|
|
Session session; |
|
|
|
|
|
@Mock |
|
|
|
|
|
GameService service; |
|
|
|
|
|
|
|
|
|
|
|
@BeforeEach |
|
|
|
|
|
void before() |
|
|
|
|
|
{ |
|
|
|
|
|
MockitoAnnotations.openMocks(this); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
|
void testCreateGameTest() |
|
|
|
|
|
{ |
|
|
|
|
|
when(request.body()).thenReturn("{\"userName\":\"TestName\",\"password\":\"TestPassword\"}"); |
|
|
|
|
|
when(request.session()).thenReturn(session); |
|
|
|
|
|
when(service.createGame(any())).thenReturn(GameId.random()); |
|
|
|
|
|
|
|
|
|
|
|
new GameController(service).createGame(request, response); |
|
|
|
|
|
} |
|
|
|
|
|
} |