1 | package edu.ucsb.cs156.example.controllers; | |
2 | ||
3 | import edu.ucsb.cs156.example.entities.UCSBDate; | |
4 | import edu.ucsb.cs156.example.entities.HelpRequest; | |
5 | ||
6 | import edu.ucsb.cs156.example.errors.EntityNotFoundException; | |
7 | import edu.ucsb.cs156.example.repositories.UCSBDateRepository; | |
8 | import edu.ucsb.cs156.example.repositories.HelpRequestRepository; | |
9 | ||
10 | import io.swagger.v3.oas.annotations.Operation; | |
11 | import io.swagger.v3.oas.annotations.Parameter; | |
12 | import io.swagger.v3.oas.annotations.tags.Tag; | |
13 | import lombok.extern.slf4j.Slf4j; | |
14 | ||
15 | import com.fasterxml.jackson.core.JsonProcessingException; | |
16 | ||
17 | import org.springframework.beans.factory.annotation.Autowired; | |
18 | import org.springframework.format.annotation.DateTimeFormat; | |
19 | import org.springframework.security.access.prepost.PreAuthorize; | |
20 | import org.springframework.web.bind.annotation.DeleteMapping; | |
21 | import org.springframework.web.bind.annotation.GetMapping; | |
22 | import org.springframework.web.bind.annotation.PostMapping; | |
23 | import org.springframework.web.bind.annotation.PutMapping; | |
24 | import org.springframework.web.bind.annotation.RequestBody; | |
25 | import org.springframework.web.bind.annotation.RequestMapping; | |
26 | import org.springframework.web.bind.annotation.RequestParam; | |
27 | import org.springframework.web.bind.annotation.RestController; | |
28 | ||
29 | import javax.validation.Valid; | |
30 | ||
31 | import java.time.LocalDateTime; | |
32 | ||
33 | @Tag(name = "HelpRequest") | |
34 | @RequestMapping("/api/helprequest") | |
35 | @RestController | |
36 | @Slf4j | |
37 | public class HelpRequestController extends ApiController { | |
38 | ||
39 | @Autowired | |
40 | HelpRequestRepository helpRequestRepository; | |
41 | ||
42 | @Operation(summary = "List all helprequests") | |
43 | @PreAuthorize("hasRole('ROLE_USER')") | |
44 | @GetMapping("/all") | |
45 | public Iterable<HelpRequest> allHelpRequest() { | |
46 | Iterable<HelpRequest> requests = helpRequestRepository.findAll(); | |
47 |
1
1. allHelpRequest : replaced return value with null for edu/ucsb/cs156/example/controllers/HelpRequestController::allHelpRequest → KILLED |
return requests; |
48 | } | |
49 | ||
50 | @Operation(summary = "Create a new help request") | |
51 | @PreAuthorize("hasRole('ROLE_ADMIN')") | |
52 | @PostMapping("/post") | |
53 | public HelpRequest postHelpRequest( | |
54 | @Parameter(name = "requesterEmail") @RequestParam String requesterEmail, | |
55 | @Parameter(name = "teamId") @RequestParam String teamId, | |
56 | @Parameter(name = "tableOrBreakoutRoom") @RequestParam String tableOrBreakoutRoom, | |
57 | @Parameter(name = "requestTime") @RequestParam("requestTime") @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) LocalDateTime requestTime, | |
58 | @Parameter(name = "explanation") @RequestParam String explanation, | |
59 | @Parameter(name = "solved") @RequestParam boolean solved) | |
60 | { | |
61 | ||
62 | HelpRequest helpRequest = new HelpRequest(); | |
63 |
1
1. postHelpRequest : removed call to edu/ucsb/cs156/example/entities/HelpRequest::setRequesterEmail → KILLED |
helpRequest.setRequesterEmail(requesterEmail); |
64 |
1
1. postHelpRequest : removed call to edu/ucsb/cs156/example/entities/HelpRequest::setTeamId → KILLED |
helpRequest.setTeamId(teamId); |
65 |
1
1. postHelpRequest : removed call to edu/ucsb/cs156/example/entities/HelpRequest::setTableOrBreakoutRoom → KILLED |
helpRequest.setTableOrBreakoutRoom(tableOrBreakoutRoom); |
66 |
1
1. postHelpRequest : removed call to edu/ucsb/cs156/example/entities/HelpRequest::setRequestTime → KILLED |
helpRequest.setRequestTime(requestTime); |
67 |
1
1. postHelpRequest : removed call to edu/ucsb/cs156/example/entities/HelpRequest::setExplanation → KILLED |
helpRequest.setExplanation(explanation); |
68 |
1
1. postHelpRequest : removed call to edu/ucsb/cs156/example/entities/HelpRequest::setSolved → KILLED |
helpRequest.setSolved(solved); |
69 | ||
70 | HelpRequest savedHelpRequest = helpRequestRepository.save(helpRequest); | |
71 | ||
72 |
1
1. postHelpRequest : replaced return value with null for edu/ucsb/cs156/example/controllers/HelpRequestController::postHelpRequest → KILLED |
return savedHelpRequest; |
73 | } | |
74 | ||
75 | @Operation(summary = "Get a single help request") | |
76 | @PreAuthorize("hasRole('ROLE_USER')") | |
77 | @GetMapping("") | |
78 | public HelpRequest getById(@Parameter(name = "id") @RequestParam Long id) { | |
79 | HelpRequest helpRequest = helpRequestRepository.findById(id) | |
80 |
1
1. lambda$getById$0 : replaced return value with null for edu/ucsb/cs156/example/controllers/HelpRequestController::lambda$getById$0 → KILLED |
.orElseThrow(() -> new EntityNotFoundException( |
81 | HelpRequest.class, id)); | |
82 | ||
83 |
1
1. getById : replaced return value with null for edu/ucsb/cs156/example/controllers/HelpRequestController::getById → KILLED |
return helpRequest; |
84 | } | |
85 | ||
86 | @Operation(summary = "Delete a HelpRequest") | |
87 | @PreAuthorize("hasRole('ROLE_ADMIN')") | |
88 | @DeleteMapping("") | |
89 | public Object deleteHelpRequest( | |
90 | @Parameter(name = "id") @RequestParam Long id) { | |
91 | HelpRequest helpRequest = helpRequestRepository.findById(id) | |
92 |
1
1. lambda$deleteHelpRequest$1 : replaced return value with null for edu/ucsb/cs156/example/controllers/HelpRequestController::lambda$deleteHelpRequest$1 → KILLED |
.orElseThrow(() -> new EntityNotFoundException( |
93 | HelpRequest.class, id)); | |
94 | ||
95 |
1
1. deleteHelpRequest : removed call to edu/ucsb/cs156/example/repositories/HelpRequestRepository::delete → KILLED |
helpRequestRepository.delete(helpRequest); |
96 |
1
1. deleteHelpRequest : replaced return value with null for edu/ucsb/cs156/example/controllers/HelpRequestController::deleteHelpRequest → KILLED |
return genericMessage("HelpRequest with id %s deleted".formatted(id)); |
97 | } | |
98 | ||
99 | @Operation(summary = "Update a single date") | |
100 | @PreAuthorize("hasRole('ROLE_ADMIN')") | |
101 | @PutMapping("") | |
102 | public HelpRequest updateHelpRequest( | |
103 | @Parameter(name = "id") @RequestParam Long id, | |
104 | @RequestBody @Valid HelpRequest incoming) { | |
105 | ||
106 | HelpRequest helpRequest = helpRequestRepository.findById(id) | |
107 |
1
1. lambda$updateHelpRequest$2 : replaced return value with null for edu/ucsb/cs156/example/controllers/HelpRequestController::lambda$updateHelpRequest$2 → KILLED |
.orElseThrow(() -> new EntityNotFoundException( |
108 | HelpRequest.class, id)); | |
109 | ||
110 |
1
1. updateHelpRequest : removed call to edu/ucsb/cs156/example/entities/HelpRequest::setRequesterEmail → KILLED |
helpRequest.setRequesterEmail(incoming.getRequesterEmail()); |
111 |
1
1. updateHelpRequest : removed call to edu/ucsb/cs156/example/entities/HelpRequest::setTeamId → KILLED |
helpRequest.setTeamId(incoming.getTeamId()); |
112 |
1
1. updateHelpRequest : removed call to edu/ucsb/cs156/example/entities/HelpRequest::setTableOrBreakoutRoom → KILLED |
helpRequest.setTableOrBreakoutRoom(incoming.getTableOrBreakoutRoom()); |
113 |
1
1. updateHelpRequest : removed call to edu/ucsb/cs156/example/entities/HelpRequest::setExplanation → KILLED |
helpRequest.setExplanation(incoming.getExplanation()); |
114 |
1
1. updateHelpRequest : removed call to edu/ucsb/cs156/example/entities/HelpRequest::setSolved → KILLED |
helpRequest.setSolved(incoming.getSolved()); |
115 |
1
1. updateHelpRequest : removed call to edu/ucsb/cs156/example/entities/HelpRequest::setRequestTime → KILLED |
helpRequest.setRequestTime(incoming.getRequestTime()); |
116 | ||
117 | helpRequestRepository.save(helpRequest); | |
118 | ||
119 |
1
1. updateHelpRequest : replaced return value with null for edu/ucsb/cs156/example/controllers/HelpRequestController::updateHelpRequest → KILLED |
return helpRequest; |
120 | } | |
121 | } | |
Mutations | ||
47 |
1.1 |
|
63 |
1.1 |
|
64 |
1.1 |
|
65 |
1.1 |
|
66 |
1.1 |
|
67 |
1.1 |
|
68 |
1.1 |
|
72 |
1.1 |
|
80 |
1.1 |
|
83 |
1.1 |
|
92 |
1.1 |
|
95 |
1.1 |
|
96 |
1.1 |
|
107 |
1.1 |
|
110 |
1.1 |
|
111 |
1.1 |
|
112 |
1.1 |
|
113 |
1.1 |
|
114 |
1.1 |
|
115 |
1.1 |
|
119 |
1.1 |