AnnouncementsController.java

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

Mutations

70

1.1
Location : createAnnouncement
Killed by : edu.ucsb.cs156.happiercows.controllers.AnnouncementsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.happiercows.controllers.AnnouncementsControllerTests]/[method:userNotInCommonsCannotPostAnnouncements()]
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:adminCanPostAnnouncements()]
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

74

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

75

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

79

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

84

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

85

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

87

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:userCannotPostAnnouncementWithEndBeforeStart()]
negated conditional → 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:userCannotPostAnnouncementWithEndBeforeStart()]
replaced return value with null for edu/ucsb/cs156/happiercows/controllers/AnnouncementsController::createAnnouncement → KILLED

102

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

112

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

118

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

119

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

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()]
replaced return value with null for edu/ucsb/cs156/happiercows/controllers/AnnouncementsController::getAnnouncements → KILLED

134

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

135

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

138

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

156

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

160

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

161

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

165

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

166

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

169

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

174

1.1
Location : editAnnouncement
Killed by : edu.ucsb.cs156.happiercows.controllers.AnnouncementsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.happiercows.controllers.AnnouncementsControllerTests]/[method:userCanEditAnnouncementWithoutStart()]
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:userCannotEditAnnouncementToHaveEndBeforeStart()]
negated conditional → KILLED

175

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

180

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

181

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

186

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

187

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

188

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

192

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

203

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

204

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

212

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

213

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