SlackUser.java

1
package edu.ucsb.cs156.frontiers.models;
2
3
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
4
import com.fasterxml.jackson.annotation.JsonProperty;
5
import lombok.AllArgsConstructor;
6
import lombok.Builder;
7
import lombok.Data;
8
import lombok.NoArgsConstructor;
9
10
/**
11
 * A member of a Slack workspace, as returned by the Slack <code>users.list</code> method.
12
 *
13
 * @see <a href="https://docs.slack.dev/reference/objects/user-object">User object</a>
14
 */
15
@Data
16
@AllArgsConstructor
17
@NoArgsConstructor
18
@Builder
19
@JsonIgnoreProperties(ignoreUnknown = true)
20
public class SlackUser {
21
22
  /** Slack's built in Slackbot user is not flagged as a bot, but is not a person either. */
23
  public static final String SLACKBOT_ID = "USLACKBOT";
24
25
  private String id;
26
  private String name;
27
28
  /** True if the account has been deactivated. */
29
  private boolean deleted;
30
31
  @JsonProperty("real_name")
32
  private String realName;
33
34
  @JsonProperty("is_bot")
35
  private boolean bot;
36
37
  /** True if the user has been invited to the workspace, but has not yet signed in. */
38
  @JsonProperty("is_invited_user")
39
  private boolean invitedUser;
40
41
  private Profile profile;
42
43
  @Data
44
  @AllArgsConstructor
45
  @NoArgsConstructor
46
  @Builder
47
  @JsonIgnoreProperties(ignoreUnknown = true)
48
  public static class Profile {
49
    /** Only present when the token has the <code>users:read.email</code> scope. */
50
    private String email;
51
52
    @JsonProperty("display_name")
53
    private String displayName;
54
55
    @JsonProperty("first_name")
56
    private String firstName;
57
58
    @JsonProperty("last_name")
59
    private String lastName;
60
  }
61
62
  /**
63
   * @return the user's email, or null if Slack did not provide one
64
   */
65
  public String email() {
66 2 1. email : negated conditional → KILLED
2. email : replaced return value with "" for edu/ucsb/cs156/frontiers/models/SlackUser::email → KILLED
    return profile == null ? null : profile.getEmail();
67
  }
68
69
  /**
70
   * @return the user's display name, or null if Slack did not provide one
71
   */
72
  public String displayName() {
73 2 1. displayName : replaced return value with "" for edu/ucsb/cs156/frontiers/models/SlackUser::displayName → KILLED
2. displayName : negated conditional → KILLED
    return profile == null ? null : profile.getDisplayName();
74
  }
75
76
  /**
77
   * @return the user's first name, or null if Slack did not provide one
78
   */
79
  public String firstName() {
80 2 1. firstName : negated conditional → KILLED
2. firstName : replaced return value with "" for edu/ucsb/cs156/frontiers/models/SlackUser::firstName → KILLED
    return profile == null ? null : profile.getFirstName();
81
  }
82
83
  /**
84
   * @return the user's last name, or null if Slack did not provide one
85
   */
86
  public String lastName() {
87 2 1. lastName : negated conditional → KILLED
2. lastName : replaced return value with "" for edu/ucsb/cs156/frontiers/models/SlackUser::lastName → KILLED
    return profile == null ? null : profile.getLastName();
88
  }
89
90
  /**
91
   * @return true if this is a person (not a bot, and not Slackbot)
92
   */
93
  public boolean isPerson() {
94 3 1. isPerson : replaced boolean return with true for edu/ucsb/cs156/frontiers/models/SlackUser::isPerson → KILLED
2. isPerson : negated conditional → KILLED
3. isPerson : negated conditional → KILLED
    return !bot && !SLACKBOT_ID.equals(id);
95
  }
96
97
  /**
98
   * @return true if this is a person with an account that is neither deactivated nor still waiting
99
   *     for an invitation to be accepted
100
   */
101
  public boolean isActivePerson() {
102 4 1. isActivePerson : replaced boolean return with true for edu/ucsb/cs156/frontiers/models/SlackUser::isActivePerson → KILLED
2. isActivePerson : negated conditional → KILLED
3. isActivePerson : negated conditional → KILLED
4. isActivePerson : negated conditional → KILLED
    return isPerson() && !deleted && !invitedUser;
103
  }
104
}

Mutations

66

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

2.2
Location : email
Killed by : edu.ucsb.cs156.frontiers.models.SlackUserTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.frontiers.models.SlackUserTests]/[method:email_and_names_are_null_without_profile()]
replaced return value with "" for edu/ucsb/cs156/frontiers/models/SlackUser::email → KILLED

73

1.1
Location : displayName
Killed by : edu.ucsb.cs156.frontiers.models.SlackUserTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.frontiers.models.SlackUserTests]/[method:email_and_names_are_null_without_profile()]
replaced return value with "" for edu/ucsb/cs156/frontiers/models/SlackUser::displayName → KILLED

2.2
Location : displayName
Killed by : edu.ucsb.cs156.frontiers.models.SlackUserTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.frontiers.models.SlackUserTests]/[method:email_and_names_are_null_without_profile()]
negated conditional → KILLED

80

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

2.2
Location : firstName
Killed by : edu.ucsb.cs156.frontiers.models.SlackUserTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.frontiers.models.SlackUserTests]/[method:email_and_names_are_null_without_profile()]
replaced return value with "" for edu/ucsb/cs156/frontiers/models/SlackUser::firstName → KILLED

87

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

2.2
Location : lastName
Killed by : edu.ucsb.cs156.frontiers.models.SlackUserTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.frontiers.models.SlackUserTests]/[method:email_and_names_are_null_without_profile()]
replaced return value with "" for edu/ucsb/cs156/frontiers/models/SlackUser::lastName → KILLED

94

1.1
Location : isPerson
Killed by : edu.ucsb.cs156.frontiers.models.SlackUserTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.frontiers.models.SlackUserTests]/[method:isPerson_excludes_bots_and_slackbot()]
replaced boolean return with true for edu/ucsb/cs156/frontiers/models/SlackUser::isPerson → KILLED

2.2
Location : isPerson
Killed by : edu.ucsb.cs156.frontiers.models.SlackUserTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.frontiers.models.SlackUserTests]/[method:isPerson_excludes_bots_and_slackbot()]
negated conditional → KILLED

3.3
Location : isPerson
Killed by : edu.ucsb.cs156.frontiers.models.SlackUserTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.frontiers.models.SlackUserTests]/[method:isPerson_excludes_bots_and_slackbot()]
negated conditional → KILLED

102

1.1
Location : isActivePerson
Killed by : edu.ucsb.cs156.frontiers.models.SlackUserTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.frontiers.models.SlackUserTests]/[method:isActivePerson_excludes_deactivated_invited_and_non_people()]
replaced boolean return with true for edu/ucsb/cs156/frontiers/models/SlackUser::isActivePerson → KILLED

2.2
Location : isActivePerson
Killed by : edu.ucsb.cs156.frontiers.models.SlackUserTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.frontiers.models.SlackUserTests]/[method:isActivePerson_excludes_deactivated_invited_and_non_people()]
negated conditional → KILLED

3.3
Location : isActivePerson
Killed by : edu.ucsb.cs156.frontiers.models.SlackUserTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.frontiers.models.SlackUserTests]/[method:isActivePerson_excludes_deactivated_invited_and_non_people()]
negated conditional → KILLED

4.4
Location : isActivePerson
Killed by : edu.ucsb.cs156.frontiers.models.SlackUserTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.frontiers.models.SlackUserTests]/[method:isActivePerson_excludes_deactivated_invited_and_non_people()]
negated conditional → KILLED

Active mutators

Tests examined


Report generated by PIT 1.30.0 support