JoinTaskMapper implements TaskMapper { @Override public List<Task> getMappedTasks(TaskMapperContext taskMapperContext) { logger.debug("TaskMapperContext {} in JoinTaskMapper", taskMapperContext); WorkflowTask taskToSchedule = taskMapperContext.getTaskToSchedule(); Workflow workflowInstance = taskMapperContext.getWorkflowInstance(); String taskId = taskMapperContext.getTaskId(); Map<String, Object> joinInput = new HashMap<>(); joinInput.put("joinOn", taskToSchedule.getJoinOn()); Task joinTask = new Task(); joinTask.setTaskType(SystemTaskType.JOIN.name()); joinTask.setTaskDefName(SystemTaskType.JOIN.name()); joinTask.setReferenceTaskName(taskToSchedule.getTaskReferenceName()); joinTask.setWorkflowInstanceId(workflowInstance.getWorkflowId()); joinTask.setCorrelationId(workflowInstance.getCorrelationId()); joinTask.setWorkflowType(workflowInstance.getWorkflowName()); joinTask.setScheduledTime(System.currentTimeMillis()); joinTask.setStartTime(System.currentTimeMillis()); joinTask.setInputData(joinInput); joinTask.setTaskId(taskId); joinTask.setStatus(Task.Status.IN_PROGRESS); joinTask.setWorkflowTask(taskToSchedule); joinTask.setWorkflowPriority(workflowInstance.getPriority()); return Collections.singletonList(joinTask); }  @Override List<Task> getMappedTasks(TaskMapperContext taskMapperContext); static final Logger logger; }
@Test public void getMappedTasks() throws Exception { WorkflowTask taskToSchedule = new WorkflowTask(); taskToSchedule.setType(TaskType.JOIN.name()); taskToSchedule.setJoinOn(Arrays.asList("task1", "task2")); String taskId = IDGenerator.generate(); WorkflowDef wd = new WorkflowDef(); Workflow w = new Workflow(); w.setWorkflowDefinition(wd); TaskMapperContext taskMapperContext = TaskMapperContext.newBuilder() .withWorkflowDefinition(wd) .withWorkflowInstance(w) .withTaskDefinition(new TaskDef()) .withTaskToSchedule(taskToSchedule) .withRetryCount(0) .withTaskId(taskId) .build(); List<Task> mappedTasks = new JoinTaskMapper().getMappedTasks(taskMapperContext); assertNotNull(mappedTasks); assertEquals(SystemTaskType.JOIN.name(), mappedTasks.get(0).getTaskType()); }