### Question:
CloudFoundryService implements CloudService { Optional<ProxyConfiguration> proxyConfiguration () { List<Proxy> proxies = ProxySelector.getDefault().select(URI.create("https: if (proxies == null || proxies.isEmpty() || proxies.get(0).equals(Proxy.NO_PROXY)) { return Optional.empty(); } Proxy proxy = proxies.get(0); SocketAddress proxyAddress = proxy.address(); if (!(proxyAddress instanceof InetSocketAddress)) { return Optional.empty(); } InetSocketAddress inetSocketAddress = (InetSocketAddress) proxyAddress; String proxyHost = inetSocketAddress.getHostString(); int proxyPort = inetSocketAddress.getPort(); return Optional.of(ProxyConfiguration.builder().host(proxyHost).port(proxyPort).build()); }  void setApiHost(String apiHost); void setPort(Integer port); void setUsername(String username); void setPassword(String password); void setOrganization(String organization); void setSpace(String space);  }### Answer:
@Test public void proxyConfiguration () { Properties oldProperties = System.getProperties(); Optional<ProxyConfiguration> proxyConfiguration; try { System.setProperty("https.proxyHost", "my-pcf-proxy"); System.setProperty("https.proxyPort", "12345"); proxyConfiguration = cloudFoundryService.proxyConfiguration(); } finally { System.setProperties(oldProperties); } assertTrue(proxyConfiguration.isPresent()); assertEquals("my-pcf-proxy", proxyConfiguration.get().getHost()); assertEquals((Integer) 12345, proxyConfiguration.get().getPort().orElseThrow()); }
@Test public void noProxyConfiguration () { Properties oldProperties = System.getProperties(); Optional<ProxyConfiguration> proxyConfiguration; try { System.clearProperty("https.proxyHost"); System.clearProperty("https.proxyPort"); proxyConfiguration = cloudFoundryService.proxyConfiguration(); } finally { System.setProperties(oldProperties); } assertTrue(proxyConfiguration.isEmpty()); }