@Test
public void failoverIsExecutedAfterFailedRequest() {

    // given
    HCHttp.Builder builder = createDefaultHttpObjectFactoryBuilder();
    HCHttp config = spy(builder.build());
    ItemSource<ByteBuf> payload1 = createDefaultTestBuffereItemSource("test1");
    ItemSource<ByteBuf> payload2 = createDefaultTestBuffereItemSource("test2");
    BatchRequest.Builder batchBuilder = spy(new BatchRequest.Builder());
    BatchRequest batchRequest = createTestBatch(batchBuilder, payload1, payload2);
    Function<BatchRequest, Boolean> failoverHandler = mock(Function.class);
    ResponseHandler<BatchResult> responseHandler = config.createResultHandler(batchRequest, failoverHandler);
    // when
    responseHandler.failed(new IOException());
    // then
    ArgumentCaptor<BatchRequest> captor = ArgumentCaptor.forClass(BatchRequest.class);
    verify(failoverHandler, times(1)).apply(captor.capture());
    verify(batchRequest, times(1)).completed();
    assertEquals(batchRequest, captor.getValue());
}