Browse Source

add findRunningGamesOfUser-Test

feat-serverGameRepresentation
Steffen Nitschke 4 years ago
parent
commit
a3f42b063a
  1. 15
      fh.fd.ci.server/src/test/java/de/fd/fh/server/game/GameServiceTest.java

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

@ -5,6 +5,7 @@ import dev.morphia.Key;
import org.junit.jupiter.api.Test;
import org.mockito.ArgumentCaptor;
import java.util.List;
import java.util.Set;
import static org.junit.jupiter.api.Assertions.*;
@ -89,4 +90,18 @@ class GameServiceTest
assertNotNull(result);
}
@Test
void given_storedGames_when_findGamesOfUser_should_returnSetOfGames()
{
final GameRepository repository = when(mock(GameRepository.class).findRunningGamesOfPlayer(any(UserId.class)))
.thenReturn(List.of(
new Game(GameId.random(), UserId.of("12345"), UserId.random(), null, null, null),
new Game(GameId.random(), UserId.random(), UserId.of("12345"), null, null, null)))
.getMock();
final List<Game> result = new GameService(repository).findRunningGamesOfUser(UserId.of("12345"));
assertEquals(2, result.size());
}
}
Loading…
Cancel
Save