| 1 | package edu.ucsb.cs156.example.controllers; | |
| 2 | ||
| 3 | import edu.ucsb.cs156.example.entities.UCSBDiningCommonsMenuItem; | |
| 4 | import edu.ucsb.cs156.example.errors.EntityNotFoundException; | |
| 5 | import edu.ucsb.cs156.example.repositories.UCSBDiningCommonsMenuItemRepository; | |
| 6 | import io.swagger.v3.oas.annotations.Operation; | |
| 7 | import io.swagger.v3.oas.annotations.Parameter; | |
| 8 | import io.swagger.v3.oas.annotations.tags.Tag; | |
| 9 | import jakarta.validation.Valid; | |
| 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.DeleteMapping; | |
| 14 | import org.springframework.web.bind.annotation.GetMapping; | |
| 15 | import org.springframework.web.bind.annotation.PostMapping; | |
| 16 | import org.springframework.web.bind.annotation.PutMapping; | |
| 17 | import org.springframework.web.bind.annotation.RequestBody; | |
| 18 | import org.springframework.web.bind.annotation.RequestMapping; | |
| 19 | import org.springframework.web.bind.annotation.RequestParam; | |
| 20 | import org.springframework.web.bind.annotation.RestController; | |
| 21 | ||
| 22 | /** This is a REST controller for UCSBDiningCommonsMenuItem */ | |
| 23 | @Tag(name = "UCSBDiningCommonsMenuItem") | |
| 24 | @RequestMapping("/api/UCSBDiningCommonsMenuItem") | |
| 25 | @RestController | |
| 26 | @Slf4j | |
| 27 | public class UCSBDiningCommonsMenuItemController extends ApiController { | |
| 28 | ||
| 29 | @Autowired UCSBDiningCommonsMenuItemRepository ucsbDiningCommonsMenuItemRepository; | |
| 30 | ||
| 31 | @Operation(summary = "List all UCSB dining commons menu items") | |
| 32 | @PreAuthorize("hasRole('ROLE_USER')") | |
| 33 | @GetMapping("/all") | |
| 34 | public Iterable<UCSBDiningCommonsMenuItem> allMenuItems() { | |
| 35 |
1
1. allMenuItems : replaced return value with Collections.emptyList for edu/ucsb/cs156/example/controllers/UCSBDiningCommonsMenuItemController::allMenuItems → KILLED |
return ucsbDiningCommonsMenuItemRepository.findAll(); |
| 36 | } | |
| 37 | ||
| 38 | @Operation(summary = "Get a single UCSB dining commons menu item") | |
| 39 | @PreAuthorize("hasRole('ROLE_USER')") | |
| 40 | @GetMapping("") | |
| 41 | public UCSBDiningCommonsMenuItem getById(@Parameter(name = "id") @RequestParam Long id) { | |
| 42 |
1
1. getById : replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBDiningCommonsMenuItemController::getById → KILLED |
return ucsbDiningCommonsMenuItemRepository |
| 43 | .findById(id) | |
| 44 |
1
1. lambda$getById$0 : replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBDiningCommonsMenuItemController::lambda$getById$0 → KILLED |
.orElseThrow(() -> new EntityNotFoundException(UCSBDiningCommonsMenuItem.class, id)); |
| 45 | } | |
| 46 | ||
| 47 | @Operation(summary = "Create a new UCSB dining commons menu item") | |
| 48 | @PreAuthorize("hasRole('ROLE_ADMIN')") | |
| 49 | @PostMapping("/post") | |
| 50 | public UCSBDiningCommonsMenuItem postMenuItem( | |
| 51 | @Parameter(name = "diningCommonsCode") @RequestParam String diningCommonsCode, | |
| 52 | @Parameter(name = "name") @RequestParam String name, | |
| 53 | @Parameter(name = "station") @RequestParam String station) { | |
| 54 | ||
| 55 | UCSBDiningCommonsMenuItem menuItem = new UCSBDiningCommonsMenuItem(); | |
| 56 |
1
1. postMenuItem : removed call to edu/ucsb/cs156/example/entities/UCSBDiningCommonsMenuItem::setDiningCommonsCode → KILLED |
menuItem.setDiningCommonsCode(diningCommonsCode); |
| 57 |
1
1. postMenuItem : removed call to edu/ucsb/cs156/example/entities/UCSBDiningCommonsMenuItem::setName → KILLED |
menuItem.setName(name); |
| 58 |
1
1. postMenuItem : removed call to edu/ucsb/cs156/example/entities/UCSBDiningCommonsMenuItem::setStation → KILLED |
menuItem.setStation(station); |
| 59 | ||
| 60 |
1
1. postMenuItem : replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBDiningCommonsMenuItemController::postMenuItem → KILLED |
return ucsbDiningCommonsMenuItemRepository.save(menuItem); |
| 61 | } | |
| 62 | ||
| 63 | @Operation(summary = "Update a single UCSB dining commons menu item") | |
| 64 | @PreAuthorize("hasRole('ROLE_ADMIN')") | |
| 65 | @PutMapping("") | |
| 66 | public UCSBDiningCommonsMenuItem updateMenuItem( | |
| 67 | @Parameter(name = "id") @RequestParam Long id, | |
| 68 | @RequestBody @Valid UCSBDiningCommonsMenuItem incoming) { | |
| 69 | ||
| 70 | UCSBDiningCommonsMenuItem menuItem = | |
| 71 | ucsbDiningCommonsMenuItemRepository | |
| 72 | .findById(id) | |
| 73 |
1
1. lambda$updateMenuItem$1 : replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBDiningCommonsMenuItemController::lambda$updateMenuItem$1 → KILLED |
.orElseThrow(() -> new EntityNotFoundException(UCSBDiningCommonsMenuItem.class, id)); |
| 74 | ||
| 75 |
1
1. updateMenuItem : removed call to edu/ucsb/cs156/example/entities/UCSBDiningCommonsMenuItem::setDiningCommonsCode → KILLED |
menuItem.setDiningCommonsCode(incoming.getDiningCommonsCode()); |
| 76 |
1
1. updateMenuItem : removed call to edu/ucsb/cs156/example/entities/UCSBDiningCommonsMenuItem::setName → KILLED |
menuItem.setName(incoming.getName()); |
| 77 |
1
1. updateMenuItem : removed call to edu/ucsb/cs156/example/entities/UCSBDiningCommonsMenuItem::setStation → KILLED |
menuItem.setStation(incoming.getStation()); |
| 78 | ||
| 79 | ucsbDiningCommonsMenuItemRepository.save(menuItem); | |
| 80 | ||
| 81 |
1
1. updateMenuItem : replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBDiningCommonsMenuItemController::updateMenuItem → KILLED |
return menuItem; |
| 82 | } | |
| 83 | ||
| 84 | @Operation(summary = "Delete a UCSB dining commons menu item") | |
| 85 | @PreAuthorize("hasRole('ROLE_ADMIN')") | |
| 86 | @DeleteMapping("") | |
| 87 | public Object deleteMenuItem(@Parameter(name = "id") @RequestParam Long id) { | |
| 88 | UCSBDiningCommonsMenuItem menuItem = | |
| 89 | ucsbDiningCommonsMenuItemRepository | |
| 90 | .findById(id) | |
| 91 |
1
1. lambda$deleteMenuItem$2 : replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBDiningCommonsMenuItemController::lambda$deleteMenuItem$2 → KILLED |
.orElseThrow(() -> new EntityNotFoundException(UCSBDiningCommonsMenuItem.class, id)); |
| 92 | ||
| 93 |
1
1. deleteMenuItem : removed call to edu/ucsb/cs156/example/repositories/UCSBDiningCommonsMenuItemRepository::delete → KILLED |
ucsbDiningCommonsMenuItemRepository.delete(menuItem); |
| 94 | ||
| 95 |
1
1. deleteMenuItem : replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBDiningCommonsMenuItemController::deleteMenuItem → KILLED |
return genericMessage("UCSBDiningCommonsMenuItem with id %s deleted".formatted(id)); |
| 96 | } | |
| 97 | } | |
Mutations | ||
| 35 |
1.1 |
|
| 42 |
1.1 |
|
| 44 |
1.1 |
|
| 56 |
1.1 |
|
| 57 |
1.1 |
|
| 58 |
1.1 |
|
| 60 |
1.1 |
|
| 73 |
1.1 |
|
| 75 |
1.1 |
|
| 76 |
1.1 |
|
| 77 |
1.1 |
|
| 81 |
1.1 |
|
| 91 |
1.1 |
|
| 93 |
1.1 |
|
| 95 |
1.1 |