### Question:
RoundRobinAgendaScheduler implements AgendaScheduler { @Override public List<ReadyAgenda> schedule(final int requestCount, Insight insight, InsightScheduleInfo insightScheduleInfo) { if(requestCount == 0) return null; PendingCustomersDecorator pendingCustomersDecorator = getPendingCustomerIds(insightScheduleInfo, insight); List<String> pendingCustomerIds = pendingCustomersDecorator.getPendingCustomerIds(); if(pendingCustomerIds == null || pendingCustomerIds.size() == 0) { logger.info("No pending customers for insightId: {} Exiting.", insight.getId()); return null; } List<ReadyAgenda> passOneScheduledReadyAgendas = new LinkedList<>(); Map<String, List<ReadyAgenda>> customerReadyAgendaMap = new HashMap<>(); List<ReadyAgenda> passTwoScheduledReadyAgendas = new LinkedList<>(); performSchedulingPass(pendingCustomerIds, insight, passOneScheduledReadyAgendas, customerReadyAgendaMap, requestCount); if(passOneScheduledReadyAgendas.size() >= requestCount) { pendingCustomerIds.removeAll( passOneScheduledReadyAgendas.stream().map(ReadyAgenda::getCustomerId).collect(Collectors.toList()) ); } else { final int passTwoRequestCount = requestCount - passOneScheduledReadyAgendas.size(); List<String> allCustomerIds = pendingCustomersDecorator.isFullSet() ? pendingCustomersDecorator.getPendingCustomerIds() : getAllCustomersForResourcePool(insight.getResourcePoolId()); while(true) { int beforeRoundSize = passTwoScheduledReadyAgendas.size(); performSchedulingPass(allCustomerIds, insight, passTwoScheduledReadyAgendas, customerReadyAgendaMap, passTwoRequestCount); if(passTwoScheduledReadyAgendas.size() >= passTwoRequestCount || beforeRoundSize == passTwoScheduledReadyAgendas.size()) break; } pendingCustomerIds = allCustomerIds; pendingCustomerIds.removeAll( passTwoScheduledReadyAgendas.stream().map(ReadyAgenda::getCustomerId).collect(Collectors.toList()) ); } List<ReadyAgenda> scheduledReadyAgendas = Stream.concat(passOneScheduledReadyAgendas.stream(), passTwoScheduledReadyAgendas.stream()) .collect(Collectors.toList()); insightScheduleInfo.setPendingCustomerIds(pendingCustomerIds); logger.info("RoundRobin Result -- InsightId: {} Scheduled: {} Requested: {} PendingCustomerIds: {}", insight.getId(), scheduledReadyAgendas.size(), requestCount, insightScheduleInfo.getPendingCustomerIds() == null ? null : insightScheduleInfo.getPendingCustomerIds().size()); return scheduledReadyAgendas; } RoundRobinAgendaScheduler(ObjectPersister<ReadyAgenda> readyAgendaPersister, ObjectClient<Customer> customerClient); @Override List<ReadyAgenda> schedule(final int requestCount, Insight insight, InsightScheduleInfo insightScheduleInfo);  }### Answer:
@Test public void testScheduleOneReadyAgenda() throws Throwable { final String EXPECTED_AGENDA_OWNER = "A"; List<String> customerIds = Arrays.asList(EXPECTED_AGENDA_OWNER, "B", "C"); insightScheduleInfo.setPendingCustomerIds(customerIds); doReturn(createReadyAgendaFeed(EXPECTED_AGENDA_OWNER)).when(mockReadyAgendaPersister).retrieve(anyList()); List<ReadyAgenda> readyAgendas = scheduler.schedule(1, insight, insightScheduleInfo); Assert.assertNotNull(readyAgendas); Assert.assertEquals(readyAgendas.size(), 1); Assert.assertEquals(EXPECTED_AGENDA_OWNER, readyAgendas.get(0).getCustomerId()); }