VespaServices { public List<VespaService> getMonitoringServices(String service) { if (service.equalsIgnoreCase(ALL_SERVICES)) return services; List<VespaService> myServices = new ArrayList<>(); for (VespaService s : services) { log.log(FINE, () -> "getMonitoringServices. service=" + service + ", checking against " + s + ", which has monitoring name " + s.getMonitoringName()); if (s.getMonitoringName().equalsIgnoreCase(service)) { myServices.add(s); } } return myServices; } @Inject  VespaServices(VespaServicesConfig config, MonitoringConfig monitoringConfig, ConfigSentinelClient sentinel); @VisibleForTesting  VespaServices(List<VespaService> services); final void updateServices(List<VespaService> services); List<VespaService> getVespaServices(); List<VespaService> getInstancesById(String id); List<VespaService> getMonitoringServices(String service); static final String ALL_SERVICES; }
@Test public void services_can_be_retrieved_from_monitoring_name() { List<VespaService> dummyServices = ImmutableList.of( new DummyService(0, "dummy/id/0"), new DummyService(1, "dummy/id/1")); VespaServices services = new VespaServices(dummyServices); assertThat(services.getMonitoringServices("vespa.dummy").size(), is(2)); }
@Test public void all_services_can_be_retrieved_by_using_special_name() { List<VespaService> dummyServices = ImmutableList.of( new DummyService(0, "dummy/id/0")); VespaServices services = new VespaServices(dummyServices); assertThat(services.getMonitoringServices(ALL_SERVICES).size(), is(1)); }