@Test
void shouldRetryWithRandomBackOffRx()
{

    Exception exception = new TransientException( "Unknown", "Retry this error." );
    Clock clock = mock( Clock.class );
    when( clock.millis() ).thenReturn( 0L, 100L, 200L, 400L, 800L );
    ExponentialBackoffRetryLogic retryLogic = new ExponentialBackoffRetryLogic( 500, 100, 2, 0.1,
            eventExecutor, clock, DEV_NULL_LOGGING );
    Flux<Integer> source = Flux.concat( Flux.range( 0, 2 ), Flux.error( exception ) );
    Flux<Integer> retriedSource = Flux.from( retryLogic.retryRx( source ) );
    StepVerifier.create( retriedSource )
            .expectNext( 0, 1 ) // first run
            .expectNext( 0, 1, 0, 1, 0, 1, 0, 1 ) // 4 retry attempts
            .verifyErrorSatisfies( e -> assertThat( e, equalTo( exception ) ) );
    List<Long> delays = eventExecutor.scheduleDelays();
    assertThat( delays.size(), equalTo( 4 ) );
    assertThat( delays.get( 0 ), allOf( greaterThanOrEqualTo( 90L ), lessThanOrEqualTo( 110L ) ) );
    assertThat( delays.get( 1 ), allOf( greaterThanOrEqualTo( 180L ), lessThanOrEqualTo( 220L ) ) );
    assertThat( delays.get( 2 ), allOf( greaterThanOrEqualTo( 260L ), lessThanOrEqualTo( 440L ) ) );
    assertThat( delays.get( 3 ), allOf( greaterThanOrEqualTo( 720L ), lessThanOrEqualTo( 880L ) ) );
}