AddTeamMemberToGithubJob.java

1
package edu.ucsb.cs156.frontiers.jobs;
2
3
import edu.ucsb.cs156.frontiers.entities.Course;
4
import edu.ucsb.cs156.frontiers.entities.TeamMember;
5
import edu.ucsb.cs156.frontiers.enums.TeamStatus;
6
import edu.ucsb.cs156.frontiers.repositories.TeamMemberRepository;
7
import edu.ucsb.cs156.frontiers.services.GithubTeamService;
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 AddTeamMemberToGithubJob implements JobContextConsumer {
14
  String memberGithubLogin;
15
  Integer githubTeamId;
16
  Long teamMemberId;
17
  Course course;
18
  GithubTeamService githubTeamService;
19
  TeamMemberRepository teamMemberRepository;
20
21
  @Override
22
  public String getScopeType() {
23 1 1. getScopeType : replaced return value with "" for edu/ucsb/cs156/frontiers/jobs/AddTeamMemberToGithubJob::getScopeType → KILLED
    return "course";
24
  }
25
26
  @Override
27
  public Long getScopeId() {
28 1 1. getScopeId : replaced Long return value with 0L for edu/ucsb/cs156/frontiers/jobs/AddTeamMemberToGithubJob::getScopeId → KILLED
    return course.getId();
29
  }
30
31
  @Override
32
  public void accept(JobContext ctx) throws Exception {
33 1 1. accept : removed call to edu/ucsb/cs156/jobs/services/JobContext::log → KILLED
    ctx.log(
34
        "Starting add team member to GitHub job for team ID "
35
            + githubTeamId
36
            + " member "
37
            + memberGithubLogin);
38
39 1 1. accept : negated conditional → KILLED
    if (githubTeamId == null) {
40 1 1. accept : removed call to edu/ucsb/cs156/jobs/services/JobContext::log → KILLED
      ctx.log("ERROR: Team has no GitHub team ID");
41
      return;
42
    }
43
44 1 1. accept : negated conditional → KILLED
    if (memberGithubLogin == null) {
45 1 1. accept : removed call to edu/ucsb/cs156/jobs/services/JobContext::log → KILLED
      ctx.log("ERROR: Team member has no GitHub login");
46
      return;
47
    }
48
49 2 1. accept : negated conditional → KILLED
2. accept : negated conditional → KILLED
    if (course.getOrgName() == null || course.getInstallationId() == null) {
50 1 1. accept : removed call to edu/ucsb/cs156/jobs/services/JobContext::log → KILLED
      ctx.log("ERROR: Course has no linked GitHub organization");
51
      return;
52
    }
53
54
    Integer orgId = null;
55
    try {
56
      orgId = githubTeamService.getOrgId(course.getOrgName(), course);
57
    } catch (Exception e) {
58
      throw new IllegalStateException(
59
          "Failed to get organization ID for org: " + course.getOrgName() + " - " + e.getMessage(),
60
          e);
61
    }
62
63
    try {
64
      TeamStatus newStatus =
65
          githubTeamService.addMemberToGithubTeam(
66
              memberGithubLogin, githubTeamId, "member", course, orgId);
67 1 1. accept : removed call to edu/ucsb/cs156/jobs/services/JobContext::log → KILLED
      ctx.log(
68
          "Successfully added " + memberGithubLogin + " to Github team with status: " + newStatus);
69
70
      TeamMember teamMember = teamMemberRepository.findById(teamMemberId).orElse(null);
71 1 1. accept : negated conditional → KILLED
      if (teamMember != null) {
72 1 1. accept : removed call to edu/ucsb/cs156/frontiers/entities/TeamMember::setTeamStatus → KILLED
        teamMember.setTeamStatus(newStatus);
73
        teamMemberRepository.save(teamMember);
74 1 1. accept : removed call to edu/ucsb/cs156/jobs/services/JobContext::log → KILLED
        ctx.log("Updated team member status in database");
75
      } else {
76 1 1. accept : removed call to edu/ucsb/cs156/jobs/services/JobContext::log → KILLED
        ctx.log("ERROR: Could not find team member in database with ID: " + teamMemberId);
77
      }
78
    } catch (Exception e) {
79
      throw new IllegalStateException("Failed to add user to GitHub team: " + e.getMessage(), e);
80
    }
81
82 1 1. accept : removed call to edu/ucsb/cs156/jobs/services/JobContext::log → KILLED
    ctx.log("Done");
83
  }
84
}

Mutations

23

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

28

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

33

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

39

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

40

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

44

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

45

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

49

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

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

50

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

67

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

71

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

72

1.1
Location : accept
Killed by : edu.ucsb.cs156.frontiers.jobs.AddTeamMemberToGithubJobTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.frontiers.jobs.AddTeamMemberToGithubJobTests]/[method:test_successfully_add_team_member_and_update_status()]
removed call to edu/ucsb/cs156/frontiers/entities/TeamMember::setTeamStatus → KILLED

74

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

76

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

82

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

Active mutators

Tests examined


Report generated by PIT 1.30.0 support