### Question:
HydraOkHttp3ClientHttpRequestFactory implements ClientHttpRequestFactory, AsyncClientHttpRequestFactory { public Builder getOkHttpClientBuilder(URI requestUri) { Builder builder = getBaseBuilder(); configureBuilderForSsl(requestUri, builder); MainConfig main = configProvider.getBaseConfig().getMain(); if (main.getProxyType() == ProxyType.NONE) { return builder; } if (isUriToBeIgnoredByProxy(requestUri.getHost())) { logger.debug("Not using proxy for request to {}", requestUri.getHost()); return builder; } if (main.getProxyType() == ProxyType.SOCKS) { return builder.socketFactory(sockProxySocketFactory); } else if (main.getProxyType() == ProxyType.HTTP) { builder = builder.proxy(new Proxy(Type.HTTP, new InetSocketAddress(main.getProxyHost(), main.getProxyPort()))).proxyAuthenticator((Route route, Response response) -> { if (response.request().header("Proxy-Authorization") != null) { logger.warn("Authentication with proxy failed"); return null; } String credential = Credentials.basic(main.getProxyUsername(), main.getProxyPassword()); return response.request().newBuilder() .header("Proxy-Authorization", credential).build(); }); } return builder; }  @PostConstruct void init(); @EventListener void handleConfigChangedEvent(ConfigChangedEvent event); @Override ClientHttpRequest createRequest(URI uri, HttpMethod httpMethod); @Override AsyncClientHttpRequest createAsyncRequest(URI uri, HttpMethod httpMethod); Builder getOkHttpClientBuilder(URI requestUri); static long ipToLong(InetAddress ip);  }### Answer:
@Test public void shouldNotUseProxyIfNotConfigured() throws URISyntaxException { baseConfig.getMain().setProxyType(ProxyType.NONE); OkHttpClient client = testee.getOkHttpClientBuilder(new URI("http: assertThat(client.socketFactory() instanceof SockProxySocketFactory, is(false)); assertThat(client.proxy(), is(nullValue())); }
@Test public void shouldUseHttpProxyIfConfigured() throws URISyntaxException { baseConfig.getMain().setProxyType(ProxyType.HTTP); baseConfig.getMain().setProxyHost("proxyhost"); baseConfig.getMain().setProxyPort(1234); OkHttpClient client = testee.getOkHttpClientBuilder(new URI("http: assertThat(client.proxy().address(), equalTo(new InetSocketAddress("proxyhost", 1234))); }