server.enqueue(new MockResponse().setBody(payloadFromResource("/error.json")));
// Response to be sent for the retried request
server.enqueue(new MockResponse().setBody(payloadFromResource("/error.json")));
DigitalOceanApi api = api(server.getUrl("/"));
ImageApi imageApi = api.getImageApi();
try {
imageApi.list();
fail("Request should have failed after retrying");
} catch (Exception ex) {
assertTrue(ex instanceof HttpResponseException, "Exception should be an HttpResponseException");
HttpResponseException exception = HttpResponseException.class.cast(ex);
assertEquals(exception.getResponse().getStatusCode(), 500);