ApiController.java

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

Mutations

19

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

23

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

29

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

37

1.1
Location : handleIllegalArgumentException
Killed by : edu.ucsb.cs156.courses.controllers.PersonalSchedulesControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.courses.controllers.PersonalSchedulesControllerTests]/[method:api_schedules__user_logged_in__cannot_post_long_name()]
replaced return value with null for edu/ucsb/cs156/courses/controllers/ApiController::handleIllegalArgumentException → KILLED

Active mutators

Tests examined


Report generated by PIT 1.7.3