### Question:
ServiceDiscoveryImpl implements ServiceDiscovery { @Override public EndpointDefinition register(final String serviceName, String host, final int port) { if (trace) { logger.trace( "ServiceDiscoveryImpl::register()" + serviceName + " " + host + ":" + port ); } watch(serviceName); EndpointDefinition endpointDefinition = new EndpointDefinition(HealthStatus.PASS, serviceName + "-" + ServiceDiscovery.uniqueString(port), serviceName, host, port); return doRegister(endpointDefinition); } ServiceDiscoveryImpl(
            final PeriodicScheduler periodicScheduler,
            final ServiceChangedEventChannel serviceChangedEventChannel,
            final ServiceDiscoveryProvider provider,
            final ServiceDiscoveryProvider backupProvider,
            final ServicePoolListener servicePoolListener,
            final ExecutorService executorService,
            final int pollForServicesIntervalSeconds,
            final int checkInIntervalInSeconds); @Override EndpointDefinition registerWithTTL(
            final String serviceName,
            final String host,
            final int port,
            final int timeToLiveSeconds); @Override EndpointDefinition registerWithIdAndTimeToLive(
            final String serviceName, final String serviceId, String host, final int port, final int timeToLiveSeconds); @Override EndpointDefinition registerWithIdAndTTLAndTags(
            final String serviceName, final String serviceId, String host, final int port, final int timeToLiveSeconds, List<String> tags); @Override EndpointDefinition register(final String serviceName, String host, final int port); @Override EndpointDefinition registerWithId(final String serviceName, final String serviceId, String host, final int port); @Override void watch(String serviceName); @Override void checkIn(final String serviceId, final HealthStatus healthStatus); @Override void checkInOk(final String serviceId); ServicePool servicePool(final String serviceName); void loadServicesAsync(Callback<List<EndpointDefinition>> callback, final String serviceName); @Override List<EndpointDefinition> loadServices(final String serviceName); List<EndpointDefinition> loadServicesNow(final String serviceName); @Override void start(); void monitor(); @Override void stop(); Set<EndpointDefinition> localDefinitions();  }### Answer:
@Test public void testRegisterService() throws Exception { serviceDiscovery.register("fooBar", "localhost", 9090); AtomicReference<EndpointDefinition> serviceDefinitionAtomicReference = new AtomicReference<>(); for (int index = 0; index < 10; index++) { Sys.sleep(1000); registeredEndpointDefinitions.forEach(serviceDefinition -> { if (serviceDefinition.getName().equals("fooBar")) { puts(serviceDefinition); serviceDefinitionAtomicReference.set(serviceDefinition); } }); if (serviceDefinitionAtomicReference.get() != null) break; } assertNotNull(serviceDefinitionAtomicReference.get()); }