@Test
void doesNotRetryWhenMaxRetryTimeExceededAsync()
{

    long retryStart = Clock.SYSTEM.millis();
    int initialDelay = 100;
    int multiplier = 2;
    long maxRetryTimeMs = 45;
    Clock clock = mock( Clock.class );
    when( clock.millis() ).thenReturn( retryStart )
            .thenReturn( retryStart + maxRetryTimeMs - 5 )
            .thenReturn( retryStart + maxRetryTimeMs + 7 );
    ExponentialBackoffRetryLogic retryLogic = newRetryLogic( maxRetryTimeMs, initialDelay, multiplier, 0, clock );
    Supplier<CompletionStage<Object>> workMock = newWorkMock();
    SessionExpiredException error = sessionExpired();
    when( workMock.get() ).thenReturn( failedFuture( error ) );
    CompletionStage<Object> future = retryLogic.retryAsync( workMock );
    Exception e = assertThrows( Exception.class, () -> await( future ) );
    assertEquals( error, e );
    List<Long> scheduleDelays = eventExecutor.scheduleDelays();
    assertEquals( 2, scheduleDelays.size() );
    assertEquals( initialDelay, scheduleDelays.get( 0 ).intValue() );
    assertEquals( initialDelay * multiplier, scheduleDelays.get( 1 ).intValue() );
    verify( workMock, times( 3 ) ).get();
}