@Test public void testQueueOkaySize() throws Throwable { doReturn(getInsightFeed(1)).when(mockInsightClient).getObjects(anyList()); doReturn(new QueueResult<>().setSuccessful(true).setMessage("0")).when(mockReadyAgendaQueue).size(); queueMonitor.processResourcePool(RESOURCE_POOL_ID); verify(mockAgendaSchedulerFactory, times(0)).getAgendaScheduler(any(), any(), any()); }
public void processResourcePool(String resourcePoolId) throws Throwable { DataObjectResponse<Insight> insightObjectFeed = insightClient.getObjects(Collections.singletonList(new ByResourcePoolId(resourcePoolId))); if(insightObjectFeed.isError()) { logger.error("Error getting any insights by resourcePoolId: {}", resourcePoolId); return; } if(insightObjectFeed.getAll() == null || insightObjectFeed.getAll().size() == 0) { logger.info("No insights found for ResourcePool: {}", resourcePoolId); return; } for(Insight insight : insightObjectFeed.getAll()) { try { InsightScheduleInfo insightScheduleInfo = retrieveInsightSchedulingInfo(resourcePoolId, insight.getId()); processInsight(insight, insightScheduleInfo); insightScheduleInfo.setLastExecuted(new Date()); insightScheduleInfoPersister.persist(insightScheduleInfo); logger.info("Persisted update to InsightScheduleInfo: {}", insightScheduleInfo.getId()); } catch(Exception e) { logger.error("Failed to process ResourcePool: {} Insight: {}", resourcePoolId, insight.getId(), e); } } logger.info("Processed ResourcePool: {}", resourcePoolId); }
QueueMonitor { public void processResourcePool(String resourcePoolId) throws Throwable { DataObjectResponse<Insight> insightObjectFeed = insightClient.getObjects(Collections.singletonList(new ByResourcePoolId(resourcePoolId))); if(insightObjectFeed.isError()) { logger.error("Error getting any insights by resourcePoolId: {}", resourcePoolId); return; } if(insightObjectFeed.getAll() == null || insightObjectFeed.getAll().size() == 0) { logger.info("No insights found for ResourcePool: {}", resourcePoolId); return; } for(Insight insight : insightObjectFeed.getAll()) { try { InsightScheduleInfo insightScheduleInfo = retrieveInsightSchedulingInfo(resourcePoolId, insight.getId()); processInsight(insight, insightScheduleInfo); insightScheduleInfo.setLastExecuted(new Date()); insightScheduleInfoPersister.persist(insightScheduleInfo); logger.info("Persisted update to InsightScheduleInfo: {}", insightScheduleInfo.getId()); } catch(Exception e) { logger.error("Failed to process ResourcePool: {} Insight: {}", resourcePoolId, insight.getId(), e); } } logger.info("Processed ResourcePool: {}", resourcePoolId); } }
QueueMonitor { public void processResourcePool(String resourcePoolId) throws Throwable { DataObjectResponse<Insight> insightObjectFeed = insightClient.getObjects(Collections.singletonList(new ByResourcePoolId(resourcePoolId))); if(insightObjectFeed.isError()) { logger.error("Error getting any insights by resourcePoolId: {}", resourcePoolId); return; } if(insightObjectFeed.getAll() == null || insightObjectFeed.getAll().size() == 0) { logger.info("No insights found for ResourcePool: {}", resourcePoolId); return; } for(Insight insight : insightObjectFeed.getAll()) { try { InsightScheduleInfo insightScheduleInfo = retrieveInsightSchedulingInfo(resourcePoolId, insight.getId()); processInsight(insight, insightScheduleInfo); insightScheduleInfo.setLastExecuted(new Date()); insightScheduleInfoPersister.persist(insightScheduleInfo); logger.info("Persisted update to InsightScheduleInfo: {}", insightScheduleInfo.getId()); } catch(Exception e) { logger.error("Failed to process ResourcePool: {} Insight: {}", resourcePoolId, insight.getId(), e); } } logger.info("Processed ResourcePool: {}", resourcePoolId); } QueueMonitor(
        ItemQueueFactory<ReadyAgenda> readyAgendaQueueFactory,
        ObjectPersister<ReadyAgenda> readyAgendaPersister,
        ObjectClient<Insight> insightClient,
        ObjectClient<Customer> customerClient,
        ObjectPersister<InsightScheduleInfo> insightScheduleInfoPersister); }
QueueMonitor { public void processResourcePool(String resourcePoolId) throws Throwable { DataObjectResponse<Insight> insightObjectFeed = insightClient.getObjects(Collections.singletonList(new ByResourcePoolId(resourcePoolId))); if(insightObjectFeed.isError()) { logger.error("Error getting any insights by resourcePoolId: {}", resourcePoolId); return; } if(insightObjectFeed.getAll() == null || insightObjectFeed.getAll().size() == 0) { logger.info("No insights found for ResourcePool: {}", resourcePoolId); return; } for(Insight insight : insightObjectFeed.getAll()) { try { InsightScheduleInfo insightScheduleInfo = retrieveInsightSchedulingInfo(resourcePoolId, insight.getId()); processInsight(insight, insightScheduleInfo); insightScheduleInfo.setLastExecuted(new Date()); insightScheduleInfoPersister.persist(insightScheduleInfo); logger.info("Persisted update to InsightScheduleInfo: {}", insightScheduleInfo.getId()); } catch(Exception e) { logger.error("Failed to process ResourcePool: {} Insight: {}", resourcePoolId, insight.getId(), e); } } logger.info("Processed ResourcePool: {}", resourcePoolId); } QueueMonitor(
        ItemQueueFactory<ReadyAgenda> readyAgendaQueueFactory,
        ObjectPersister<ReadyAgenda> readyAgendaPersister,
        ObjectClient<Insight> insightClient,
        ObjectClient<Customer> customerClient,
        ObjectPersister<InsightScheduleInfo> insightScheduleInfoPersister); void processResourcePool(String resourcePoolId); void setAgendaSchedulerFactory(AgendaSchedulerFactory agendaSchedulerFactory); }
QueueMonitor { public void processResourcePool(String resourcePoolId) throws Throwable { DataObjectResponse<Insight> insightObjectFeed = insightClient.getObjects(Collections.singletonList(new ByResourcePoolId(resourcePoolId))); if(insightObjectFeed.isError()) { logger.error("Error getting any insights by resourcePoolId: {}", resourcePoolId); return; } if(insightObjectFeed.getAll() == null || insightObjectFeed.getAll().size() == 0) { logger.info("No insights found for ResourcePool: {}", resourcePoolId); return; } for(Insight insight : insightObjectFeed.getAll()) { try { InsightScheduleInfo insightScheduleInfo = retrieveInsightSchedulingInfo(resourcePoolId, insight.getId()); processInsight(insight, insightScheduleInfo); insightScheduleInfo.setLastExecuted(new Date()); insightScheduleInfoPersister.persist(insightScheduleInfo); logger.info("Persisted update to InsightScheduleInfo: {}", insightScheduleInfo.getId()); } catch(Exception e) { logger.error("Failed to process ResourcePool: {} Insight: {}", resourcePoolId, insight.getId(), e); } } logger.info("Processed ResourcePool: {}", resourcePoolId); } QueueMonitor(
        ItemQueueFactory<ReadyAgenda> readyAgendaQueueFactory,
        ObjectPersister<ReadyAgenda> readyAgendaPersister,
        ObjectClient<Insight> insightClient,
        ObjectClient<Customer> customerClient,
        ObjectPersister<InsightScheduleInfo> insightScheduleInfoPersister); void processResourcePool(String resourcePoolId); void setAgendaSchedulerFactory(AgendaSchedulerFactory agendaSchedulerFactory);  }