### Question:
AdaptiveTimingStrategy implements TimingStrategy { @Override public long nextDelay(long lastTaskDuration) { if (delayAdjuster == null || loadMonitor == null) { throw new IllegalStateException("Initialization hasn't been performed, this is a bug."); } long newDelay = delayAdjuster.determineNextDelay(previousDelay, lastTaskDuration, loadMonitor.getLoad()); previousDelay = newDelay; return newDelay; } private  AdaptiveTimingStrategy(long delta, long defaultDelay, long minDelay, long maxDelay, long busyThreshold, int maxSamples, int maxTime); static AdaptiveTimingStrategy defaultConfiguration(); AdaptiveTimingStrategy withDelta(long delta); AdaptiveTimingStrategy withDefaultDelayMillis(long defaultDelay); AdaptiveTimingStrategy withMinimumDelayMillis(long minDelay); AdaptiveTimingStrategy withMaximumDelayMillis(long maxDelay); AdaptiveTimingStrategy withBusyThreshold(int busyThreshold); AdaptiveTimingStrategy withMaxSamples(int maxSamples); AdaptiveTimingStrategy withMaxTime(int maxTime); @Override void initialize(GraphDatabaseService database); @Override long nextDelay(long lastTaskDuration); @Override boolean equals(Object o); @Override int hashCode();  }### Answer:
@Test public void shouldUseInitialDelayFromGivenConfiguration() { Mockito.stub(txCounters.getNumberOfStartedTransactions()).toReturn(9L); long nextDelay = timingStrategy.nextDelay(0L); assertThat(nextDelay, is(equalTo(1000L))); }
@Test public void shouldIncreaseDelayFromPreviousIfCurrentPeriodIsDeemedToBeBusy() throws InterruptedException { Mockito.stub(txCounters.getNumberOfStartedTransactions()).toReturn(10L).toReturn(20L).toReturn(30L); timingStrategy.nextDelay(30_000_000L); Thread.sleep(100); timingStrategy.nextDelay(27_000_000L); Thread.sleep(100); long nextDelay = timingStrategy.nextDelay(0L); assertTrue(nextDelay > 1000L); }
@Test public void shouldDecreaseDelayFromPreviousIfCurrentPeriodIsDeemedToBeQuiet() throws InterruptedException { Mockito.stub(txCounters.getNumberOfStartedTransactions()).toReturn(1L).toReturn(2L).toReturn(3L).toReturn(3L); timingStrategy.nextDelay(16_000_000L); Thread.sleep(100); timingStrategy.nextDelay(12_000_000L); Thread.sleep(100); timingStrategy.nextDelay(14_000_000L); Thread.sleep(100); long nextDelay = timingStrategy.nextDelay(0L); assertTrue(nextDelay < 1000L); }