RecordCommonStatsJob.java

1
package edu.ucsb.cs156.happiercows.jobs;
2
3
import edu.ucsb.cs156.happiercows.entities.Commons;
4
import edu.ucsb.cs156.happiercows.entities.CommonStats;
5
import edu.ucsb.cs156.happiercows.repositories.CommonsRepository;
6
import edu.ucsb.cs156.happiercows.services.CommonStatsService;
7
import edu.ucsb.cs156.happiercows.services.jobs.JobContext;
8
import edu.ucsb.cs156.happiercows.services.jobs.JobContextConsumer;
9
import lombok.AllArgsConstructor;
10
import lombok.Getter;
11
12
13
/** This job computes the stats for all games in progress and creates one new row in the CommonsStats table for each commons.   It uses the Average Cow Health Service to compute the cowhealth for each commons.
14
*/
15
16
@AllArgsConstructor
17
public class RecordCommonStatsJob implements JobContextConsumer {
18
19
    @Getter
20
    private CommonStatsService commonStatsService;
21
22
    @Getter
23
    private CommonsRepository commonsRepository;
24
25
    @Override
26
    public void accept(JobContext ctx) throws Exception {
27 1 1. accept : removed call to edu/ucsb/cs156/happiercows/services/jobs/JobContext::log → KILLED
        ctx.log("Starting record common stats job...");
28
        Iterable<Commons> allCommons = commonsRepository.findAll();
29
30
        for (Commons commons : allCommons) {
31 1 1. accept : removed call to edu/ucsb/cs156/happiercows/services/jobs/JobContext::log → KILLED
            ctx.log(String.format("Starting Commons id=%d (%s)...", commons.getId(), commons.getName()));
32
            CommonStats commonStats = commonStatsService.createAndSaveCommonStats(commons.getId());
33 1 1. accept : removed call to edu/ucsb/cs156/happiercows/services/jobs/JobContext::log → KILLED
            ctx.log(String.format("CommonStats %d for commons id=%d (%s) finished.", commonStats.getId(), commons.getId(),
34
                    commons.getName()));
35
        }
36 1 1. accept : removed call to edu/ucsb/cs156/happiercows/services/jobs/JobContext::log → KILLED
        ctx.log("Record common stats job done!");
37
    }
38
}
39

Mutations

27

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

31

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

33

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

36

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

Active mutators

Tests examined


Report generated by PIT 1.7.3