### Question:
AddressResolver { HostnamePort resolveCorrectHAAddress( Config config, OptionalHostnamePort userProvidedAddress ) { HostnamePort defaultValues = readDefaultConfigAddressHA( config ); return new HostnamePort( userProvidedAddress.getHostname().orElse( defaultValues.getHost() ), userProvidedAddress.getPort().orElse( defaultValues.getPort() ) ); }    }### Answer:
@Test public void noPortResolvesToDefault_ha() { Integer portIsNotSupplied = null; HostnamePort resolved = subject.resolveCorrectHAAddress( defaultConfig, new OptionalHostnamePort( "localhost", portIsNotSupplied, null ) ); assertEquals( 6362, resolved.getPort() ); }
@Test public void suppliedPortResolvesToGiven_ha() { Integer portIsSupplied = 1234; HostnamePort resolved = subject.resolveCorrectHAAddress( defaultConfig, new OptionalHostnamePort( "localhost", portIsSupplied, null ) ); assertEquals( resolved.getPort(), portIsSupplied.intValue() ); }