InstructorReportJobSingleGame.java

1
package edu.ucsb.cs156.happiercows.jobs;
2
3
4
import java.util.Optional;
5
6
import edu.ucsb.cs156.happiercows.entities.Game;
7
import edu.ucsb.cs156.happiercows.entities.Report;
8
import edu.ucsb.cs156.happiercows.repositories.GameRepository;
9
import edu.ucsb.cs156.jobs.services.JobContext;
10
import edu.ucsb.cs156.jobs.services.JobContextConsumer;
11
import edu.ucsb.cs156.happiercows.services.ReportService;
12
import lombok.AllArgsConstructor;
13
import lombok.Getter;
14
15
@AllArgsConstructor
16
public class InstructorReportJobSingleGame implements JobContextConsumer {
17
18
    @Getter
19
    private long gameId;
20
21
    @Getter
22
    private ReportService reportService;
23
24
    @Getter
25
    private GameRepository gameRepository;
26
27
    @Override
28
    public void accept(JobContext ctx) throws Exception {
29 1 1. accept : removed call to edu/ucsb/cs156/jobs/services/JobContext::log → KILLED
        ctx.log("Producing instructor report for game id: " + gameId);
30
        Optional<Game> gameOpt = gameRepository.findById(gameId);
31 1 1. accept : negated conditional → KILLED
        if (!gameOpt.isPresent()) {
32 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));
33
            return;
34
        }
35 1 1. accept : negated conditional → KILLED
        if (!GameGate.shouldProcess(gameOpt.get(), gameRepository, ctx)) {
36
            return;
37
        }
38
        Report report = reportService.createReport(gameId);
39 1 1. accept : removed call to edu/ucsb/cs156/jobs/services/JobContext::log → KILLED
        ctx.log(String.format("Instructor report %d for game %s has been produced!", report.getId(), report.getName()));
40
    }
41
}

Mutations

29

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

31

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

32

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

35

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

39

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

Active mutators

Tests examined


Report generated by PIT 1.22.1