diff --git a/src/main/java/de/pnreichmuth/timekeep_backend/services/TeamService.java b/src/main/java/de/pnreichmuth/timekeep_backend/services/TeamService.java index 18b5b81..fc57f42 100644 --- a/src/main/java/de/pnreichmuth/timekeep_backend/services/TeamService.java +++ b/src/main/java/de/pnreichmuth/timekeep_backend/services/TeamService.java @@ -1,6 +1,5 @@ package de.pnreichmuth.timekeep_backend.services; -import de.pnreichmuth.timekeep_backend.entities.Racer; import de.pnreichmuth.timekeep_backend.entities.Team; import de.pnreichmuth.timekeep_backend.exceptions.TeamExistsException; import de.pnreichmuth.timekeep_backend.exceptions.TeamNotFoundException; @@ -20,7 +19,6 @@ import java.util.UUID; @RequiredArgsConstructor public class TeamService { private final TeamRepository teamRepository; - private final RacerRepository racerRepository; private void checkTeamIsDuplicate(Team team) throws TeamExistsException { List teams = teamRepository.findAll(); @@ -30,12 +28,14 @@ public class TeamService { } public Team getTeam(UUID id){ - return teamRepository.findById(id).orElse(null); + Team team = teamRepository.findById(id).orElse(null); + if(team == null) throw new TeamNotFoundException("Team with id "+id+" not found"); + return team; } public Team getTeam(String name){ Team team = teamRepository.getTeamByTeamName(name).orElse(null); - if(team == null) throw new TeamNotFoundException("Team "+name+" not found"); + if(team == null) throw new TeamNotFoundException("Team with name "+name+" not found"); return team; }