You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

26 lines
750 B

3 years ago
3 years ago
  1. package de.fd.fh.server.game;
  2. import dev.morphia.Key;
  3. import org.junit.jupiter.api.Test;
  4. import static org.junit.jupiter.api.Assertions.*;
  5. import static org.mockito.ArgumentMatchers.any;
  6. import static org.mockito.Mockito.mock;
  7. import static org.mockito.Mockito.when;
  8. class GameServiceTest
  9. {
  10. @Test
  11. void testCreateGame()
  12. {
  13. final GameRepository repository = when(mock(GameRepository.class).save(any()))
  14. .thenReturn(new Key<>(Game.class, "testCollection", GameId.of("98765")))
  15. .getMock();
  16. final Game game = new Game();
  17. final GameId result = new GameService(repository).createGame(game);
  18. assertNotNull(result);
  19. assertEquals("98765", result.getIdentifier());
  20. }
  21. }