SubWorkflowTaskMapper implements TaskMapper { @VisibleForTesting SubWorkflowParams getSubWorkflowParams(WorkflowTask taskToSchedule) { return Optional.ofNullable(taskToSchedule.getSubWorkflowParam()) .orElseThrow(() -> { String reason = String.format("Task %s is defined as sub-workflow and is missing subWorkflowParams. " + "Please check the blueprint", taskToSchedule.getName()); logger.error(reason); return new TerminateWorkflowException(reason); }); } @Inject  SubWorkflowTaskMapper(ParametersUtils parametersUtils, MetadataDAO metadataDAO); @Override List<Task> getMappedTasks(TaskMapperContext taskMapperContext);  }
@Test public void getSubWorkflowParams() { WorkflowTask workflowTask = new WorkflowTask(); SubWorkflowParams subWorkflowParams = new SubWorkflowParams(); subWorkflowParams.setName("Foo"); subWorkflowParams.setVersion(2); workflowTask.setSubWorkflowParam(subWorkflowParams); assertEquals(subWorkflowParams, subWorkflowTaskMapper.getSubWorkflowParams(workflowTask)); }
@Test public void getExceptionWhenNoSubWorkflowParamsPassed() { WorkflowTask workflowTask = new WorkflowTask(); workflowTask.setName("FooWorkFLow"); expectedException.expect(TerminateWorkflowException.class); expectedException.expectMessage(String.format("Task %s is defined as sub-workflow and is missing subWorkflowParams. " + "Please check the blueprint", workflowTask.getName())); subWorkflowTaskMapper.getSubWorkflowParams(workflowTask); }