StartAllDueGamesAutomaticallyUseCaseService.java

1
package org.hplr.game.core.usecases.service;
2
3
import lombok.RequiredArgsConstructor;
4
import lombok.extern.slf4j.Slf4j;
5
6
import org.hplr.game.core.enums.Status;
7
import org.hplr.game.core.model.Game;
8
import org.hplr.game.core.model.GameSnapshot;
9
import org.hplr.game.core.model.GameValidator;
10
import org.hplr.game.core.usecases.port.dto.GameSelectDto;
11
import org.hplr.game.core.usecases.port.in.StartAllDueGamesAutomaticallyUseCaseInterface;
12
import org.hplr.game.core.usecases.port.out.command.StartAllDueGamesCommandInterface;
13
import org.hplr.game.core.usecases.port.out.query.SelectAllGamesQueryInterface;
14
15
import org.hplr.library.exception.HPLRValidationException;
16
17
import org.springframework.stereotype.Service;
18
19
import java.time.LocalDateTime;
20
import java.util.List;
21
22
@Slf4j
23
@Service
24
@RequiredArgsConstructor
25
public class StartAllDueGamesAutomaticallyUseCaseService implements StartAllDueGamesAutomaticallyUseCaseInterface {
26
    final SelectAllGamesQueryInterface selectAllGamesQueryInterface;
27
    final StartAllDueGamesCommandInterface startAllDueGamesCommandInterface;
28
    @Override
29
    public void startGameAutomatically() {
30
        List<GameSelectDto> gameSelectDtoList = selectAllGamesQueryInterface.selectAllGames();
31
        List<GameSnapshot> gameToStartIdList = gameSelectDtoList
32
                .stream()
33
                .map(Game::fromDto)
34
                .filter(game -> {
35
                    try{
36 1 1. lambda$startGameAutomatically$0 : removed call to org/hplr/game/core/model/GameValidator::validateStartingGame → KILLED
                        GameValidator.validateStartingGame(game);
37 1 1. lambda$startGameAutomatically$0 : replaced boolean return with false for org/hplr/game/core/usecases/service/StartAllDueGamesAutomaticallyUseCaseService::lambda$startGameAutomatically$0 → KILLED
                        return true;
38
                    }
39
                    catch(HPLRValidationException e){
40
                        log.error("game {} could not be started", game.getGameId().gameId());
41 1 1. lambda$startGameAutomatically$0 : replaced boolean return with true for org/hplr/game/core/usecases/service/StartAllDueGamesAutomaticallyUseCaseService::lambda$startGameAutomatically$0 → KILLED
                        return false;
42
                    }
43
                })
44 2 1. lambda$startGameAutomatically$1 : replaced boolean return with true for org/hplr/game/core/usecases/service/StartAllDueGamesAutomaticallyUseCaseService::lambda$startGameAutomatically$1 → KILLED
2. lambda$startGameAutomatically$1 : replaced boolean return with false for org/hplr/game/core/usecases/service/StartAllDueGamesAutomaticallyUseCaseService::lambda$startGameAutomatically$1 → KILLED
                .filter(game -> Status.AWAITING.equals(game.getGameStatus()))
45 2 1. lambda$startGameAutomatically$2 : replaced boolean return with false for org/hplr/game/core/usecases/service/StartAllDueGamesAutomaticallyUseCaseService::lambda$startGameAutomatically$2 → KILLED
2. lambda$startGameAutomatically$2 : replaced boolean return with true for org/hplr/game/core/usecases/service/StartAllDueGamesAutomaticallyUseCaseService::lambda$startGameAutomatically$2 → KILLED
                .filter(game -> game.getGameData().gameStartTime().isBefore(LocalDateTime.now()))
46
                .map(Game::toSnapshot)
47
                .toList();
48 1 1. startGameAutomatically : removed call to org/hplr/game/core/usecases/port/out/command/StartAllDueGamesCommandInterface::startAllDueGames → KILLED
        startAllDueGamesCommandInterface.startAllDueGames(gameToStartIdList);
49
    }
50
}

Mutations

36

1.1
Location : lambda$startGameAutomatically$0
Killed by : org.hplr.game.core.usecases.service.StartAllDueGamesAutomaticallyUseCaseServiceTests.[engine:junit-jupiter]/[class:org.hplr.game.core.usecases.service.StartAllDueGamesAutomaticallyUseCaseServiceTests]/[method:get_all_games_fail_validation_and_start_none()]
removed call to org/hplr/game/core/model/GameValidator::validateStartingGame → KILLED

37

1.1
Location : lambda$startGameAutomatically$0
Killed by : org.hplr.game.core.usecases.service.StartAllDueGamesAutomaticallyUseCaseServiceTests.[engine:junit-jupiter]/[class:org.hplr.game.core.usecases.service.StartAllDueGamesAutomaticallyUseCaseServiceTests]/[method:get_all_games_pass_validation_and_start_one()]
replaced boolean return with false for org/hplr/game/core/usecases/service/StartAllDueGamesAutomaticallyUseCaseService::lambda$startGameAutomatically$0 → KILLED

41

1.1
Location : lambda$startGameAutomatically$0
Killed by : org.hplr.game.core.usecases.service.StartAllDueGamesAutomaticallyUseCaseServiceTests.[engine:junit-jupiter]/[class:org.hplr.game.core.usecases.service.StartAllDueGamesAutomaticallyUseCaseServiceTests]/[method:get_all_games_fail_validation_and_start_none()]
replaced boolean return with true for org/hplr/game/core/usecases/service/StartAllDueGamesAutomaticallyUseCaseService::lambda$startGameAutomatically$0 → KILLED

44

1.1
Location : lambda$startGameAutomatically$1
Killed by : org.hplr.game.core.usecases.service.StartAllDueGamesAutomaticallyUseCaseServiceTests.[engine:junit-jupiter]/[class:org.hplr.game.core.usecases.service.StartAllDueGamesAutomaticallyUseCaseServiceTests]/[method:get_all_games_pass_validation_wrong_status_and_start_one()]
replaced boolean return with true for org/hplr/game/core/usecases/service/StartAllDueGamesAutomaticallyUseCaseService::lambda$startGameAutomatically$1 → KILLED

2.2
Location : lambda$startGameAutomatically$1
Killed by : org.hplr.game.core.usecases.service.StartAllDueGamesAutomaticallyUseCaseServiceTests.[engine:junit-jupiter]/[class:org.hplr.game.core.usecases.service.StartAllDueGamesAutomaticallyUseCaseServiceTests]/[method:get_all_games_pass_validation_and_start_one()]
replaced boolean return with false for org/hplr/game/core/usecases/service/StartAllDueGamesAutomaticallyUseCaseService::lambda$startGameAutomatically$1 → KILLED

45

1.1
Location : lambda$startGameAutomatically$2
Killed by : org.hplr.game.core.usecases.service.StartAllDueGamesAutomaticallyUseCaseServiceTests.[engine:junit-jupiter]/[class:org.hplr.game.core.usecases.service.StartAllDueGamesAutomaticallyUseCaseServiceTests]/[method:get_all_games_pass_validation_and_start_one()]
replaced boolean return with false for org/hplr/game/core/usecases/service/StartAllDueGamesAutomaticallyUseCaseService::lambda$startGameAutomatically$2 → KILLED

2.2
Location : lambda$startGameAutomatically$2
Killed by : org.hplr.game.core.usecases.service.StartAllDueGamesAutomaticallyUseCaseServiceTests.[engine:junit-jupiter]/[class:org.hplr.game.core.usecases.service.StartAllDueGamesAutomaticallyUseCaseServiceTests]/[method:get_all_games_pass_validation_wrong_date_and_start_one()]
replaced boolean return with true for org/hplr/game/core/usecases/service/StartAllDueGamesAutomaticallyUseCaseService::lambda$startGameAutomatically$2 → KILLED

48

1.1
Location : startGameAutomatically
Killed by : org.hplr.game.core.usecases.service.StartAllDueGamesAutomaticallyUseCaseServiceTests.[engine:junit-jupiter]/[class:org.hplr.game.core.usecases.service.StartAllDueGamesAutomaticallyUseCaseServiceTests]/[method:get_all_games_pass_validation_and_start_one()]
removed call to org/hplr/game/core/usecases/port/out/command/StartAllDueGamesCommandInterface::startAllDueGames → KILLED

Active mutators

Tests examined


Report generated by PIT 1.16.1