| 1 | package org.hplr.tournament.infrastructure.dbadapter.adapters; | |
| 2 | ||
| 3 | import lombok.RequiredArgsConstructor; | |
| 4 | import lombok.extern.slf4j.Slf4j; | |
| 5 | import org.hplr.tournament.core.usecases.port.dto.TournamentSelectDto; | |
| 6 | import org.hplr.tournament.core.usecases.port.out.query.SelectAllTournamentsQueryInterface; | |
| 7 | import org.hplr.tournament.core.usecases.port.out.query.SelectTournamentByTournamentIdQueryInterface; | |
| 8 | import org.hplr.tournament.infrastructure.dbadapter.entities.TournamentEntity; | |
| 9 | import org.hplr.tournament.infrastructure.dbadapter.mappers.TournamentDatabaseMapper; | |
| 10 | import org.hplr.tournament.infrastructure.dbadapter.repositories.TournamentRepository; | |
| 11 | import org.springframework.stereotype.Service; | |
| 12 | ||
| 13 | import java.util.List; | |
| 14 | import java.util.NoSuchElementException; | |
| 15 | import java.util.Optional; | |
| 16 | import java.util.UUID; | |
| 17 | ||
| 18 | @Service | |
| 19 | @Slf4j | |
| 20 | @RequiredArgsConstructor | |
| 21 | public class TournamentQueryAdapter implements SelectTournamentByTournamentIdQueryInterface, | |
| 22 | SelectAllTournamentsQueryInterface { | |
| 23 | ||
| 24 | private final TournamentRepository tournamentRepository; | |
| 25 | ||
| 26 | @Override | |
| 27 | public Optional<TournamentSelectDto> selectTournamentByTournamentId(UUID tournamentId) { | |
| 28 | TournamentEntity tournamentEntity = tournamentRepository.findByTournamentId(tournamentId).orElseThrow(NoSuchElementException::new); | |
| 29 |
1
1. selectTournamentByTournamentId : replaced return value with Optional.empty for org/hplr/tournament/infrastructure/dbadapter/adapters/TournamentQueryAdapter::selectTournamentByTournamentId → KILLED |
return Optional.of(TournamentDatabaseMapper.fromEntity(tournamentEntity)); |
| 30 | } | |
| 31 | ||
| 32 | @Override | |
| 33 | public List<TournamentSelectDto> selectAllTournaments(Boolean closed) { | |
| 34 |
1
1. selectAllTournaments : replaced return value with Collections.emptyList for org/hplr/tournament/infrastructure/dbadapter/adapters/TournamentQueryAdapter::selectAllTournaments → KILLED |
return tournamentRepository.findAllByClosed(closed).stream().map( |
| 35 | TournamentDatabaseMapper::fromEntity).toList(); | |
| 36 | } | |
| 37 | } | |
Mutations | ||
| 29 |
1.1 |
|
| 34 |
1.1 |