@Test
public void failoverHandlerIsNotExecutedImmediatelyIfBackoffPolicyShouldNotApply() {

    // given
    BackoffPolicy<AbstractAction<BulkResult>> backoffPolicy = mock(BackoffPolicy.class);
    when(backoffPolicy.shouldApply(any())).thenReturn(false);
    Builder builder = createTestObjectFactoryBuilder();
    builder.withBackoffPolicy(backoffPolicy);
    JestHttpObjectFactory config = spy(builder.build());
    String payload1 = "test1";
    Bulk bulk = createTestBatch(payload1);
    FailoverPolicy failoverPolicy = mock(FailoverPolicy.class);
    Function<Bulk, Boolean> listener = config.createBatchListener(failoverPolicy);
    // when
    listener.apply(bulk);
    // then
    ArgumentCaptor<FailedItemSource> captor = ArgumentCaptor.forClass(FailedItemSource.class);
    verify(failoverPolicy, never()).deliver(captor.capture());
}