RosterStudent.java

1
package edu.ucsb.cs156.frontiers.entities;
2
3
import com.fasterxml.jackson.annotation.JsonIgnore;
4
import edu.ucsb.cs156.frontiers.enums.OrgStatus;
5
import edu.ucsb.cs156.frontiers.enums.RosterStatus;
6
import jakarta.persistence.*;
7
import java.util.List;
8
import lombok.AllArgsConstructor;
9
import lombok.Builder;
10
import lombok.Data;
11
import lombok.EqualsAndHashCode;
12
import lombok.NoArgsConstructor;
13
import lombok.ToString;
14
import org.hibernate.annotations.Fetch;
15
import org.hibernate.annotations.FetchMode;
16
17
@Data
18
@AllArgsConstructor
19
@NoArgsConstructor
20
@Builder
21
@Entity
22
@Table(
23
    uniqueConstraints = {
24
      @UniqueConstraint(
25
          name = "UK_ROSTER_STUDENT_COURSE_STUDENT",
26
          columnNames = {"course_id", "student_id"}),
27
      @UniqueConstraint(
28
          name = "UK_ROSTER_STUDENT_COURSE_EMAIL",
29
          columnNames = {"course_id", "email"})
30
    })
31
@EqualsAndHashCode(exclude = {"teamMembers"})
32
public class RosterStudent {
33
  @Id
34
  @GeneratedValue(strategy = GenerationType.IDENTITY)
35
  private Long id;
36
37
  @ManyToOne
38
  @JoinColumn(name = "course_id")
39
  private Course course;
40
41
  private String studentId;
42
  private String firstName;
43
  private String lastName;
44
  private String email;
45
  @Builder.Default private String section = "";
46
47
  @ManyToOne
48
  @JoinColumn(name = "user_id")
49
  @ToString.Exclude
50
  private User user;
51
52
  @OneToMany(cascade = CascadeType.ALL, mappedBy = "rosterStudent")
53
  @Fetch(FetchMode.JOIN)
54
  @JsonIgnore
55
  @ToString.Exclude
56
  private List<TeamMember> teamMembers;
57
58
  @Enumerated(EnumType.STRING)
59
  private RosterStatus rosterStatus;
60
61
  @Enumerated(EnumType.STRING)
62
  private OrgStatus orgStatus;
63
64
  private Integer githubId;
65
  private String githubLogin;
66
67
  public List<String> getTeams() {
68 1 1. getTeams : negated conditional → KILLED
    if (teamMembers == null) {
69
      return List.of();
70
    } else {
71 2 1. lambda$getTeams$0 : replaced return value with "" for edu/ucsb/cs156/frontiers/entities/RosterStudent::lambda$getTeams$0 → KILLED
2. getTeams : replaced return value with Collections.emptyList for edu/ucsb/cs156/frontiers/entities/RosterStudent::getTeams → KILLED
      return teamMembers.stream().map(tm -> tm.getTeam().getName()).toList();
72
    }
73
  }
74
}

Mutations

68

1.1
Location : getTeams
Killed by : edu.ucsb.cs156.frontiers.models.RosterStudentDTOTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.frontiers.models.RosterStudentDTOTests]/[method:test_from_when_user_is_null()]
negated conditional → KILLED

71

1.1
Location : lambda$getTeams$0
Killed by : edu.ucsb.cs156.frontiers.models.RosterStudentDTOTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.frontiers.models.RosterStudentDTOTests]/[method:test_when_student_is_on_team()]
replaced return value with "" for edu/ucsb/cs156/frontiers/entities/RosterStudent::lambda$getTeams$0 → KILLED

2.2
Location : getTeams
Killed by : edu.ucsb.cs156.frontiers.models.RosterStudentDTOTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.frontiers.models.RosterStudentDTOTests]/[method:test_when_student_is_on_team()]
replaced return value with Collections.emptyList for edu/ucsb/cs156/frontiers/entities/RosterStudent::getTeams → KILLED

Active mutators

Tests examined


Report generated by PIT 1.17.0