@Test
public void testRateLimitInvalidTryReservation() throws InterruptedException {

  long nanoTime = TestTimeSource.freezeTime();
  try {
  ScheduledExecutorService mockExec = Mockito.mock(ScheduledExecutorService.class);
  ScheduledFuture mockFut = Mockito.mock(ScheduledFuture.class);
  Mockito.when(mockExec.scheduleAtFixedRate(Mockito.any(), Mockito.anyLong(), Mockito.anyLong(),
          Mockito.eq(TimeUnit.NANOSECONDS))).thenReturn(mockFut);
  try (RateLimiter rateLimiter = new RateLimiter(10, Duration.ofNanos(10000000), 100, mockExec)) {
    long s1Nanos = TimeUnit.SECONDS.toNanos(1);
    PermitSupplier.Acquisition acq = rateLimiter.tryAcquireGetDelayNanos(1000, nanoTime + s1Nanos);
    Assert.assertEquals(s1Nanos, acq.permitAvailableEstimateInNanos());
  }
  } finally {
    TestTimeSource.clear();
  }
}