UCSBDiningCommonsController.java

1
package edu.ucsb.cs156.example.controllers;
2
3
import edu.ucsb.cs156.example.entities.UCSBDiningCommons;
4
import edu.ucsb.cs156.example.errors.EntityNotFoundException;
5
import edu.ucsb.cs156.example.repositories.UCSBDiningCommonsRepository;
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 = "UCSBDiningCommons")
26
@RequestMapping("/api/ucsbdiningcommons")
27
@RestController
28
@Slf4j
29
public class UCSBDiningCommonsController extends ApiController {
30
31
    @Autowired
32
    UCSBDiningCommonsRepository ucsbDiningCommonsRepository;
33
34
    @Operation(summary= "List all ucsb dining commons")
35
    @PreAuthorize("hasRole('ROLE_USER')")
36
    @GetMapping("/all")
37
    public Iterable<UCSBDiningCommons> allCommonss() {
38
        Iterable<UCSBDiningCommons> commons = ucsbDiningCommonsRepository.findAll();
39 1 1. allCommonss : replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBDiningCommonsController::allCommonss → KILLED
        return commons;
40
    }
41
42
    @Operation(summary= "Create a new commons")
43
    @PreAuthorize("hasRole('ROLE_ADMIN')")
44
    @PostMapping("/post")
45
    public UCSBDiningCommons postCommons(
46
        @Parameter(name="code") @RequestParam String code,
47
        @Parameter(name="name") @RequestParam String name,
48
        @Parameter(name="hasSackMeal") @RequestParam boolean hasSackMeal,
49
        @Parameter(name="hasTakeOutMeal") @RequestParam boolean hasTakeOutMeal,
50
        @Parameter(name="hasDiningCam") @RequestParam boolean hasDiningCam,
51
        @Parameter(name="latitude") @RequestParam double latitude,
52
        @Parameter(name="longitude") @RequestParam double longitude
53
        )
54
        {
55
56
        UCSBDiningCommons commons = new UCSBDiningCommons();
57 1 1. postCommons : removed call to edu/ucsb/cs156/example/entities/UCSBDiningCommons::setCode → KILLED
        commons.setCode(code);
58 1 1. postCommons : removed call to edu/ucsb/cs156/example/entities/UCSBDiningCommons::setName → KILLED
        commons.setName(name);
59 1 1. postCommons : removed call to edu/ucsb/cs156/example/entities/UCSBDiningCommons::setHasSackMeal → KILLED
        commons.setHasSackMeal(hasSackMeal);
60 1 1. postCommons : removed call to edu/ucsb/cs156/example/entities/UCSBDiningCommons::setHasTakeOutMeal → KILLED
        commons.setHasTakeOutMeal(hasTakeOutMeal);
61 1 1. postCommons : removed call to edu/ucsb/cs156/example/entities/UCSBDiningCommons::setHasDiningCam → KILLED
        commons.setHasDiningCam(hasDiningCam);
62 1 1. postCommons : removed call to edu/ucsb/cs156/example/entities/UCSBDiningCommons::setLatitude → KILLED
        commons.setLatitude(latitude);
63 1 1. postCommons : removed call to edu/ucsb/cs156/example/entities/UCSBDiningCommons::setLongitude → KILLED
        commons.setLongitude(longitude);
64
65
        UCSBDiningCommons savedCommons = ucsbDiningCommonsRepository.save(commons);
66
67 1 1. postCommons : replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBDiningCommonsController::postCommons → KILLED
        return savedCommons;
68
    }
69
70
    @Operation(summary= "Get a single commons")
71
    @PreAuthorize("hasRole('ROLE_USER')")
72
    @GetMapping("")
73
    public UCSBDiningCommons getById(
74
            @Parameter(name="code") @RequestParam String code) {
75
        UCSBDiningCommons commons = ucsbDiningCommonsRepository.findById(code)
76 1 1. lambda$getById$0 : replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBDiningCommonsController::lambda$getById$0 → KILLED
                .orElseThrow(() -> new EntityNotFoundException(UCSBDiningCommons.class, code));
77
78 1 1. getById : replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBDiningCommonsController::getById → KILLED
        return commons;
79
    }
80
81
    @Operation(summary= "Delete a UCSBDiningCommons")
82
    @PreAuthorize("hasRole('ROLE_ADMIN')")
83
    @DeleteMapping("")
84
    public Object deleteCommons(
85
            @Parameter(name="code") @RequestParam String code) {
86
        UCSBDiningCommons commons = ucsbDiningCommonsRepository.findById(code)
87 1 1. lambda$deleteCommons$1 : replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBDiningCommonsController::lambda$deleteCommons$1 → KILLED
                .orElseThrow(() -> new EntityNotFoundException(UCSBDiningCommons.class, code));
88
89 1 1. deleteCommons : removed call to edu/ucsb/cs156/example/repositories/UCSBDiningCommonsRepository::delete → KILLED
        ucsbDiningCommonsRepository.delete(commons);
90 1 1. deleteCommons : replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBDiningCommonsController::deleteCommons → KILLED
        return genericMessage("UCSBDiningCommons with id %s deleted".formatted(code));
91
    }
92
93
    @Operation(summary= "Update a single commons")
94
    @PreAuthorize("hasRole('ROLE_ADMIN')")
95
    @PutMapping("")
96
    public UCSBDiningCommons updateCommons(
97
            @Parameter(name="code") @RequestParam String code,
98
            @RequestBody @Valid UCSBDiningCommons incoming) {
99
100
        UCSBDiningCommons commons = ucsbDiningCommonsRepository.findById(code)
101 1 1. lambda$updateCommons$2 : replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBDiningCommonsController::lambda$updateCommons$2 → KILLED
                .orElseThrow(() -> new EntityNotFoundException(UCSBDiningCommons.class, code));
102
103
104 1 1. updateCommons : removed call to edu/ucsb/cs156/example/entities/UCSBDiningCommons::setName → KILLED
        commons.setName(incoming.getName());  
105 1 1. updateCommons : removed call to edu/ucsb/cs156/example/entities/UCSBDiningCommons::setHasSackMeal → KILLED
        commons.setHasSackMeal(incoming.getHasSackMeal());
106 1 1. updateCommons : removed call to edu/ucsb/cs156/example/entities/UCSBDiningCommons::setHasTakeOutMeal → KILLED
        commons.setHasTakeOutMeal(incoming.getHasTakeOutMeal());
107 1 1. updateCommons : removed call to edu/ucsb/cs156/example/entities/UCSBDiningCommons::setHasDiningCam → KILLED
        commons.setHasDiningCam(incoming.getHasDiningCam());
108 1 1. updateCommons : removed call to edu/ucsb/cs156/example/entities/UCSBDiningCommons::setLatitude → KILLED
        commons.setLatitude(incoming.getLatitude());
109 1 1. updateCommons : removed call to edu/ucsb/cs156/example/entities/UCSBDiningCommons::setLongitude → KILLED
        commons.setLongitude(incoming.getLongitude());
110
111
        ucsbDiningCommonsRepository.save(commons);
112
113 1 1. updateCommons : replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBDiningCommonsController::updateCommons → KILLED
        return commons;
114
    }
115
}

Mutations

39

1.1
Location : allCommonss
Killed by : edu.ucsb.cs156.example.controllers.UCSBDiningCommonsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.example.controllers.UCSBDiningCommonsControllerTests]/[method:logged_in_user_can_get_all_ucsbdiningcommons()]
replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBDiningCommonsController::allCommonss → KILLED

57

1.1
Location : postCommons
Killed by : edu.ucsb.cs156.example.controllers.UCSBDiningCommonsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.example.controllers.UCSBDiningCommonsControllerTests]/[method:an_admin_user_can_post_a_new_commons()]
removed call to edu/ucsb/cs156/example/entities/UCSBDiningCommons::setCode → KILLED

58

1.1
Location : postCommons
Killed by : edu.ucsb.cs156.example.controllers.UCSBDiningCommonsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.example.controllers.UCSBDiningCommonsControllerTests]/[method:an_admin_user_can_post_a_new_commons()]
removed call to edu/ucsb/cs156/example/entities/UCSBDiningCommons::setName → KILLED

59

1.1
Location : postCommons
Killed by : edu.ucsb.cs156.example.controllers.UCSBDiningCommonsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.example.controllers.UCSBDiningCommonsControllerTests]/[method:an_admin_user_can_post_a_new_commons()]
removed call to edu/ucsb/cs156/example/entities/UCSBDiningCommons::setHasSackMeal → KILLED

60

1.1
Location : postCommons
Killed by : edu.ucsb.cs156.example.controllers.UCSBDiningCommonsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.example.controllers.UCSBDiningCommonsControllerTests]/[method:an_admin_user_can_post_a_new_commons()]
removed call to edu/ucsb/cs156/example/entities/UCSBDiningCommons::setHasTakeOutMeal → KILLED

61

1.1
Location : postCommons
Killed by : edu.ucsb.cs156.example.controllers.UCSBDiningCommonsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.example.controllers.UCSBDiningCommonsControllerTests]/[method:an_admin_user_can_post_a_new_commons()]
removed call to edu/ucsb/cs156/example/entities/UCSBDiningCommons::setHasDiningCam → KILLED

62

1.1
Location : postCommons
Killed by : edu.ucsb.cs156.example.controllers.UCSBDiningCommonsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.example.controllers.UCSBDiningCommonsControllerTests]/[method:an_admin_user_can_post_a_new_commons()]
removed call to edu/ucsb/cs156/example/entities/UCSBDiningCommons::setLatitude → KILLED

63

1.1
Location : postCommons
Killed by : edu.ucsb.cs156.example.controllers.UCSBDiningCommonsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.example.controllers.UCSBDiningCommonsControllerTests]/[method:an_admin_user_can_post_a_new_commons()]
removed call to edu/ucsb/cs156/example/entities/UCSBDiningCommons::setLongitude → KILLED

67

1.1
Location : postCommons
Killed by : edu.ucsb.cs156.example.controllers.UCSBDiningCommonsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.example.controllers.UCSBDiningCommonsControllerTests]/[method:an_admin_user_can_post_a_new_commons()]
replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBDiningCommonsController::postCommons → KILLED

76

1.1
Location : lambda$getById$0
Killed by : edu.ucsb.cs156.example.controllers.UCSBDiningCommonsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.example.controllers.UCSBDiningCommonsControllerTests]/[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/UCSBDiningCommonsController::lambda$getById$0 → KILLED

78

1.1
Location : getById
Killed by : edu.ucsb.cs156.example.controllers.UCSBDiningCommonsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.example.controllers.UCSBDiningCommonsControllerTests]/[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/UCSBDiningCommonsController::getById → KILLED

87

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

89

1.1
Location : deleteCommons
Killed by : edu.ucsb.cs156.example.controllers.UCSBDiningCommonsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.example.controllers.UCSBDiningCommonsControllerTests]/[method:admin_can_delete_a_date()]
removed call to edu/ucsb/cs156/example/repositories/UCSBDiningCommonsRepository::delete → KILLED

90

1.1
Location : deleteCommons
Killed by : edu.ucsb.cs156.example.controllers.UCSBDiningCommonsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.example.controllers.UCSBDiningCommonsControllerTests]/[method:admin_can_delete_a_date()]
replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBDiningCommonsController::deleteCommons → KILLED

101

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

104

1.1
Location : updateCommons
Killed by : edu.ucsb.cs156.example.controllers.UCSBDiningCommonsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.example.controllers.UCSBDiningCommonsControllerTests]/[method:admin_can_edit_an_existing_commons()]
removed call to edu/ucsb/cs156/example/entities/UCSBDiningCommons::setName → KILLED

105

1.1
Location : updateCommons
Killed by : edu.ucsb.cs156.example.controllers.UCSBDiningCommonsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.example.controllers.UCSBDiningCommonsControllerTests]/[method:admin_can_edit_an_existing_commons()]
removed call to edu/ucsb/cs156/example/entities/UCSBDiningCommons::setHasSackMeal → KILLED

106

1.1
Location : updateCommons
Killed by : edu.ucsb.cs156.example.controllers.UCSBDiningCommonsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.example.controllers.UCSBDiningCommonsControllerTests]/[method:admin_can_edit_an_existing_commons()]
removed call to edu/ucsb/cs156/example/entities/UCSBDiningCommons::setHasTakeOutMeal → KILLED

107

1.1
Location : updateCommons
Killed by : edu.ucsb.cs156.example.controllers.UCSBDiningCommonsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.example.controllers.UCSBDiningCommonsControllerTests]/[method:admin_can_edit_an_existing_commons()]
removed call to edu/ucsb/cs156/example/entities/UCSBDiningCommons::setHasDiningCam → KILLED

108

1.1
Location : updateCommons
Killed by : edu.ucsb.cs156.example.controllers.UCSBDiningCommonsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.example.controllers.UCSBDiningCommonsControllerTests]/[method:admin_can_edit_an_existing_commons()]
removed call to edu/ucsb/cs156/example/entities/UCSBDiningCommons::setLatitude → KILLED

109

1.1
Location : updateCommons
Killed by : edu.ucsb.cs156.example.controllers.UCSBDiningCommonsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.example.controllers.UCSBDiningCommonsControllerTests]/[method:admin_can_edit_an_existing_commons()]
removed call to edu/ucsb/cs156/example/entities/UCSBDiningCommons::setLongitude → KILLED

113

1.1
Location : updateCommons
Killed by : edu.ucsb.cs156.example.controllers.UCSBDiningCommonsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.example.controllers.UCSBDiningCommonsControllerTests]/[method:admin_can_edit_an_existing_commons()]
replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBDiningCommonsController::updateCommons → KILLED

Active mutators

Tests examined


Report generated by PIT 1.7.3