Skip to content
Snippets Groups Projects
Commit 22419625 authored by Erik Moravec's avatar Erik Moravec
Browse files

test: added tests for remove away game and createTeam

parent 59901df0
No related branches found
No related tags found
No related merge requests found
......@@ -240,6 +240,65 @@ class TeamServiceImplTest {
assertThat(team.getHomeGames()).containsOnly(game);
}
@Test
public void removeAwayGameOneOfOne() {
Team team = buildTeam("Florida Panthers");
Game game = buildGame();
team.setAwayGames(Set.of(game));
teamService.removeAwayGame(team, game);
assertThat(team.getAwayGames()).isEmpty();
verify(teamDao).update(team);
}
@Test
public void removeAwayGameOneOfMany() {
Team team = buildTeam("Florida Panthers");
Game game = buildGame();
game.setId(2L);
Game game2 = buildGame();
team.setAwayGames(Set.of(game, game2));
teamService.removeAwayGame(team, game);
assertThat(team.getAwayGames()).containsOnly(game2);
verify(teamDao).update(team);
}
@Test
public void removeAwayGameGameIsNull() {
Team team = buildTeam("Florida Panthers");
assertThatExceptionOfType(NullPointerException.class).isThrownBy(
() -> teamService.addAwayGame(team, null)
);
assertThat(team.getAwayGames()).isEmpty();
}
@Test
public void removeAwayGameTeamIsNull() {
Game game = buildGame();
assertThatExceptionOfType(NullPointerException.class).isThrownBy(
() -> teamService.addAwayGame(null, game)
);
}
@Test
public void removeAwayGameNotPresent() {
Team team = buildTeam("Florida Panthers");
Game game = buildGame();
game.setId(2L);
Game game2 = buildGame();
team.setAwayGames(Set.of(game));
assertThatExceptionOfType(UnknownGameException.class).isThrownBy(
() -> teamService.removeAwayGame(team, game2)
);
assertThat(team.getAwayGames()).containsOnly(game);
}
@Test
public void createTeam() {
Team team = buildTeam("Florida Panthers");
teamService.createTeam(team);
verify(teamDao).create(team);
}
private Game buildGame() {
var game = new Game();
game.setId(1L);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment