@Test public void testScheduleNoReadyAgendas() throws Throwable { doReturn(new DataObjectFeed<ReadyAgenda>()).when(mockReadyAgendaPersister).retrieve(anyList()); List<ReadyAgenda> readyAgendas = scheduler.schedule(1, insight, insightScheduleInfo); Assert.assertNotNull(readyAgendas); Assert.assertEquals(readyAgendas.size(), 0); }
@Override public List<ReadyAgenda> schedule(int requestCount, Insight insight, InsightScheduleInfo insightScheduleInfo) { DataObjectFeed<ReadyAgenda> readyAgendaFeed; try { readyAgendaFeed = readyAgendaPersister.retrieve(Arrays.asList(new ByInsightId(insight.getId()))); } catch(PersistenceException e) { logger.error("Failed to retrieve ReadyAgendas for queue.", e); return null; } if(readyAgendaFeed.isError()) { logger.error("ReadyAgenda feed returned with an error.", readyAgendaFeed.getException()); return null; } List<ReadyAgenda> readyAgendas = readyAgendaFeed.getAll(); List<ReadyAgenda> scheduledReadyAgendas = new ArrayList<>(); if(readyAgendas.size() > 0) { scheduledReadyAgendas = readyAgendas.subList(0, Math.min(requestCount, readyAgendas.size())); } logger.info("FIFO Result -- InsightId: {} Scheduled: {} Requested: {}", insight.getId(), scheduledReadyAgendas.size(), requestCount); return scheduledReadyAgendas; }
FIFOAgendaScheduler implements AgendaScheduler { @Override public List<ReadyAgenda> schedule(int requestCount, Insight insight, InsightScheduleInfo insightScheduleInfo) { DataObjectFeed<ReadyAgenda> readyAgendaFeed; try { readyAgendaFeed = readyAgendaPersister.retrieve(Arrays.asList(new ByInsightId(insight.getId()))); } catch(PersistenceException e) { logger.error("Failed to retrieve ReadyAgendas for queue.", e); return null; } if(readyAgendaFeed.isError()) { logger.error("ReadyAgenda feed returned with an error.", readyAgendaFeed.getException()); return null; } List<ReadyAgenda> readyAgendas = readyAgendaFeed.getAll(); List<ReadyAgenda> scheduledReadyAgendas = new ArrayList<>(); if(readyAgendas.size() > 0) { scheduledReadyAgendas = readyAgendas.subList(0, Math.min(requestCount, readyAgendas.size())); } logger.info("FIFO Result -- InsightId: {} Scheduled: {} Requested: {}", insight.getId(), scheduledReadyAgendas.size(), requestCount); return scheduledReadyAgendas; } }
FIFOAgendaScheduler implements AgendaScheduler { @Override public List<ReadyAgenda> schedule(int requestCount, Insight insight, InsightScheduleInfo insightScheduleInfo) { DataObjectFeed<ReadyAgenda> readyAgendaFeed; try { readyAgendaFeed = readyAgendaPersister.retrieve(Arrays.asList(new ByInsightId(insight.getId()))); } catch(PersistenceException e) { logger.error("Failed to retrieve ReadyAgendas for queue.", e); return null; } if(readyAgendaFeed.isError()) { logger.error("ReadyAgenda feed returned with an error.", readyAgendaFeed.getException()); return null; } List<ReadyAgenda> readyAgendas = readyAgendaFeed.getAll(); List<ReadyAgenda> scheduledReadyAgendas = new ArrayList<>(); if(readyAgendas.size() > 0) { scheduledReadyAgendas = readyAgendas.subList(0, Math.min(requestCount, readyAgendas.size())); } logger.info("FIFO Result -- InsightId: {} Scheduled: {} Requested: {}", insight.getId(), scheduledReadyAgendas.size(), requestCount); return scheduledReadyAgendas; } FIFOAgendaScheduler(ObjectPersister<ReadyAgenda> readyAgendaPersister); }
FIFOAgendaScheduler implements AgendaScheduler { @Override public List<ReadyAgenda> schedule(int requestCount, Insight insight, InsightScheduleInfo insightScheduleInfo) { DataObjectFeed<ReadyAgenda> readyAgendaFeed; try { readyAgendaFeed = readyAgendaPersister.retrieve(Arrays.asList(new ByInsightId(insight.getId()))); } catch(PersistenceException e) { logger.error("Failed to retrieve ReadyAgendas for queue.", e); return null; } if(readyAgendaFeed.isError()) { logger.error("ReadyAgenda feed returned with an error.", readyAgendaFeed.getException()); return null; } List<ReadyAgenda> readyAgendas = readyAgendaFeed.getAll(); List<ReadyAgenda> scheduledReadyAgendas = new ArrayList<>(); if(readyAgendas.size() > 0) { scheduledReadyAgendas = readyAgendas.subList(0, Math.min(requestCount, readyAgendas.size())); } logger.info("FIFO Result -- InsightId: {} Scheduled: {} Requested: {}", insight.getId(), scheduledReadyAgendas.size(), requestCount); return scheduledReadyAgendas; } FIFOAgendaScheduler(ObjectPersister<ReadyAgenda> readyAgendaPersister); @Override List<ReadyAgenda> schedule(int requestCount, Insight insight, InsightScheduleInfo insightScheduleInfo); }
FIFOAgendaScheduler implements AgendaScheduler { @Override public List<ReadyAgenda> schedule(int requestCount, Insight insight, InsightScheduleInfo insightScheduleInfo) { DataObjectFeed<ReadyAgenda> readyAgendaFeed; try { readyAgendaFeed = readyAgendaPersister.retrieve(Arrays.asList(new ByInsightId(insight.getId()))); } catch(PersistenceException e) { logger.error("Failed to retrieve ReadyAgendas for queue.", e); return null; } if(readyAgendaFeed.isError()) { logger.error("ReadyAgenda feed returned with an error.", readyAgendaFeed.getException()); return null; } List<ReadyAgenda> readyAgendas = readyAgendaFeed.getAll(); List<ReadyAgenda> scheduledReadyAgendas = new ArrayList<>(); if(readyAgendas.size() > 0) { scheduledReadyAgendas = readyAgendas.subList(0, Math.min(requestCount, readyAgendas.size())); } logger.info("FIFO Result -- InsightId: {} Scheduled: {} Requested: {}", insight.getId(), scheduledReadyAgendas.size(), requestCount); return scheduledReadyAgendas; } FIFOAgendaScheduler(ObjectPersister<ReadyAgenda> readyAgendaPersister); @Override List<ReadyAgenda> schedule(int requestCount, Insight insight, InsightScheduleInfo insightScheduleInfo);  }