@Test public void getAllWithoutCereebroMetadataShouldUseServiceInstanceInfo() { Mockito.when(eurekaServerContextMock.getRegistry()).thenReturn(instanceRegistryMock); InstanceInfo instanceInfo = InstanceInfo.Builder.newBuilder() .setInstanceId("id") .setAppName("a") .setMetadata(new HashMap<>()) .setHostName("service-instance") .setPort(6090) .build(); Application application = new Application("a", Arrays.asList(instanceInfo)); Mockito.when(instanceRegistryMock.getSortedApplications()).thenReturn(Arrays.asList(application)); List<Snitch> result = registry.getAll(); Assertions.assertThat(result).hasSize(1); Snitch snitch = result.get(0); Assertions.assertThat(snitch.getUri()).isEqualTo(URI.create("http: Component expectedComponent = Component.of("a", ComponentType.HTTP_APPLICATION); SystemFragment expected = SystemFragment.of(ComponentRelationships.of(expectedComponent)); Assertions.assertThat(snitch.snitch()).isEqualTo(expected); }
@Override public List<Snitch> getAll() { return eurekaServerContext.getRegistry().getSortedApplications().stream() .map(Application::getInstances) .flatMap(Collection::stream) .map(instance -> new ServiceInstanceSnitch(objectMapper, new EurekaServiceInstance(instance))) .collect(Collectors.toList()); }
EurekaServerSnitchRegistry implements SnitchRegistry { @Override public List<Snitch> getAll() { return eurekaServerContext.getRegistry().getSortedApplications().stream() .map(Application::getInstances) .flatMap(Collection::stream) .map(instance -> new ServiceInstanceSnitch(objectMapper, new EurekaServiceInstance(instance))) .collect(Collectors.toList()); } }
EurekaServerSnitchRegistry implements SnitchRegistry { @Override public List<Snitch> getAll() { return eurekaServerContext.getRegistry().getSortedApplications().stream() .map(Application::getInstances) .flatMap(Collection::stream) .map(instance -> new ServiceInstanceSnitch(objectMapper, new EurekaServiceInstance(instance))) .collect(Collectors.toList()); } EurekaServerSnitchRegistry(EurekaServerContext eurekaServerContext, ObjectMapper objectMapper); }
EurekaServerSnitchRegistry implements SnitchRegistry { @Override public List<Snitch> getAll() { return eurekaServerContext.getRegistry().getSortedApplications().stream() .map(Application::getInstances) .flatMap(Collection::stream) .map(instance -> new ServiceInstanceSnitch(objectMapper, new EurekaServiceInstance(instance))) .collect(Collectors.toList()); } EurekaServerSnitchRegistry(EurekaServerContext eurekaServerContext, ObjectMapper objectMapper); @Override List<Snitch> getAll(); }
EurekaServerSnitchRegistry implements SnitchRegistry { @Override public List<Snitch> getAll() { return eurekaServerContext.getRegistry().getSortedApplications().stream() .map(Application::getInstances) .flatMap(Collection::stream) .map(instance -> new ServiceInstanceSnitch(objectMapper, new EurekaServiceInstance(instance))) .collect(Collectors.toList()); } EurekaServerSnitchRegistry(EurekaServerContext eurekaServerContext, ObjectMapper objectMapper); @Override List<Snitch> getAll();  }