@Test
public void testSleeping() throws Exception {

  ExponentialBackoffRetryHandler handler = new ExponentialBackoffRetryHandler(6, ofMillis(10), ofMillis(200), sleeper);
  handler.retryRequest(mock(IOException.class), 2);
  ArgumentCaptor<Duration> durationArgumentCaptor = ArgumentCaptor.forClass(Duration.class);
  verify(sleeper).sleep(durationArgumentCaptor.capture());
  assertThat(durationArgumentCaptor.getValue(), is(both(greaterThan(ofMillis(9L))).and(lessThan(ofMillis(31L)))));
}