@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()); }
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 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 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); }
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); }
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);  }