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

Mutations

20

1.1
Location : getCourse
Killed by : edu.ucsb.cs156.frontiers.jobs.AddTeamToGithubJobTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.frontiers.jobs.AddTeamToGithubJobTests]/[method:test_getCourse_returnsCourse()]
replaced return value with null for edu/ucsb/cs156/frontiers/jobs/AddTeamToGithubJob::getCourse → 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_teamNameIsNull()]
negated conditional → KILLED

32

1.1
Location : accept
Killed by : edu.ucsb.cs156.frontiers.jobs.AddTeamToGithubJobTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.frontiers.jobs.AddTeamToGithubJobTests]/[method:test_TeamCreationFailure()]
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

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_TeamCreationFailure()]
negated conditional → KILLED

49

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