@Test public void testNotStartedWithServices() { discoveryClient.addDiscoveredService(APPLE_1_SERVICE); discoveryClient.addDiscoveredService(APPLE_2_SERVICE); discoveryClient.addDiscoveredService(DIFFERENT_TYPE); discoveryClient.addDiscoveredService(DIFFERENT_POOL); assertEquals(serviceSelector.selectAllServices(), ImmutableList.of()); }
@Test public void testStartedWithServices() throws Exception { discoveryClient.addDiscoveredService(APPLE_1_SERVICE); discoveryClient.addDiscoveredService(APPLE_2_SERVICE); discoveryClient.addDiscoveredService(DIFFERENT_TYPE); discoveryClient.addDiscoveredService(DIFFERENT_POOL); updater.start(); Thread.sleep(100); assertEqualsIgnoreOrder( serviceSelector.selectAllServices(), ImmutableList.of(APPLE_1_SERVICE, APPLE_2_SERVICE)); }
@Test public void testServiceUpdaterDefaultToNodePool() throws Exception { discoveryClient.addDiscoveredService(APPLE_1_SERVICE); discoveryClient.addDiscoveredService(APPLE_2_SERVICE); discoveryClient.addDiscoveredService(DIFFERENT_TYPE); discoveryClient.addDiscoveredService(DIFFERENT_POOL); updater = new ServiceDescriptorsUpdater( serviceSelector, "apple", new ServiceSelectorConfig(), new NodeInfo( "test-application", new NodeConfig().setEnvironment("environment").setPool("pool")), discoveryClient, executor); updater.start(); Thread.sleep(100); assertEqualsIgnoreOrder( serviceSelector.selectAllServices(), ImmutableList.of(APPLE_1_SERVICE, APPLE_2_SERVICE)); }
@Test public void testStartedEmpty() throws Exception { updater.start(); assertEquals(serviceSelector.selectAllServices(), ImmutableList.of()); }
@Test public void testNotStartedEmpty() { assertEquals(serviceSelector.selectAllServices(), ImmutableList.of()); }