@Test public void getAllUsingCereebroMetadata() throws IOException { Mockito.when(eurekaServerContextMock.getRegistry()).thenReturn(instanceRegistryMock); String uri = "http: String json = "{}"; Map<String, String> metadata = new HashMap<>(); metadata.put(CereebroMetadata.KEY_SNITCH_URI, uri); metadata.put(CereebroMetadata.KEY_SNITCH_SYSTEM_FRAGMENT_JSON, json); InstanceInfo instanceInfo = InstanceInfo.Builder.newBuilder() .setInstanceId("id") .setAppName("a") .setMetadata(metadata) .build(); Application application = new Application("a", Arrays.asList(instanceInfo)); Mockito.when(instanceRegistryMock.getSortedApplications()).thenReturn(Arrays.asList(application)); Mockito.when(objectMapperMock.readValue(json, SystemFragment.class)).thenReturn(SystemFragment.empty()); List<Snitch> result = registry.getAll(); Assertions.assertThat(result).hasSize(1); Snitch snitch = result.get(0); Assertions.assertThat(snitch.getUri()).isEqualTo(URI.create(uri)); Assertions.assertThat(snitch.snitch()).isEqualTo(SystemFragment.empty()); }
@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();  }