StatisticsController.java

1
package edu.ucsb.cs156.dining.controllers;
2
3
import edu.ucsb.cs156.dining.entities.MenuItem;
4
import edu.ucsb.cs156.dining.entities.Review;
5
import edu.ucsb.cs156.dining.models.CommonsAverage;
6
import edu.ucsb.cs156.dining.models.CommonsAverageOverTime;
7
import edu.ucsb.cs156.dining.models.ItemStatistic;
8
import edu.ucsb.cs156.dining.models.MealAverage;
9
import edu.ucsb.cs156.dining.repositories.ReviewRepository;
10
import edu.ucsb.cs156.dining.statuses.ModerationStatus;
11
import io.swagger.v3.oas.annotations.Operation;
12
import io.swagger.v3.oas.annotations.Parameter;
13
import io.swagger.v3.oas.annotations.tags.Tag;
14
import java.time.LocalDateTime;
15
import java.time.format.DateTimeFormatter;
16
import java.util.ArrayList;
17
import java.util.Comparator;
18
import java.util.HashMap;
19
import java.util.List;
20
import java.util.Map;
21
import java.util.stream.Collectors;
22
import lombok.extern.slf4j.Slf4j;
23
import org.springframework.beans.factory.annotation.Autowired;
24
import org.springframework.http.ResponseEntity;
25
import org.springframework.security.access.prepost.PreAuthorize;
26
import org.springframework.web.bind.annotation.ExceptionHandler;
27
import org.springframework.web.bind.annotation.GetMapping;
28
import org.springframework.web.bind.annotation.PathVariable;
29
import org.springframework.web.bind.annotation.RequestMapping;
30
import org.springframework.web.bind.annotation.RequestParam;
31
import org.springframework.web.bind.annotation.RestController;
32
33
/**
34
 * REST controller that exposes aggregated review statistics. These endpoints power the "Review
35
 * Statistics" pages of the frontend (see issue #18).
36
 *
37
 * <p>Only reviews with moderation status {@link ModerationStatus#APPROVED} (or reviews that have no
38
 * comments and were therefore auto-approved) are considered when computing the statistics, so that
39
 * unmoderated user content does not influence what we publish.
40
 */
41
@Tag(name = "Statistics")
42
@RequestMapping("/api/statistics")
43
@RestController
44
@Slf4j
45
public class StatisticsController extends ApiController {
46
47
  @Autowired ReviewRepository reviewRepository;
48
49
  @ExceptionHandler(IllegalArgumentException.class)
50
  public ResponseEntity<Map<String, String>> handleValidationExceptions(
51
      IllegalArgumentException ex) {
52
    Map<String, String> errors = new HashMap<>();
53
    errors.put("error", ex.getMessage());
54 1 1. handleValidationExceptions : replaced return value with null for edu/ucsb/cs156/dining/controllers/StatisticsController::handleValidationExceptions → KILLED
    return ResponseEntity.badRequest().body(errors);
55
  }
56
57
  /** Supported time-period filters for the best/worst items endpoints. */
58
  public static final String PERIOD_ALL = "ALL";
59
60
  public static final String PERIOD_6M = "6M";
61
  public static final String PERIOD_1M = "1M";
62
  public static final String PERIOD_1W = "1W";
63
64
  private static final DateTimeFormatter MONTH_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM");
65
66
  /** Maximum number of reviewer comments included per item in {@link #aggregateByItem}. */
67
  static final int MAX_COMMENTS_PER_ITEM = 5;
68
69
  /**
70
   * Returns the cutoff {@link LocalDateTime} for the supplied period. {@code ALL} (or any
71
   * unrecognised value) maps to {@code null}, meaning no lower bound.
72
   */
73
  static LocalDateTime cutoffForPeriod(String period, LocalDateTime now) {
74 1 1. cutoffForPeriod : negated conditional → KILLED
    if (period == null) {
75
      return null;
76
    }
77
    switch (period) {
78
      case PERIOD_6M:
79 1 1. cutoffForPeriod : replaced return value with null for edu/ucsb/cs156/dining/controllers/StatisticsController::cutoffForPeriod → KILLED
        return now.minusMonths(6);
80
      case PERIOD_1M:
81 1 1. cutoffForPeriod : replaced return value with null for edu/ucsb/cs156/dining/controllers/StatisticsController::cutoffForPeriod → KILLED
        return now.minusMonths(1);
82
      case PERIOD_1W:
83 1 1. cutoffForPeriod : replaced return value with null for edu/ucsb/cs156/dining/controllers/StatisticsController::cutoffForPeriod → KILLED
        return now.minusWeeks(1);
84
      case PERIOD_ALL:
85
      default:
86
        return null;
87
    }
88
  }
89
90
  /** Loads only approved reviews from the repository (the only ones we expose in statistics). */
91
  private List<Review> approvedReviews() {
92
    List<Review> approved = new ArrayList<>();
93
    for (Review r : reviewRepository.findByStatus(ModerationStatus.APPROVED)) {
94
      approved.add(r);
95
    }
96 1 1. approvedReviews : replaced return value with Collections.emptyList for edu/ucsb/cs156/dining/controllers/StatisticsController::approvedReviews → KILLED
    return approved;
97
  }
98
99
  /** Applies a "served on or after the cutoff" filter (if a cutoff was given). */
100
  private List<Review> filterByCutoff(List<Review> reviews, LocalDateTime cutoff) {
101 1 1. filterByCutoff : negated conditional → KILLED
    if (cutoff == null) {
102 1 1. filterByCutoff : replaced return value with Collections.emptyList for edu/ucsb/cs156/dining/controllers/StatisticsController::filterByCutoff → KILLED
      return reviews;
103
    }
104
    List<Review> filtered = new ArrayList<>();
105
    for (Review r : reviews) {
106 2 1. filterByCutoff : negated conditional → KILLED
2. filterByCutoff : negated conditional → KILLED
      if (r.getDateItemServed() != null && !r.getDateItemServed().isBefore(cutoff)) {
107
        filtered.add(r);
108
      }
109
    }
110 1 1. filterByCutoff : replaced return value with Collections.emptyList for edu/ucsb/cs156/dining/controllers/StatisticsController::filterByCutoff → KILLED
    return filtered;
111
  }
112
113
  /** Groups reviews by their associated menu item id and computes aggregate statistics. */
114
  private List<ItemStatistic> aggregateByItem(List<Review> reviews) {
115
    Map<Long, List<Review>> byItem = new HashMap<>();
116
    for (Review r : reviews) {
117
      MenuItem item = r.getItem();
118 1 1. aggregateByItem : negated conditional → KILLED
      if (item == null) {
119
        continue;
120
      }
121 1 1. lambda$aggregateByItem$0 : replaced return value with Collections.emptyList for edu/ucsb/cs156/dining/controllers/StatisticsController::lambda$aggregateByItem$0 → KILLED
      byItem.computeIfAbsent(item.getId(), k -> new ArrayList<>()).add(r);
122
    }
123
    List<ItemStatistic> stats = new ArrayList<>();
124
    for (Map.Entry<Long, List<Review>> entry : byItem.entrySet()) {
125
      List<Review> itemReviews = entry.getValue();
126
      MenuItem item = itemReviews.get(0).getItem();
127
      double total = 0.0;
128
      long count = 0L;
129
      for (Review r : itemReviews) {
130 1 1. aggregateByItem : negated conditional → KILLED
        if (r.getItemsStars() != null) {
131 1 1. aggregateByItem : Replaced double addition with subtraction → KILLED
          total += r.getItemsStars();
132 1 1. aggregateByItem : Replaced long addition with subtraction → KILLED
          count++;
133
        }
134
      }
135 1 1. aggregateByItem : negated conditional → KILLED
      if (count == 0L) {
136
        continue;
137
      }
138
      stats.add(
139
          ItemStatistic.builder()
140
              .itemId(entry.getKey())
141
              .itemName(item.getName())
142
              .diningCommonsCode(item.getDiningCommonsCode())
143
              .mealCode(item.getMealCode())
144 1 1. aggregateByItem : Replaced double division with multiplication → KILLED
              .station(item.getStation())
145
              .averageStars(total / count)
146
              .reviewCount(count)
147
              .comments(recentComments(itemReviews))
148
              .build());
149
    }
150 1 1. aggregateByItem : replaced return value with Collections.emptyList for edu/ucsb/cs156/dining/controllers/StatisticsController::aggregateByItem → KILLED
    return stats;
151
  }
152
153
  /**
154
   * Returns up to {@link #MAX_COMMENTS_PER_ITEM} non-blank reviewer comments from the given
155
   * reviews, most recently served first.
156
   */
157
  private List<String> recentComments(List<Review> reviews) {
158 1 1. recentComments : replaced return value with Collections.emptyList for edu/ucsb/cs156/dining/controllers/StatisticsController::recentComments → KILLED
    return reviews.stream()
159 3 1. lambda$recentComments$0 : replaced boolean return with true for edu/ucsb/cs156/dining/controllers/StatisticsController::lambda$recentComments$0 → KILLED
2. lambda$recentComments$0 : negated conditional → KILLED
3. lambda$recentComments$0 : negated conditional → KILLED
        .filter(r -> r.getReviewerComments() != null && !r.getReviewerComments().isBlank())
160
        .sorted(
161
            Comparator.comparing(
162
                    Review::getDateItemServed, Comparator.nullsLast(Comparator.naturalOrder()))
163
                .reversed())
164
        .map(Review::getReviewerComments)
165
        .limit(MAX_COMMENTS_PER_ITEM)
166
        .collect(Collectors.toList());
167
  }
168
169
  /** Rejects negative limits before they reach {@code Stream.limit}, which throws. */
170
  private void validateLimit(int limit) {
171 2 1. validateLimit : negated conditional → KILLED
2. validateLimit : changed conditional boundary → KILLED
    if (limit < 0) {
172
      throw new IllegalArgumentException("limit must be non-negative");
173
    }
174
  }
175
176
  /** Best items endpoint, supports a time period filter and a maximum result count. */
177
  @Operation(summary = "Best rated items, optionally restricted to a recent time period")
178
  @PreAuthorize("hasRole('ROLE_USER')")
179
  @GetMapping("/items/best")
180
  public List<ItemStatistic> bestItems(
181
      @Parameter(name = "period", description = "ALL, 6M, 1M, or 1W")
182
          @RequestParam(name = "period", defaultValue = PERIOD_ALL)
183
          String period,
184
      @Parameter(name = "limit", description = "Maximum number of items to return")
185
          @RequestParam(name = "limit", defaultValue = "5")
186
          int limit) {
187
    log.info("statistics.bestItems period={} limit={}", period, limit);
188 1 1. bestItems : removed call to edu/ucsb/cs156/dining/controllers/StatisticsController::validateLimit → KILLED
    validateLimit(limit);
189
    LocalDateTime cutoff = cutoffForPeriod(period, LocalDateTime.now());
190
    List<ItemStatistic> stats = aggregateByItem(filterByCutoff(approvedReviews(), cutoff));
191 1 1. bestItems : removed call to java/util/List::sort → KILLED
    stats.sort(
192
        Comparator.comparingDouble(ItemStatistic::getAverageStars)
193
            .reversed()
194
            .thenComparing(Comparator.comparingLong(ItemStatistic::getReviewCount).reversed())
195
            .thenComparing(Comparator.comparing(ItemStatistic::getItemId)));
196 1 1. bestItems : replaced return value with Collections.emptyList for edu/ucsb/cs156/dining/controllers/StatisticsController::bestItems → KILLED
    return stats.stream().limit(limit).collect(Collectors.toCollection(ArrayList::new));
197
  }
198
199
  /** Worst items endpoint, supports a time period filter and a maximum result count. */
200
  @Operation(summary = "Worst rated items, optionally restricted to a recent time period")
201
  @PreAuthorize("hasRole('ROLE_USER')")
202
  @GetMapping("/items/worst")
203
  public List<ItemStatistic> worstItems(
204
      @Parameter(name = "period", description = "ALL, 6M, 1M, or 1W")
205
          @RequestParam(name = "period", defaultValue = PERIOD_ALL)
206
          String period,
207
      @Parameter(name = "limit", description = "Maximum number of items to return")
208
          @RequestParam(name = "limit", defaultValue = "5")
209
          int limit) {
210
    log.info("statistics.worstItems period={} limit={}", period, limit);
211 1 1. worstItems : removed call to edu/ucsb/cs156/dining/controllers/StatisticsController::validateLimit → KILLED
    validateLimit(limit);
212
    LocalDateTime cutoff = cutoffForPeriod(period, LocalDateTime.now());
213
    List<ItemStatistic> stats = aggregateByItem(filterByCutoff(approvedReviews(), cutoff));
214 1 1. worstItems : removed call to java/util/List::sort → KILLED
    stats.sort(
215
        Comparator.comparingDouble(ItemStatistic::getAverageStars)
216
            .thenComparing(Comparator.comparingLong(ItemStatistic::getReviewCount).reversed())
217
            .thenComparing(Comparator.comparing(ItemStatistic::getItemId)));
218 1 1. worstItems : replaced return value with Collections.emptyList for edu/ucsb/cs156/dining/controllers/StatisticsController::worstItems → KILLED
    return stats.stream().limit(limit).collect(Collectors.toCollection(ArrayList::new));
219
  }
220
221
  /** Average review score for each dining commons. */
222
  @Operation(summary = "Average review score for each dining commons")
223
  @PreAuthorize("hasRole('ROLE_USER')")
224
  @GetMapping("/commons/averages")
225
  public List<CommonsAverage> commonsAverages() {
226
    log.info("statistics.commonsAverages");
227
    Map<String, double[]> byCommons = new HashMap<>();
228
    for (Review r : approvedReviews()) {
229
      MenuItem item = r.getItem();
230 3 1. commonsAverages : negated conditional → KILLED
2. commonsAverages : negated conditional → KILLED
3. commonsAverages : negated conditional → KILLED
      if (item == null || item.getDiningCommonsCode() == null || r.getItemsStars() == null) {
231
        continue;
232
      }
233 1 1. lambda$commonsAverages$0 : replaced return value with null for edu/ucsb/cs156/dining/controllers/StatisticsController::lambda$commonsAverages$0 → KILLED
      double[] acc = byCommons.computeIfAbsent(item.getDiningCommonsCode(), k -> new double[2]);
234 1 1. commonsAverages : Replaced double addition with subtraction → KILLED
      acc[0] += r.getItemsStars();
235 1 1. commonsAverages : Replaced double addition with subtraction → KILLED
      acc[1] += 1.0;
236
    }
237
    List<CommonsAverage> result = new ArrayList<>();
238
    for (Map.Entry<String, double[]> entry : byCommons.entrySet()) {
239
      double[] acc = entry.getValue();
240
      long count = (long) acc[1];
241
      result.add(
242
          CommonsAverage.builder()
243 1 1. commonsAverages : Replaced double division with multiplication → KILLED
              .diningCommonsCode(entry.getKey())
244
              .averageStars(acc[0] / acc[1])
245
              .reviewCount(count)
246
              .build());
247
    }
248 1 1. commonsAverages : removed call to java/util/List::sort → KILLED
    result.sort(Comparator.comparing(CommonsAverage::getDiningCommonsCode));
249 1 1. commonsAverages : replaced return value with Collections.emptyList for edu/ucsb/cs156/dining/controllers/StatisticsController::commonsAverages → KILLED
    return result;
250
  }
251
252
  /** Average review score for each dining commons grouped by month (used to draw a graph). */
253
  @Operation(summary = "Average review score for each dining commons grouped by month")
254
  @PreAuthorize("hasRole('ROLE_USER')")
255
  @GetMapping("/commons/averages/overtime")
256
  public List<CommonsAverageOverTime> commonsAveragesOverTime() {
257
    log.info("statistics.commonsAveragesOverTime");
258
    Map<String, double[]> buckets = new HashMap<>();
259
    Map<String, String[]> labels = new HashMap<>();
260
    for (Review r : approvedReviews()) {
261
      MenuItem item = r.getItem();
262 1 1. commonsAveragesOverTime : negated conditional → KILLED
      if (item == null
263 1 1. commonsAveragesOverTime : negated conditional → KILLED
          || item.getDiningCommonsCode() == null
264 1 1. commonsAveragesOverTime : negated conditional → KILLED
          || r.getItemsStars() == null
265 1 1. commonsAveragesOverTime : negated conditional → KILLED
          || r.getDateItemServed() == null) {
266
        continue;
267
      }
268
      String code = item.getDiningCommonsCode();
269
      String period = r.getDateItemServed().format(MONTH_FORMATTER);
270
      String key = code + "|" + period;
271 1 1. lambda$commonsAveragesOverTime$0 : replaced return value with null for edu/ucsb/cs156/dining/controllers/StatisticsController::lambda$commonsAveragesOverTime$0 → KILLED
      double[] acc = buckets.computeIfAbsent(key, k -> new double[2]);
272 1 1. commonsAveragesOverTime : Replaced double addition with subtraction → KILLED
      acc[0] += r.getItemsStars();
273 1 1. commonsAveragesOverTime : Replaced double addition with subtraction → KILLED
      acc[1] += 1.0;
274 1 1. lambda$commonsAveragesOverTime$1 : replaced return value with null for edu/ucsb/cs156/dining/controllers/StatisticsController::lambda$commonsAveragesOverTime$1 → KILLED
      labels.computeIfAbsent(key, k -> new String[] {code, period});
275
    }
276
    List<CommonsAverageOverTime> result = new ArrayList<>();
277
    for (Map.Entry<String, double[]> entry : buckets.entrySet()) {
278
      String[] label = labels.get(entry.getKey());
279
      double[] acc = entry.getValue();
280
      long count = (long) acc[1];
281
      result.add(
282
          CommonsAverageOverTime.builder()
283
              .diningCommonsCode(label[0])
284 1 1. commonsAveragesOverTime : Replaced double division with multiplication → KILLED
              .period(label[1])
285
              .averageStars(acc[0] / acc[1])
286
              .reviewCount(count)
287
              .build());
288
    }
289 1 1. commonsAveragesOverTime : removed call to java/util/List::sort → KILLED
    result.sort(
290
        Comparator.comparing(CommonsAverageOverTime::getDiningCommonsCode)
291
            .thenComparing(CommonsAverageOverTime::getPeriod));
292 1 1. commonsAveragesOverTime : replaced return value with Collections.emptyList for edu/ucsb/cs156/dining/controllers/StatisticsController::commonsAveragesOverTime → KILLED
    return result;
293
  }
294
295
  /** Average review score for each meal slot at the supplied dining commons. */
296
  @Operation(summary = "Average review score grouped by meal for a single dining commons")
297
  @PreAuthorize("hasRole('ROLE_USER')")
298
  @GetMapping("/commons/{code}/meals/averages")
299
  public List<MealAverage> commonsMealAverages(
300
      @Parameter(name = "code", description = "dining commons code, e.g. 'carrillo'")
301
          @PathVariable("code")
302
          String code) {
303
    log.info("statistics.commonsMealAverages code={}", code);
304
    Map<String, double[]> byMeal = new HashMap<>();
305
    for (Review r : approvedReviews()) {
306
      MenuItem item = r.getItem();
307 1 1. commonsMealAverages : negated conditional → KILLED
      if (item == null
308 1 1. commonsMealAverages : negated conditional → KILLED
          || item.getMealCode() == null
309 1 1. commonsMealAverages : negated conditional → KILLED
          || r.getItemsStars() == null
310 1 1. commonsMealAverages : negated conditional → KILLED
          || !code.equals(item.getDiningCommonsCode())) {
311
        continue;
312
      }
313 1 1. lambda$commonsMealAverages$0 : replaced return value with null for edu/ucsb/cs156/dining/controllers/StatisticsController::lambda$commonsMealAverages$0 → KILLED
      double[] acc = byMeal.computeIfAbsent(item.getMealCode(), k -> new double[2]);
314 1 1. commonsMealAverages : Replaced double addition with subtraction → KILLED
      acc[0] += r.getItemsStars();
315 1 1. commonsMealAverages : Replaced double addition with subtraction → KILLED
      acc[1] += 1.0;
316
    }
317
    List<MealAverage> result = new ArrayList<>();
318
    for (Map.Entry<String, double[]> entry : byMeal.entrySet()) {
319
      double[] acc = entry.getValue();
320
      long count = (long) acc[1];
321
      result.add(
322
          MealAverage.builder()
323
              .diningCommonsCode(code)
324 1 1. commonsMealAverages : Replaced double division with multiplication → KILLED
              .mealCode(entry.getKey())
325
              .averageStars(acc[0] / acc[1])
326
              .reviewCount(count)
327
              .build());
328
    }
329 1 1. commonsMealAverages : removed call to java/util/List::sort → KILLED
    result.sort(Comparator.comparing(MealAverage::getMealCode));
330 1 1. commonsMealAverages : replaced return value with Collections.emptyList for edu/ucsb/cs156/dining/controllers/StatisticsController::commonsMealAverages → KILLED
    return result;
331
  }
332
}

Mutations

54

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

74

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

79

1.1
Location : cutoffForPeriod
Killed by : edu.ucsb.cs156.dining.controllers.StatisticsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.dining.controllers.StatisticsControllerTests]/[method:cutoffForPeriod_6M()]
replaced return value with null for edu/ucsb/cs156/dining/controllers/StatisticsController::cutoffForPeriod → KILLED

81

1.1
Location : cutoffForPeriod
Killed by : edu.ucsb.cs156.dining.controllers.StatisticsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.dining.controllers.StatisticsControllerTests]/[method:cutoffForPeriod_1M()]
replaced return value with null for edu/ucsb/cs156/dining/controllers/StatisticsController::cutoffForPeriod → KILLED

83

1.1
Location : cutoffForPeriod
Killed by : edu.ucsb.cs156.dining.controllers.StatisticsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.dining.controllers.StatisticsControllerTests]/[method:cutoffForPeriod_1W()]
replaced return value with null for edu/ucsb/cs156/dining/controllers/StatisticsController::cutoffForPeriod → KILLED

96

1.1
Location : approvedReviews
Killed by : edu.ucsb.cs156.dining.controllers.StatisticsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.dining.controllers.StatisticsControllerTests]/[method:commons_averages_ignores_reviews_missing_required_fields()]
replaced return value with Collections.emptyList for edu/ucsb/cs156/dining/controllers/StatisticsController::approvedReviews → KILLED

101

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

102

1.1
Location : filterByCutoff
Killed by : edu.ucsb.cs156.dining.controllers.StatisticsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.dining.controllers.StatisticsControllerTests]/[method:best_items_ignores_reviews_with_null_stars()]
replaced return value with Collections.emptyList for edu/ucsb/cs156/dining/controllers/StatisticsController::filterByCutoff → KILLED

106

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

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

110

1.1
Location : filterByCutoff
Killed by : edu.ucsb.cs156.dining.controllers.StatisticsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.dining.controllers.StatisticsControllerTests]/[method:best_items_filters_by_period_1M()]
replaced return value with Collections.emptyList for edu/ucsb/cs156/dining/controllers/StatisticsController::filterByCutoff → KILLED

118

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

121

1.1
Location : lambda$aggregateByItem$0
Killed by : edu.ucsb.cs156.dining.controllers.StatisticsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.dining.controllers.StatisticsControllerTests]/[method:best_items_drops_items_whose_reviews_are_all_starless()]
replaced return value with Collections.emptyList for edu/ucsb/cs156/dining/controllers/StatisticsController::lambda$aggregateByItem$0 → KILLED

130

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

131

1.1
Location : aggregateByItem
Killed by : edu.ucsb.cs156.dining.controllers.StatisticsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.dining.controllers.StatisticsControllerTests]/[method:best_items_ignores_reviews_with_null_stars()]
Replaced double addition with subtraction → KILLED

132

1.1
Location : aggregateByItem
Killed by : edu.ucsb.cs156.dining.controllers.StatisticsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.dining.controllers.StatisticsControllerTests]/[method:best_items_ignores_reviews_with_null_stars()]
Replaced long addition with subtraction → KILLED

135

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

144

1.1
Location : aggregateByItem
Killed by : edu.ucsb.cs156.dining.controllers.StatisticsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.dining.controllers.StatisticsControllerTests]/[method:worst_items_breaks_ties_using_review_count_then_id()]
Replaced double division with multiplication → KILLED

150

1.1
Location : aggregateByItem
Killed by : edu.ucsb.cs156.dining.controllers.StatisticsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.dining.controllers.StatisticsControllerTests]/[method:best_items_ignores_reviews_with_null_stars()]
replaced return value with Collections.emptyList for edu/ucsb/cs156/dining/controllers/StatisticsController::aggregateByItem → KILLED

158

1.1
Location : recentComments
Killed by : edu.ucsb.cs156.dining.controllers.StatisticsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.dining.controllers.StatisticsControllerTests]/[method:best_items_include_comments_most_recently_served_first()]
replaced return value with Collections.emptyList for edu/ucsb/cs156/dining/controllers/StatisticsController::recentComments → KILLED

159

1.1
Location : lambda$recentComments$0
Killed by : edu.ucsb.cs156.dining.controllers.StatisticsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.dining.controllers.StatisticsControllerTests]/[method:best_items_excludes_null_and_blank_comments()]
replaced boolean return with true for edu/ucsb/cs156/dining/controllers/StatisticsController::lambda$recentComments$0 → KILLED

2.2
Location : lambda$recentComments$0
Killed by : edu.ucsb.cs156.dining.controllers.StatisticsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.dining.controllers.StatisticsControllerTests]/[method:best_items_include_comments_most_recently_served_first()]
negated conditional → KILLED

3.3
Location : lambda$recentComments$0
Killed by : edu.ucsb.cs156.dining.controllers.StatisticsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.dining.controllers.StatisticsControllerTests]/[method:best_items_ignores_reviews_with_null_stars()]
negated conditional → KILLED

171

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

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

188

1.1
Location : bestItems
Killed by : edu.ucsb.cs156.dining.controllers.StatisticsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.dining.controllers.StatisticsControllerTests]/[method:best_items_returns_bad_request_for_negative_limit()]
removed call to edu/ucsb/cs156/dining/controllers/StatisticsController::validateLimit → KILLED

191

1.1
Location : bestItems
Killed by : edu.ucsb.cs156.dining.controllers.StatisticsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.dining.controllers.StatisticsControllerTests]/[method:best_items_breaks_ties_using_review_count_then_id()]
removed call to java/util/List::sort → KILLED

196

1.1
Location : bestItems
Killed by : edu.ucsb.cs156.dining.controllers.StatisticsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.dining.controllers.StatisticsControllerTests]/[method:best_items_ignores_reviews_with_null_stars()]
replaced return value with Collections.emptyList for edu/ucsb/cs156/dining/controllers/StatisticsController::bestItems → KILLED

211

1.1
Location : worstItems
Killed by : edu.ucsb.cs156.dining.controllers.StatisticsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.dining.controllers.StatisticsControllerTests]/[method:worst_items_returns_bad_request_for_negative_limit()]
removed call to edu/ucsb/cs156/dining/controllers/StatisticsController::validateLimit → KILLED

214

1.1
Location : worstItems
Killed by : edu.ucsb.cs156.dining.controllers.StatisticsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.dining.controllers.StatisticsControllerTests]/[method:worst_items_breaks_ties_using_review_count_then_id()]
removed call to java/util/List::sort → KILLED

218

1.1
Location : worstItems
Killed by : edu.ucsb.cs156.dining.controllers.StatisticsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.dining.controllers.StatisticsControllerTests]/[method:worst_items_breaks_ties_using_review_count_then_id()]
replaced return value with Collections.emptyList for edu/ucsb/cs156/dining/controllers/StatisticsController::worstItems → KILLED

230

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

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

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

233

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

234

1.1
Location : commonsAverages
Killed by : edu.ucsb.cs156.dining.controllers.StatisticsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.dining.controllers.StatisticsControllerTests]/[method:commons_averages_ignores_reviews_missing_required_fields()]
Replaced double addition with subtraction → KILLED

235

1.1
Location : commonsAverages
Killed by : edu.ucsb.cs156.dining.controllers.StatisticsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.dining.controllers.StatisticsControllerTests]/[method:commons_averages_ignores_reviews_missing_required_fields()]
Replaced double addition with subtraction → KILLED

243

1.1
Location : commonsAverages
Killed by : edu.ucsb.cs156.dining.controllers.StatisticsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.dining.controllers.StatisticsControllerTests]/[method:commons_averages_groups_by_commons_and_sorts_alphabetically()]
Replaced double division with multiplication → KILLED

248

1.1
Location : commonsAverages
Killed by : edu.ucsb.cs156.dining.controllers.StatisticsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.dining.controllers.StatisticsControllerTests]/[method:commons_averages_sorts_alphabetically_when_data_arrives_unsorted()]
removed call to java/util/List::sort → KILLED

249

1.1
Location : commonsAverages
Killed by : edu.ucsb.cs156.dining.controllers.StatisticsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.dining.controllers.StatisticsControllerTests]/[method:commons_averages_ignores_reviews_missing_required_fields()]
replaced return value with Collections.emptyList for edu/ucsb/cs156/dining/controllers/StatisticsController::commonsAverages → KILLED

262

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

263

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

264

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

265

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

271

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

272

1.1
Location : commonsAveragesOverTime
Killed by : edu.ucsb.cs156.dining.controllers.StatisticsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.dining.controllers.StatisticsControllerTests]/[method:commons_averages_over_time_ignores_reviews_missing_required_fields()]
Replaced double addition with subtraction → KILLED

273

1.1
Location : commonsAveragesOverTime
Killed by : edu.ucsb.cs156.dining.controllers.StatisticsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.dining.controllers.StatisticsControllerTests]/[method:commons_averages_over_time_ignores_reviews_missing_required_fields()]
Replaced double addition with subtraction → KILLED

274

1.1
Location : lambda$commonsAveragesOverTime$1
Killed by : edu.ucsb.cs156.dining.controllers.StatisticsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.dining.controllers.StatisticsControllerTests]/[method:commons_averages_over_time_ignores_reviews_missing_required_fields()]
replaced return value with null for edu/ucsb/cs156/dining/controllers/StatisticsController::lambda$commonsAveragesOverTime$1 → KILLED

284

1.1
Location : commonsAveragesOverTime
Killed by : edu.ucsb.cs156.dining.controllers.StatisticsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.dining.controllers.StatisticsControllerTests]/[method:commons_averages_over_time_groups_by_month_and_sorts()]
Replaced double division with multiplication → KILLED

289

1.1
Location : commonsAveragesOverTime
Killed by : edu.ucsb.cs156.dining.controllers.StatisticsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.dining.controllers.StatisticsControllerTests]/[method:commons_averages_over_time_groups_by_month_and_sorts()]
removed call to java/util/List::sort → KILLED

292

1.1
Location : commonsAveragesOverTime
Killed by : edu.ucsb.cs156.dining.controllers.StatisticsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.dining.controllers.StatisticsControllerTests]/[method:commons_averages_over_time_ignores_reviews_missing_required_fields()]
replaced return value with Collections.emptyList for edu/ucsb/cs156/dining/controllers/StatisticsController::commonsAveragesOverTime → KILLED

307

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

308

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

309

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

310

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

313

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

314

1.1
Location : commonsMealAverages
Killed by : edu.ucsb.cs156.dining.controllers.StatisticsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.dining.controllers.StatisticsControllerTests]/[method:commons_meal_averages_ignores_reviews_missing_required_fields()]
Replaced double addition with subtraction → KILLED

315

1.1
Location : commonsMealAverages
Killed by : edu.ucsb.cs156.dining.controllers.StatisticsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.dining.controllers.StatisticsControllerTests]/[method:commons_meal_averages_ignores_reviews_missing_required_fields()]
Replaced double addition with subtraction → KILLED

324

1.1
Location : commonsMealAverages
Killed by : edu.ucsb.cs156.dining.controllers.StatisticsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.dining.controllers.StatisticsControllerTests]/[method:commons_meal_averages_returns_only_matching_commons_and_groups_by_meal()]
Replaced double division with multiplication → KILLED

329

1.1
Location : commonsMealAverages
Killed by : edu.ucsb.cs156.dining.controllers.StatisticsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.dining.controllers.StatisticsControllerTests]/[method:commons_meal_averages_returns_only_matching_commons_and_groups_by_meal()]
removed call to java/util/List::sort → KILLED

330

1.1
Location : commonsMealAverages
Killed by : edu.ucsb.cs156.dining.controllers.StatisticsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.dining.controllers.StatisticsControllerTests]/[method:commons_meal_averages_ignores_reviews_missing_required_fields()]
replaced return value with Collections.emptyList for edu/ucsb/cs156/dining/controllers/StatisticsController::commonsMealAverages → KILLED

Active mutators

Tests examined


Report generated by PIT 1.22.1