@Test
public void failureHandlerExecutesFailoverForEachBatchItemSeparately() {

    // given
    HCHttp.Builder builder = createDefaultHttpObjectFactoryBuilder();
    ClientObjectFactory<HttpClient, BatchRequest> config = builder.build();
    FailoverPolicy failoverPolicy = Mockito.spy(new NoopFailoverPolicy());
    String payload1 = "test1";
    String payload2 = "test2";
    ItemSource<ByteBuf> source1 = createDefaultTestBuffereItemSource(payload1);
    ItemSource<ByteBuf> source2 = createDefaultTestBuffereItemSource(payload2);
    BatchRequest.Builder batchBuilder = spy(new BatchRequest.Builder());
    BatchRequest request = createTestBatch(batchBuilder, source1, source2);
    // when
    config.createFailureHandler(failoverPolicy).apply(request);
    // then
    ArgumentCaptor<FailedItemSource> captor = ArgumentCaptor.forClass(FailedItemSource.class);
    verify(failoverPolicy, times(2)).deliver(captor.capture());
    assertTrue(captor.getAllValues().get(0).getSource().equals(source1.getSource()));
    assertTrue(captor.getAllValues().get(1).getSource().equals(source2.getSource()));
}