AddTeamToGithubJob.java

1
package edu.ucsb.cs156.frontiers.jobs;
2
3
import edu.ucsb.cs156.frontiers.entities.Course;
4
import edu.ucsb.cs156.frontiers.entities.Team;
5
import edu.ucsb.cs156.frontiers.repositories.TeamRepository;
6
import edu.ucsb.cs156.frontiers.services.GithubTeamService;
7
import edu.ucsb.cs156.frontiers.services.GithubTeamService.GithubTeamInfo;
8
import edu.ucsb.cs156.jobs.services.JobContext;
9
import edu.ucsb.cs156.jobs.services.JobContextConsumer;
10
import lombok.Builder;
11
12
@Builder
13
public class AddTeamToGithubJob implements JobContextConsumer {
14
  Course course;
15
  String teamName;
16
  TeamRepository teamRepository;
17
  GithubTeamService githubTeamService;
18
19
  @Override
20
  public String getScopeType() {
21 1 1. getScopeType : replaced return value with "" for edu/ucsb/cs156/frontiers/jobs/AddTeamToGithubJob::getScopeType → KILLED
    return "course";
22
  }
23
24
  @Override
25
  public Long getScopeId() {
26 1 1. getScopeId : replaced Long return value with 0L for edu/ucsb/cs156/frontiers/jobs/AddTeamToGithubJob::getScopeId → KILLED
    return course.getId();
27
  }
28
29
  @Override
30
  public void accept(JobContext ctx) throws Exception {
31 1 1. accept : removed call to edu/ucsb/cs156/jobs/services/JobContext::log → KILLED
    ctx.log("Starting add team to GitHub job for team: " + teamName);
32
33 1 1. accept : negated conditional → KILLED
    if (teamName == null) {
34 1 1. accept : removed call to edu/ucsb/cs156/jobs/services/JobContext::log → KILLED
      ctx.log("ERROR: Team has no name");
35
      return;
36
    }
37
38 2 1. accept : negated conditional → KILLED
2. accept : negated conditional → KILLED
    if (course.getOrgName() == null || course.getInstallationId() == null) {
39 1 1. accept : removed call to edu/ucsb/cs156/jobs/services/JobContext::log → KILLED
      ctx.log("ERROR: Course has no linked GitHub organization");
40
      return;
41
    }
42
43
    Team team = teamRepository.findByCourseIdAndName(course.getId(), teamName).orElse(null);
44 1 1. accept : negated conditional → KILLED
    if (team == null) {
45 1 1. accept : removed call to edu/ucsb/cs156/jobs/services/JobContext::log → KILLED
      ctx.log(
46
          "ERROR: Team with name '"
47
              + teamName
48
              + "' not found for course "
49
              + course.getCourseName());
50
      return;
51
    }
52
53
    try {
54
      GithubTeamInfo githubTeamInfo = githubTeamService.createTeamInfo(teamName, course);
55 1 1. accept : removed call to edu/ucsb/cs156/frontiers/entities/Team::setGithubTeamId → KILLED
      team.setGithubTeamId(githubTeamInfo.id());
56 1 1. accept : removed call to edu/ucsb/cs156/frontiers/entities/Team::setGithubTeamSlug → KILLED
      team.setGithubTeamSlug(githubTeamInfo.slug());
57
      teamRepository.save(team);
58 1 1. accept : removed call to edu/ucsb/cs156/jobs/services/JobContext::log → KILLED
      ctx.log(
59
          "Successfully added team '"
60
              + team.getName()
61
              + "' to GitHub with GitHub team ID: "
62
              + githubTeamInfo.id());
63
    } catch (Exception e) {
64
      throw new IllegalStateException("Failed to add team to GitHub: " + e.getMessage(), e);
65
    }
66
67 1 1. accept : negated conditional → KILLED
    if (Boolean.TRUE.equals(team.getIsStaffTeam())) {
68
      Integer orgId;
69
      try {
70
        orgId = githubTeamService.getOrgId(course.getOrgName(), course);
71
      } catch (Exception e) {
72
        throw new IllegalStateException(
73
            "Failed to get organization ID for org: "
74
                + course.getOrgName()
75
                + " - "
76
                + e.getMessage(),
77
            e);
78
      }
79 1 1. accept : removed call to edu/ucsb/cs156/frontiers/jobs/StaffTeamGithubSync::addStaffMembers → KILLED
      StaffTeamGithubSync.addStaffMembers(ctx, course, team, orgId, githubTeamService);
80
    }
81
82 1 1. accept : removed call to edu/ucsb/cs156/jobs/services/JobContext::log → KILLED
    ctx.log("Done");
83
  }
84
}

Mutations

21

1.1
Location : getScopeType
Killed by : edu.ucsb.cs156.frontiers.jobs.AddTeamToGithubJobTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.frontiers.jobs.AddTeamToGithubJobTests]/[method:test_getScope_returnsCourseScope()]
replaced return value with "" for edu/ucsb/cs156/frontiers/jobs/AddTeamToGithubJob::getScopeType → KILLED

26

1.1
Location : getScopeId
Killed by : edu.ucsb.cs156.frontiers.jobs.AddTeamToGithubJobTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.frontiers.jobs.AddTeamToGithubJobTests]/[method:test_getScope_returnsCourseScope()]
replaced Long return value with 0L for edu/ucsb/cs156/frontiers/jobs/AddTeamToGithubJob::getScopeId → KILLED

31

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

33

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

34

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

38

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

2.2
Location : accept
Killed by : edu.ucsb.cs156.frontiers.jobs.AddTeamToGithubJobTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.frontiers.jobs.AddTeamToGithubJobTests]/[method:test_CourseWithOrgNameButNoInstallationId()]
negated conditional → KILLED

39

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

44

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

45

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

55

1.1
Location : accept
Killed by : edu.ucsb.cs156.frontiers.jobs.AddTeamToGithubJobTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.frontiers.jobs.AddTeamToGithubJobTests]/[method:test_staffTeam_failsWhenTheOrgIdCannotBeFound()]
removed call to edu/ucsb/cs156/frontiers/entities/Team::setGithubTeamId → KILLED

56

1.1
Location : accept
Killed by : edu.ucsb.cs156.frontiers.jobs.AddTeamToGithubJobTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.frontiers.jobs.AddTeamToGithubJobTests]/[method:test_successfully_add_team()]
removed call to edu/ucsb/cs156/frontiers/entities/Team::setGithubTeamSlug → KILLED

58

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

67

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

79

1.1
Location : accept
Killed by : edu.ucsb.cs156.frontiers.jobs.AddTeamToGithubJobTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.frontiers.jobs.AddTeamToGithubJobTests]/[method:test_staffTeam_addsTheCourseStaffToTheNewGithubTeam()]
removed call to edu/ucsb/cs156/frontiers/jobs/StaffTeamGithubSync::addStaffMembers → KILLED

82

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

Active mutators

Tests examined


Report generated by PIT 1.30.0 support