DeciderService { @VisibleForTesting Workflow populateWorkflowAndTaskData(Workflow workflow) { Workflow workflowInstance = workflow.copy(); if (StringUtils.isNotBlank(workflow.getExternalInputPayloadStoragePath())) { Map<String, Object> workflowInputParams = externalPayloadStorageUtils.downloadPayload(workflow.getExternalInputPayloadStoragePath()); Monitors.recordExternalPayloadStorageUsage(workflow.getWorkflowName(), Operation.READ.toString(), PayloadType.WORKFLOW_INPUT.toString()); workflowInstance.setInput(workflowInputParams); workflowInstance.setExternalInputPayloadStoragePath(null); } workflowInstance.getTasks().stream() .filter(task -> StringUtils.isNotBlank(task.getExternalInputPayloadStoragePath()) || StringUtils.isNotBlank(task.getExternalOutputPayloadStoragePath())) .forEach(this::populateTaskData); return workflowInstance; } @Inject  DeciderService(ParametersUtils parametersUtils, MetadataDAO metadataDAO,
                          ExternalPayloadStorageUtils externalPayloadStorageUtils,
                          @Named("TaskMappers") Map<String, TaskMapper> taskMappers, Configuration configuration); DeciderOutcome decide(Workflow workflow); List<Task> getTasksToBeScheduled(Workflow workflow,
                                            WorkflowTask taskToSchedule, int retryCount); List<Task> getTasksToBeScheduled(Workflow workflow,
                                            WorkflowTask taskToSchedule, int retryCount, String retriedTaskId);  }
@Test public void testPopulateWorkflowAndTaskData() { String workflowInputPath = "workflow/input/test.json"; String taskInputPath = "task/input/test.json"; String taskOutputPath = "task/output/test.json"; Map<String, Object> workflowParams = new HashMap<>(); workflowParams.put("key1", "value1"); workflowParams.put("key2", 100); when(externalPayloadStorageUtils.downloadPayload(workflowInputPath)).thenReturn(workflowParams); Map<String, Object> taskInputParams = new HashMap<>(); taskInputParams.put("key", "taskInput"); when(externalPayloadStorageUtils.downloadPayload(taskInputPath)).thenReturn(taskInputParams); Map<String, Object> taskOutputParams = new HashMap<>(); taskOutputParams.put("key", "taskOutput"); when(externalPayloadStorageUtils.downloadPayload(taskOutputPath)).thenReturn(taskOutputParams); Task task = new Task(); task.setExternalInputPayloadStoragePath(taskInputPath); task.setExternalOutputPayloadStoragePath(taskOutputPath); Workflow workflow = new Workflow(); workflow.setExternalInputPayloadStoragePath(workflowInputPath); workflow.getTasks().add(task); Workflow workflowInstance = deciderService.populateWorkflowAndTaskData(workflow); assertNotNull(workflowInstance); assertTrue(workflow.getInput().isEmpty()); assertNotNull(workflowInstance.getInput()); assertEquals(workflowParams, workflowInstance.getInput()); assertTrue(workflow.getTasks().get(0).getInputData().isEmpty()); assertNotNull(workflowInstance.getTasks().get(0).getInputData()); assertEquals(taskInputParams, workflowInstance.getTasks().get(0).getInputData()); assertTrue(workflow.getTasks().get(0).getOutputData().isEmpty()); assertNotNull(workflowInstance.getTasks().get(0).getOutputData()); assertEquals(taskOutputParams, workflowInstance.getTasks().get(0).getOutputData()); assertNull(workflowInstance.getExternalInputPayloadStoragePath()); assertNull(workflowInstance.getTasks().get(0).getExternalInputPayloadStoragePath()); assertNull(workflowInstance.getTasks().get(0).getExternalOutputPayloadStoragePath()); }