1 | package edu.ucsb.cs156.example.controllers; | |
2 | ||
3 | import org.springframework.beans.factory.annotation.Autowired; | |
4 | import org.springframework.web.bind.annotation.GetMapping; | |
5 | import org.springframework.web.bind.annotation.RestController; | |
6 | ||
7 | import edu.ucsb.cs156.example.services.CurrentUserService; | |
8 | ||
9 | @RestController | |
10 | public class HomepageController { | |
11 | ||
12 | @Autowired | |
13 | CurrentUserService currentUserService; | |
14 | ||
15 | @GetMapping("/") | |
16 | public String index() { | |
17 | String HomePageHTMLTemplate = """ | |
18 | <p>This is the homepage for team01 which is simply a backend with no frontend.</p> | |
19 | <p> | |
20 | <ul> | |
21 | %s | |
22 | %s | |
23 | %s | |
24 | <li><a href="/swagger-ui/index.html">Swagger API Links</a></li> | |
25 | <li><a href="/h2-console">H2 console (only on localhost)</a></li> | |
26 | </ul> | |
27 | </p> | |
28 | """; | |
29 |
1
1. index : replaced return value with "" for edu/ucsb/cs156/example/controllers/HomepageController::index → KILLED |
return String.format(HomePageHTMLTemplate, getLoggedInAs(), getLoginLogoutLink(), getRoles()); |
30 | } | |
31 | ||
32 | private String getLoginLogoutLink() { | |
33 | ||
34 |
2
1. getLoginLogoutLink : replaced return value with "" for edu/ucsb/cs156/example/controllers/HomepageController::getLoginLogoutLink → KILLED 2. getLoginLogoutLink : negated conditional → KILLED |
return currentUserService.isLoggedIn() ? |
35 | """ | |
36 | <li><a href="/logout">Logout</a></li>""" : | |
37 | """ | |
38 | <li><a href="/oauth2/authorization/google">Login</a></li>""" ; | |
39 | } | |
40 | ||
41 | private String getLoggedInAs() { | |
42 |
2
1. getLoggedInAs : replaced return value with "" for edu/ucsb/cs156/example/controllers/HomepageController::getLoggedInAs → KILLED 2. getLoggedInAs : negated conditional → KILLED |
return currentUserService.isLoggedIn() |
43 | ? String.format("<li>Currently logged in as %s</li>", currentUserService.getUser().getEmail()) | |
44 | : "<li>Not logged in</li>"; | |
45 | } | |
46 | ||
47 | private String getRoles() { | |
48 |
1
1. getRoles : replaced return value with "" for edu/ucsb/cs156/example/controllers/HomepageController::getRoles → KILLED |
return String.format("<li>Roles: %s</li>", currentUserService.getRolesSorted()); |
49 | } | |
50 | ||
51 | } | |
Mutations | ||
29 |
1.1 |
|
34 |
1.1 2.2 |
|
42 |
1.1 2.2 |
|
48 |
1.1 |