UpdateCowHealthJobInd.java

1
package edu.ucsb.cs156.happiercows.jobs;
2
3
import java.util.Optional;
4
5
import edu.ucsb.cs156.happiercows.entities.Game;
6
import edu.ucsb.cs156.happiercows.entities.GamePlus;
7
import edu.ucsb.cs156.happiercows.repositories.GameRepository;
8
import edu.ucsb.cs156.happiercows.repositories.FarmerRepository;
9
import edu.ucsb.cs156.happiercows.repositories.UserRepository;
10
import edu.ucsb.cs156.happiercows.repositories.CowHerdRepository;
11
import edu.ucsb.cs156.happiercows.services.GamePlusBuilderService;
12
import edu.ucsb.cs156.jobs.services.JobContext;
13
import edu.ucsb.cs156.jobs.services.JobContextConsumer;
14
import lombok.AllArgsConstructor;
15
import lombok.Getter;
16
17
@AllArgsConstructor
18
public class UpdateCowHealthJobInd implements JobContextConsumer {
19
20
    @Getter
21
    private GameRepository gameRepository;
22
    @Getter
23
    private FarmerRepository farmerRepository;
24
    @Getter
25
    private UserRepository userRepository;
26
    @Getter
27
    private GamePlusBuilderService gamePlusBuilderService;
28
    @Getter
29
    private CowHerdRepository cowHerdRepository;
30
    @Getter
31
    private Long gameID;
32
33
    @Override
34
    public void accept(JobContext ctx) throws Exception {
35 1 1. accept : removed call to edu/ucsb/cs156/jobs/services/JobContext::log → KILLED
        ctx.log("Updating cow health...");
36
37
       Optional<Game> commonUpdatedOpt = gameRepository.findById(gameID);
38
39
40 1 1. accept : negated conditional → KILLED
        if(commonUpdatedOpt.isPresent()){
41
            Game gameUpdated = commonUpdatedOpt.get();
42 1 1. accept : negated conditional → KILLED
            if (!GameGate.shouldProcess(gameUpdated, gameRepository, ctx)) {
43
                return;
44
            }
45
            GamePlus gamePlus = gamePlusBuilderService.toGamePlus(gameUpdated);
46 1 1. accept : removed call to edu/ucsb/cs156/happiercows/jobs/UpdateCowHealthJob::runUpdateJobInGame → KILLED
            UpdateCowHealthJob.runUpdateJobInGame(
47
                gameUpdated, gamePlus, gamePlusBuilderService,
48
                gameRepository, farmerRepository, cowHerdRepository, ctx);
49 1 1. accept : removed call to edu/ucsb/cs156/jobs/services/JobContext::log → KILLED
            ctx.log("Cow health has been updated!");
50
        } else {
51 1 1. accept : removed call to edu/ucsb/cs156/jobs/services/JobContext::log → KILLED
            ctx.log(String.format("No game found for id %d", gameID));
52
        }
53
    }
54
    
55
}

Mutations

35

1.1
Location : accept
Killed by : edu.ucsb.cs156.happiercows.jobs.UpdateCowHealthJobIndTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.happiercows.jobs.UpdateCowHealthJobIndTests]/[method:test_log_output_with_no_game()]
removed call to edu/ucsb/cs156/jobs/services/JobContext::log → KILLED

40

1.1
Location : accept
Killed by : edu.ucsb.cs156.happiercows.jobs.UpdateCowHealthJobIndTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.happiercows.jobs.UpdateCowHealthJobIndTests]/[method:test_log_output_with_no_game()]
negated conditional → KILLED

42

1.1
Location : accept
Killed by : edu.ucsb.cs156.happiercows.jobs.UpdateCowHealthJobIndTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.happiercows.jobs.UpdateCowHealthJobIndTests]/[method:test_skips_game_when_game_not_in_progress()]
negated conditional → KILLED

46

1.1
Location : accept
Killed by : edu.ucsb.cs156.happiercows.jobs.UpdateCowHealthJobIndTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.happiercows.jobs.UpdateCowHealthJobIndTests]/[method:test_update_one_game()]
removed call to edu/ucsb/cs156/happiercows/jobs/UpdateCowHealthJob::runUpdateJobInGame → KILLED

49

1.1
Location : accept
Killed by : edu.ucsb.cs156.happiercows.jobs.UpdateCowHealthJobIndTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.happiercows.jobs.UpdateCowHealthJobIndTests]/[method:test_update_one_game()]
removed call to edu/ucsb/cs156/jobs/services/JobContext::log → KILLED

51

1.1
Location : accept
Killed by : edu.ucsb.cs156.happiercows.jobs.UpdateCowHealthJobIndTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.happiercows.jobs.UpdateCowHealthJobIndTests]/[method:test_log_output_with_no_game()]
removed call to edu/ucsb/cs156/jobs/services/JobContext::log → KILLED

Active mutators

Tests examined


Report generated by PIT 1.22.1