1 | package edu.ucsb.cs156.example.controllers; | |
2 | ||
3 | import edu.ucsb.cs156.example.entities.UCSBDiningCommonsMenuItems; | |
4 | import edu.ucsb.cs156.example.errors.EntityNotFoundException; | |
5 | import edu.ucsb.cs156.example.repositories.UCSBDiningCommonsMenuItemsRepository; | |
6 | ||
7 | import io.swagger.v3.oas.annotations.Operation; | |
8 | import io.swagger.v3.oas.annotations.Parameter; | |
9 | import io.swagger.v3.oas.annotations.tags.Tag; | |
10 | import lombok.extern.slf4j.Slf4j; | |
11 | ||
12 | import org.springframework.beans.factory.annotation.Autowired; | |
13 | import org.springframework.security.access.prepost.PreAuthorize; | |
14 | import org.springframework.web.bind.annotation.DeleteMapping; | |
15 | import org.springframework.web.bind.annotation.GetMapping; | |
16 | import org.springframework.web.bind.annotation.PostMapping; | |
17 | import org.springframework.web.bind.annotation.PutMapping; | |
18 | import org.springframework.web.bind.annotation.RequestBody; | |
19 | import org.springframework.web.bind.annotation.RequestMapping; | |
20 | import org.springframework.web.bind.annotation.RequestParam; | |
21 | import org.springframework.web.bind.annotation.RestController; | |
22 | ||
23 | import com.fasterxml.jackson.core.JsonProcessingException; | |
24 | ||
25 | import javax.validation.Valid; | |
26 | ||
27 | @Tag(name = "UCSBDiningCommonsMenuItems") | |
28 | @RequestMapping("/api/ucsbdiningcommonsmenuitems") | |
29 | @RestController | |
30 | @Slf4j | |
31 | ||
32 | public class UCSBDiningCommonsMenuItemsController extends ApiController{ | |
33 | | |
34 | @Autowired | |
35 | UCSBDiningCommonsMenuItemsRepository ucsbDiningCommonsMenuItemsRepository; | |
36 | ||
37 | @Operation(summary = "List all UCSB Dining Common Menu Items") | |
38 | @PreAuthorize("hasRole('ROLE_USER')") | |
39 | @GetMapping("/all") | |
40 | public Iterable<UCSBDiningCommonsMenuItems> allMenuItems(){ | |
41 | Iterable<UCSBDiningCommonsMenuItems> menuItems = ucsbDiningCommonsMenuItemsRepository.findAll(); | |
42 |
1
1. allMenuItems : replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBDiningCommonsMenuItemsController::allMenuItems → KILLED |
return menuItems; |
43 | } | |
44 | ||
45 | @Operation(summary = "Create a New Menu Item") | |
46 | @PreAuthorize("hasRole('ROLE_USER')") | |
47 | @PostMapping("/post") | |
48 | public UCSBDiningCommonsMenuItems postMenuItems( | |
49 | @Parameter(name="diningCommonsCode") @RequestParam String diningCommonsCode, | |
50 | @Parameter(name="name") @RequestParam String name, | |
51 | @Parameter(name="station") @RequestParam String station) | |
52 | throws JsonProcessingException { | |
53 | ||
54 | UCSBDiningCommonsMenuItems menuItems = new UCSBDiningCommonsMenuItems(); | |
55 |
1
1. postMenuItems : removed call to edu/ucsb/cs156/example/entities/UCSBDiningCommonsMenuItems::setDiningCommonsCode → KILLED |
menuItems.setDiningCommonsCode(diningCommonsCode); |
56 |
1
1. postMenuItems : removed call to edu/ucsb/cs156/example/entities/UCSBDiningCommonsMenuItems::setName → KILLED |
menuItems.setName(name); |
57 |
1
1. postMenuItems : removed call to edu/ucsb/cs156/example/entities/UCSBDiningCommonsMenuItems::setStation → KILLED |
menuItems.setStation(station); |
58 | ||
59 | UCSBDiningCommonsMenuItems savedMenuItems = ucsbDiningCommonsMenuItemsRepository.save(menuItems); | |
60 | ||
61 |
1
1. postMenuItems : replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBDiningCommonsMenuItemsController::postMenuItems → KILLED |
return savedMenuItems; |
62 | } | |
63 | ||
64 | @Operation(summary= "Get a Single Menu Item") | |
65 | @PreAuthorize("hasRole('ROLE_USER')") | |
66 | @GetMapping("") | |
67 | public UCSBDiningCommonsMenuItems getById( | |
68 | @Parameter(name="id") @RequestParam Long id){ | |
69 | UCSBDiningCommonsMenuItems menuItems = ucsbDiningCommonsMenuItemsRepository.findById(id) | |
70 |
1
1. lambda$getById$0 : replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBDiningCommonsMenuItemsController::lambda$getById$0 → KILLED |
.orElseThrow(() -> new EntityNotFoundException(UCSBDiningCommonsMenuItems.class, id)); |
71 | ||
72 |
1
1. getById : replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBDiningCommonsMenuItemsController::getById → KILLED |
return menuItems; |
73 | } | |
74 | ||
75 | @Operation(summary= "Delete a UCSBDiningCommonsMenuItem") | |
76 | @PreAuthorize("hasRole('ROLE_ADMIN')") | |
77 | @DeleteMapping("") | |
78 | public Object deleteMenuItem( | |
79 | @Parameter(name="id") @RequestParam Long id){ | |
80 | UCSBDiningCommonsMenuItems menuItems = ucsbDiningCommonsMenuItemsRepository.findById(id) | |
81 |
1
1. lambda$deleteMenuItem$1 : replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBDiningCommonsMenuItemsController::lambda$deleteMenuItem$1 → KILLED |
.orElseThrow(() -> new EntityNotFoundException(UCSBDiningCommonsMenuItems.class, id)); |
82 | ||
83 |
1
1. deleteMenuItem : removed call to edu/ucsb/cs156/example/repositories/UCSBDiningCommonsMenuItemsRepository::delete → KILLED |
ucsbDiningCommonsMenuItemsRepository.delete(menuItems); |
84 |
1
1. deleteMenuItem : replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBDiningCommonsMenuItemsController::deleteMenuItem → KILLED |
return genericMessage("UCSBDiningCommonsMenuItems with id %s deleted".formatted(id)); |
85 | } | |
86 | ||
87 | @Operation(summary= "Update a single Menu Items") | |
88 | @PreAuthorize("hasRole('ROLE_ADMIN')") | |
89 | @PutMapping("") | |
90 | public UCSBDiningCommonsMenuItems updateMenuItem( | |
91 | @Parameter(name="id") @RequestParam Long id, | |
92 | @RequestBody @Valid UCSBDiningCommonsMenuItems incoming){ | |
93 | ||
94 | UCSBDiningCommonsMenuItems menuItem = ucsbDiningCommonsMenuItemsRepository.findById(id) | |
95 |
1
1. lambda$updateMenuItem$2 : replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBDiningCommonsMenuItemsController::lambda$updateMenuItem$2 → KILLED |
.orElseThrow(() -> new EntityNotFoundException(UCSBDiningCommonsMenuItems.class, id)); |
96 | | |
97 |
1
1. updateMenuItem : removed call to edu/ucsb/cs156/example/entities/UCSBDiningCommonsMenuItems::setDiningCommonsCode → KILLED |
menuItem.setDiningCommonsCode(incoming.getDiningCommonsCode()); |
98 |
1
1. updateMenuItem : removed call to edu/ucsb/cs156/example/entities/UCSBDiningCommonsMenuItems::setName → KILLED |
menuItem.setName(incoming.getName()); |
99 |
1
1. updateMenuItem : removed call to edu/ucsb/cs156/example/entities/UCSBDiningCommonsMenuItems::setStation → KILLED |
menuItem.setStation(incoming.getStation()); |
100 | ||
101 | ucsbDiningCommonsMenuItemsRepository.save(menuItem); | |
102 | | |
103 |
1
1. updateMenuItem : replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBDiningCommonsMenuItemsController::updateMenuItem → KILLED |
return menuItem; |
104 | } | |
105 | } | |
Mutations | ||
42 |
1.1 |
|
55 |
1.1 |
|
56 |
1.1 |
|
57 |
1.1 |
|
61 |
1.1 |
|
70 |
1.1 |
|
72 |
1.1 |
|
81 |
1.1 |
|
83 |
1.1 |
|
84 |
1.1 |
|
95 |
1.1 |
|
97 |
1.1 |
|
98 |
1.1 |
|
99 |
1.1 |
|
103 |
1.1 |