SetVariableTaskMapper implements TaskMapper { @Override public List<Task> getMappedTasks(TaskMapperContext taskMapperContext) throws TerminateWorkflowException { LOGGER.debug("TaskMapperContext {} in SetVariableMapper", taskMapperContext); WorkflowTask taskToSchedule = taskMapperContext.getTaskToSchedule(); Workflow workflowInstance = taskMapperContext.getWorkflowInstance(); Map<String, Object> taskInput = taskMapperContext.getTaskInput(); String taskId = taskMapperContext.getTaskId(); Task varTask = new Task(); varTask.setTaskType(taskToSchedule.getType()); varTask.setTaskDefName(taskToSchedule.getName()); varTask.setReferenceTaskName(taskToSchedule.getTaskReferenceName()); varTask.setWorkflowInstanceId(workflowInstance.getWorkflowId()); varTask.setWorkflowType(workflowInstance.getWorkflowName()); varTask.setCorrelationId(workflowInstance.getCorrelationId()); varTask.setStartTime(System.currentTimeMillis()); varTask.setScheduledTime(System.currentTimeMillis()); varTask.setInputData(taskInput); varTask.setTaskId(taskId); varTask.setStatus(Task.Status.IN_PROGRESS); varTask.setWorkflowTask(taskToSchedule); varTask.setWorkflowPriority(workflowInstance.getPriority()); return Collections.singletonList(varTask); }  @Override List<Task> getMappedTasks(TaskMapperContext taskMapperContext); static final Logger LOGGER; }
@Test public void getMappedTasks() throws Exception { WorkflowTask taskToSchedule = new WorkflowTask(); taskToSchedule.setType(TaskType.TASK_TYPE_SET_VARIABLE); String taskId = IDGenerator.generate(); WorkflowDef workflowDef = new WorkflowDef(); Workflow workflow = new Workflow(); workflow.setWorkflowDefinition(workflowDef); TaskMapperContext taskMapperContext = TaskMapperContext.newBuilder() .withWorkflowDefinition(workflowDef) .withWorkflowInstance(workflow) .withTaskDefinition(new TaskDef()) .withTaskToSchedule(taskToSchedule) .withRetryCount(0) .withTaskId(taskId) .build(); List<Task> mappedTasks = new SetVariableTaskMapper().getMappedTasks(taskMapperContext); Assert.assertNotNull(mappedTasks); Assert.assertEquals(1, mappedTasks.size()); Assert.assertEquals(TaskType.TASK_TYPE_SET_VARIABLE, mappedTasks.get(0).getTaskType()); }