@Override
    public void maybeThrottle(double observed) throws InterruptedException {
      throttleCount.incrementAndGet();
      if (!isThrottlerStarted) {
        isThrottlerStarted = true;
        startedLatch.countDown();
        assertTrue("IndexScanner is held for too long", holdLatch.await(5, TimeUnit.SECONDS));
      }
      if (throttleCountLatch != null && throttleCount.get() == throttleCountAtInterest) {
        throttleCountLatch.countDown();
        assertTrue("IndexScanner is held for too long", throttleCountHoldLatch.await(5, TimeUnit.SECONDS));
      }
    }
Mock {@link Throttler} with latches and a counter to track and control various states during a scan.
ambry-store/src/test/java/com/github/ambry/store/BlobStoreStatsTest.java