ProxySettings { public static ProxySettings noProxy() { return EMPTY_SETTINGS; } private  ProxySettings(String proxyHost, int proxyPort); static ProxySettings noProxy(); static ProxySettings useProxy(String host, int port); static ProxySettings fromConfig(boolean useProxy, String host, int port); boolean isProxyUse(); String getProxyHost(); int getProxyPort(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); static final String UNDEFINED_HOST; static final int UNDEFINED_PORT; }
@Test public void testNoProxy() { ProxySettings emptySettings = ProxySettings.noProxy(); assertThat(emptySettings.isProxyUse()).isFalse(); assertThat(emptySettings.getProxyHost()).isEqualTo(ProxySettings.UNDEFINED_HOST); assertThat(emptySettings.getProxyPort()).isEqualTo(ProxySettings.UNDEFINED_PORT); }
@Test public void testNoProxyReturnsACachedInstance() { ProxySettings empty = ProxySettings.noProxy(); assertThat(ProxySettings.noProxy()).isSameAs(empty); }