@Test
  public void basicTest() throws Exception {
    final int numJobTypes = 5;
    Map<String, Throttler> throttlers = new HashMap<>();
    for (int i = 0; i < numJobTypes; i++) {
      String jobType = Integer.toString(i);
      throttlers.put(jobType, new MockThrottler());
    }
    DiskIOScheduler scheduler = new DiskIOScheduler(throttlers);

    // recognized job types
    for (int i = 0; i < numJobTypes; i++) {
      String jobType = Integer.toString(i);
      Long usedSinceLastCall = ThreadLocalRandom.current().nextLong(Long.MAX_VALUE);
      assertEquals("Unexpected i/o slice availability returned", Long.MAX_VALUE,
          scheduler.getSlice(jobType, "job", usedSinceLastCall));
      MockThrottler throttler = (MockThrottler) throttlers.get(jobType);
      assertTrue("maybeThrottle should have been called for this jobType", throttler.called);
      assertEquals("observed units passed to throttler not as expected", usedSinceLastCall, throttler.observedUnits,
          0.0);
    }
    for (Throttler throttler : throttlers.values()) {
      ((MockThrottler) throttler).reset();
    }

    // unrecognized job type
    String jobType = Integer.toString(numJobTypes);
    assertEquals("Unexpected i/o slice availability returned", Long.MAX_VALUE, scheduler.getSlice(jobType, "job", 0));
    for (Throttler throttler : throttlers.values()) {
      assertFalse("maybeThrottle should not have been called for this jobType", ((MockThrottler) throttler).called);
    }

    // disabling scheduler
    scheduler.disable();
    for (Throttler throttler : throttlers.values()) {
      assertTrue("Throttler should be closed.", ((MockThrottler) throttler).closed);
    }
  }
Test that the correct throttlers are used for different job types.
@throws Exception
ambry-store/src/test/java/com/github/ambry/store/DiskIOSchedulerTest.java