### Question:
RoundRobinAgendaScheduler implements AgendaScheduler { protected PendingCustomersDecorator getPendingCustomerIds(InsightScheduleInfo insightScheduleInfo, Insight insight) { List<String> pendingCustomerIds; boolean fullSet = false; if(insightScheduleInfo.getPendingCustomerIds() == null || insightScheduleInfo.getPendingCustomerIds().size() == 0) { logger.info("No pending customers, attempting to generate a new set."); pendingCustomerIds = getAllCustomersForResourcePool(insight.getResourcePoolId()); fullSet = true; } else { pendingCustomerIds = new ArrayList<>(insightScheduleInfo.getPendingCustomerIds()); } logger.info("PendingCustomerIds size: {}", pendingCustomerIds == null ? 0 : pendingCustomerIds.size()); return new PendingCustomersDecorator(pendingCustomerIds, fullSet); } RoundRobinAgendaScheduler(ObjectPersister<ReadyAgenda> readyAgendaPersister, ObjectClient<Customer> customerClient); @Override List<ReadyAgenda> schedule(final int requestCount, Insight insight, InsightScheduleInfo insightScheduleInfo);  }### Answer:
@Test public void testGetPendingCustomerIdsNoPendingCustomers() throws Throwable { DataObjectResponse<Customer> customerFeed = new DefaultDataObjectResponse<>(); doReturn(customerFeed).when(mockCustomerClient).getObjects(anyList()); List<String> result = scheduler.getPendingCustomerIds(insightScheduleInfo, insight).getPendingCustomerIds(); Assert.assertEquals(result.size(), 0); verify(mockCustomerClient, times(1)).getObjects(anyList()); }
@Test public void testGetPendingCustomerIdsClientError() throws Throwable { DataObjectResponse<Customer> customerFeed = new DefaultDataObjectResponse<>(); customerFeed.setErrorResponse(new ErrorResponse()); doReturn(customerFeed).when(mockCustomerClient).getObjects(anyList()); List<String> result = scheduler.getPendingCustomerIds(insightScheduleInfo, insight).getPendingCustomerIds(); Assert.assertEquals(result.size(), 0); verify(mockCustomerClient, times(1)).getObjects(anyList()); }
@Test public void testGetPendingCustomerIdsClientSuccess() throws Throwable { List<String> customerIds = Arrays.asList("A", "B", "C"); DataObjectResponse<Customer> customerFeed = new DefaultDataObjectResponse<>(); customerFeed.addAll(customerIds.stream().map(this::createCustomer).collect(Collectors.toList())); doReturn(customerFeed).when(mockCustomerClient).getObjects(anyList()); List<String> result = scheduler.getPendingCustomerIds(insightScheduleInfo, insight).getPendingCustomerIds(); Assert.assertTrue(customerIds.containsAll(result)); Assert.assertEquals(customerIds.size(), result.size()); verify(mockCustomerClient, times(1)).getObjects(anyList()); }
@Test public void testGetPendingCustomerIdsWithPending() throws Throwable { List<String> customerIds = Arrays.asList("A", "B", "C"); insightScheduleInfo.setPendingCustomerIds(customerIds); List<String> result = scheduler.getPendingCustomerIds(insightScheduleInfo, insight).getPendingCustomerIds(); Assert.assertTrue(customerIds.containsAll(result)); Assert.assertEquals(customerIds.size(), result.size()); verify(mockCustomerClient, times(0)).getObjects(anyList()); }