| 1 | package edu.ucsb.cs156.example.controllers; | |
| 2 | ||
| 3 | import edu.ucsb.cs156.example.entities.IceCreamShop; | |
| 4 | import edu.ucsb.cs156.example.errors.EntityNotFoundException; | |
| 5 | import edu.ucsb.cs156.example.repositories.IceCreamShopRepository; | |
| 6 | import io.swagger.annotations.Api; | |
| 7 | import io.swagger.annotations.ApiOperation; | |
| 8 | import io.swagger.annotations.ApiParam; | |
| 9 | import lombok.extern.slf4j.Slf4j; | |
| 10 | ||
| 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 | import javax.validation.Valid; | |
| 23 | ||
| 24 | ||
| 25 | @Api(description = "IceCreamShop") | |
| 26 | @RequestMapping("/api/icecreamshop") | |
| 27 | @RestController | |
| 28 | @Slf4j | |
| 29 | public class IceCreamShopController extends ApiController { | |
| 30 | ||
| 31 | @Autowired | |
| 32 | IceCreamShopRepository iceCreamShopRepository; | |
| 33 | ||
| 34 | @ApiOperation(value = "List all ice cream shops") | |
| 35 | @PreAuthorize("hasRole('ROLE_USER')") | |
| 36 | @GetMapping("/all") | |
| 37 | public Iterable<IceCreamShop> allIceCreamShop() { | |
| 38 | Iterable<IceCreamShop> iceCreamShop = iceCreamShopRepository.findAll(); | |
| 39 |
1
1. allIceCreamShop : replaced return value with null for edu/ucsb/cs156/example/controllers/IceCreamShopController::allIceCreamShop → KILLED |
return iceCreamShop; |
| 40 | } | |
| 41 | ||
| 42 | @ApiOperation(value = "Get a single iceCreamShop") | |
| 43 | @PreAuthorize("hasRole('ROLE_USER')") | |
| 44 | @GetMapping("") | |
| 45 | public IceCreamShop getById( | |
| 46 | @ApiParam("id") @RequestParam Long id) { | |
| 47 | IceCreamShop iceCreamShop = iceCreamShopRepository.findById(id) | |
| 48 |
1
1. lambda$getById$0 : replaced return value with null for edu/ucsb/cs156/example/controllers/IceCreamShopController::lambda$getById$0 → KILLED |
.orElseThrow(() -> new EntityNotFoundException(IceCreamShop.class, id)); |
| 49 | ||
| 50 |
1
1. getById : replaced return value with null for edu/ucsb/cs156/example/controllers/IceCreamShopController::getById → KILLED |
return iceCreamShop; |
| 51 | } | |
| 52 | ||
| 53 | @ApiOperation(value = "Create a new iceCreamShop") | |
| 54 | @PreAuthorize("hasRole('ROLE_ADMIN')") | |
| 55 | @PostMapping("/post") | |
| 56 | public IceCreamShop postIceCreamShop( | |
| 57 | @ApiParam("name") @RequestParam String name, | |
| 58 | @ApiParam("flavor") @RequestParam String flavor, | |
| 59 | @ApiParam("description") @RequestParam String description | |
| 60 | ) | |
| 61 | { | |
| 62 | ||
| 63 | IceCreamShop iceCreamShop = new IceCreamShop(); | |
| 64 |
1
1. postIceCreamShop : removed call to edu/ucsb/cs156/example/entities/IceCreamShop::setName → KILLED |
iceCreamShop.setName(name); |
| 65 |
1
1. postIceCreamShop : removed call to edu/ucsb/cs156/example/entities/IceCreamShop::setFlavor → KILLED |
iceCreamShop.setFlavor(flavor); |
| 66 |
1
1. postIceCreamShop : removed call to edu/ucsb/cs156/example/entities/IceCreamShop::setDescription → KILLED |
iceCreamShop.setDescription(description); |
| 67 | ||
| 68 | IceCreamShop savedIceCreamShop = iceCreamShopRepository.save(iceCreamShop); | |
| 69 | ||
| 70 |
1
1. postIceCreamShop : replaced return value with null for edu/ucsb/cs156/example/controllers/IceCreamShopController::postIceCreamShop → KILLED |
return savedIceCreamShop; |
| 71 | } | |
| 72 | ||
| 73 | @ApiOperation(value = "Delete a IceCreamShop") | |
| 74 | @PreAuthorize("hasRole('ROLE_ADMIN')") | |
| 75 | @DeleteMapping("") | |
| 76 | public Object deleteIceCreamShop( | |
| 77 | @ApiParam("id") @RequestParam Long id) { | |
| 78 | IceCreamShop iceCreamShop = iceCreamShopRepository.findById(id) | |
| 79 |
1
1. lambda$deleteIceCreamShop$1 : replaced return value with null for edu/ucsb/cs156/example/controllers/IceCreamShopController::lambda$deleteIceCreamShop$1 → KILLED |
.orElseThrow(() -> new EntityNotFoundException(IceCreamShop.class, id)); |
| 80 | ||
| 81 |
1
1. deleteIceCreamShop : removed call to edu/ucsb/cs156/example/repositories/IceCreamShopRepository::delete → KILLED |
iceCreamShopRepository.delete(iceCreamShop); |
| 82 |
1
1. deleteIceCreamShop : replaced return value with null for edu/ucsb/cs156/example/controllers/IceCreamShopController::deleteIceCreamShop → KILLED |
return genericMessage("IceCreamShop with id %s deleted".formatted(id)); |
| 83 | } | |
| 84 | ||
| 85 | @ApiOperation(value = "Update a single iceCreamShop") | |
| 86 | @PreAuthorize("hasRole('ROLE_ADMIN')") | |
| 87 | @PutMapping("") | |
| 88 | public IceCreamShop updateCommons( | |
| 89 | @ApiParam("id") @RequestParam Long id, | |
| 90 | @RequestBody @Valid IceCreamShop incoming) { | |
| 91 | ||
| 92 | IceCreamShop iceCreamShop = iceCreamShopRepository.findById(id) | |
| 93 |
1
1. lambda$updateCommons$2 : replaced return value with null for edu/ucsb/cs156/example/controllers/IceCreamShopController::lambda$updateCommons$2 → KILLED |
.orElseThrow(() -> new EntityNotFoundException(IceCreamShop.class, id)); |
| 94 | ||
| 95 | ||
| 96 |
1
1. updateCommons : removed call to edu/ucsb/cs156/example/entities/IceCreamShop::setName → KILLED |
iceCreamShop.setName(incoming.getName()); |
| 97 |
1
1. updateCommons : removed call to edu/ucsb/cs156/example/entities/IceCreamShop::setFlavor → KILLED |
iceCreamShop.setFlavor(incoming.getFlavor()); |
| 98 |
1
1. updateCommons : removed call to edu/ucsb/cs156/example/entities/IceCreamShop::setDescription → KILLED |
iceCreamShop.setDescription(incoming.getDescription()); |
| 99 | ||
| 100 | ||
| 101 | iceCreamShopRepository.save(iceCreamShop); | |
| 102 | ||
| 103 |
1
1. updateCommons : replaced return value with null for edu/ucsb/cs156/example/controllers/IceCreamShopController::updateCommons → KILLED |
return iceCreamShop; |
| 104 | } | |
| 105 | } | |
Mutations | ||
| 39 |
1.1 |
|
| 48 |
1.1 |
|
| 50 |
1.1 |
|
| 64 |
1.1 |
|
| 65 |
1.1 |
|
| 66 |
1.1 |
|
| 70 |
1.1 |
|
| 79 |
1.1 |
|
| 81 |
1.1 |
|
| 82 |
1.1 |
|
| 93 |
1.1 |
|
| 96 |
1.1 |
|
| 97 |
1.1 |
|
| 98 |
1.1 |
|
| 103 |
1.1 |