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

test: added test case for remove away/home game and a little refactoring

parent 22c0c626
No related branches found
No related tags found
No related merge requests found
...@@ -150,7 +150,7 @@ class TeamServiceImplTest { ...@@ -150,7 +150,7 @@ class TeamServiceImplTest {
assertThatExceptionOfType(NullPointerException.class).isThrownBy( assertThatExceptionOfType(NullPointerException.class).isThrownBy(
() -> teamService.addHomeGame(team, null) () -> teamService.addHomeGame(team, null)
); );
assertThat(team.getHomeGames()).hasSameElementsAs(List.of()); assertThat(team.getHomeGames()).isEmpty();
} }
@Test @Test
...@@ -176,7 +176,7 @@ class TeamServiceImplTest { ...@@ -176,7 +176,7 @@ class TeamServiceImplTest {
assertThatExceptionOfType(NullPointerException.class).isThrownBy( assertThatExceptionOfType(NullPointerException.class).isThrownBy(
() -> teamService.addAwayGame(team, null) () -> teamService.addAwayGame(team, null)
); );
assertThat(team.getAwayGames()).hasSameElementsAs(List.of()); assertThat(team.getAwayGames()).isEmpty();
} }
@Test @Test
...@@ -188,12 +188,24 @@ class TeamServiceImplTest { ...@@ -188,12 +188,24 @@ class TeamServiceImplTest {
} }
@Test @Test
public void removeHomeGame() { public void removeHomeGameOneOfOne() {
Team team = buildTeam("Florida Panthers"); Team team = buildTeam("Florida Panthers");
Game game = buildGame(); Game game = buildGame();
team.setHomeGames(Set.of(game)); team.setHomeGames(Set.of(game));
teamService.removeHomeGame(team, game); teamService.removeHomeGame(team, game);
assertThat(team.getHomeGames()).hasSameElementsAs(List.of()); assertThat(team.getHomeGames()).isEmpty();
verify(teamDao).update(team);
}
@Test
public void removeHomeGameOnOfMany() {
Team team = buildTeam("Florida Panthers");
Game game = buildGame();
game.setId(2L);
Game game2 = buildGame();
team.setHomeGames(Set.of(game, game2));
teamService.removeHomeGame(team, game);
assertThat(team.getHomeGames()).hasSameElementsAs(Set.of(game2));
verify(teamDao).update(team); verify(teamDao).update(team);
} }
......
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