@Test
  public void checkIntervalTest() throws InterruptedException {
    time.setCurrentMilliseconds(0);
    // positive check interval
    Throttler throttler = new Throttler(100, 10, true, time);
    throttler.maybeThrottle(150);
    // no throttling because checkInterval has not elapsed
    Assert.assertEquals(0, time.milliseconds());
    time.setCurrentMilliseconds(11);
    throttler.maybeThrottle(0);
    Assert.assertEquals(1500, time.milliseconds());

    // zero check interval
    time.setCurrentMilliseconds(0);
    throttler = new Throttler(100, 0, true, time);
    throttler.maybeThrottle(130);
    // no throttling because checkInterval has not elapsed
    Assert.assertEquals(0, time.milliseconds());
    time.setCurrentNanoSeconds(10);
    throttler.maybeThrottle(20);
    Assert.assertEquals(1500, time.milliseconds());

    // no check interval, check every time
    time.setCurrentMilliseconds(0);
    throttler = new Throttler(100, -1, true, time);
    throttler.maybeThrottle(0);
    // no throttling because no work done
    Assert.assertEquals(0, time.milliseconds());
    throttler.maybeThrottle(150);
    Assert.assertEquals(1500, time.milliseconds());
  }
Tests for different check intervals - positive, zero and check every time.
@throws InterruptedException
ambry-utils/src/test/java/com/github/ambry/utils/ThrottlerTest.java