Skip to content
Snippets Groups Projects
Commit cb26ef2f authored by Ján Dovjak's avatar Ján Dovjak
Browse files

test: addPlayerToTeam extended tests

parent d62ef708
No related branches found
No related tags found
No related merge requests found
......@@ -2,6 +2,7 @@ package cz.muni.fi.pa165.icehockeymanager.services;
import cz.muni.fi.pa165.icehockeymanager.config.ApplicationConfig;
import cz.muni.fi.pa165.icehockeymanager.dao.TeamDao;
import cz.muni.fi.pa165.icehockeymanager.exceptions.PlayerNotInTeamException;
import cz.muni.fi.pa165.icehockeymanager.model.Player;
import cz.muni.fi.pa165.icehockeymanager.model.Team;
import org.junit.jupiter.api.Test;
......@@ -14,6 +15,7 @@ import org.springframework.test.context.junit.jupiter.SpringExtension;
import java.util.*;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
......@@ -72,6 +74,25 @@ class TeamServiceImplTest {
verify(teamDao).update(team);
}
@Test
public void addPlayerToTeamPlayerIsNull() {
Team team = buildTeam("Florida Panthers");
var players = buildPlayers();
team.setPlayers(players);
assertThatExceptionOfType(NullPointerException.class).isThrownBy(
() -> teamService.addPlayerToTeam(team, null)
);
assertThat(team.getPlayers()).hasSameElementsAs(players);
}
@Test
public void addPlayerToTeamTeamIsNull() {
var player = buildPlayer(1L, "Stan Mikita");
assertThatExceptionOfType(NullPointerException.class).isThrownBy(
() -> teamService.addPlayerToTeam(null,player)
);
}
......
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