Browse Source

better createGame-Test

feat-serverGameRepresentation
Steffen Nitschke 4 years ago
parent
commit
3d03f51a6a
  1. 3
      fh.fd.ci.server/src/main/java/de/fd/fh/server/game/GameService.java
  2. 13
      fh.fd.ci.server/src/test/java/de/fd/fh/server/game/GameServiceTest.java

3
fh.fd.ci.server/src/main/java/de/fd/fh/server/game/GameService.java

@ -15,6 +15,7 @@ public class GameService
public GameId createGame(final UserId blackUser, final UserId whiteUser) public GameId createGame(final UserId blackUser, final UserId whiteUser)
{ {
return null;
final Game game = new Game(null, null, null, null, null, null);
return (GameId) repository.save(game).getId();
} }
} }

13
fh.fd.ci.server/src/test/java/de/fd/fh/server/game/GameServiceTest.java

@ -7,8 +7,8 @@ import org.mockito.ArgumentCaptor;
import static org.junit.jupiter.api.Assertions.*; import static org.junit.jupiter.api.Assertions.*;
import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import static org.mockito.BDDMockito.then;
import static org.mockito.Mockito.*;
class GameServiceTest class GameServiceTest
{ {
@ -40,5 +40,14 @@ class GameServiceTest
final ArgumentCaptor<Game> captor = ArgumentCaptor.forClass(Game.class); final ArgumentCaptor<Game> captor = ArgumentCaptor.forClass(Game.class);
final GameId result = new GameService(repository).createGame(blackPlayer, whitePlayer); final GameId result = new GameService(repository).createGame(blackPlayer, whitePlayer);
verify(repository).save(captor.capture());
assertEquals("4242", result.getIdentifier());
assertNotNull(captor.getValue());
then(repository).should().save(any(Game.class));
then(repository).shouldHaveNoMoreInteractions();
} }
} }
Loading…
Cancel
Save