@Test(expectedExceptions = RuntimeException.class, expectedExceptionsMessageRegExp = ".*Error processing resource pool.*") public void testProcessingError() throws Throwable { doReturn("valid").when(mockEnvironmentFacade).getEnv(anyString()); doReturn(ENCRYPTED_PASS).when(mockEnvironmentLookupUtils).getEncryptedVarFromEnvironment(anyString()); doThrow(new Exception()).when(mockQueueMonitor).processResourcePool(anyString()); callHandleRequest(objectMapper.writeValueAsString(new ResourcePoolSchedulerRequest().setResourcePoolId("a").setStageId("b"))); }
private void processResourcePool(ResourcePoolSchedulerRequest request, String endpointURL) { String insightEndpointPath = getEnvironmentVar(ENV_INSIGHT_ENDPOINT_PATH); String customerEndpointPath = getEnvironmentVar(ENV_CUSTOMER_ENDPOINT_PATH); String insightSchedulingInfoTablePrefix = getEnvironmentVar(ENV_INSIGHT_SCHEDULING_INFO_TABLE); String readyAgendaTablePrefix = getEnvironmentVar(ENV_READY_AGENDA_TABLE); HttpObjectClient<Insight> insightClient = new HttpObjectClient<>( environmentLookupUtils.getAPIEndpointURL(endpointURL, request.getStageId(), insightEndpointPath), getHttpURLConnectionFactory(), Insight.class); HttpObjectClient<Customer> customerClient = new HttpObjectClient<>( environmentLookupUtils.getAPIEndpointURL(endpointURL, request.getStageId(), customerEndpointPath), getHttpURLConnectionFactory(), Customer.class); final String readyAgendaTableName = environmentLookupUtils.getTableName(readyAgendaTablePrefix, request.getStageId()); final String scheduleInfoTableName = environmentLookupUtils.getTableName(insightSchedulingInfoTablePrefix, request.getStageId()); logger.info("ReadyAgenda Table: {} ScheduleInfo Table: {}", readyAgendaTableName, scheduleInfoTableName); QueueMonitor queueMonitor = queueMonitorFactory.createQueueMonitor( readyAgendaQueueFactory, readyAgendaPersisterFactory.getObjectPersister(readyAgendaTableName), insightClient, customerClient, insightScheduleInfoPersisterFactory.getObjectPersister(scheduleInfoTableName)); try { queueMonitor.processResourcePool(request.getResourcePoolId()); } catch(Throwable t) { throw new RuntimeException(String.format("Error processing resource pool: %1$s ", request.getResourcePoolId()), t); } }
AWSLambdaStreamEntry implements RequestStreamHandler { private void processResourcePool(ResourcePoolSchedulerRequest request, String endpointURL) { String insightEndpointPath = getEnvironmentVar(ENV_INSIGHT_ENDPOINT_PATH); String customerEndpointPath = getEnvironmentVar(ENV_CUSTOMER_ENDPOINT_PATH); String insightSchedulingInfoTablePrefix = getEnvironmentVar(ENV_INSIGHT_SCHEDULING_INFO_TABLE); String readyAgendaTablePrefix = getEnvironmentVar(ENV_READY_AGENDA_TABLE); HttpObjectClient<Insight> insightClient = new HttpObjectClient<>( environmentLookupUtils.getAPIEndpointURL(endpointURL, request.getStageId(), insightEndpointPath), getHttpURLConnectionFactory(), Insight.class); HttpObjectClient<Customer> customerClient = new HttpObjectClient<>( environmentLookupUtils.getAPIEndpointURL(endpointURL, request.getStageId(), customerEndpointPath), getHttpURLConnectionFactory(), Customer.class); final String readyAgendaTableName = environmentLookupUtils.getTableName(readyAgendaTablePrefix, request.getStageId()); final String scheduleInfoTableName = environmentLookupUtils.getTableName(insightSchedulingInfoTablePrefix, request.getStageId()); logger.info("ReadyAgenda Table: {} ScheduleInfo Table: {}", readyAgendaTableName, scheduleInfoTableName); QueueMonitor queueMonitor = queueMonitorFactory.createQueueMonitor( readyAgendaQueueFactory, readyAgendaPersisterFactory.getObjectPersister(readyAgendaTableName), insightClient, customerClient, insightScheduleInfoPersisterFactory.getObjectPersister(scheduleInfoTableName)); try { queueMonitor.processResourcePool(request.getResourcePoolId()); } catch(Throwable t) { throw new RuntimeException(String.format("Error processing resource pool: %1$s ", request.getResourcePoolId()), t); } } }
AWSLambdaStreamEntry implements RequestStreamHandler { private void processResourcePool(ResourcePoolSchedulerRequest request, String endpointURL) { String insightEndpointPath = getEnvironmentVar(ENV_INSIGHT_ENDPOINT_PATH); String customerEndpointPath = getEnvironmentVar(ENV_CUSTOMER_ENDPOINT_PATH); String insightSchedulingInfoTablePrefix = getEnvironmentVar(ENV_INSIGHT_SCHEDULING_INFO_TABLE); String readyAgendaTablePrefix = getEnvironmentVar(ENV_READY_AGENDA_TABLE); HttpObjectClient<Insight> insightClient = new HttpObjectClient<>( environmentLookupUtils.getAPIEndpointURL(endpointURL, request.getStageId(), insightEndpointPath), getHttpURLConnectionFactory(), Insight.class); HttpObjectClient<Customer> customerClient = new HttpObjectClient<>( environmentLookupUtils.getAPIEndpointURL(endpointURL, request.getStageId(), customerEndpointPath), getHttpURLConnectionFactory(), Customer.class); final String readyAgendaTableName = environmentLookupUtils.getTableName(readyAgendaTablePrefix, request.getStageId()); final String scheduleInfoTableName = environmentLookupUtils.getTableName(insightSchedulingInfoTablePrefix, request.getStageId()); logger.info("ReadyAgenda Table: {} ScheduleInfo Table: {}", readyAgendaTableName, scheduleInfoTableName); QueueMonitor queueMonitor = queueMonitorFactory.createQueueMonitor( readyAgendaQueueFactory, readyAgendaPersisterFactory.getObjectPersister(readyAgendaTableName), insightClient, customerClient, insightScheduleInfoPersisterFactory.getObjectPersister(scheduleInfoTableName)); try { queueMonitor.processResourcePool(request.getResourcePoolId()); } catch(Throwable t) { throw new RuntimeException(String.format("Error processing resource pool: %1$s ", request.getResourcePoolId()), t); } } AWSLambdaStreamEntry();  AWSLambdaStreamEntry(
        ObjectPersisterFactory<InsightScheduleInfo> insightScheduleInfoPersisterFactory,
        ItemQueueFactory<ReadyAgenda> readyAgendaQueueFactory,
        ObjectPersisterFactory<ReadyAgenda> readyAgendaPersisterFactory
    ); }
AWSLambdaStreamEntry implements RequestStreamHandler { private void processResourcePool(ResourcePoolSchedulerRequest request, String endpointURL) { String insightEndpointPath = getEnvironmentVar(ENV_INSIGHT_ENDPOINT_PATH); String customerEndpointPath = getEnvironmentVar(ENV_CUSTOMER_ENDPOINT_PATH); String insightSchedulingInfoTablePrefix = getEnvironmentVar(ENV_INSIGHT_SCHEDULING_INFO_TABLE); String readyAgendaTablePrefix = getEnvironmentVar(ENV_READY_AGENDA_TABLE); HttpObjectClient<Insight> insightClient = new HttpObjectClient<>( environmentLookupUtils.getAPIEndpointURL(endpointURL, request.getStageId(), insightEndpointPath), getHttpURLConnectionFactory(), Insight.class); HttpObjectClient<Customer> customerClient = new HttpObjectClient<>( environmentLookupUtils.getAPIEndpointURL(endpointURL, request.getStageId(), customerEndpointPath), getHttpURLConnectionFactory(), Customer.class); final String readyAgendaTableName = environmentLookupUtils.getTableName(readyAgendaTablePrefix, request.getStageId()); final String scheduleInfoTableName = environmentLookupUtils.getTableName(insightSchedulingInfoTablePrefix, request.getStageId()); logger.info("ReadyAgenda Table: {} ScheduleInfo Table: {}", readyAgendaTableName, scheduleInfoTableName); QueueMonitor queueMonitor = queueMonitorFactory.createQueueMonitor( readyAgendaQueueFactory, readyAgendaPersisterFactory.getObjectPersister(readyAgendaTableName), insightClient, customerClient, insightScheduleInfoPersisterFactory.getObjectPersister(scheduleInfoTableName)); try { queueMonitor.processResourcePool(request.getResourcePoolId()); } catch(Throwable t) { throw new RuntimeException(String.format("Error processing resource pool: %1$s ", request.getResourcePoolId()), t); } } AWSLambdaStreamEntry();  AWSLambdaStreamEntry(
        ObjectPersisterFactory<InsightScheduleInfo> insightScheduleInfoPersisterFactory,
        ItemQueueFactory<ReadyAgenda> readyAgendaQueueFactory,
        ObjectPersisterFactory<ReadyAgenda> readyAgendaPersisterFactory
    ); void handleRequest(InputStream inputStream, OutputStream outputStream, Context context); void setEnvironmentFacade(EnvironmentFacade environmentFacade); void setEnvironmentLookupUtils(EnvironmentLookupUtils environmentLookupUtils); void setQueueMonitorFactory(QueueMonitorFactory queueMonitorFactory); }
AWSLambdaStreamEntry implements RequestStreamHandler { private void processResourcePool(ResourcePoolSchedulerRequest request, String endpointURL) { String insightEndpointPath = getEnvironmentVar(ENV_INSIGHT_ENDPOINT_PATH); String customerEndpointPath = getEnvironmentVar(ENV_CUSTOMER_ENDPOINT_PATH); String insightSchedulingInfoTablePrefix = getEnvironmentVar(ENV_INSIGHT_SCHEDULING_INFO_TABLE); String readyAgendaTablePrefix = getEnvironmentVar(ENV_READY_AGENDA_TABLE); HttpObjectClient<Insight> insightClient = new HttpObjectClient<>( environmentLookupUtils.getAPIEndpointURL(endpointURL, request.getStageId(), insightEndpointPath), getHttpURLConnectionFactory(), Insight.class); HttpObjectClient<Customer> customerClient = new HttpObjectClient<>( environmentLookupUtils.getAPIEndpointURL(endpointURL, request.getStageId(), customerEndpointPath), getHttpURLConnectionFactory(), Customer.class); final String readyAgendaTableName = environmentLookupUtils.getTableName(readyAgendaTablePrefix, request.getStageId()); final String scheduleInfoTableName = environmentLookupUtils.getTableName(insightSchedulingInfoTablePrefix, request.getStageId()); logger.info("ReadyAgenda Table: {} ScheduleInfo Table: {}", readyAgendaTableName, scheduleInfoTableName); QueueMonitor queueMonitor = queueMonitorFactory.createQueueMonitor( readyAgendaQueueFactory, readyAgendaPersisterFactory.getObjectPersister(readyAgendaTableName), insightClient, customerClient, insightScheduleInfoPersisterFactory.getObjectPersister(scheduleInfoTableName)); try { queueMonitor.processResourcePool(request.getResourcePoolId()); } catch(Throwable t) { throw new RuntimeException(String.format("Error processing resource pool: %1$s ", request.getResourcePoolId()), t); } } AWSLambdaStreamEntry();  AWSLambdaStreamEntry(
        ObjectPersisterFactory<InsightScheduleInfo> insightScheduleInfoPersisterFactory,
        ItemQueueFactory<ReadyAgenda> readyAgendaQueueFactory,
        ObjectPersisterFactory<ReadyAgenda> readyAgendaPersisterFactory
    ); void handleRequest(InputStream inputStream, OutputStream outputStream, Context context); void setEnvironmentFacade(EnvironmentFacade environmentFacade); void setEnvironmentLookupUtils(EnvironmentLookupUtils environmentLookupUtils); void setQueueMonitorFactory(QueueMonitorFactory queueMonitorFactory);  }