TournamentQueryAdapter.java

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
Location : selectTournamentByTournamentId
Killed by : org.hplr.tournament.infrastructure.dbadapter.adapters.TournamentQueryAdapterTests.[engine:junit-jupiter]/[class:org.hplr.tournament.infrastructure.dbadapter.adapters.TournamentQueryAdapterTests]/[method:select_tournament_find_one_and_succeed()]
replaced return value with Optional.empty for org/hplr/tournament/infrastructure/dbadapter/adapters/TournamentQueryAdapter::selectTournamentByTournamentId → KILLED

34

1.1
Location : selectAllTournaments
Killed by : org.hplr.tournament.infrastructure.dbadapter.adapters.TournamentQueryAdapterTests.[engine:junit-jupiter]/[class:org.hplr.tournament.infrastructure.dbadapter.adapters.TournamentQueryAdapterTests]/[method:find_all_tournaments_by_status_find_one_and_succeed()]
replaced return value with Collections.emptyList for org/hplr/tournament/infrastructure/dbadapter/adapters/TournamentQueryAdapter::selectAllTournaments → KILLED

Active mutators

Tests examined


Report generated by PIT 1.16.1