RestFunctions { protected static Optional<HttpHost> getProxy(RestConfig restConfig) { Optional<HttpHost> proxy = Optional.empty(); if (restConfig.getProxyHost() != null && restConfig.getProxyPort() != null) { proxy = Optional.of(new HttpHost(restConfig.getProxyHost(), restConfig.getProxyPort(), "http")); } return proxy; }  static T getArg(int index, Class<T> clazz, List<Object> args);  }
@Test public void restGetShouldGetProxy() { { RestConfig restConfig = new RestConfig(); Optional<HttpHost> actual = RestFunctions.getProxy(restConfig); assertEquals(Optional.empty(), actual); } { RestConfig restConfig = new RestConfig(); restConfig.put(PROXY_HOST, "localhost"); Optional<HttpHost> actual = RestFunctions.getProxy(restConfig); assertEquals(Optional.empty(), actual); } { RestConfig restConfig = new RestConfig(); restConfig.put(PROXY_PORT, 3128); Optional<HttpHost> actual = RestFunctions.getProxy(restConfig); assertEquals(Optional.empty(), actual); } { RestConfig restConfig = new RestConfig(); restConfig.put(PROXY_HOST, "localhost"); restConfig.put(PROXY_PORT, 3128); Optional<HttpHost> actual = RestFunctions.getProxy(restConfig); assertEquals(new HttpHost("localhost", 3128), actual.get()); } }