### Question:
EnodeURL { public static Builder builder() { return new Builder(); } private  EnodeURL(
      final Bytes nodeId,
      final InetAddress address,
      final Optional<String> maybeHostname,
      final Optional<Integer> listeningPort,
      final Optional<Integer> discoveryPort); static Builder builder(); static EnodeURL fromString(final String value); static EnodeURL fromString(
      final String value, final EnodeDnsConfiguration enodeDnsConfiguration); static EnodeURL fromURI(final URI uri); static EnodeURL fromURI(final URI uri, final EnodeDnsConfiguration enodeDnsConfiguration); static boolean sameListeningEndpoint(final EnodeURL enodeA, final EnodeURL enodeB); static Bytes parseNodeId(final String nodeId); URI toURI(); URI toURIWithoutDiscoveryPort(); static URI asURI(final String url); static URI asURI(final String url, final EnodeDnsConfiguration enodeDnsConfiguration); Bytes getNodeId(); String getIpAsString(); InetAddress getIp(); boolean isListening(); boolean isRunningDiscovery(); Optional<Integer> getListeningPort(); int getListeningPortOrZero(); Optional<Integer> getDiscoveryPort(); int getDiscoveryPortOrZero(); @Override boolean equals(final Object o); @Override int hashCode(); @Override String toString(); static final int DEFAULT_LISTENING_PORT; static final int NODE_ID_SIZE; }### Answer:
@Test public void builder_setInvalidPorts() { final EnodeURL.Builder validBuilder = EnodeURL.builder().nodeId(VALID_NODE_ID).ipAddress(IPV4_ADDRESS); Stream.<ThrowableAssert.ThrowingCallable>of( () -> validBuilder.listeningPort(200_000).disableDiscovery().build(), () -> validBuilder.listeningPort(-2).disableDiscovery().build(), () -> validBuilder.discoveryPort(-1).disableListening().build(), () -> validBuilder.discoveryPort(100_000).disableListening().build()) .forEach(assertThatExceptionOfType(IllegalPortException.class)::isThrownBy); }
@Test public void builder_discoveryNotSpecified() { final EnodeURL.Builder builder = EnodeURL.builder().nodeId(VALID_NODE_ID).ipAddress(IPV4_ADDRESS).listeningPort(P2P_PORT); assertThatThrownBy(builder::build) .isInstanceOf(IllegalStateException.class) .hasMessageContaining("Discovery port must be configured"); }
@Test public void builder_listeningPortNotSpecified() { final EnodeURL.Builder builder = EnodeURL.builder().nodeId(VALID_NODE_ID).ipAddress(IPV4_ADDRESS).discoveryPort(P2P_PORT); assertThatThrownBy(builder::build) .isInstanceOf(IllegalStateException.class) .hasMessageContaining("Listening port must be configured"); }
@Test public void builder_nodeIdNotSpecified() { final EnodeURL.Builder builder = EnodeURL.builder().ipAddress(IPV4_ADDRESS).discoveryAndListeningPorts(P2P_PORT); assertThatThrownBy(builder::build) .isInstanceOf(IllegalStateException.class) .hasMessageContaining("Node id must be configured"); }
@Test public void builder_ipNotSpecified() { final EnodeURL.Builder builder = EnodeURL.builder().nodeId(VALID_NODE_ID).discoveryAndListeningPorts(P2P_PORT); assertThatThrownBy(builder::build) .isInstanceOf(IllegalStateException.class) .hasMessageContaining("Ip address must be configured"); }