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