### Question:
HostnamePort { public static String getHostAddress( String host, String defaultHost ) { if ( host == null ) { return defaultHost; } else { return host; } } HostnamePort( String hostnamePort );  HostnamePort( String host, int port );  HostnamePort( String host, int portFrom, int portTo ); String getHost(); static String getHostAddress( String host, String defaultHost ); String getHost( String defaultHost ); int[] getPorts(); int getPort(); boolean isRange(); @Override String toString(); String toString( String defaultHost ); boolean matches( URI toMatch ); @Override boolean equals( Object o ); @Override int hashCode();  }### Answer:
@Test void testGetHostAddress() throws Exception { String hostName = InetAddress.getLocalHost().getHostName(); assertThat( HostnamePort.getHostAddress( null, "default" ), equalTo( "default" ) ); assertThat( HostnamePort.getHostAddress( hostName, "default" ), equalTo( hostName ) ); }
@Test void testGetHostAddressUnknown() { String unknownHost = "unknownHost"; assertThrows( UnknownHostException.class, () -> InetAddress.getByName( unknownHost ) ); assertThat( HostnamePort.getHostAddress( unknownHost, "default" ), equalTo( unknownHost ) ); }