ApiController.java

1
package edu.ucsb.cs156.example.controllers;
2
3
import edu.ucsb.cs156.example.errors.EntityNotFoundException;
4
import net.bytebuddy.implementation.bytecode.Throw;
5
import org.springframework.beans.factory.annotation.Autowired;
6
7
import edu.ucsb.cs156.example.models.CurrentUser;
8
import edu.ucsb.cs156.example.services.CurrentUserService;
9
import lombok.extern.slf4j.Slf4j;
10
import org.springframework.http.HttpStatus;
11
import org.springframework.web.bind.annotation.ExceptionHandler;
12
import org.springframework.web.bind.annotation.ResponseStatus;
13
14
import java.util.Map;
15
16
@Slf4j
17
public abstract class ApiController {
18
  @Autowired
19
  private CurrentUserService currentUserService;
20
21
  protected CurrentUser getCurrentUser() {
22 1 1. getCurrentUser : replaced return value with null for edu/ucsb/cs156/example/controllers/ApiController::getCurrentUser → KILLED
    return currentUserService.getCurrentUser();
23
  }
24
25
  protected Object genericMessage(String message) {
26 1 1. genericMessage : replaced return value with null for edu/ucsb/cs156/example/controllers/ApiController::genericMessage → KILLED
    return Map.of("message", message);
27
  }
28
29
  @ExceptionHandler({ EntityNotFoundException.class })
30
  @ResponseStatus(HttpStatus.NOT_FOUND)
31
  public Object handleGenericException(Throwable e) {
32 1 1. handleGenericException : replaced return value with null for edu/ucsb/cs156/example/controllers/ApiController::handleGenericException → KILLED
    return Map.of(
33
      "type", e.getClass().getSimpleName(),
34
      "message", e.getMessage()
35
    );
36
  }
37
}

Mutations

22

1.1
Location : getCurrentUser
Killed by : edu.ucsb.cs156.example.controllers.UserInfoControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.example.controllers.UserInfoControllerTests]/[method:currentUser__logged_in()]
replaced return value with null for edu/ucsb/cs156/example/controllers/ApiController::getCurrentUser → KILLED

26

1.1
Location : genericMessage
Killed by : edu.ucsb.cs156.example.controllers.UCSBDatesControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.example.controllers.UCSBDatesControllerTests]/[method:admin_can_delete_a_date()]
replaced return value with null for edu/ucsb/cs156/example/controllers/ApiController::genericMessage → KILLED

32

1.1
Location : handleGenericException
Killed by : edu.ucsb.cs156.example.controllers.UCSBDiningCommonsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.example.controllers.UCSBDiningCommonsControllerTests]/[method:test_that_logged_in_user_can_get_by_id_when_the_id_does_not_exist()]
replaced return value with null for edu/ucsb/cs156/example/controllers/ApiController::handleGenericException → KILLED

Active mutators

Tests examined


Report generated by PIT 1.7.3