@Test
public void executeShouldRetryIfStatusCodeIsGreaterThan400AndReturnResponseIsRetryIsSuccess() throws Exception {

    RequestException requestException1 = mock(RequestException.class);
    ArgumentCaptor<RequestException> requestException2 = ArgumentCaptor.forClass(RequestException.class);
    Response badResponse = mock(Response.class);
    when(badResponse.getStatusCode()).thenReturn(123);
    when(retryHandler.retry(requestException1, 2)).thenReturn(true);
    when(retryHandler.retry(requestException2.capture(), eq(3))).thenReturn(true);
    when(mockRequestExecutor.execute(request)).thenThrow(requestException1).thenReturn(badResponse, expected);
    Response actual = toTest.execute(request);
    assertSame(expected, actual);
    verify(requestException1).dispose();
}