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