UpdateCowHealthJobInd.java

1
package edu.ucsb.cs156.happiercows.jobs;
2
3
import java.util.Optional;
4
5
import edu.ucsb.cs156.happiercows.entities.Commons;
6
import edu.ucsb.cs156.happiercows.entities.CommonsPlus;
7
import edu.ucsb.cs156.happiercows.repositories.CommonsRepository;
8
import edu.ucsb.cs156.happiercows.repositories.UserCommonsRepository;
9
import edu.ucsb.cs156.happiercows.repositories.UserRepository;
10
import edu.ucsb.cs156.happiercows.services.CommonsPlusBuilderService;
11
import edu.ucsb.cs156.happiercows.services.jobs.JobContext;
12
import edu.ucsb.cs156.happiercows.services.jobs.JobContextConsumer;
13
import lombok.AllArgsConstructor;
14
import lombok.Getter;
15
16
@AllArgsConstructor
17
public class UpdateCowHealthJobInd implements JobContextConsumer {
18
19
    @Getter
20
    private CommonsRepository commonsRepository;
21
    @Getter
22
    private UserCommonsRepository userCommonsRepository;
23
    @Getter
24
    private UserRepository userRepository;
25
    @Getter
26
    private CommonsPlusBuilderService commonsPlusBuilderService;
27
    @Getter
28
    private Long commonsID;
29
30
    @Override
31
    public void accept(JobContext ctx) throws Exception {
32 1 1. accept : removed call to edu/ucsb/cs156/happiercows/services/jobs/JobContext::log → KILLED
        ctx.log("Updating cow health...");
33
34
       Optional<Commons> commonUpdatedOpt = commonsRepository.findById(commonsID);
35
36
37 1 1. accept : negated conditional → KILLED
        if(commonUpdatedOpt.isPresent()){
38
            Commons commonsUpdated = commonUpdatedOpt.get();
39
            CommonsPlus commonsPlus = commonsPlusBuilderService.toCommonsPlus(commonsUpdated);
40 1 1. accept : removed call to edu/ucsb/cs156/happiercows/jobs/UpdateCowHealthJob::runUpdateJobInCommons → KILLED
            UpdateCowHealthJob.runUpdateJobInCommons(commonsUpdated, commonsPlus, commonsPlusBuilderService, commonsRepository, userCommonsRepository, ctx); 
41 1 1. accept : removed call to edu/ucsb/cs156/happiercows/services/jobs/JobContext::log → KILLED
            ctx.log("Cow health has been updated!");
42
        } else {
43 1 1. accept : removed call to edu/ucsb/cs156/happiercows/services/jobs/JobContext::log → KILLED
            ctx.log(String.format("No commons found for id %d", commonsID));
44
        }
45
    }
46
    
47
}

Mutations

32

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_commons()]
removed call to edu/ucsb/cs156/happiercows/services/jobs/JobContext::log → KILLED

37

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_commons()]
negated conditional → 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_update_one_commons()]
removed call to edu/ucsb/cs156/happiercows/jobs/UpdateCowHealthJob::runUpdateJobInCommons → KILLED

41

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_commons()]
removed call to edu/ucsb/cs156/happiercows/services/jobs/JobContext::log → KILLED

43

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_commons()]
removed call to edu/ucsb/cs156/happiercows/services/jobs/JobContext::log → KILLED

Active mutators

Tests examined


Report generated by PIT 1.7.3