UCSBOrganizationsController.java

1
package edu.ucsb.cs156.example.controllers;
2
3
import edu.ucsb.cs156.example.entities.UCSBOrganizations;
4
import edu.ucsb.cs156.example.errors.EntityNotFoundException;
5
import edu.ucsb.cs156.example.repositories.UCSBOrganizationsRepository;
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 = "UCSBOrganizations")
26
@RequestMapping("/api/UCSBOrganization")
27
@RestController
28
@Slf4j
29
public class UCSBOrganizationsController extends ApiController {
30
31
    @Autowired
32
    UCSBOrganizationsRepository ucsbOrganizationsRepository;
33
34
    @Operation(summary = "List all UCSBOrganizations")
35
    @PreAuthorize("hasRole('ROLE_USER')")
36
    @GetMapping("/all")
37
    public Iterable<UCSBOrganizations> allOrgss() {
38
        Iterable<UCSBOrganizations> orgs = ucsbOrganizationsRepository.findAll();
39 1 1. allOrgss : replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBOrganizationsController::allOrgss → KILLED
        return orgs;
40
    }
41
42
    @Operation(summary = "Create a new UCSBOrganizations")
43
    @PreAuthorize("hasRole('ROLE_ADMIN')")
44
    @PostMapping("/post")
45
    public UCSBOrganizations postOrgs(
46
            @Parameter(name = "orgCode") @RequestParam String orgCode,
47
            @Parameter(name = "orgTranslationShort") @RequestParam String orgTranslationShort,
48
            @Parameter(name = "orgTranslation") @RequestParam String orgTranslation,
49
            @Parameter(name = "inactive") @RequestParam boolean inactive) {
50
51
        UCSBOrganizations org = new UCSBOrganizations();
52 1 1. postOrgs : removed call to edu/ucsb/cs156/example/entities/UCSBOrganizations::setOrgCode → KILLED
        org.setOrgCode(orgCode);
53 1 1. postOrgs : removed call to edu/ucsb/cs156/example/entities/UCSBOrganizations::setOrgTranslationShort → KILLED
        org.setOrgTranslationShort(orgTranslationShort);
54 1 1. postOrgs : removed call to edu/ucsb/cs156/example/entities/UCSBOrganizations::setOrgTranslation → KILLED
        org.setOrgTranslation(orgTranslation);
55 1 1. postOrgs : removed call to edu/ucsb/cs156/example/entities/UCSBOrganizations::setInactive → KILLED
        org.setInactive(inactive);
56
57
        UCSBOrganizations savedOrgs = ucsbOrganizationsRepository.save(org);
58
59 1 1. postOrgs : replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBOrganizationsController::postOrgs → KILLED
        return savedOrgs;
60
    }
61
62
    @Operation(summary = "Get a single UCSBOrganizations")
63
    @PreAuthorize("hasRole('ROLE_USER')")
64
    @GetMapping("")
65
    public UCSBOrganizations getById(
66
            @Parameter(name = "orgCode") @RequestParam(name = "orgCode") String id) {
67
        UCSBOrganizations orgs = ucsbOrganizationsRepository.findById(id)
68 1 1. lambda$getById$0 : replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBOrganizationsController::lambda$getById$0 → KILLED
                .orElseThrow(() -> new EntityNotFoundException(UCSBOrganizations.class, id));
69
70 1 1. getById : replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBOrganizationsController::getById → KILLED
        return orgs;
71
    }
72
73
    @Operation(summary = "Delete a UCSBOrganizations")
74
    @PreAuthorize("hasRole('ROLE_ADMIN')")
75
    @DeleteMapping("")
76
    public Object deleteOrgs(
77
            @Parameter(name = "orgCode") @RequestParam(name = "orgCode") String id) {
78
        UCSBOrganizations orgs = ucsbOrganizationsRepository.findById(id)
79 1 1. lambda$deleteOrgs$1 : replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBOrganizationsController::lambda$deleteOrgs$1 → KILLED
                .orElseThrow(() -> new EntityNotFoundException(UCSBOrganizations.class, id));
80
81 1 1. deleteOrgs : removed call to edu/ucsb/cs156/example/repositories/UCSBOrganizationsRepository::delete → KILLED
        ucsbOrganizationsRepository.delete(orgs);
82 1 1. deleteOrgs : replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBOrganizationsController::deleteOrgs → KILLED
        return genericMessage("UCSBOrganizations with id %s deleted".formatted(id));
83
    }
84
85
    @Operation(summary = "Update a single UCSBOrganizations")
86
    @PreAuthorize("hasRole('ROLE_ADMIN')")
87
    @PutMapping("")
88
    public UCSBOrganizations updateOrgs(
89
            @Parameter(name = "orgCode") @RequestParam(name = "orgCode") String id,
90
            @RequestBody @Valid UCSBOrganizations incoming) {
91
92
        UCSBOrganizations orgs = ucsbOrganizationsRepository.findById(id)
93 1 1. lambda$updateOrgs$2 : replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBOrganizationsController::lambda$updateOrgs$2 → KILLED
                .orElseThrow(() -> new EntityNotFoundException(UCSBOrganizations.class, id));
94
95
        // orgs.setOrgCode(incoming.getOrgCode());
96 1 1. updateOrgs : removed call to edu/ucsb/cs156/example/entities/UCSBOrganizations::setOrgTranslationShort → KILLED
        orgs.setOrgTranslationShort(incoming.getOrgTranslationShort());
97 1 1. updateOrgs : removed call to edu/ucsb/cs156/example/entities/UCSBOrganizations::setOrgTranslation → KILLED
        orgs.setOrgTranslation(incoming.getOrgTranslation());
98 1 1. updateOrgs : removed call to edu/ucsb/cs156/example/entities/UCSBOrganizations::setInactive → KILLED
        orgs.setInactive(incoming.getInactive());
99
100
        ucsbOrganizationsRepository.save(orgs);
101
102 1 1. updateOrgs : replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBOrganizationsController::updateOrgs → KILLED
        return orgs;
103
    }
104
}

Mutations

39

1.1
Location : allOrgss
Killed by : edu.ucsb.cs156.example.controllers.UCSBOrganizationsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.example.controllers.UCSBOrganizationsControllerTests]/[method:logged_in_user_can_get_all_ucsborganizations()]
replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBOrganizationsController::allOrgss → KILLED

52

1.1
Location : postOrgs
Killed by : edu.ucsb.cs156.example.controllers.UCSBOrganizationsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.example.controllers.UCSBOrganizationsControllerTests]/[method:an_admin_user_can_post_a_new_commons()]
removed call to edu/ucsb/cs156/example/entities/UCSBOrganizations::setOrgCode → KILLED

53

1.1
Location : postOrgs
Killed by : edu.ucsb.cs156.example.controllers.UCSBOrganizationsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.example.controllers.UCSBOrganizationsControllerTests]/[method:an_admin_user_can_post_a_new_commons()]
removed call to edu/ucsb/cs156/example/entities/UCSBOrganizations::setOrgTranslationShort → KILLED

54

1.1
Location : postOrgs
Killed by : edu.ucsb.cs156.example.controllers.UCSBOrganizationsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.example.controllers.UCSBOrganizationsControllerTests]/[method:an_admin_user_can_post_a_new_commons()]
removed call to edu/ucsb/cs156/example/entities/UCSBOrganizations::setOrgTranslation → KILLED

55

1.1
Location : postOrgs
Killed by : edu.ucsb.cs156.example.controllers.UCSBOrganizationsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.example.controllers.UCSBOrganizationsControllerTests]/[method:an_admin_user_can_post_a_new_commons()]
removed call to edu/ucsb/cs156/example/entities/UCSBOrganizations::setInactive → KILLED

59

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

68

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

70

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

79

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

81

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

82

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

93

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

96

1.1
Location : updateOrgs
Killed by : edu.ucsb.cs156.example.controllers.UCSBOrganizationsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.example.controllers.UCSBOrganizationsControllerTests]/[method:admin_can_edit_an_existing_commons()]
removed call to edu/ucsb/cs156/example/entities/UCSBOrganizations::setOrgTranslationShort → KILLED

97

1.1
Location : updateOrgs
Killed by : edu.ucsb.cs156.example.controllers.UCSBOrganizationsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.example.controllers.UCSBOrganizationsControllerTests]/[method:admin_can_edit_an_existing_commons()]
removed call to edu/ucsb/cs156/example/entities/UCSBOrganizations::setOrgTranslation → KILLED

98

1.1
Location : updateOrgs
Killed by : edu.ucsb.cs156.example.controllers.UCSBOrganizationsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.example.controllers.UCSBOrganizationsControllerTests]/[method:admin_can_edit_an_existing_commons()]
removed call to edu/ucsb/cs156/example/entities/UCSBOrganizations::setInactive → KILLED

102

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

Active mutators

Tests examined


Report generated by PIT 1.7.3