ReviewController.java

1
package edu.ucsb.cs156.dining.controllers;
2
3
import com.fasterxml.jackson.core.JsonProcessingException;
4
import edu.ucsb.cs156.dining.entities.MenuItem;
5
import edu.ucsb.cs156.dining.entities.Review;
6
import edu.ucsb.cs156.dining.entities.User;
7
import edu.ucsb.cs156.dining.errors.EntityNotFoundException;
8
import edu.ucsb.cs156.dining.models.CurrentUser;
9
import edu.ucsb.cs156.dining.models.EditedReview;
10
import edu.ucsb.cs156.dining.repositories.MenuItemRepository;
11
import edu.ucsb.cs156.dining.repositories.ReviewRepository;
12
import edu.ucsb.cs156.dining.services.ModeratorNotificationService;
13
import edu.ucsb.cs156.dining.statuses.ModerationStatus;
14
import io.swagger.v3.oas.annotations.Operation;
15
import io.swagger.v3.oas.annotations.Parameter;
16
import io.swagger.v3.oas.annotations.tags.Tag;
17
import jakarta.validation.Valid;
18
import java.time.LocalDateTime;
19
import java.util.HashMap;
20
import java.util.Map;
21
import lombok.extern.slf4j.Slf4j;
22
import org.springframework.beans.factory.annotation.Autowired;
23
import org.springframework.format.annotation.DateTimeFormat;
24
import org.springframework.http.ResponseEntity;
25
import org.springframework.security.access.AccessDeniedException;
26
import org.springframework.security.access.hierarchicalroles.RoleHierarchy;
27
import org.springframework.security.access.prepost.PreAuthorize;
28
import org.springframework.security.core.GrantedAuthority;
29
import org.springframework.web.bind.annotation.DeleteMapping;
30
import org.springframework.web.bind.annotation.ExceptionHandler;
31
import org.springframework.web.bind.annotation.GetMapping;
32
import org.springframework.web.bind.annotation.PathVariable;
33
import org.springframework.web.bind.annotation.PostMapping;
34
import org.springframework.web.bind.annotation.PutMapping;
35
import org.springframework.web.bind.annotation.RequestBody;
36
import org.springframework.web.bind.annotation.RequestMapping;
37
import org.springframework.web.bind.annotation.RequestParam;
38
import org.springframework.web.bind.annotation.RestController;
39
40
/** This is a REST controller for Reviews */
41
@Tag(name = "Review")
42
@RequestMapping("/api/reviews")
43
@RestController
44
@Slf4j
45
public class ReviewController extends ApiController {
46
47
  private boolean hasReviewerComments(String reviewerComments) {
48 3 1. hasReviewerComments : replaced boolean return with true for edu/ucsb/cs156/dining/controllers/ReviewController::hasReviewerComments → KILLED
2. hasReviewerComments : negated conditional → KILLED
3. hasReviewerComments : negated conditional → KILLED
    return reviewerComments != null && !reviewerComments.trim().isEmpty();
49
  }
50
51
  @ExceptionHandler(IllegalArgumentException.class)
52
  public ResponseEntity<Map<String, String>> handleValidationExceptions(
53
      IllegalArgumentException ex) {
54
    Map<String, String> errors = new HashMap<>();
55
    errors.put("error", ex.getMessage());
56 1 1. handleValidationExceptions : replaced return value with null for edu/ucsb/cs156/dining/controllers/ReviewController::handleValidationExceptions → KILLED
    return ResponseEntity.badRequest().body(errors);
57
  }
58
59
  @Autowired ReviewRepository reviewRepository;
60
61
  @Autowired MenuItemRepository menuItemRepository;
62
63
  @Autowired ModeratorNotificationService moderatorNotificationService;
64
65
  @Autowired RoleHierarchy roleHierarchy;
66
67
  private boolean currentUserHasRole(String role) {
68 2 1. currentUserHasRole : replaced boolean return with true for edu/ucsb/cs156/dining/controllers/ReviewController::currentUserHasRole → KILLED
2. currentUserHasRole : replaced boolean return with false for edu/ucsb/cs156/dining/controllers/ReviewController::currentUserHasRole → KILLED
    return roleHierarchy.getReachableGrantedAuthorities(getCurrentUser().getRoles()).stream()
69
        .map(GrantedAuthority::getAuthority)
70
        .anyMatch(role::equals);
71
  }
72
73
  /**
74
   * This method returns a list of all Reviews.
75
   *
76
   * @return a list of all Reviews
77
   */
78
  @Operation(summary = "List all Reviews")
79
  @PreAuthorize("hasRole('ROLE_ADMIN')")
80
  @GetMapping("/all")
81
  public Iterable<Review> allReviews() {
82
    log.info("Attempting to log all reviews");
83
    Iterable<Review> reviews = reviewRepository.findAll();
84
    log.info("all reviews found, ", reviews);
85 1 1. allReviews : replaced return value with Collections.emptyList for edu/ucsb/cs156/dining/controllers/ReviewController::allReviews → KILLED
    return reviews;
86
  }
87
88
  /**
89
   * This method returns a list of all Reviews.
90
   *
91
   * @return a list of all Reviews
92
   */
93
  @Operation(summary = "List all approved reviews for a specific item")
94
  @GetMapping("/approved/forItem/{itemId}")
95
  public Iterable<Review> allApprovedReviewsForItem(
96
      @Parameter(name = "itemId") @PathVariable("itemId") long itemId) {
97
    log.info("Attempting to log all approved reviews for item with id: {}", itemId);
98
    MenuItem item =
99
        menuItemRepository
100
            .findById(itemId)
101 1 1. lambda$allApprovedReviewsForItem$0 : replaced return value with null for edu/ucsb/cs156/dining/controllers/ReviewController::lambda$allApprovedReviewsForItem$0 → KILLED
            .orElseThrow(() -> new EntityNotFoundException(MenuItem.class, itemId));
102
    Iterable<Review> reviews =
103
        reviewRepository.findByItemAndStatus(item, ModerationStatus.APPROVED);
104
    log.info("all approved reviews for item found, ", reviews);
105 1 1. allApprovedReviewsForItem : replaced return value with Collections.emptyList for edu/ucsb/cs156/dining/controllers/ReviewController::allApprovedReviewsForItem → KILLED
    return reviews;
106
  }
107
108
  /**
109
   * This method allows a user to submit a review
110
   *
111
   * @return message that says an review was added to the database
112
   * @param itemId id of the item
113
   * @param dateItemServed localDataTime All others params must not be parameters and instead
114
   *     derived from data sources that are dynamic (Date), or set to be null or some other
115
   *     signifier
116
   */
117
  @Operation(summary = "Create a new review")
118
  @PreAuthorize("hasRole('ROLE_USER')")
119
  @PostMapping("/post")
120
  public Review postReview(
121
      @Parameter(name = "itemId") @RequestParam long itemId,
122
      @Parameter(description = "Comments by the reviewer, can be blank")
123
          @RequestParam(required = false)
124
          String reviewerComments,
125
      @Parameter(name = "itemsStars") @RequestParam Long itemsStars,
126
      @Parameter(
127
              name = "dateItemServed",
128
              description =
129
                  "date (in iso format, e.g. YYYY-mm-ddTHH:MM:SS; see https://en.wikipedia.org/wiki/ISO_8601)")
130
          @RequestParam("dateItemServed")
131
          @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME)
132
          LocalDateTime dateItemServed) // For
133
      throws JsonProcessingException {
134
    LocalDateTime now = LocalDateTime.now();
135
    Review review = new Review();
136 1 1. postReview : removed call to edu/ucsb/cs156/dining/entities/Review::setDateItemServed → KILLED
    review.setDateItemServed(dateItemServed);
137
138 1 1. postReview : negated conditional → KILLED
    if (hasReviewerComments(reviewerComments)) {
139 1 1. postReview : removed call to edu/ucsb/cs156/dining/entities/Review::setReviewerComments → KILLED
      review.setReviewerComments(reviewerComments);
140
    } else {
141 1 1. postReview : removed call to edu/ucsb/cs156/dining/entities/Review::setStatus → KILLED
      review.setStatus(ModerationStatus.APPROVED);
142
    }
143
144
    // Ensure user inputs rating 1-5
145 4 1. postReview : negated conditional → KILLED
2. postReview : changed conditional boundary → KILLED
3. postReview : negated conditional → KILLED
4. postReview : changed conditional boundary → KILLED
    if (itemsStars < 1 || itemsStars > 5) {
146
      throw new IllegalArgumentException("Items stars must be between 1 and 5.");
147
    }
148
149 1 1. postReview : removed call to edu/ucsb/cs156/dining/entities/Review::setItemsStars → KILLED
    review.setItemsStars(itemsStars);
150
151
    MenuItem reviewedItem =
152
        menuItemRepository
153
            .findById(itemId)
154 1 1. lambda$postReview$0 : replaced return value with null for edu/ucsb/cs156/dining/controllers/ReviewController::lambda$postReview$0 → KILLED
            .orElseThrow(() -> new EntityNotFoundException(MenuItem.class, itemId));
155
156 1 1. postReview : removed call to edu/ucsb/cs156/dining/entities/Review::setItem → KILLED
    review.setItem(reviewedItem);
157
    CurrentUser user = getCurrentUser();
158 1 1. postReview : removed call to edu/ucsb/cs156/dining/entities/Review::setReviewer → KILLED
    review.setReviewer(user.getUser());
159
    log.info("reviews={}", review);
160
    // Decide before saving: a review with comments starts out AWAITING_REVIEW.
161 1 1. postReview : negated conditional → KILLED
    boolean needsModeration = review.getStatus() == ModerationStatus.AWAITING_REVIEW;
162
    review = reviewRepository.save(review);
163
    // Only after the review is saved, so email problems can never stop it from being saved.
164
    // notifyModerators never throws.
165 1 1. postReview : negated conditional → KILLED
    if (needsModeration) {
166 1 1. postReview : removed call to edu/ucsb/cs156/dining/services/ModeratorNotificationService::notifyModerators → KILLED
      moderatorNotificationService.notifyModerators(review);
167
    }
168 1 1. postReview : replaced return value with null for edu/ucsb/cs156/dining/controllers/ReviewController::postReview → KILLED
    return review;
169
  }
170
171
  /**
172
   * This method allows a user to get a list of reviews that they have previously made. Only user
173
   * can only get a list of their own reviews, and you cant request another persons reviews
174
   *
175
   * @return a list of reviews sent by a given user
176
   */
177
  @Operation(summary = "Get all reviews a user has sent: only callable by the user")
178
  @PreAuthorize("hasRole('ROLE_USER')")
179
  @GetMapping("/userReviews")
180
  public Iterable<Review> get_all_review_by_user_id() {
181
    CurrentUser user = getCurrentUser();
182
    Iterable<Review> reviews = reviewRepository.findByReviewer(user.getUser());
183 1 1. get_all_review_by_user_id : replaced return value with Collections.emptyList for edu/ucsb/cs156/dining/controllers/ReviewController::get_all_review_by_user_id → KILLED
    return reviews;
184
  }
185
186
  @Operation(summary = "Edit a review")
187
  @PreAuthorize("hasRole('ROLE_USER')")
188
  @PutMapping("/reviewer")
189
  public Review editReview(@Parameter Long id, @RequestBody @Valid EditedReview incoming) {
190
191
    Review oldReview =
192
        reviewRepository
193
            .findById(id)
194 1 1. lambda$editReview$0 : replaced return value with null for edu/ucsb/cs156/dining/controllers/ReviewController::lambda$editReview$0 → KILLED
            .orElseThrow(() -> new EntityNotFoundException(Review.class, id));
195
    User current = getCurrentUser().getUser();
196 1 1. editReview : negated conditional → KILLED
    if (current.getId() != oldReview.getReviewer().getId()) {
197
      throw new AccessDeniedException("No permission to edit review");
198
    }
199
200 4 1. editReview : negated conditional → KILLED
2. editReview : changed conditional boundary → KILLED
3. editReview : negated conditional → KILLED
4. editReview : changed conditional boundary → KILLED
    if (incoming.getItemStars() < 1 || incoming.getItemStars() > 5) {
201
      throw new IllegalArgumentException("Items stars must be between 1 and 5.");
202
    } else {
203 1 1. editReview : removed call to edu/ucsb/cs156/dining/entities/Review::setItemsStars → KILLED
      oldReview.setItemsStars(incoming.getItemStars());
204
    }
205
206 1 1. editReview : negated conditional → KILLED
    if (hasReviewerComments(incoming.getReviewerComments())) {
207 1 1. editReview : removed call to edu/ucsb/cs156/dining/entities/Review::setReviewerComments → KILLED
      oldReview.setReviewerComments(incoming.getReviewerComments());
208 1 1. editReview : removed call to edu/ucsb/cs156/dining/entities/Review::setStatus → KILLED
      oldReview.setStatus(ModerationStatus.AWAITING_REVIEW);
209
    } else {
210 1 1. editReview : removed call to edu/ucsb/cs156/dining/entities/Review::setReviewerComments → KILLED
      oldReview.setReviewerComments(null);
211 1 1. editReview : removed call to edu/ucsb/cs156/dining/entities/Review::setStatus → KILLED
      oldReview.setStatus(ModerationStatus.APPROVED);
212
    }
213
214 1 1. editReview : removed call to edu/ucsb/cs156/dining/entities/Review::setDateItemServed → KILLED
    oldReview.setDateItemServed(incoming.getDateItemServed());
215
216 1 1. editReview : removed call to edu/ucsb/cs156/dining/entities/Review::setModeratorComments → KILLED
    oldReview.setModeratorComments(null);
217
218
    Review review = reviewRepository.save(oldReview);
219
220 1 1. editReview : replaced return value with null for edu/ucsb/cs156/dining/controllers/ReviewController::editReview → KILLED
    return review;
221
  }
222
223
  @Operation(summary = "Delete a review")
224
  @PreAuthorize("hasRole('ROLE_USER')")
225
  @DeleteMapping("/reviewer")
226
  public Object deleteReview(@Parameter Long id) {
227
    Review review =
228
        reviewRepository
229
            .findById(id)
230 1 1. lambda$deleteReview$0 : replaced return value with null for edu/ucsb/cs156/dining/controllers/ReviewController::lambda$deleteReview$0 → KILLED
            .orElseThrow(() -> new EntityNotFoundException(Review.class, id));
231
232
    User current = getCurrentUser().getUser();
233 2 1. deleteReview : negated conditional → KILLED
2. deleteReview : negated conditional → KILLED
    if (current.getId() != review.getReviewer().getId() && !currentUserHasRole("ROLE_ADMIN")) {
234
      throw new AccessDeniedException("No permission to delete review");
235
    }
236
237 1 1. deleteReview : removed call to edu/ucsb/cs156/dining/repositories/ReviewRepository::delete → KILLED
    reviewRepository.delete(review);
238 1 1. deleteReview : replaced return value with null for edu/ucsb/cs156/dining/controllers/ReviewController::deleteReview → KILLED
    return genericMessage("Review with id %s deleted".formatted(id));
239
  }
240
241
  @Operation(summary = "Moderate a review")
242
  @PreAuthorize("hasRole('ROLE_MODERATOR')")
243
  @PutMapping("/moderate")
244
  public Review moderateReview(
245
      @Parameter Long id, @Parameter ModerationStatus status, @Parameter String moderatorComments) {
246
    Review review =
247
        reviewRepository
248
            .findById(id)
249 1 1. lambda$moderateReview$0 : replaced return value with null for edu/ucsb/cs156/dining/controllers/ReviewController::lambda$moderateReview$0 → KILLED
            .orElseThrow(() -> new EntityNotFoundException(Review.class, id));
250
251 1 1. moderateReview : removed call to edu/ucsb/cs156/dining/entities/Review::setModeratorComments → KILLED
    review.setModeratorComments(moderatorComments);
252 1 1. moderateReview : removed call to edu/ucsb/cs156/dining/entities/Review::setStatus → KILLED
    review.setStatus(status);
253
254
    review = reviewRepository.save(review);
255 1 1. moderateReview : replaced return value with null for edu/ucsb/cs156/dining/controllers/ReviewController::moderateReview → KILLED
    return review;
256
  }
257
258
  @Operation(summary = "See reviews that need moderation")
259
  @PreAuthorize("hasRole('ROLE_MODERATOR')")
260
  @GetMapping("/needsmoderation")
261
  public Iterable<Review> needsmoderation() {
262
    Iterable<Review> reviewsList = reviewRepository.findByStatus(ModerationStatus.AWAITING_REVIEW);
263 1 1. needsmoderation : replaced return value with Collections.emptyList for edu/ucsb/cs156/dining/controllers/ReviewController::needsmoderation → KILLED
    return reviewsList;
264
  }
265
266
  @PreAuthorize("hasRole('ROLE_USER')")
267
  @GetMapping("/{id}")
268
  public Review getReviewById(@PathVariable Long id) {
269
270
    // 1. Look up the review or 404
271
    Review review =
272
        reviewRepository
273
            .findById(id)
274 1 1. lambda$getReviewById$0 : replaced return value with null for edu/ucsb/cs156/dining/controllers/ReviewController::lambda$getReviewById$0 → KILLED
            .orElseThrow(() -> new EntityNotFoundException(Review.class, id));
275
276
    // 2. Get current requester
277
    User requester = getCurrentUser().getUser();
278
279
    // 3. Evaluate permissions
280 1 1. getReviewById : negated conditional → KILLED
    boolean isOwner = (review.getReviewer().getId() == requester.getId());
281
282
    // 4. Enforce access rules (admins are moderators via the role hierarchy)
283 2 1. getReviewById : negated conditional → KILLED
2. getReviewById : negated conditional → KILLED
    if (!(isOwner || currentUserHasRole("ROLE_MODERATOR"))) {
284
      throw new AccessDeniedException("No permission to view this review");
285
    }
286
287
    // 5. Return the review
288 1 1. getReviewById : replaced return value with null for edu/ucsb/cs156/dining/controllers/ReviewController::getReviewById → KILLED
    return review;
289
  }
290
}

Mutations

48

1.1
Location : hasReviewerComments
Killed by : edu.ucsb.cs156.dining.controllers.ReviewControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.dining.controllers.ReviewControllerTests]/[method:trim_works_correctly()]
replaced boolean return with true for edu/ucsb/cs156/dining/controllers/ReviewController::hasReviewerComments → KILLED

2.2
Location : hasReviewerComments
Killed by : edu.ucsb.cs156.dining.controllers.ReviewControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.dining.controllers.ReviewControllerTests]/[method:edit_works_correctly()]
negated conditional → KILLED

3.3
Location : hasReviewerComments
Killed by : edu.ucsb.cs156.dining.controllers.ReviewControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.dining.controllers.ReviewControllerTests]/[method:edit_works_correctly()]
negated conditional → KILLED

56

1.1
Location : handleValidationExceptions
Killed by : edu.ucsb.cs156.dining.controllers.ReviewControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.dining.controllers.ReviewControllerTests]/[method:test_rating_below_1_throws_exception()]
replaced return value with null for edu/ucsb/cs156/dining/controllers/ReviewController::handleValidationExceptions → KILLED

68

1.1
Location : currentUserHasRole
Killed by : edu.ucsb.cs156.dining.controllers.ReviewControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.dining.controllers.ReviewControllerTests]/[method:wrong_user_cannot_delete()]
replaced boolean return with true for edu/ucsb/cs156/dining/controllers/ReviewController::currentUserHasRole → KILLED

2.2
Location : currentUserHasRole
Killed by : edu.ucsb.cs156.dining.controllers.ReviewControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.dining.controllers.ReviewControllerTests]/[method:admin_without_other_roles_can_delete_another_users_review()]
replaced boolean return with false for edu/ucsb/cs156/dining/controllers/ReviewController::currentUserHasRole → KILLED

85

1.1
Location : allReviews
Killed by : edu.ucsb.cs156.dining.controllers.ReviewControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.dining.controllers.ReviewControllerTests]/[method:a_logged_in_admin_can_get_all()]
replaced return value with Collections.emptyList for edu/ucsb/cs156/dining/controllers/ReviewController::allReviews → KILLED

101

1.1
Location : lambda$allApprovedReviewsForItem$0
Killed by : edu.ucsb.cs156.dining.controllers.ReviewControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.dining.controllers.ReviewControllerTests]/[method:allApprovedReviewsForItem_returns_not_found_for_nonexistent_item()]
replaced return value with null for edu/ucsb/cs156/dining/controllers/ReviewController::lambda$allApprovedReviewsForItem$0 → KILLED

105

1.1
Location : allApprovedReviewsForItem
Killed by : edu.ucsb.cs156.dining.controllers.ReviewControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.dining.controllers.ReviewControllerTests]/[method:allApprovedReviewsForItem_returns_approved_reviews_for_existing_item()]
replaced return value with Collections.emptyList for edu/ucsb/cs156/dining/controllers/ReviewController::allApprovedReviewsForItem → KILLED

136

1.1
Location : postReview
Killed by : edu.ucsb.cs156.dining.controllers.ReviewControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.dining.controllers.ReviewControllerTests]/[method:test_no_string_on_creating_new_review()]
removed call to edu/ucsb/cs156/dining/entities/Review::setDateItemServed → KILLED

138

1.1
Location : postReview
Killed by : edu.ucsb.cs156.dining.controllers.ReviewControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.dining.controllers.ReviewControllerTests]/[method:test_no_string_on_creating_new_review()]
negated conditional → KILLED

139

1.1
Location : postReview
Killed by : edu.ucsb.cs156.dining.controllers.ReviewControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.dining.controllers.ReviewControllerTests]/[method:a_user_can_post_a_new_review()]
removed call to edu/ucsb/cs156/dining/entities/Review::setReviewerComments → KILLED

141

1.1
Location : postReview
Killed by : edu.ucsb.cs156.dining.controllers.ReviewControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.dining.controllers.ReviewControllerTests]/[method:test_no_string_on_creating_new_review()]
removed call to edu/ucsb/cs156/dining/entities/Review::setStatus → KILLED

145

1.1
Location : postReview
Killed by : edu.ucsb.cs156.dining.controllers.ReviewControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.dining.controllers.ReviewControllerTests]/[method:test_rating_above_5_throws_exception()]
negated conditional → KILLED

2.2
Location : postReview
Killed by : edu.ucsb.cs156.dining.controllers.ReviewControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.dining.controllers.ReviewControllerTests]/[method:testItemIdIsInvalid_NotFound()]
changed conditional boundary → KILLED

3.3
Location : postReview
Killed by : edu.ucsb.cs156.dining.controllers.ReviewControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.dining.controllers.ReviewControllerTests]/[method:test_rating_below_1_throws_exception()]
negated conditional → KILLED

4.4
Location : postReview
Killed by : edu.ucsb.cs156.dining.controllers.ReviewControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.dining.controllers.ReviewControllerTests]/[method:postReview_ShouldAcceptRatingAtBoundaries()]
changed conditional boundary → KILLED

149

1.1
Location : postReview
Killed by : edu.ucsb.cs156.dining.controllers.ReviewControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.dining.controllers.ReviewControllerTests]/[method:test_no_string_on_creating_new_review()]
removed call to edu/ucsb/cs156/dining/entities/Review::setItemsStars → KILLED

154

1.1
Location : lambda$postReview$0
Killed by : edu.ucsb.cs156.dining.controllers.ReviewControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.dining.controllers.ReviewControllerTests]/[method:testItemIdIsInvalid_NotFound()]
replaced return value with null for edu/ucsb/cs156/dining/controllers/ReviewController::lambda$postReview$0 → KILLED

156

1.1
Location : postReview
Killed by : edu.ucsb.cs156.dining.controllers.ReviewControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.dining.controllers.ReviewControllerTests]/[method:test_no_string_on_creating_new_review()]
removed call to edu/ucsb/cs156/dining/entities/Review::setItem → KILLED

158

1.1
Location : postReview
Killed by : edu.ucsb.cs156.dining.controllers.ReviewControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.dining.controllers.ReviewControllerTests]/[method:test_no_string_on_creating_new_review()]
removed call to edu/ucsb/cs156/dining/entities/Review::setReviewer → KILLED

161

1.1
Location : postReview
Killed by : edu.ucsb.cs156.dining.controllers.ReviewControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.dining.controllers.ReviewControllerTests]/[method:test_no_string_on_creating_new_review()]
negated conditional → KILLED

165

1.1
Location : postReview
Killed by : edu.ucsb.cs156.dining.controllers.ReviewControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.dining.controllers.ReviewControllerTests]/[method:test_no_string_on_creating_new_review()]
negated conditional → KILLED

166

1.1
Location : postReview
Killed by : edu.ucsb.cs156.dining.controllers.ReviewControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.dining.controllers.ReviewControllerTests]/[method:a_user_can_post_a_new_review()]
removed call to edu/ucsb/cs156/dining/services/ModeratorNotificationService::notifyModerators → KILLED

168

1.1
Location : postReview
Killed by : edu.ucsb.cs156.dining.controllers.ReviewControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.dining.controllers.ReviewControllerTests]/[method:test_no_string_on_creating_new_review()]
replaced return value with null for edu/ucsb/cs156/dining/controllers/ReviewController::postReview → KILLED

183

1.1
Location : get_all_review_by_user_id
Killed by : edu.ucsb.cs156.dining.controllers.ReviewControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.dining.controllers.ReviewControllerTests]/[method:user_reviews_response_includes_item_field()]
replaced return value with Collections.emptyList for edu/ucsb/cs156/dining/controllers/ReviewController::get_all_review_by_user_id → KILLED

194

1.1
Location : lambda$editReview$0
Killed by : edu.ucsb.cs156.dining.controllers.ReviewControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.dining.controllers.ReviewControllerTests]/[method:not_found_throws_exception()]
replaced return value with null for edu/ucsb/cs156/dining/controllers/ReviewController::lambda$editReview$0 → KILLED

196

1.1
Location : editReview
Killed by : edu.ucsb.cs156.dining.controllers.ReviewControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.dining.controllers.ReviewControllerTests]/[method:can_set_stars_at_low_boundary()]
negated conditional → KILLED

200

1.1
Location : editReview
Killed by : edu.ucsb.cs156.dining.controllers.ReviewControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.dining.controllers.ReviewControllerTests]/[method:can_set_stars_at_low_boundary()]
negated conditional → KILLED

2.2
Location : editReview
Killed by : edu.ucsb.cs156.dining.controllers.ReviewControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.dining.controllers.ReviewControllerTests]/[method:can_set_stars_at_low_boundary()]
changed conditional boundary → KILLED

3.3
Location : editReview
Killed by : edu.ucsb.cs156.dining.controllers.ReviewControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.dining.controllers.ReviewControllerTests]/[method:can_set_stars_at_low_boundary()]
negated conditional → KILLED

4.4
Location : editReview
Killed by : edu.ucsb.cs156.dining.controllers.ReviewControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.dining.controllers.ReviewControllerTests]/[method:can_set_stars_at_high_boundary()]
changed conditional boundary → KILLED

203

1.1
Location : editReview
Killed by : edu.ucsb.cs156.dining.controllers.ReviewControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.dining.controllers.ReviewControllerTests]/[method:edit_works_correctly()]
removed call to edu/ucsb/cs156/dining/entities/Review::setItemsStars → KILLED

206

1.1
Location : editReview
Killed by : edu.ucsb.cs156.dining.controllers.ReviewControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.dining.controllers.ReviewControllerTests]/[method:edit_works_correctly()]
negated conditional → KILLED

207

1.1
Location : editReview
Killed by : edu.ucsb.cs156.dining.controllers.ReviewControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.dining.controllers.ReviewControllerTests]/[method:edit_works_correctly()]
removed call to edu/ucsb/cs156/dining/entities/Review::setReviewerComments → KILLED

208

1.1
Location : editReview
Killed by : edu.ucsb.cs156.dining.controllers.ReviewControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.dining.controllers.ReviewControllerTests]/[method:edit_works_correctly()]
removed call to edu/ucsb/cs156/dining/entities/Review::setStatus → KILLED

210

1.1
Location : editReview
Killed by : edu.ucsb.cs156.dining.controllers.ReviewControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.dining.controllers.ReviewControllerTests]/[method:null_works_correctly()]
removed call to edu/ucsb/cs156/dining/entities/Review::setReviewerComments → KILLED

211

1.1
Location : editReview
Killed by : edu.ucsb.cs156.dining.controllers.ReviewControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.dining.controllers.ReviewControllerTests]/[method:trim_works_correctly()]
removed call to edu/ucsb/cs156/dining/entities/Review::setStatus → KILLED

214

1.1
Location : editReview
Killed by : edu.ucsb.cs156.dining.controllers.ReviewControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.dining.controllers.ReviewControllerTests]/[method:edit_works_correctly()]
removed call to edu/ucsb/cs156/dining/entities/Review::setDateItemServed → KILLED

216

1.1
Location : editReview
Killed by : edu.ucsb.cs156.dining.controllers.ReviewControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.dining.controllers.ReviewControllerTests]/[method:edit_works_correctly()]
removed call to edu/ucsb/cs156/dining/entities/Review::setModeratorComments → KILLED

220

1.1
Location : editReview
Killed by : edu.ucsb.cs156.dining.controllers.ReviewControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.dining.controllers.ReviewControllerTests]/[method:edit_works_correctly()]
replaced return value with null for edu/ucsb/cs156/dining/controllers/ReviewController::editReview → KILLED

230

1.1
Location : lambda$deleteReview$0
Killed by : edu.ucsb.cs156.dining.controllers.ReviewControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.dining.controllers.ReviewControllerTests]/[method:nonexistent_cannot_delete()]
replaced return value with null for edu/ucsb/cs156/dining/controllers/ReviewController::lambda$deleteReview$0 → KILLED

233

1.1
Location : deleteReview
Killed by : edu.ucsb.cs156.dining.controllers.ReviewControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.dining.controllers.ReviewControllerTests]/[method:user_can_delete()]
negated conditional → KILLED

2.2
Location : deleteReview
Killed by : edu.ucsb.cs156.dining.controllers.ReviewControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.dining.controllers.ReviewControllerTests]/[method:wrong_user_cannot_delete()]
negated conditional → KILLED

237

1.1
Location : deleteReview
Killed by : edu.ucsb.cs156.dining.controllers.ReviewControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.dining.controllers.ReviewControllerTests]/[method:user_can_delete()]
removed call to edu/ucsb/cs156/dining/repositories/ReviewRepository::delete → KILLED

238

1.1
Location : deleteReview
Killed by : edu.ucsb.cs156.dining.controllers.ReviewControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.dining.controllers.ReviewControllerTests]/[method:user_can_delete()]
replaced return value with null for edu/ucsb/cs156/dining/controllers/ReviewController::deleteReview → KILLED

249

1.1
Location : lambda$moderateReview$0
Killed by : edu.ucsb.cs156.dining.controllers.ReviewControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.dining.controllers.ReviewControllerTests]/[method:admin_nonexistent_cannot_approve()]
replaced return value with null for edu/ucsb/cs156/dining/controllers/ReviewController::lambda$moderateReview$0 → KILLED

251

1.1
Location : moderateReview
Killed by : edu.ucsb.cs156.dining.controllers.ReviewControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.dining.controllers.ReviewControllerTests]/[method:admin_can_moderate_a_review()]
removed call to edu/ucsb/cs156/dining/entities/Review::setModeratorComments → KILLED

252

1.1
Location : moderateReview
Killed by : edu.ucsb.cs156.dining.controllers.ReviewControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.dining.controllers.ReviewControllerTests]/[method:admin_can_moderate_a_review()]
removed call to edu/ucsb/cs156/dining/entities/Review::setStatus → KILLED

255

1.1
Location : moderateReview
Killed by : edu.ucsb.cs156.dining.controllers.ReviewControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.dining.controllers.ReviewControllerTests]/[method:admin_can_moderate_a_review()]
replaced return value with null for edu/ucsb/cs156/dining/controllers/ReviewController::moderateReview → KILLED

263

1.1
Location : needsmoderation
Killed by : edu.ucsb.cs156.dining.controllers.ReviewControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.dining.controllers.ReviewControllerTests]/[method:moderator_get_needs_moderation_returns_moderation_needed()]
replaced return value with Collections.emptyList for edu/ucsb/cs156/dining/controllers/ReviewController::needsmoderation → KILLED

274

1.1
Location : lambda$getReviewById$0
Killed by : edu.ucsb.cs156.dining.controllers.ReviewControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.dining.controllers.ReviewControllerTests]/[method:getReviewById_not_found_returns_404()]
replaced return value with null for edu/ucsb/cs156/dining/controllers/ReviewController::lambda$getReviewById$0 → KILLED

280

1.1
Location : getReviewById
Killed by : edu.ucsb.cs156.dining.controllers.ReviewControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.dining.controllers.ReviewControllerTests]/[method:getReviewById_owner_can_view()]
negated conditional → KILLED

283

1.1
Location : getReviewById
Killed by : edu.ucsb.cs156.dining.controllers.ReviewControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.dining.controllers.ReviewControllerTests]/[method:getReviewById_owner_can_view()]
negated conditional → KILLED

2.2
Location : getReviewById
Killed by : edu.ucsb.cs156.dining.controllers.ReviewControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.dining.controllers.ReviewControllerTests]/[method:getReviewById_non_owner_user_forbidden()]
negated conditional → KILLED

288

1.1
Location : getReviewById
Killed by : edu.ucsb.cs156.dining.controllers.ReviewControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.dining.controllers.ReviewControllerTests]/[method:getReviewById_owner_can_view()]
replaced return value with null for edu/ucsb/cs156/dining/controllers/ReviewController::getReviewById → KILLED

Active mutators

Tests examined


Report generated by PIT 1.22.1