StatsWindow.java

1
package edu.ucsb.cs156.dining.util;
2
3
import java.time.LocalDateTime;
4
5
/** Time windows for filtering review statistics by {@code dateItemServed}. */
6
public enum StatsWindow {
7
  ALL,
8
  SIX_MONTHS,
9
  ONE_MONTH,
10
  ONE_WEEK;
11
12
  /**
13
   * @param now reference time (typically {@code LocalDateTime.now()})
14
   * @return earliest {@code dateItemServed} to include for this window
15
   */
16
  public LocalDateTime since(LocalDateTime now) {
17 1 1. since : replaced return value with null for edu/ucsb/cs156/dining/util/StatsWindow::since → KILLED
    return switch (this) {
18
      case ALL -> LocalDateTime.of(1970, 1, 1, 0, 0);
19
      case SIX_MONTHS -> now.minusMonths(6);
20
      case ONE_MONTH -> now.minusMonths(1);
21
      case ONE_WEEK -> now.minusWeeks(1);
22
    };
23
  }
24
}

Mutations

17

1.1
Location : since
Killed by : edu.ucsb.cs156.dining.util.StatsWindowTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.dining.util.StatsWindowTests]/[method:one_week_since_subtracts_one_week()]
replaced return value with null for edu/ucsb/cs156/dining/util/StatsWindow::since → KILLED

Active mutators

Tests examined


Report generated by PIT 1.17.0