CurrentUserService.java

1
package edu.ucsb.cs156.frontiers.services;
2
3
import edu.ucsb.cs156.frontiers.entities.User;
4
import edu.ucsb.cs156.frontiers.models.CurrentUser;
5
import java.util.Collection;
6
import org.springframework.security.core.GrantedAuthority;
7
8
/**
9
 * This is a service that provides information about the current user.
10
 *
11
 * <p>It is an abstract class because we have different implementations for testing and production.
12
 */
13
public abstract class CurrentUserService {
14
15
  /**
16
   * This method returns the current user as a User object.
17
   *
18
   * @return the current user
19
   */
20
  public abstract User getUser();
21
22
  /**
23
   * This method returns the current user as a CurrentUser object
24
   *
25
   * @return the current user
26
   */
27
  public abstract CurrentUser getCurrentUser();
28
29
  /**
30
   * This method returns the roles of the current user.
31
   *
32
   * @return a collection of roles
33
   */
34
  public abstract Collection<? extends GrantedAuthority> getRoles();
35
36
  /**
37
   * This method returns whether the current user is logged in.
38
   *
39
   * @return whether the current user is logged in
40
   */
41
  public final boolean isLoggedIn() {
42 2 1. isLoggedIn : negated conditional → KILLED
2. isLoggedIn : replaced boolean return with true for edu/ucsb/cs156/frontiers/services/CurrentUserService::isLoggedIn → KILLED
    return getUser() != null;
43
  }
44
}

Mutations

42

1.1
Location : isLoggedIn
Killed by : edu.ucsb.cs156.frontiers.services.CurrentUserServiceTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.frontiers.services.CurrentUserServiceTests]/[method:test_isLoggedIn_returns_true()]
negated conditional → KILLED

2.2
Location : isLoggedIn
Killed by : edu.ucsb.cs156.frontiers.services.CurrentUserServiceTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.frontiers.services.CurrentUserServiceTests]/[method:test_isLoggedIn_returns_false()]
replaced boolean return with true for edu/ucsb/cs156/frontiers/services/CurrentUserService::isLoggedIn → KILLED

Active mutators

Tests examined


Report generated by PIT 1.17.0