UCSBDiningCommonsMenuItemsController.java

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 javax.validation.Valid;
24
25
@Tag(name = "UCSBDiningCommonsMenuItems")
26
@RequestMapping("/api/ucsbdiningcommonsmenuitem")
27
@RestController
28
@Slf4j
29
public class UCSBDiningCommonsMenuItemsController extends ApiController {
30
31
    @Autowired
32
    UCSBDiningCommonsMenuItemsRepository ucsbDiningCommonsMenuItemsRepository;
33
34
    @Operation(summary= "List all ucsb dining commonsmenuitem")
35
    @PreAuthorize("hasRole('ROLE_USER')")
36
    @GetMapping("/all")
37
    public Iterable<UCSBDiningCommonsMenuItems> allCommonsMenuItems() {
38
        Iterable<UCSBDiningCommonsMenuItems> commonsmenuitem = ucsbDiningCommonsMenuItemsRepository.findAll();
39 1 1. allCommonsMenuItems : replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBDiningCommonsMenuItemsController::allCommonsMenuItems → KILLED
        return commonsmenuitem;
40
    }
41
42
    @Operation(summary= "Create a new commonsmenuitem")
43
    @PreAuthorize("hasRole('ROLE_ADMIN')")
44
    @PostMapping("/post")
45
    public UCSBDiningCommonsMenuItems postCommonsMenuItems(
46
        @Parameter(name="code") @RequestParam String code,
47
        @Parameter(name="name") @RequestParam String name,
48
        @Parameter(name="station") @RequestParam String station     
49
        )
50
        {
51
52
        UCSBDiningCommonsMenuItems commonsmenuitem = new UCSBDiningCommonsMenuItems();
53 1 1. postCommonsMenuItems : removed call to edu/ucsb/cs156/example/entities/UCSBDiningCommonsMenuItems::setCode → KILLED
        commonsmenuitem.setCode(code);
54 1 1. postCommonsMenuItems : removed call to edu/ucsb/cs156/example/entities/UCSBDiningCommonsMenuItems::setName → KILLED
        commonsmenuitem.setName(name);
55 1 1. postCommonsMenuItems : removed call to edu/ucsb/cs156/example/entities/UCSBDiningCommonsMenuItems::setStation → KILLED
        commonsmenuitem.setStation(station);
56
57
        UCSBDiningCommonsMenuItems savedCommonsMenuItems = ucsbDiningCommonsMenuItemsRepository.save(commonsmenuitem);
58
59 1 1. postCommonsMenuItems : replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBDiningCommonsMenuItemsController::postCommonsMenuItems → KILLED
        return savedCommonsMenuItems;
60
    }
61
62
    @Operation(summary= "Get a single commonsmenuitem")
63
    @PreAuthorize("hasRole('ROLE_USER')")
64
    @GetMapping("")
65
    public UCSBDiningCommonsMenuItems getById(
66
            @Parameter(name="id") @RequestParam Long id) {
67
        UCSBDiningCommonsMenuItems commonsmenuitem = ucsbDiningCommonsMenuItemsRepository.findById(id)
68 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));
69
70 1 1. getById : replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBDiningCommonsMenuItemsController::getById → KILLED
        return commonsmenuitem;
71
    }
72
73
    @Operation(summary= "Delete a UCSBDiningCommonsMenuItems")
74
    @PreAuthorize("hasRole('ROLE_ADMIN')")
75
    @DeleteMapping("")
76
    public Object deleteCommonsMenuItems(
77
            @Parameter(name="id") @RequestParam Long id) {
78
        UCSBDiningCommonsMenuItems commonsmenuitem = ucsbDiningCommonsMenuItemsRepository.findById(id)
79 1 1. lambda$deleteCommonsMenuItems$1 : replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBDiningCommonsMenuItemsController::lambda$deleteCommonsMenuItems$1 → KILLED
                .orElseThrow(() -> new EntityNotFoundException(UCSBDiningCommonsMenuItems.class, id));
80
81 1 1. deleteCommonsMenuItems : removed call to edu/ucsb/cs156/example/repositories/UCSBDiningCommonsMenuItemsRepository::delete → KILLED
        ucsbDiningCommonsMenuItemsRepository.delete(commonsmenuitem);
82 1 1. deleteCommonsMenuItems : replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBDiningCommonsMenuItemsController::deleteCommonsMenuItems → KILLED
        return genericMessage("UCSBDiningCommonsMenuItems with id %s deleted".formatted(id));
83
    }
84
85
    @Operation(summary= "Update a single commonsmenuitem")
86
    @PreAuthorize("hasRole('ROLE_ADMIN')")
87
    @PutMapping("")
88
    public UCSBDiningCommonsMenuItems updateCommonsMenuItems(
89
            @Parameter(name="id") @RequestParam Long id,
90
            @RequestBody @Valid UCSBDiningCommonsMenuItems incoming) {
91
92
        UCSBDiningCommonsMenuItems commonsmenuitem = ucsbDiningCommonsMenuItemsRepository.findById(id)
93 1 1. lambda$updateCommonsMenuItems$2 : replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBDiningCommonsMenuItemsController::lambda$updateCommonsMenuItems$2 → KILLED
                .orElseThrow(() -> new EntityNotFoundException(UCSBDiningCommonsMenuItems.class, id));
94
95
96 1 1. updateCommonsMenuItems : removed call to edu/ucsb/cs156/example/entities/UCSBDiningCommonsMenuItems::setName → KILLED
        commonsmenuitem.setName(incoming.getName());  
97 1 1. updateCommonsMenuItems : removed call to edu/ucsb/cs156/example/entities/UCSBDiningCommonsMenuItems::setCode → KILLED
        commonsmenuitem.setCode(incoming.getCode());
98 1 1. updateCommonsMenuItems : removed call to edu/ucsb/cs156/example/entities/UCSBDiningCommonsMenuItems::setStation → KILLED
        commonsmenuitem.setStation(incoming.getStation());
99
100
        ucsbDiningCommonsMenuItemsRepository.save(commonsmenuitem);
101
102 1 1. updateCommonsMenuItems : replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBDiningCommonsMenuItemsController::updateCommonsMenuItems → KILLED
        return commonsmenuitem;
103
    }
104
}

Mutations

39

1.1
Location : allCommonsMenuItems
Killed by : edu.ucsb.cs156.example.controllers.UCSBDiningCommonsMenuItemsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.example.controllers.UCSBDiningCommonsMenuItemsControllerTests]/[method:logged_in_user_can_get_all_ucsbdiningcommonsmenuitem()]
replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBDiningCommonsMenuItemsController::allCommonsMenuItems → KILLED

53

1.1
Location : postCommonsMenuItems
Killed by : edu.ucsb.cs156.example.controllers.UCSBDiningCommonsMenuItemsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.example.controllers.UCSBDiningCommonsMenuItemsControllerTests]/[method:an_admin_user_can_post_a_new_commonsmenuitem()]
removed call to edu/ucsb/cs156/example/entities/UCSBDiningCommonsMenuItems::setCode → KILLED

54

1.1
Location : postCommonsMenuItems
Killed by : edu.ucsb.cs156.example.controllers.UCSBDiningCommonsMenuItemsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.example.controllers.UCSBDiningCommonsMenuItemsControllerTests]/[method:an_admin_user_can_post_a_new_commonsmenuitem()]
removed call to edu/ucsb/cs156/example/entities/UCSBDiningCommonsMenuItems::setName → KILLED

55

1.1
Location : postCommonsMenuItems
Killed by : edu.ucsb.cs156.example.controllers.UCSBDiningCommonsMenuItemsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.example.controllers.UCSBDiningCommonsMenuItemsControllerTests]/[method:an_admin_user_can_post_a_new_commonsmenuitem()]
removed call to edu/ucsb/cs156/example/entities/UCSBDiningCommonsMenuItems::setStation → KILLED

59

1.1
Location : postCommonsMenuItems
Killed by : edu.ucsb.cs156.example.controllers.UCSBDiningCommonsMenuItemsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.example.controllers.UCSBDiningCommonsMenuItemsControllerTests]/[method:an_admin_user_can_post_a_new_commonsmenuitem()]
replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBDiningCommonsMenuItemsController::postCommonsMenuItems → KILLED

68

1.1
Location : lambda$getById$0
Killed by : edu.ucsb.cs156.example.controllers.UCSBDiningCommonsMenuItemsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.example.controllers.UCSBDiningCommonsMenuItemsControllerTests]/[method:test_that_logged_in_user_can_get_by_id_when_the_id_does_not_exist()]
replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBDiningCommonsMenuItemsController::lambda$getById$0 → KILLED

70

1.1
Location : getById
Killed by : edu.ucsb.cs156.example.controllers.UCSBDiningCommonsMenuItemsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.example.controllers.UCSBDiningCommonsMenuItemsControllerTests]/[method:test_that_logged_in_user_can_get_by_id_when_the_id_exists()]
replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBDiningCommonsMenuItemsController::getById → KILLED

79

1.1
Location : lambda$deleteCommonsMenuItems$1
Killed by : edu.ucsb.cs156.example.controllers.UCSBDiningCommonsMenuItemsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.example.controllers.UCSBDiningCommonsMenuItemsControllerTests]/[method:admin_tries_to_delete_non_existant_commonsmenuitem_and_gets_right_error_message()]
replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBDiningCommonsMenuItemsController::lambda$deleteCommonsMenuItems$1 → KILLED

81

1.1
Location : deleteCommonsMenuItems
Killed by : edu.ucsb.cs156.example.controllers.UCSBDiningCommonsMenuItemsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.example.controllers.UCSBDiningCommonsMenuItemsControllerTests]/[method:admin_can_delete_a_diningcommonsmenuitem()]
removed call to edu/ucsb/cs156/example/repositories/UCSBDiningCommonsMenuItemsRepository::delete → KILLED

82

1.1
Location : deleteCommonsMenuItems
Killed by : edu.ucsb.cs156.example.controllers.UCSBDiningCommonsMenuItemsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.example.controllers.UCSBDiningCommonsMenuItemsControllerTests]/[method:admin_can_delete_a_diningcommonsmenuitem()]
replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBDiningCommonsMenuItemsController::deleteCommonsMenuItems → KILLED

93

1.1
Location : lambda$updateCommonsMenuItems$2
Killed by : edu.ucsb.cs156.example.controllers.UCSBDiningCommonsMenuItemsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.example.controllers.UCSBDiningCommonsMenuItemsControllerTests]/[method:admin_cannot_edit_commonsmenuitem_that_does_not_exist()]
replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBDiningCommonsMenuItemsController::lambda$updateCommonsMenuItems$2 → KILLED

96

1.1
Location : updateCommonsMenuItems
Killed by : edu.ucsb.cs156.example.controllers.UCSBDiningCommonsMenuItemsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.example.controllers.UCSBDiningCommonsMenuItemsControllerTests]/[method:admin_can_edit_an_existing_commonsmenuitem()]
removed call to edu/ucsb/cs156/example/entities/UCSBDiningCommonsMenuItems::setName → KILLED

97

1.1
Location : updateCommonsMenuItems
Killed by : edu.ucsb.cs156.example.controllers.UCSBDiningCommonsMenuItemsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.example.controllers.UCSBDiningCommonsMenuItemsControllerTests]/[method:admin_can_edit_an_existing_commonsmenuitem()]
removed call to edu/ucsb/cs156/example/entities/UCSBDiningCommonsMenuItems::setCode → KILLED

98

1.1
Location : updateCommonsMenuItems
Killed by : edu.ucsb.cs156.example.controllers.UCSBDiningCommonsMenuItemsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.example.controllers.UCSBDiningCommonsMenuItemsControllerTests]/[method:admin_can_edit_an_existing_commonsmenuitem()]
removed call to edu/ucsb/cs156/example/entities/UCSBDiningCommonsMenuItems::setStation → KILLED

102

1.1
Location : updateCommonsMenuItems
Killed by : edu.ucsb.cs156.example.controllers.UCSBDiningCommonsMenuItemsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.example.controllers.UCSBDiningCommonsMenuItemsControllerTests]/[method:admin_can_edit_an_existing_commonsmenuitem()]
replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBDiningCommonsMenuItemsController::updateCommonsMenuItems → KILLED

Active mutators

Tests examined


Report generated by PIT 1.7.3