### Question:
HttpRequestBuilder { @SuppressWarnings("PMD.ExceptionAsFlowControl") public HttpResponse send() throws IOException { HttpResponse response = null; for (int attempt = 1; attempt <= numAttempts; ++attempt) { entry.withAttempt(attempt); try { response = sendImpl(); int s = response.status(); if (s == 429 || s == 503) { try { long delay = initialRetryDelay << (attempt - 1); LOGGER.debug("request throttled, delaying for {}ms: {} {}", delay, method, uri); Thread.sleep(delay); } catch (InterruptedException e) { Thread.currentThread().interrupt(); throw new IOException("request failed " + method + " " + uri, e); } } else if (s < 500) { return response; } } catch (IOException e) { if (attempt == numAttempts) { throw e; } else { LOGGER.warn("attempt {} of {} failed: {} {}", attempt, numAttempts, method, uri); } } } if (response == null) { throw new IOException("request failed " + method + " " + uri); } return response; } HttpRequestBuilder(String clientName, URI uri); HttpRequestBuilder withMethod(String m); HttpRequestBuilder addHeader(String name, String value); HttpRequestBuilder userAgent(String agent); HttpRequestBuilder acceptJson(); HttpRequestBuilder accept(String type); HttpRequestBuilder acceptGzip(); HttpRequestBuilder acceptEncoding(String enc); HttpRequestBuilder withConnectTimeout(int timeout); HttpRequestBuilder withReadTimeout(int timeout); HttpRequestBuilder withJsonContent(String content); HttpRequestBuilder withContent(String type, String content); HttpRequestBuilder withContent(String type, byte[] content); HttpRequestBuilder compress(); HttpRequestBuilder compress(int level); HttpRequestBuilder withRetries(int n); HttpRequestBuilder withInitialRetryDelay(long delay); HttpRequestBuilder withHostnameVerifier(HostnameVerifier verifier); HttpRequestBuilder allowAllHosts(); HttpRequestBuilder withSSLSocketFactory(SSLSocketFactory factory); @SuppressWarnings("PMD.ExceptionAsFlowControl") HttpResponse send();  }### Answer:
@Test public void ok() throws IOException { HttpResponse res = new TestRequestBuilder(() -> OK).send(); Assertions.assertEquals(200, res.status()); }
@Test public void retry0() throws Exception { Assertions.assertThrows(IOException.class, () -> new TestRequestBuilder(() -> { throw new IOException("failed"); }).send()); }