@Test
void shouldRetryOnError() throws Throwable
{

    // Given
    int retryCount = 2;
    NetworkSession session = mock( NetworkSession.class );
    UnmanagedTransaction tx = mock( UnmanagedTransaction.class );
    when( tx.commitAsync() ).thenReturn( completedWithNull() );
    when( tx.rollbackAsync() ).thenReturn( completedWithNull() );
    when( session.beginTransactionAsync( any( AccessMode.class ), any( TransactionConfig.class ) ) ).thenReturn( completedFuture( tx ) );
    when( session.retryLogic() ).thenReturn( new FixedRetryLogic( retryCount ) );
    InternalRxSession rxSession = new InternalRxSession( session );
    // When
    Publisher<String> strings = rxSession.readTransaction( t ->
            Flux.just( "a" ).then( Mono.error( new RuntimeException( "Errored" ) ) ) );
    StepVerifier.create( Flux.from( strings ) )
            // we lost the "a"s too as the user only see the last failure
            .expectError( RuntimeException.class )
            .verify();
    // Then
    verify( session, times( retryCount + 1 ) ).beginTransactionAsync( any( AccessMode.class ), any( TransactionConfig.class ) );
    verify( tx, times( retryCount + 1 ) ).rollbackAsync();
}