@Test public void testGetServiceEndpoint() { String hostAddressString = randomHostname(); verifyGetServiceEndpoint(hostAddressString, RandomUtils.nextInt(1, 65535)); verifyGetServiceEndpoint(hostAddressString, null); }
@Nonnull @Override public <T extends ServiceEndpoint> T getServiceEndpoint(@Nonnull ServiceEndpointRequest<T> serviceEndpointRequest) { final Optional<HostEndpoint> hostEndpoint = serviceEndpointRequest.getTargetInstance().getHostEndpoint(); if (!hostEndpoint.isPresent()) { throw new IllegalArgumentException("No host endpoint provided"); } ServiceFamily<T> serviceFamily = serviceEndpointRequest.getServiceFamily(); int port = serviceEndpointRequest.getPort().orElse(serviceFamily.getDefaultPort()); return serviceFamily.getServiceEndpoint(hostEndpoint.get(), port); }
DirectServiceEndpointFinder implements ServiceEndpointFinder { @Nonnull @Override public <T extends ServiceEndpoint> T getServiceEndpoint(@Nonnull ServiceEndpointRequest<T> serviceEndpointRequest) { final Optional<HostEndpoint> hostEndpoint = serviceEndpointRequest.getTargetInstance().getHostEndpoint(); if (!hostEndpoint.isPresent()) { throw new IllegalArgumentException("No host endpoint provided"); } ServiceFamily<T> serviceFamily = serviceEndpointRequest.getServiceFamily(); int port = serviceEndpointRequest.getPort().orElse(serviceFamily.getDefaultPort()); return serviceFamily.getServiceEndpoint(hostEndpoint.get(), port); } }
DirectServiceEndpointFinder implements ServiceEndpointFinder { @Nonnull @Override public <T extends ServiceEndpoint> T getServiceEndpoint(@Nonnull ServiceEndpointRequest<T> serviceEndpointRequest) { final Optional<HostEndpoint> hostEndpoint = serviceEndpointRequest.getTargetInstance().getHostEndpoint(); if (!hostEndpoint.isPresent()) { throw new IllegalArgumentException("No host endpoint provided"); } ServiceFamily<T> serviceFamily = serviceEndpointRequest.getServiceFamily(); int port = serviceEndpointRequest.getPort().orElse(serviceFamily.getDefaultPort()); return serviceFamily.getServiceEndpoint(hostEndpoint.get(), port); }  }
DirectServiceEndpointFinder implements ServiceEndpointFinder { @Nonnull @Override public <T extends ServiceEndpoint> T getServiceEndpoint(@Nonnull ServiceEndpointRequest<T> serviceEndpointRequest) { final Optional<HostEndpoint> hostEndpoint = serviceEndpointRequest.getTargetInstance().getHostEndpoint(); if (!hostEndpoint.isPresent()) { throw new IllegalArgumentException("No host endpoint provided"); } ServiceFamily<T> serviceFamily = serviceEndpointRequest.getServiceFamily(); int port = serviceEndpointRequest.getPort().orElse(serviceFamily.getDefaultPort()); return serviceFamily.getServiceEndpoint(hostEndpoint.get(), port); }  @Nonnull @Override T getServiceEndpoint(@Nonnull ServiceEndpointRequest<T> serviceEndpointRequest); }
DirectServiceEndpointFinder implements ServiceEndpointFinder { @Nonnull @Override public <T extends ServiceEndpoint> T getServiceEndpoint(@Nonnull ServiceEndpointRequest<T> serviceEndpointRequest) { final Optional<HostEndpoint> hostEndpoint = serviceEndpointRequest.getTargetInstance().getHostEndpoint(); if (!hostEndpoint.isPresent()) { throw new IllegalArgumentException("No host endpoint provided"); } ServiceFamily<T> serviceFamily = serviceEndpointRequest.getServiceFamily(); int port = serviceEndpointRequest.getPort().orElse(serviceFamily.getDefaultPort()); return serviceFamily.getServiceEndpoint(hostEndpoint.get(), port); }  @Nonnull @Override T getServiceEndpoint(@Nonnull ServiceEndpointRequest<T> serviceEndpointRequest);  }