AnnouncementsController.java

1
package edu.ucsb.cs156.happiercows.controllers;
2
3
import com.fasterxml.jackson.databind.ObjectMapper;
4
import io.swagger.v3.oas.annotations.tags.Tag;
5
import lombok.extern.slf4j.Slf4j;
6
import io.swagger.v3.oas.annotations.Operation;
7
import io.swagger.v3.oas.annotations.Parameter;
8
import org.springframework.beans.factory.annotation.Autowired;
9
import org.springframework.http.ResponseEntity;
10
import org.springframework.security.access.prepost.PreAuthorize;
11
import org.springframework.security.core.context.SecurityContextHolder;
12
import org.springframework.web.bind.annotation.*;
13
import org.springframework.data.domain.Page;
14
import org.springframework.data.domain.PageRequest;
15
import org.springframework.data.domain.Sort;
16
import org.springframework.format.annotation.DateTimeFormat;
17
18
import edu.ucsb.cs156.happiercows.entities.Announcement;
19
import edu.ucsb.cs156.happiercows.repositories.AnnouncementRepository;
20
21
import edu.ucsb.cs156.happiercows.entities.User;
22
import edu.ucsb.cs156.happiercows.entities.UserCommons;
23
import edu.ucsb.cs156.happiercows.repositories.UserCommonsRepository;
24
25
import org.springframework.security.core.Authentication;
26
import java.util.Date;
27
28
import java.util.Calendar;
29
30
31
import java.util.Optional;
32
33
@Tag(name = "Announcements")
34
@RequestMapping("/api/announcements")
35
@RestController
36
@Slf4j
37
public class AnnouncementsController extends ApiController{
38
39
    @Autowired
40
    private AnnouncementRepository announcementRepository;
41
42
    @Autowired
43
    private UserCommonsRepository userCommonsRepository;
44
45
    @Autowired
46
    ObjectMapper mapper;
47
48
49
    @Operation(summary = "Create an announcement", description = "Create an announcement associated with a specific commons")
50
    @PreAuthorize("hasAnyRole('ROLE_USER', 'ROLE_ADMIN')")
51
    @PostMapping("/post/{commonsId}")
52
    public ResponseEntity<Object> createAnnouncement(
53
        @Parameter(description = "The id of the common") @PathVariable Long commonsId,
54
        @Parameter(description = "The datetime at which the announcement will be shown (current time)") 
55
        @RequestParam(required = false) @DateTimeFormat(pattern = "yyyy-MM-dd")
56
        Date startDate,
57
        @Parameter(description = "The datetime at which the announcement will stop being shown (optional)") 
58
        @RequestParam(required = false)  @DateTimeFormat(pattern = "yyyy-MM-dd")
59
        Date endDate,
60
        @Parameter(description = "The announcement to be sent out") @RequestParam String announcementText) {
61
62
        User user = getCurrentUser().getUser();
63
        Long userId = user.getId();
64
65
        // Make sure the user is part of the commons or is an admin
66
        Authentication auth = SecurityContextHolder.getContext().getAuthentication();
67 3 1. createAnnouncement : negated conditional → KILLED
2. lambda$createAnnouncement$0 : replaced boolean return with false for edu/ucsb/cs156/happiercows/controllers/AnnouncementsController::lambda$createAnnouncement$0 → KILLED
3. lambda$createAnnouncement$0 : replaced boolean return with true for edu/ucsb/cs156/happiercows/controllers/AnnouncementsController::lambda$createAnnouncement$0 → KILLED
        if (!auth.getAuthorities().stream().anyMatch(a -> a.getAuthority().equals("ROLE_ADMIN"))){
68
            log.info("User is not an admin");
69
            Optional<UserCommons> userCommonsLookup = userCommonsRepository.findByCommonsIdAndUserId(commonsId, userId);
70
71 1 1. createAnnouncement : negated conditional → KILLED
            if (!userCommonsLookup.isPresent()) {
72 1 1. createAnnouncement : replaced return value with null for edu/ucsb/cs156/happiercows/controllers/AnnouncementsController::createAnnouncement → KILLED
                return ResponseEntity.badRequest().body("Commons_id must exist.");
73
            }
74
        }
75
76
        // Fix timezone difference for PST
77 1 1. createAnnouncement : negated conditional → KILLED
        if (startDate != null) {
78
            Calendar calendar = Calendar.getInstance(); 
79 1 1. createAnnouncement : removed call to java/util/Calendar::setTime → KILLED
            calendar.setTime(startDate);
80
81 1 1. createAnnouncement : removed call to java/util/Calendar::set → KILLED
            calendar.set(Calendar.HOUR_OF_DAY, 8); 
82
            startDate = calendar.getTime();
83
        }
84
        else {
85
            log.info("Start date not specified. Defaulting to current date.");
86
            startDate = new Date(); 
87
        }
88 1 1. createAnnouncement : negated conditional → KILLED
        if (endDate != null) {
89
            Calendar calendar = Calendar.getInstance(); 
90 1 1. createAnnouncement : removed call to java/util/Calendar::setTime → KILLED
            calendar.setTime(endDate);
91
92 1 1. createAnnouncement : removed call to java/util/Calendar::set → KILLED
            calendar.set(Calendar.HOUR_OF_DAY, 8); 
93
            endDate = calendar.getTime();
94
        }
95
96
97 1 1. createAnnouncement : negated conditional → KILLED
        if (announcementText == "") {
98 1 1. createAnnouncement : replaced return value with null for edu/ucsb/cs156/happiercows/controllers/AnnouncementsController::createAnnouncement → KILLED
            return ResponseEntity.badRequest().body("Announcement cannot be empty.");
99
        }
100 2 1. createAnnouncement : negated conditional → KILLED
2. createAnnouncement : negated conditional → KILLED
        if (endDate != null && startDate.after(endDate)) {
101 1 1. createAnnouncement : replaced return value with null for edu/ucsb/cs156/happiercows/controllers/AnnouncementsController::createAnnouncement → KILLED
            return ResponseEntity.badRequest().body("Start date must be before end date.");
102
        }
103
104
        // Create the announcement
105
        Announcement announcementObj = Announcement.builder()
106
        .commonsId(commonsId)
107
        .startDate(startDate)
108
        .endDate(endDate)
109
        .announcementText(announcementText)
110
        .build();
111
112
        // Save the announcement
113
        announcementRepository.save(announcementObj);
114
115 1 1. createAnnouncement : replaced return value with null for edu/ucsb/cs156/happiercows/controllers/AnnouncementsController::createAnnouncement → KILLED
        return ResponseEntity.ok(announcementObj);
116
    }
117
118
    @Operation(summary = "Get all announcements", description = "Get all announcements associated with a specific commons.")
119
    @PreAuthorize("hasAnyRole('ROLE_USER', 'ROLE_ADMIN')")
120
    @GetMapping("/getbycommonsid")
121
    public ResponseEntity<Object> getAnnouncements(@Parameter(description = "The id of the common") @RequestParam Long commonsId) {
122
123
        // Make sure the user is part of the commons or is an admin
124
        Authentication auth = SecurityContextHolder.getContext().getAuthentication();
125 3 1. getAnnouncements : negated conditional → KILLED
2. lambda$getAnnouncements$1 : replaced boolean return with false for edu/ucsb/cs156/happiercows/controllers/AnnouncementsController::lambda$getAnnouncements$1 → KILLED
3. lambda$getAnnouncements$1 : replaced boolean return with true for edu/ucsb/cs156/happiercows/controllers/AnnouncementsController::lambda$getAnnouncements$1 → KILLED
        if (!auth.getAuthorities().stream().anyMatch(a -> a.getAuthority().equals("ROLE_ADMIN"))){
126
            log.info("User is not an admin");
127
            User user = getCurrentUser().getUser();
128
            Long userId = user.getId();
129
            Optional<UserCommons> userCommonsLookup = userCommonsRepository.findByCommonsIdAndUserId(commonsId, userId);
130
131 1 1. getAnnouncements : negated conditional → KILLED
            if (!userCommonsLookup.isPresent()) {
132 1 1. getAnnouncements : replaced return value with null for edu/ucsb/cs156/happiercows/controllers/AnnouncementsController::getAnnouncements → KILLED
                return ResponseEntity.badRequest().body("Commons_id must exist.");
133
            }
134
        }
135
136
        int MAX_ANNOUNCEMENTS = 1000;
137
        Page<Announcement> announcements = announcementRepository.findByCommonsId(commonsId, PageRequest.of(0, MAX_ANNOUNCEMENTS, Sort.by("startDate").descending()));
138 1 1. getAnnouncements : replaced return value with null for edu/ucsb/cs156/happiercows/controllers/AnnouncementsController::getAnnouncements → KILLED
        return ResponseEntity.ok(announcements);
139
    }
140
141
    @Operation(summary = "Get announcements by id", description = "Get announcement by its id.")
142
    @PreAuthorize("hasAnyRole('ROLE_USER', 'ROLE_ADMIN')")
143
    @GetMapping("/getbyid")
144
    public ResponseEntity<Object> getAnnouncementById(@Parameter(description = "The id of the announcement") @RequestParam Long id) {
145
146
        Optional<Announcement> announcementLookup = announcementRepository.findByAnnouncementId(id);
147 1 1. getAnnouncementById : negated conditional → KILLED
        if (!announcementLookup.isPresent()) {
148 1 1. getAnnouncementById : replaced return value with null for edu/ucsb/cs156/happiercows/controllers/AnnouncementsController::getAnnouncementById → KILLED
            return ResponseEntity.badRequest().body("Cannot find announcement. id is invalid.");
149
150
        }
151 1 1. getAnnouncementById : replaced return value with null for edu/ucsb/cs156/happiercows/controllers/AnnouncementsController::getAnnouncementById → KILLED
        return ResponseEntity.ok(announcementLookup.get());
152
    }
153
154
    @Operation(summary = "Edit an announcement", description = "Edit an announcement by its id.")
155
    @PreAuthorize("hasAnyRole('ROLE_USER', 'ROLE_ADMIN')")
156
    @PutMapping("/put")
157
    public ResponseEntity<Object> editAnnouncement(
158
        @Parameter(description = "The id of the announcement") @RequestParam Long id,
159
        @Parameter(description = "The id of the common") @RequestParam Long commonsId,
160
        @Parameter(description = "The datetime at which the announcement will be shown (defaults to current time)") @RequestParam(required = false) Date startDate,
161
        @Parameter(description = "The datetime at which the announcement will stop being shown (optional)") @RequestParam(required = false) Date endDate,
162
        @Parameter(description = "The announcement to be sent out") @RequestParam String announcementText) {
163
164
        User user = getCurrentUser().getUser();
165
        Long userId = user.getId();
166
167
        // Make sure the user is part of the commons or is an admin
168
        Authentication auth = SecurityContextHolder.getContext().getAuthentication();
169 3 1. editAnnouncement : negated conditional → KILLED
2. lambda$editAnnouncement$2 : replaced boolean return with false for edu/ucsb/cs156/happiercows/controllers/AnnouncementsController::lambda$editAnnouncement$2 → KILLED
3. lambda$editAnnouncement$2 : replaced boolean return with true for edu/ucsb/cs156/happiercows/controllers/AnnouncementsController::lambda$editAnnouncement$2 → KILLED
        if (!auth.getAuthorities().stream().anyMatch(a -> a.getAuthority().equals("ROLE_ADMIN"))){
170
            log.info("User is not an admin");
171
            Optional<UserCommons> userCommonsLookup = userCommonsRepository.findByCommonsIdAndUserId(commonsId, userId);
172
173 1 1. editAnnouncement : negated conditional → KILLED
            if (!userCommonsLookup.isPresent()) {
174 1 1. editAnnouncement : replaced return value with null for edu/ucsb/cs156/happiercows/controllers/AnnouncementsController::editAnnouncement → KILLED
                return ResponseEntity.badRequest().body("Commons_id must exist.");
175
            }
176
        }
177
178 1 1. editAnnouncement : negated conditional → KILLED
        if (announcementText == "") {
179 1 1. editAnnouncement : replaced return value with null for edu/ucsb/cs156/happiercows/controllers/AnnouncementsController::editAnnouncement → KILLED
            return ResponseEntity.badRequest().body("Announcement cannot be empty.");
180
        }
181
182 1 1. editAnnouncement : negated conditional → KILLED
        if (startDate == null) {
183
            log.info("Start date not specified. Defaulting to current date.");
184
            startDate = new Date();
185
        }
186
187 2 1. editAnnouncement : negated conditional → KILLED
2. editAnnouncement : negated conditional → KILLED
        if (endDate != null && startDate.after(endDate)) {
188 1 1. editAnnouncement : replaced return value with null for edu/ucsb/cs156/happiercows/controllers/AnnouncementsController::editAnnouncement → KILLED
            return ResponseEntity.badRequest().body("Start date must be before end date.");
189
        }
190
191
        Optional<Announcement> announcementLookup = announcementRepository.findByAnnouncementId(id);
192
193 1 1. editAnnouncement : negated conditional → KILLED
        if (!announcementLookup.isPresent()) {
194 1 1. editAnnouncement : replaced return value with null for edu/ucsb/cs156/happiercows/controllers/AnnouncementsController::editAnnouncement → KILLED
            return ResponseEntity.badRequest().body("Announcement could not be found. Invalid id.");
195
        }
196
197
        // Create the announcement
198
        Announcement announcementObj = announcementLookup.get();
199 1 1. editAnnouncement : removed call to edu/ucsb/cs156/happiercows/entities/Announcement::setStartDate → KILLED
        announcementObj.setStartDate(startDate);
200 1 1. editAnnouncement : removed call to edu/ucsb/cs156/happiercows/entities/Announcement::setEndDate → KILLED
        announcementObj.setEndDate(endDate);
201 1 1. editAnnouncement : removed call to edu/ucsb/cs156/happiercows/entities/Announcement::setAnnouncementText → KILLED
        announcementObj.setAnnouncementText(announcementText);
202
203
        // Save the announcement
204
        announcementRepository.save(announcementObj);
205 1 1. editAnnouncement : replaced return value with null for edu/ucsb/cs156/happiercows/controllers/AnnouncementsController::editAnnouncement → KILLED
        return ResponseEntity.ok(announcementObj);
206
    }
207
208
209
    @Operation(summary = "Delete an announcement", description = "Delete an announcement associated with an id")
210
    @PreAuthorize("hasAnyRole('ROLE_ADMIN')")
211
    @DeleteMapping("/delete")
212
    public ResponseEntity<Object> deleteAnnouncement(@Parameter(description = "The id of the chat message") @RequestParam Long id) {
213
214
        // Try to get the chat message
215
        Optional<Announcement> announcementLookup = announcementRepository.findByAnnouncementId(id);
216 1 1. deleteAnnouncement : negated conditional → KILLED
        if (!announcementLookup.isPresent()) {
217 1 1. deleteAnnouncement : replaced return value with null for edu/ucsb/cs156/happiercows/controllers/AnnouncementsController::deleteAnnouncement → KILLED
            return ResponseEntity.badRequest().body("Cannot find announcement. id is invalid.");
218
        }
219
        Announcement announcementObj = announcementLookup.get();
220
221
        User user = getCurrentUser().getUser();
222
        Long userId = user.getId();
223
224
        // Hide the message
225 1 1. deleteAnnouncement : removed call to edu/ucsb/cs156/happiercows/repositories/AnnouncementRepository::delete → KILLED
        announcementRepository.delete(announcementObj);
226 1 1. deleteAnnouncement : replaced return value with null for edu/ucsb/cs156/happiercows/controllers/AnnouncementsController::deleteAnnouncement → KILLED
        return ResponseEntity.ok(announcementObj);
227
    }
228
229
230
}

Mutations

67

1.1
Location : createAnnouncement
Killed by : edu.ucsb.cs156.happiercows.controllers.AnnouncementsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.happiercows.controllers.AnnouncementsControllerTests]/[method:adminCannotPostAnnouncementWithEmptyString()]
negated conditional → KILLED

2.2
Location : lambda$createAnnouncement$0
Killed by : edu.ucsb.cs156.happiercows.controllers.AnnouncementsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.happiercows.controllers.AnnouncementsControllerTests]/[method:adminCannotPostAnnouncementWithEmptyString()]
replaced boolean return with false for edu/ucsb/cs156/happiercows/controllers/AnnouncementsController::lambda$createAnnouncement$0 → KILLED

3.3
Location : lambda$createAnnouncement$0
Killed by : edu.ucsb.cs156.happiercows.controllers.AnnouncementsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.happiercows.controllers.AnnouncementsControllerTests]/[method:userNotInCommonsCannotPostAnnouncements()]
replaced boolean return with true for edu/ucsb/cs156/happiercows/controllers/AnnouncementsController::lambda$createAnnouncement$0 → KILLED

71

1.1
Location : createAnnouncement
Killed by : edu.ucsb.cs156.happiercows.controllers.AnnouncementsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.happiercows.controllers.AnnouncementsControllerTests]/[method:userCanPostAnnouncementWithoutStartAndEndTime()]
negated conditional → KILLED

72

1.1
Location : createAnnouncement
Killed by : edu.ucsb.cs156.happiercows.controllers.AnnouncementsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.happiercows.controllers.AnnouncementsControllerTests]/[method:userNotInCommonsCannotPostAnnouncements()]
replaced return value with null for edu/ucsb/cs156/happiercows/controllers/AnnouncementsController::createAnnouncement → KILLED

77

1.1
Location : createAnnouncement
Killed by : edu.ucsb.cs156.happiercows.controllers.AnnouncementsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.happiercows.controllers.AnnouncementsControllerTests]/[method:adminCanPostAnnouncements()]
negated conditional → KILLED

79

1.1
Location : createAnnouncement
Killed by : edu.ucsb.cs156.happiercows.controllers.AnnouncementsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.happiercows.controllers.AnnouncementsControllerTests]/[method:adminCanPostAnnouncements()]
removed call to java/util/Calendar::setTime → KILLED

81

1.1
Location : createAnnouncement
Killed by : edu.ucsb.cs156.happiercows.controllers.AnnouncementsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.happiercows.controllers.AnnouncementsControllerTests]/[method:adminCanPostAnnouncements()]
removed call to java/util/Calendar::set → KILLED

88

1.1
Location : createAnnouncement
Killed by : edu.ucsb.cs156.happiercows.controllers.AnnouncementsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.happiercows.controllers.AnnouncementsControllerTests]/[method:adminCannotPostAnnouncementWithEmptyString()]
negated conditional → KILLED

90

1.1
Location : createAnnouncement
Killed by : edu.ucsb.cs156.happiercows.controllers.AnnouncementsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.happiercows.controllers.AnnouncementsControllerTests]/[method:adminCanPostAnnouncements()]
removed call to java/util/Calendar::setTime → KILLED

92

1.1
Location : createAnnouncement
Killed by : edu.ucsb.cs156.happiercows.controllers.AnnouncementsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.happiercows.controllers.AnnouncementsControllerTests]/[method:adminCanPostAnnouncements()]
removed call to java/util/Calendar::set → KILLED

97

1.1
Location : createAnnouncement
Killed by : edu.ucsb.cs156.happiercows.controllers.AnnouncementsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.happiercows.controllers.AnnouncementsControllerTests]/[method:adminCannotPostAnnouncementWithEmptyString()]
negated conditional → KILLED

98

1.1
Location : createAnnouncement
Killed by : edu.ucsb.cs156.happiercows.controllers.AnnouncementsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.happiercows.controllers.AnnouncementsControllerTests]/[method:adminCannotPostAnnouncementWithEmptyString()]
replaced return value with null for edu/ucsb/cs156/happiercows/controllers/AnnouncementsController::createAnnouncement → KILLED

100

1.1
Location : createAnnouncement
Killed by : edu.ucsb.cs156.happiercows.controllers.AnnouncementsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.happiercows.controllers.AnnouncementsControllerTests]/[method:userCanPostAnnouncementWithoutStartAndEndTime()]
negated conditional → KILLED

2.2
Location : createAnnouncement
Killed by : edu.ucsb.cs156.happiercows.controllers.AnnouncementsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.happiercows.controllers.AnnouncementsControllerTests]/[method:adminCanPostAnnouncements()]
negated conditional → KILLED

101

1.1
Location : createAnnouncement
Killed by : edu.ucsb.cs156.happiercows.controllers.AnnouncementsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.happiercows.controllers.AnnouncementsControllerTests]/[method:adminCannotPostAnnouncementWithEndBeforeStart()]
replaced return value with null for edu/ucsb/cs156/happiercows/controllers/AnnouncementsController::createAnnouncement → KILLED

115

1.1
Location : createAnnouncement
Killed by : edu.ucsb.cs156.happiercows.controllers.AnnouncementsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.happiercows.controllers.AnnouncementsControllerTests]/[method:adminCanPostAnnouncements()]
replaced return value with null for edu/ucsb/cs156/happiercows/controllers/AnnouncementsController::createAnnouncement → KILLED

125

1.1
Location : getAnnouncements
Killed by : edu.ucsb.cs156.happiercows.controllers.AnnouncementsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.happiercows.controllers.AnnouncementsControllerTests]/[method:adminCanGetAllAnnouncements()]
negated conditional → KILLED

2.2
Location : lambda$getAnnouncements$1
Killed by : edu.ucsb.cs156.happiercows.controllers.AnnouncementsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.happiercows.controllers.AnnouncementsControllerTests]/[method:adminCanGetAllAnnouncements()]
replaced boolean return with false for edu/ucsb/cs156/happiercows/controllers/AnnouncementsController::lambda$getAnnouncements$1 → KILLED

3.3
Location : lambda$getAnnouncements$1
Killed by : edu.ucsb.cs156.happiercows.controllers.AnnouncementsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.happiercows.controllers.AnnouncementsControllerTests]/[method:userCannotGetAllAnnouncementsIfNotInCommons()]
replaced boolean return with true for edu/ucsb/cs156/happiercows/controllers/AnnouncementsController::lambda$getAnnouncements$1 → KILLED

131

1.1
Location : getAnnouncements
Killed by : edu.ucsb.cs156.happiercows.controllers.AnnouncementsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.happiercows.controllers.AnnouncementsControllerTests]/[method:userCannotGetAllAnnouncementsIfNotInCommons()]
negated conditional → KILLED

132

1.1
Location : getAnnouncements
Killed by : edu.ucsb.cs156.happiercows.controllers.AnnouncementsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.happiercows.controllers.AnnouncementsControllerTests]/[method:userCannotGetAllAnnouncementsIfNotInCommons()]
replaced return value with null for edu/ucsb/cs156/happiercows/controllers/AnnouncementsController::getAnnouncements → KILLED

138

1.1
Location : getAnnouncements
Killed by : edu.ucsb.cs156.happiercows.controllers.AnnouncementsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.happiercows.controllers.AnnouncementsControllerTests]/[method:adminCanGetAllAnnouncements()]
replaced return value with null for edu/ucsb/cs156/happiercows/controllers/AnnouncementsController::getAnnouncements → KILLED

147

1.1
Location : getAnnouncementById
Killed by : edu.ucsb.cs156.happiercows.controllers.AnnouncementsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.happiercows.controllers.AnnouncementsControllerTests]/[method:userCanGetAnnouncementById()]
negated conditional → KILLED

148

1.1
Location : getAnnouncementById
Killed by : edu.ucsb.cs156.happiercows.controllers.AnnouncementsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.happiercows.controllers.AnnouncementsControllerTests]/[method:userCannotGetAnnouncementByIdThatDoesNotExist()]
replaced return value with null for edu/ucsb/cs156/happiercows/controllers/AnnouncementsController::getAnnouncementById → KILLED

151

1.1
Location : getAnnouncementById
Killed by : edu.ucsb.cs156.happiercows.controllers.AnnouncementsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.happiercows.controllers.AnnouncementsControllerTests]/[method:userCanGetAnnouncementById()]
replaced return value with null for edu/ucsb/cs156/happiercows/controllers/AnnouncementsController::getAnnouncementById → KILLED

169

1.1
Location : editAnnouncement
Killed by : edu.ucsb.cs156.happiercows.controllers.AnnouncementsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.happiercows.controllers.AnnouncementsControllerTests]/[method:userCannotEditAnnouncementIfNotInCommons()]
negated conditional → KILLED

2.2
Location : lambda$editAnnouncement$2
Killed by : edu.ucsb.cs156.happiercows.controllers.AnnouncementsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.happiercows.controllers.AnnouncementsControllerTests]/[method:adminCanEditAnnouncement()]
replaced boolean return with false for edu/ucsb/cs156/happiercows/controllers/AnnouncementsController::lambda$editAnnouncement$2 → KILLED

3.3
Location : lambda$editAnnouncement$2
Killed by : edu.ucsb.cs156.happiercows.controllers.AnnouncementsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.happiercows.controllers.AnnouncementsControllerTests]/[method:userCannotEditAnnouncementIfNotInCommons()]
replaced boolean return with true for edu/ucsb/cs156/happiercows/controllers/AnnouncementsController::lambda$editAnnouncement$2 → KILLED

173

1.1
Location : editAnnouncement
Killed by : edu.ucsb.cs156.happiercows.controllers.AnnouncementsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.happiercows.controllers.AnnouncementsControllerTests]/[method:userCannotEditAnnouncementThatDoesNotExist()]
negated conditional → KILLED

174

1.1
Location : editAnnouncement
Killed by : edu.ucsb.cs156.happiercows.controllers.AnnouncementsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.happiercows.controllers.AnnouncementsControllerTests]/[method:userCannotEditAnnouncementIfNotInCommons()]
replaced return value with null for edu/ucsb/cs156/happiercows/controllers/AnnouncementsController::editAnnouncement → KILLED

178

1.1
Location : editAnnouncement
Killed by : edu.ucsb.cs156.happiercows.controllers.AnnouncementsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.happiercows.controllers.AnnouncementsControllerTests]/[method:userCannotEditAnnouncementThatDoesNotExist()]
negated conditional → KILLED

179

1.1
Location : editAnnouncement
Killed by : edu.ucsb.cs156.happiercows.controllers.AnnouncementsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.happiercows.controllers.AnnouncementsControllerTests]/[method:userCannotEditAnnouncementToHaveEmptyStringAsAnnouncement()]
replaced return value with null for edu/ucsb/cs156/happiercows/controllers/AnnouncementsController::editAnnouncement → KILLED

182

1.1
Location : editAnnouncement
Killed by : edu.ucsb.cs156.happiercows.controllers.AnnouncementsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.happiercows.controllers.AnnouncementsControllerTests]/[method:adminCanEditAnnouncement()]
negated conditional → KILLED

187

1.1
Location : editAnnouncement
Killed by : edu.ucsb.cs156.happiercows.controllers.AnnouncementsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.happiercows.controllers.AnnouncementsControllerTests]/[method:userCannotEditAnnouncementThatDoesNotExist()]
negated conditional → KILLED

2.2
Location : editAnnouncement
Killed by : edu.ucsb.cs156.happiercows.controllers.AnnouncementsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.happiercows.controllers.AnnouncementsControllerTests]/[method:adminCanEditAnnouncement()]
negated conditional → KILLED

188

1.1
Location : editAnnouncement
Killed by : edu.ucsb.cs156.happiercows.controllers.AnnouncementsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.happiercows.controllers.AnnouncementsControllerTests]/[method:userCannotEditAnnouncementToHaveEndBeforeStart()]
replaced return value with null for edu/ucsb/cs156/happiercows/controllers/AnnouncementsController::editAnnouncement → KILLED

193

1.1
Location : editAnnouncement
Killed by : edu.ucsb.cs156.happiercows.controllers.AnnouncementsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.happiercows.controllers.AnnouncementsControllerTests]/[method:userCannotEditAnnouncementThatDoesNotExist()]
negated conditional → KILLED

194

1.1
Location : editAnnouncement
Killed by : edu.ucsb.cs156.happiercows.controllers.AnnouncementsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.happiercows.controllers.AnnouncementsControllerTests]/[method:userCannotEditAnnouncementThatDoesNotExist()]
replaced return value with null for edu/ucsb/cs156/happiercows/controllers/AnnouncementsController::editAnnouncement → KILLED

199

1.1
Location : editAnnouncement
Killed by : edu.ucsb.cs156.happiercows.controllers.AnnouncementsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.happiercows.controllers.AnnouncementsControllerTests]/[method:adminCanEditAnnouncement()]
removed call to edu/ucsb/cs156/happiercows/entities/Announcement::setStartDate → KILLED

200

1.1
Location : editAnnouncement
Killed by : edu.ucsb.cs156.happiercows.controllers.AnnouncementsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.happiercows.controllers.AnnouncementsControllerTests]/[method:adminCanEditAnnouncement()]
removed call to edu/ucsb/cs156/happiercows/entities/Announcement::setEndDate → KILLED

201

1.1
Location : editAnnouncement
Killed by : edu.ucsb.cs156.happiercows.controllers.AnnouncementsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.happiercows.controllers.AnnouncementsControllerTests]/[method:adminCanEditAnnouncement()]
removed call to edu/ucsb/cs156/happiercows/entities/Announcement::setAnnouncementText → KILLED

205

1.1
Location : editAnnouncement
Killed by : edu.ucsb.cs156.happiercows.controllers.AnnouncementsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.happiercows.controllers.AnnouncementsControllerTests]/[method:adminCanEditAnnouncement()]
replaced return value with null for edu/ucsb/cs156/happiercows/controllers/AnnouncementsController::editAnnouncement → KILLED

216

1.1
Location : deleteAnnouncement
Killed by : edu.ucsb.cs156.happiercows.controllers.AnnouncementsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.happiercows.controllers.AnnouncementsControllerTests]/[method:adminCannotDeleteAnnouncementsThatDontExist()]
negated conditional → KILLED

217

1.1
Location : deleteAnnouncement
Killed by : edu.ucsb.cs156.happiercows.controllers.AnnouncementsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.happiercows.controllers.AnnouncementsControllerTests]/[method:adminCannotDeleteAnnouncementsThatDontExist()]
replaced return value with null for edu/ucsb/cs156/happiercows/controllers/AnnouncementsController::deleteAnnouncement → KILLED

225

1.1
Location : deleteAnnouncement
Killed by : edu.ucsb.cs156.happiercows.controllers.AnnouncementsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.happiercows.controllers.AnnouncementsControllerTests]/[method:adminCanDeleteAnnouncements()]
removed call to edu/ucsb/cs156/happiercows/repositories/AnnouncementRepository::delete → KILLED

226

1.1
Location : deleteAnnouncement
Killed by : edu.ucsb.cs156.happiercows.controllers.AnnouncementsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.happiercows.controllers.AnnouncementsControllerTests]/[method:adminCanDeleteAnnouncements()]
replaced return value with null for edu/ucsb/cs156/happiercows/controllers/AnnouncementsController::deleteAnnouncement → KILLED

Active mutators

Tests examined


Report generated by PIT 1.7.3