PersistentUpperLimit { public void increaseToAtLeast(long newLimit) { if (newLimit > currentLimit) { updateLimit(newLimit); } } PersistentUpperLimit(TimestampBoundStore boundStore); long get(); void increaseToAtLeast(long newLimit);  }
@Test public void shouldNotIncreaseTheUpperLimitIfWouldOverflow() { assertThatExceptionOfType(ArithmeticException.class) .isThrownBy(() -> upperLimit.increaseToAtLeast(Long.MAX_VALUE - BUFFER + 1)); }