### Question:
Throttler { public Throttler(double desiredRatePerSec, long checkIntervalMs, boolean throttleDown, Time time) { this.desiredRatePerSec = desiredRatePerSec; this.checkIntervalMs = checkIntervalMs; this.throttleDown = throttleDown; this.time = time; this.observedSoFar = 0.0; this.periodStartNs = time.nanoseconds(); this.enabled = true; } Throttler(double desiredRatePerSec, long checkIntervalMs, boolean throttleDown, Time time); void maybeThrottle(double observed); void disable();  }### Answer:
@Test public void throttlerTest() throws InterruptedException { time.setCurrentMilliseconds(0); Throttler throttler = new Throttler(100, 10, true, time); throttler.maybeThrottle(0); Assert.assertEquals(0, time.milliseconds()); throttler.maybeThrottle(50); Assert.assertEquals(0, time.milliseconds()); time.setCurrentMilliseconds(11); throttler.maybeThrottle(100); Assert.assertEquals(1500, time.milliseconds()); throttler.maybeThrottle(500); Assert.assertEquals(5011, time.milliseconds()); throttler.disable(); throttler.maybeThrottle(500); Assert.assertEquals(5011, time.milliseconds()); }