@Test public void compareWithCurrentThresholdShouldReturnAboveWithRecentChangesWhenThresholdExceededDuringDuration() { assertThat( new QuotaThresholdHistory( new QuotaThresholdChange(_50, NOW.minus(Duration.ofDays(24))), new QuotaThresholdChange(_75, NOW.minus(Duration.ofHours(12))), new QuotaThresholdChange(_50, NOW.minus(Duration.ofHours(6)))) .compareWithCurrentThreshold(new QuotaThresholdChange(_75, NOW), GRACE_PERIOD)) .isEqualTo(HistoryEvolution.higherThresholdReached(new QuotaThresholdChange(_75, NOW), AlreadyReachedDuringGracePeriod)); }
public HistoryEvolution compareWithCurrentThreshold(QuotaThresholdChange thresholdChange, Duration gracePeriod) { Optional<QuotaThreshold> lastThreshold = Optional.ofNullable(Iterables.getLast(changes, null)) .map(QuotaThresholdChange::getQuotaThreshold); return compareWithCurrentThreshold(thresholdChange, gracePeriod, lastThreshold.orElse(QuotaThreshold.ZERO)); }
QuotaThresholdHistory { public HistoryEvolution compareWithCurrentThreshold(QuotaThresholdChange thresholdChange, Duration gracePeriod) { Optional<QuotaThreshold> lastThreshold = Optional.ofNullable(Iterables.getLast(changes, null)) .map(QuotaThresholdChange::getQuotaThreshold); return compareWithCurrentThreshold(thresholdChange, gracePeriod, lastThreshold.orElse(QuotaThreshold.ZERO)); } }
QuotaThresholdHistory { public HistoryEvolution compareWithCurrentThreshold(QuotaThresholdChange thresholdChange, Duration gracePeriod) { Optional<QuotaThreshold> lastThreshold = Optional.ofNullable(Iterables.getLast(changes, null)) .map(QuotaThresholdChange::getQuotaThreshold); return compareWithCurrentThreshold(thresholdChange, gracePeriod, lastThreshold.orElse(QuotaThreshold.ZERO)); } QuotaThresholdHistory();  QuotaThresholdHistory(QuotaThresholdChange... changes);  QuotaThresholdHistory(List<QuotaThresholdChange> changes); }
QuotaThresholdHistory { public HistoryEvolution compareWithCurrentThreshold(QuotaThresholdChange thresholdChange, Duration gracePeriod) { Optional<QuotaThreshold> lastThreshold = Optional.ofNullable(Iterables.getLast(changes, null)) .map(QuotaThresholdChange::getQuotaThreshold); return compareWithCurrentThreshold(thresholdChange, gracePeriod, lastThreshold.orElse(QuotaThreshold.ZERO)); } QuotaThresholdHistory();  QuotaThresholdHistory(QuotaThresholdChange... changes);  QuotaThresholdHistory(List<QuotaThresholdChange> changes); HistoryEvolution compareWithCurrentThreshold(QuotaThresholdChange thresholdChange, Duration gracePeriod); QuotaThresholdHistory combineWith(QuotaThresholdChange change); ImmutableList<QuotaThresholdChange> getChanges(); @Override final boolean equals(Object o); @Override final int hashCode(); @Override String toString(); }
QuotaThresholdHistory { public HistoryEvolution compareWithCurrentThreshold(QuotaThresholdChange thresholdChange, Duration gracePeriod) { Optional<QuotaThreshold> lastThreshold = Optional.ofNullable(Iterables.getLast(changes, null)) .map(QuotaThresholdChange::getQuotaThreshold); return compareWithCurrentThreshold(thresholdChange, gracePeriod, lastThreshold.orElse(QuotaThreshold.ZERO)); } QuotaThresholdHistory();  QuotaThresholdHistory(QuotaThresholdChange... changes);  QuotaThresholdHistory(List<QuotaThresholdChange> changes); HistoryEvolution compareWithCurrentThreshold(QuotaThresholdChange thresholdChange, Duration gracePeriod); QuotaThresholdHistory combineWith(QuotaThresholdChange change); ImmutableList<QuotaThresholdChange> getChanges(); @Override final boolean equals(Object o); @Override final int hashCode(); @Override String toString();  }