UserCommons.java

1
package edu.ucsb.cs156.happiercows.entities;
2
3
import java.util.HashSet;
4
import java.util.Set;
5
import lombok.Data;
6
import lombok.EqualsAndHashCode;
7
import lombok.AllArgsConstructor;
8
import lombok.NoArgsConstructor;
9
import lombok.NonNull;
10
import lombok.Builder;
11
import lombok.AccessLevel;
12
13
14
import javax.persistence.*;
15
16
import com.fasterxml.jackson.annotation.JsonManagedReference;
17
18
@Data
19
@AllArgsConstructor
20
@NoArgsConstructor(access = AccessLevel.PROTECTED)
21
@Builder
22
@Entity(name = "user_commons")
23
public class UserCommons {
24
  @Id
25
  @GeneratedValue(strategy = GenerationType.IDENTITY)
26
  private long id;  
27
28
  @Column(name="commons_id")
29
  private long commonsId;  
30
31
  @Column(name="user_id")
32
  private long userId;  
33
34
  private String username;
35
36
  private double totalWealth;
37
38
  @EqualsAndHashCode.Exclude
39
  @JsonManagedReference
40
  @Builder.Default
41
  @OneToMany(mappedBy = "userCommons", cascade = CascadeType.ALL, fetch = FetchType.EAGER)
42
  private Set<CowHerd> cowHerds = new HashSet<CowHerd>();
43
44
  public Set<CowHerd> getCowHerds() {
45
    // Required for backwards compatibility
46 1 1. getCowHerds : negated conditional → KILLED
    if (this.cowHerds == null) {
47
      this.cowHerds = new HashSet<>();
48
    }
49 1 1. getCowHerds : replaced return value with Collections.emptySet for edu/ucsb/cs156/happiercows/entities/UserCommons::getCowHerds → KILLED
    return this.cowHerds;
50
  }
51
52
  // TODO: Remove once `cowHerds` is fully implemented
53
  private int numOfCows;
54
55
  private double cowHealth;
56
57
  private int lifetimeCowsBought;
58
59
  private int lifetimeCowsSold;
60
}
61

Mutations

46

1.1
Location : getCowHerds
Killed by : edu.ucsb.cs156.happiercows.entities.UserCommonsTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.happiercows.entities.UserCommonsTests]/[method:getCowHerds_when_not_null()]
negated conditional → KILLED

49

1.1
Location : getCowHerds
Killed by : edu.ucsb.cs156.happiercows.entities.UserCommonsTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.happiercows.entities.UserCommonsTests]/[method:getCowHerds_when_not_null()]
replaced return value with Collections.emptySet for edu/ucsb/cs156/happiercows/entities/UserCommons::getCowHerds → KILLED

Active mutators

Tests examined


Report generated by PIT 1.7.3