UploadGradeDataJob.java

1
package edu.ucsb.cs156.courses.jobs;
2
3
import edu.ucsb.cs156.courses.entities.GradeHistory;
4
import edu.ucsb.cs156.courses.repositories.GradeHistoryRepository;
5
import edu.ucsb.cs156.courses.services.UCSBGradeHistoryServiceImpl;
6
import edu.ucsb.cs156.courses.services.jobs.JobContext;
7
import edu.ucsb.cs156.courses.services.jobs.JobContextConsumer;
8
import java.util.ArrayList;
9
import java.util.List;
10
import lombok.AllArgsConstructor;
11
import lombok.Getter;
12
13
@AllArgsConstructor
14
public class UploadGradeDataJob implements JobContextConsumer {
15
  @Getter private UCSBGradeHistoryServiceImpl ucsbGradeHistoryServiceImpl;
16
  @Getter private GradeHistoryRepository gradeHistoryRepository;
17
18
  @Override
19
  public void accept(JobContext ctx) throws Exception {
20 1 1. accept : removed call to edu/ucsb/cs156/courses/services/jobs/JobContext::log → KILLED
    ctx.log("Updating UCSB Grade History Data");
21
    List<String> urls = ucsbGradeHistoryServiceImpl.getUrls();
22
    GradeHistory previous = new GradeHistory();
23
    List<GradeHistory> results = null;
24
    for (String url : urls) {
25
      results = ucsbGradeHistoryServiceImpl.getGradeData(url);
26
      GradeHistory topRow = results.get(0);
27
      upsertAll(gradeHistoryRepository, results);
28 1 1. accept : removed call to edu/ucsb/cs156/courses/jobs/UploadGradeDataJob::logProgress → KILLED
      logProgress(ctx, topRow, previous);
29
    }
30
31 1 1. accept : removed call to edu/ucsb/cs156/courses/services/jobs/JobContext::log → KILLED
    ctx.log("Finished updating UCSB Grade History Data");
32
  }
33
34
  private void logProgress(JobContext ctx, GradeHistory topRow, GradeHistory previous) {
35 1 1. logProgress : negated conditional → KILLED
    if (!topRow.getYyyyq().equals(previous.getYyyyq())) {
36 1 1. logProgress : removed call to edu/ucsb/cs156/courses/services/jobs/JobContext::log → KILLED
      ctx.log("Processing data for year: " + topRow.getYyyyq());
37 1 1. logProgress : removed call to edu/ucsb/cs156/courses/entities/GradeHistory::setYyyyq → KILLED
      previous.setYyyyq(topRow.getYyyyq());
38
    }
39 1 1. logProgress : removed call to edu/ucsb/cs156/courses/services/jobs/JobContext::log → KILLED
    ctx.log("Processing data for subjectArea: " + topRow.getSubjectArea());
40
  }
41
42
  public static List<GradeHistory> upsertAll(
43
      GradeHistoryRepository gradeHistoryRepository, List<GradeHistory> gradeHistories) {
44
    List<GradeHistory> result = new ArrayList<GradeHistory>();
45
    for (GradeHistory gradeHistory : gradeHistories) {
46
      List<GradeHistory> query =
47
          gradeHistoryRepository.findByYyyyqAndCourseAndInstructorAndGrade(
48
              gradeHistory.getYyyyq(),
49
              gradeHistory.getCourse(),
50
              gradeHistory.getInstructor(),
51
              gradeHistory.getGrade());
52 1 1. upsertAll : negated conditional → KILLED
      if (query.size() == 0) {
53
        gradeHistoryRepository.save(gradeHistory);
54
        result.add(gradeHistory);
55
      } else {
56
        GradeHistory existing = query.get(0);
57 1 1. upsertAll : removed call to edu/ucsb/cs156/courses/entities/GradeHistory::setCount → KILLED
        existing.setCount(gradeHistory.getCount());
58
        existing = gradeHistoryRepository.save(existing);
59
        result.add(existing);
60
      }
61
    }
62 1 1. upsertAll : replaced return value with Collections.emptyList for edu/ucsb/cs156/courses/jobs/UploadGradeDataJob::upsertAll → KILLED
    return result;
63
  }
64
}

Mutations

20

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

28

1.1
Location : accept
Killed by : edu.ucsb.cs156.courses.jobs.UploadGradeDataJobTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.courses.jobs.UploadGradeDataJobTests]/[method:test_log_output_success()]
removed call to edu/ucsb/cs156/courses/jobs/UploadGradeDataJob::logProgress → KILLED

31

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

35

1.1
Location : logProgress
Killed by : edu.ucsb.cs156.courses.jobs.UploadGradeDataJobTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.courses.jobs.UploadGradeDataJobTests]/[method:test_log_output_success()]
negated conditional → KILLED

36

1.1
Location : logProgress
Killed by : edu.ucsb.cs156.courses.jobs.UploadGradeDataJobTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.courses.jobs.UploadGradeDataJobTests]/[method:test_log_output_success()]
removed call to edu/ucsb/cs156/courses/services/jobs/JobContext::log → KILLED

37

1.1
Location : logProgress
Killed by : edu.ucsb.cs156.courses.jobs.UploadGradeDataJobTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.courses.jobs.UploadGradeDataJobTests]/[method:test_log_output_success()]
removed call to edu/ucsb/cs156/courses/entities/GradeHistory::setYyyyq → KILLED

39

1.1
Location : logProgress
Killed by : edu.ucsb.cs156.courses.jobs.UploadGradeDataJobTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.courses.jobs.UploadGradeDataJobTests]/[method:test_log_output_success()]
removed call to edu/ucsb/cs156/courses/services/jobs/JobContext::log → KILLED

52

1.1
Location : upsertAll
Killed by : edu.ucsb.cs156.courses.jobs.UploadGradeDataJobTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.courses.jobs.UploadGradeDataJobTests]/[method:test_upsertAll()]
negated conditional → KILLED

57

1.1
Location : upsertAll
Killed by : edu.ucsb.cs156.courses.jobs.UploadGradeDataJobTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.courses.jobs.UploadGradeDataJobTests]/[method:test_upsertAll()]
removed call to edu/ucsb/cs156/courses/entities/GradeHistory::setCount → KILLED

62

1.1
Location : upsertAll
Killed by : edu.ucsb.cs156.courses.jobs.UploadGradeDataJobTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.courses.jobs.UploadGradeDataJobTests]/[method:test_upsertAll()]
replaced return value with Collections.emptyList for edu/ucsb/cs156/courses/jobs/UploadGradeDataJob::upsertAll → KILLED

Active mutators

Tests examined


Report generated by PIT 1.7.3