Skip to content
Snippets Groups Projects
Commit 1829abb8 authored by Tomas Madeja's avatar Tomas Madeja
Browse files

fix: bad non-empty league teams test

parent 7e1b0e48
No related branches found
No related tags found
No related merge requests found
......@@ -5,6 +5,7 @@ import lombok.Setter;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.util.Objects;
public class TeamDTO {
@NotNull
......@@ -16,4 +17,18 @@ public class TeamDTO {
@Setter
@Getter
private String name;
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
TeamDTO teamDTO = (TeamDTO) o;
return getId().equals(teamDTO.getId()) &&
getName().equals(teamDTO.getName());
}
@Override
public int hashCode() {
return Objects.hash(getId(), getName());
}
}
......@@ -2,6 +2,7 @@ package cz.muni.fi.pa165.icehockeymanager.facades;
import cz.muni.fi.pa165.icehockeymanager.config.ApplicationConfig;
import cz.muni.fi.pa165.icehockeymanager.dto.PlayerDTO;
import cz.muni.fi.pa165.icehockeymanager.dto.TeamDTO;
import cz.muni.fi.pa165.icehockeymanager.model.Player;
import cz.muni.fi.pa165.icehockeymanager.model.Team;
import cz.muni.fi.pa165.icehockeymanager.services.BeanMappingService;
......@@ -86,8 +87,9 @@ class UserFacadeImplTest {
buildTeamMock(2L, "Chicago Blackhawks"),
buildTeamMock(3L, "Florida Panthers")
);
when(teamService.getAllTeams()).thenReturn(new ArrayList<>());
assertThat(userFacade.getTeamsInLeague()).isEmpty();
var expected = beanMappingService.mapTo(teams, TeamDTO.class);
when(teamService.getAllTeams()).thenReturn(teams);
assertThat(userFacade.getTeamsInLeague()).hasSameElementsAs(expected);
verify(teamService).getAllTeams();
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment