@Test
public void executeShouldRetryUntilRetryHandlerReturnsFalseAndRethrowLastException() throws Exception {

    RequestException requestException1 = mock(RequestException.class);
    RequestException requestException2 = mock(RequestException.class);
    when(retryHandler.retry(requestException1, 2)).thenReturn(true);
    when(retryHandler.retry(requestException2, 3)).thenReturn(false);
    when(mockRequestExecutor.execute(request)).thenThrow(requestException1, requestException2);
    try {
        toTest.execute(request);
    } catch (Exception e) {
        assertSame(requestException2, e);
        verify(requestException1).dispose();
        verifyNoMoreInteractions(requestException2);
    }
}