@Test(expected = RejectedExecutionException.class)
public void testRateLimit() throws Exception {

  try (RateLimiter limiter = new RateLimiter(10, Duration.ofSeconds(1), 10)) {
    LimitingExecutor<?, Callable<?>> executor = new LimitingExecutor<>(limiter);
    Assert.assertEquals(10, limiter.getPermitsPerReplenishInterval());
    Assert.assertEquals(1000000000, limiter.getPermitReplenishIntervalNanos());
    for (int i = 0; i < 10; i++) {
      final int val = i;
      executor.execute(() -> {
        LOG.debug("executed nr {}", val);
        return null;
      });
    }
    Assert.fail();
  }
}