@Test public void is_not_ok_when_response_timeout() throws Exception { addRequestProcessingDelay((int) TimeUnit.SECONDS.toMillis(5)); stubFor(get(urlEqualTo("/ping")) .willReturn(aResponse() .withStatus(200)) ); boolean isOk = httpValidator.isOk(); assertFalse(isOk); }
@Override public boolean isOk() { Request request = new Request.Builder() .url(endpoint) .build(); try { Response response = httpClient.newCall(request).execute(); return validateResponse(response); } catch (IOException e) { return false; } }
HttpValidator implements ApiValidator { @Override public boolean isOk() { Request request = new Request.Builder() .url(endpoint) .build(); try { Response response = httpClient.newCall(request).execute(); return validateResponse(response); } catch (IOException e) { return false; } } }
HttpValidator implements ApiValidator { @Override public boolean isOk() { Request request = new Request.Builder() .url(endpoint) .build(); try { Response response = httpClient.newCall(request).execute(); return validateResponse(response); } catch (IOException e) { return false; } } HttpValidator(OkHttpClient httpClient, String endpoint); }
HttpValidator implements ApiValidator { @Override public boolean isOk() { Request request = new Request.Builder() .url(endpoint) .build(); try { Response response = httpClient.newCall(request).execute(); return validateResponse(response); } catch (IOException e) { return false; } } HttpValidator(OkHttpClient httpClient, String endpoint); @Override boolean isOk(); String getEndpoint(); }
HttpValidator implements ApiValidator { @Override public boolean isOk() { Request request = new Request.Builder() .url(endpoint) .build(); try { Response response = httpClient.newCall(request).execute(); return validateResponse(response); } catch (IOException e) { return false; } } HttpValidator(OkHttpClient httpClient, String endpoint); @Override boolean isOk(); String getEndpoint();  }