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