EurekaHostsSupplier implements HostSupplier { @Override public List<Host> getHosts() { return getUpdateFromEureka(); } @Deprecated  EurekaHostsSupplier(String applicationName, DiscoveryClient dClient);  EurekaHostsSupplier(String applicationName, EurekaClient dClient); static EurekaHostsSupplier newInstance(String applicationName, EurekaHostsSupplier hostsSupplier); @Override List<Host> getHosts(); @Override String toString(); String getApplicationName(); EurekaClient getDiscoveryClient();  }
@Test public void testGetHosts() { String zone = "us-east-1c"; String hostname = "1.2.3.4"; Application app = new Application(); AmazonInfo amazonInfo = AmazonInfo.Builder.newBuilder() .addMetadata(MetaDataKey.availabilityZone, zone).build(); InstanceInfo instance = InstanceInfo.Builder.newBuilder() .setInstanceId(UUID.randomUUID().toString()) .setDataCenterInfo(amazonInfo) .setHostName(hostname) .setAppName(APPLICATION_NAME) .build(); app.addInstance(instance); when(eurekaClient.getApplication(APPLICATION_NAME)).thenReturn(app); List<Host> hosts = hostsSupplier.getHosts(); assertFalse(hosts.isEmpty()); assertEquals(hostname, hosts.get(0).getHostName()); assertEquals(zone, hosts.get(0).getRack()); }