PartialHealthCheckStrategy implements HealthCheckStrategy { @Override public void updateCandidates(List<Endpoint> candidates) { requireNonNull(candidates, "candidates"); synchronized (selectedEndpoints) { this.candidates = ImmutableSet.copyOf(candidates); final Set<Endpoint> removedEndpoints = Sets.difference(selectedEndpoints, this.candidates); removeAndSelectNewEndpoints(removedEndpoints); } } PartialHealthCheckStrategy(EndpointLimitingFunction endpointLimitingFunction); @Override void updateCandidates(List<Endpoint> candidates); @Override List<Endpoint> getSelectedEndpoints(); @Override boolean updateHealth(Endpoint endpoint, double health);  }
@Test void updateCandidates() { final List<Endpoint> newCandidates = createCandidates(5); maxCountStrategy.updateCandidates(newCandidates); assertCandidates(maxCountStrategy.getSelectedEndpoints(), newCandidates); final List<Endpoint> someOfOldCandidates = candidatesForMaxCount.subList(0, 3); maxCountStrategy.updateCandidates(someOfOldCandidates); assertCandidates(maxCountStrategy.getSelectedEndpoints(), someOfOldCandidates); final List<Endpoint> mixedCandidates = Streams.concat(createCandidates(2).stream(), someOfOldCandidates.stream()) .collect(toImmutableList()); maxCountStrategy.updateCandidates(mixedCandidates); assertCandidates(maxCountStrategy.getSelectedEndpoints(), mixedCandidates); }