HomepageController.java

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
import org.springframework.web.util.HtmlUtils;
8
9
@RestController
10
public class HomepageController {
11
12
  @Autowired CurrentUserService currentUserService;
13
14
  @GetMapping("/")
15
  public String index() {
16
    String HomePageHTMLTemplate =
17
        """
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(
44
            "<li>Currently logged in as %s</li>",
45
            HtmlUtils.htmlEscape(currentUserService.getUser().getEmail()))
46
        : "<li>Not logged in</li>";
47
  }
48
49
  private String getRoles() {
50 1 1. getRoles : replaced return value with "" for edu/ucsb/cs156/example/controllers/HomepageController::getRoles → KILLED
    return String.format(
51
        "<li>Roles: %s</li>", HtmlUtils.htmlEscape(currentUserService.getRolesSorted().toString()));
52
  }
53
}

Mutations

29

1.1
Location : index
Killed by : edu.ucsb.cs156.example.controllers.HomepageControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.example.controllers.HomepageControllerTests]/[method:test_homepage_admin_logged_in()]
replaced return value with "" for edu/ucsb/cs156/example/controllers/HomepageController::index → KILLED

34

1.1
Location : getLoginLogoutLink
Killed by : edu.ucsb.cs156.example.controllers.HomepageControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.example.controllers.HomepageControllerTests]/[method:test_homepage_admin_logged_in()]
replaced return value with "" for edu/ucsb/cs156/example/controllers/HomepageController::getLoginLogoutLink → KILLED

2.2
Location : getLoginLogoutLink
Killed by : edu.ucsb.cs156.example.controllers.HomepageControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.example.controllers.HomepageControllerTests]/[method:test_homepage_admin_logged_in()]
negated conditional → KILLED

42

1.1
Location : getLoggedInAs
Killed by : edu.ucsb.cs156.example.controllers.HomepageControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.example.controllers.HomepageControllerTests]/[method:test_homepage_admin_logged_in()]
replaced return value with "" for edu/ucsb/cs156/example/controllers/HomepageController::getLoggedInAs → KILLED

2.2
Location : getLoggedInAs
Killed by : edu.ucsb.cs156.example.controllers.HomepageControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.example.controllers.HomepageControllerTests]/[method:test_homepage_admin_logged_in()]
negated conditional → KILLED

50

1.1
Location : getRoles
Killed by : edu.ucsb.cs156.example.controllers.HomepageControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.example.controllers.HomepageControllerTests]/[method:test_homepage_admin_logged_in()]
replaced return value with "" for edu/ucsb/cs156/example/controllers/HomepageController::getRoles → KILLED

Active mutators

Tests examined


Report generated by PIT 1.17.0