@Test
public void failoverIsExecutedAfterNonSuccessfulRequest() {

    // 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 request = createTestBatch(batchBuilder, payload1, payload2);
    Function<BatchRequest, Boolean> failoverHandler = mock(Function.class);
    ResponseHandler<BatchResult> responseHandler = config.createResultHandler(request, failoverHandler);
    BatchResult result = mock(BatchResult.class);
    when(result.isSucceeded()).thenReturn(false);
    // when
    responseHandler.completed(result);
    // then
    ArgumentCaptor<BatchRequest> captor = ArgumentCaptor.forClass(BatchRequest.class);
    verify(failoverHandler, times(1)).apply(captor.capture());
    verify(request, times(1)).completed();
    assertEquals(request, captor.getValue());
}