User.java

1
package edu.ucsb.cs156.happiercows.entities;
2
3
import com.fasterxml.jackson.annotation.JsonIgnore;
4
import lombok.*;
5
6
import javax.persistence.*;
7
import java.time.Instant;
8
import java.util.List;
9
10
@Data
11
@AllArgsConstructor
12
@NoArgsConstructor(access = AccessLevel.PROTECTED)
13
@Builder
14
@Entity(name = "users")
15
public class User {
16
    @Id
17
    @GeneratedValue(strategy = GenerationType.IDENTITY)
18
    private long id;
19
    private String email;
20
    private String googleSub;
21
    private String pictureUrl;
22
    private String fullName;
23
    private String givenName;
24
    private String familyName;
25
    private boolean emailVerified;
26
    private String locale;
27
    private String hostedDomain;
28
    private boolean admin;
29
30
    // using object wrapper class Boolean instead of primitive boolean to allow for null values
31
    // so that the @NoArgsConstructor can set the default value to null and the @Builder can set the default value to false
32
    // this is necessary because it breaks OAuth2 login otherwise
33
    @Builder.Default
34
    private Boolean suspended = false;
35
36
  @Builder.Default
37
  private Instant lastOnline = Instant.now();
38
39
  @ManyToMany(fetch = FetchType.EAGER, cascade = {CascadeType.PERSIST,CascadeType.REMOVE})
40
  @JoinTable(name = "user_commons", 
41
    joinColumns = @JoinColumn(name = "user_id", referencedColumnName = "id"), 
42
    inverseJoinColumns = @JoinColumn(name = "commons_id", referencedColumnName = "id"))
43
    private List<Commons> commons;
44
45
    @OneToMany(mappedBy = "user", cascade = CascadeType.REMOVE)
46
    @JsonIgnore
47
    private List<UserCommons> joinedCommons;
48
49
50
    @Override
51
    public String toString() {
52 1 1. toString : replaced return value with "" for edu/ucsb/cs156/happiercows/entities/User::toString → KILLED
        return String.format("User: id=%d email=%s", id, email);
53
    }
54
}

Mutations

52

1.1
Location : toString
Killed by : edu.ucsb.cs156.happiercows.entities.UserTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.happiercows.entities.UserTests]/[method:test_toString()]
replaced return value with "" for edu/ucsb/cs156/happiercows/entities/User::toString → KILLED

Active mutators

Tests examined


Report generated by PIT 1.7.3