StandaloneAgentTracker { public void addAvailability(AgentAvailability availability) { cleanOutdatedAvailability(); availabilityMap.put(availability.getInstanceId(), availability); }  void addAvailability(AgentAvailability availability); AgentAvailability getAvailabilityForAgent(String instanceId); Collection<AgentAvailability> getAvailabilities(); @Nullable List<AgentAvailability> getAgents(int numUsers);  }
@Test @Tag(TestGroups.FUNCTIONAL) public void addAvailability() { for (int i = 0; i < 4; i++) { AgentAvailability a = new AgentAvailability("instance-id-" + i, "url", 500, AgentAvailabilityStatus.AVAILABLE); tracker.addAvailability(a); assertSame(a, tracker.getAvailabilityForAgent(a.getInstanceId())); } assertEquals(4, tracker.getAvailabilities().size()); List<AgentAvailability> agents = tracker.getAgents(1000); assertEquals(2, agents.size()); for (AgentAvailability a : agents) { assertEquals(AgentAvailabilityStatus.DELEGATING, a.getAvailabilityStatus()); } int availableAgents = 0; for (AgentAvailability a : tracker.getAvailabilities()) { if (a.getAvailabilityStatus() == AgentAvailabilityStatus.AVAILABLE) { availableAgents++; } } assertEquals(2, availableAgents); agents = tracker.getAgents(2000); assertNull(agents); }