1 | package edu.ucsb.cs156.courses.controllers; | |
2 | ||
3 | import edu.ucsb.cs156.courses.entities.UCSBAPIQuarter; | |
4 | import edu.ucsb.cs156.courses.repositories.UserRepository; | |
5 | import edu.ucsb.cs156.courses.services.UCSBAPIQuarterService; | |
6 | import io.swagger.v3.oas.annotations.Operation; | |
7 | import io.swagger.v3.oas.annotations.tags.Tag; | |
8 | import java.util.List; | |
9 | import java.util.ArrayList; | |
10 | import lombok.extern.slf4j.Slf4j; | |
11 | import org.springframework.beans.factory.annotation.Autowired; | |
12 | import org.springframework.security.access.prepost.PreAuthorize; | |
13 | import org.springframework.web.bind.annotation.GetMapping; | |
14 | import org.springframework.web.bind.annotation.PostMapping; | |
15 | import org.springframework.web.bind.annotation.RequestMapping; | |
16 | import org.springframework.web.bind.annotation.RestController; | |
17 | ||
18 | @Tag(name = "UCSBAPIQuarterController") | |
19 | @RestController | |
20 | @RequestMapping("/api/public") | |
21 | @Slf4j | |
22 | public class UCSBAPIQuarterController extends ApiController { | |
23 | ||
24 | @Autowired UserRepository userRepository; | |
25 | @Autowired UCSBAPIQuarterService ucsbAPIQuarterService; | |
26 | ||
27 | @Operation(summary = "Get dates for current quarter") | |
28 | @GetMapping(value = "/currentQuarter", produces = "application/json") | |
29 | public UCSBAPIQuarter getCurrentQuarter() throws Exception { | |
30 |
1
1. getCurrentQuarter : replaced return value with null for edu/ucsb/cs156/courses/controllers/UCSBAPIQuarterController::getCurrentQuarter → KILLED |
return ucsbAPIQuarterService.getCurrentQuarter(); |
31 | } | |
32 | ||
33 | @Operation(summary = "Get active quarters between start and end quarters") | |
34 | @GetMapping(value = "/activeQuarters", produces = "application/json") | |
35 | public ArrayList<String> getActiveQuarters() throws Exception { | |
36 |
1
1. getActiveQuarters : replaced return value with null for edu/ucsb/cs156/courses/controllers/UCSBAPIQuarterController::getActiveQuarters → NO_COVERAGE |
return ucsbAPIQuarterService.getActiveQuarterList(); |
37 | } | |
38 | ||
39 | @Operation(summary = "Get dates for all quarters") | |
40 | @GetMapping(value = "/allQuarters", produces = "application/json") | |
41 | public List<UCSBAPIQuarter> getAllQuarters() throws Exception { | |
42 |
1
1. getAllQuarters : replaced return value with Collections.emptyList for edu/ucsb/cs156/courses/controllers/UCSBAPIQuarterController::getAllQuarters → KILLED |
return ucsbAPIQuarterService.getAllQuarters(); |
43 | } | |
44 | ||
45 | @Operation(summary = "Load quarters into database from UCSB API") | |
46 | @PreAuthorize("hasRole('ROLE_ADMIN')") | |
47 | @PostMapping("/loadQuarters") | |
48 | public List<UCSBAPIQuarter> loadQuarters() throws Exception { | |
49 | List<UCSBAPIQuarter> savedQuarters = ucsbAPIQuarterService.loadAllQuarters(); | |
50 |
1
1. loadQuarters : replaced return value with Collections.emptyList for edu/ucsb/cs156/courses/controllers/UCSBAPIQuarterController::loadQuarters → KILLED |
return savedQuarters; |
51 | } | |
52 | } | |
Mutations | ||
30 |
1.1 |
|
36 |
1.1 |
|
42 |
1.1 |
|
50 |
1.1 |