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.jobs.JobContext;
8
import edu.ucsb.cs156.frontiers.services.jobs.JobContextConsumer;
9
import lombok.Builder;
10
11
@Builder
12
public class AddTeamToGithubJob implements JobContextConsumer {
13
  Course course;
14
  String teamName;
15
  TeamRepository teamRepository;
16
  GithubTeamService githubTeamService;
17
18
  @Override
19
  public void accept(JobContext ctx) throws Exception {
20
    ctx.log("Starting add team to GitHub job for team: " + teamName);
21
22 1 1. accept : negated conditional → KILLED
    if (teamName == null) {
23
      ctx.log("ERROR: Team has no name");
24
      return;
25
    }
26
27 2 1. accept : negated conditional → KILLED
2. accept : negated conditional → KILLED
    if (course.getOrgName() == null || course.getInstallationId() == null) {
28
      ctx.log("ERROR: Course has no linked GitHub organization");
29
      return;
30
    }
31
32
    Team team = teamRepository.findByCourseIdAndName(course.getId(), teamName).orElse(null);
33 1 1. accept : negated conditional → KILLED
    if (team == null) {
34
      ctx.log(
35
          "ERROR: Team with name '"
36
              + teamName
37
              + "' not found for course "
38
              + course.getCourseName());
39
      return;
40
    }
41
42
    try {
43
      Integer githubTeamId = githubTeamService.createTeam(teamName, course);
44 1 1. accept : removed call to edu/ucsb/cs156/frontiers/entities/Team::setGithubTeamId → KILLED
      team.setGithubTeamId(githubTeamId);
45
      teamRepository.save(team);
46
      ctx.log(
47
          "Successfully added team '"
48
              + team.getName()
49
              + "' to GitHub with GitHub team ID: "
50
              + githubTeamId);
51
    } catch (Exception e) {
52
      ctx.log("ERROR: Failed to add team to GitHub: " + e.getMessage());
53
    }
54
55
    ctx.log("Done");
56
  }
57
}

Mutations

22

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

27

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

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_teamIsNull()]
negated conditional → 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_successfully_add_team()]
removed call to edu/ucsb/cs156/frontiers/entities/Team::setGithubTeamId → KILLED

Active mutators

Tests examined


Report generated by PIT 1.17.0