SimpleActionProcessor implements ActionProcessor { public Map<String, Object> execute(Action action, Object payloadObject, String event, String messageId) { logger.debug("Executing action: {} for event: {} with messageId:{}", action.getAction(), event, messageId); Object jsonObject = payloadObject; if (action.isExpandInlineJSON()) { jsonObject = jsonUtils.expand(payloadObject); } switch (action.getAction()) { case start_workflow: return startWorkflow(action, jsonObject, event, messageId); case complete_task: return completeTask(action, jsonObject, action.getComplete_task(), Status.COMPLETED, event, messageId); case fail_task: return completeTask(action, jsonObject, action.getFail_task(), Status.FAILED, event, messageId); default: break; } throw new UnsupportedOperationException("Action not supported " + action.getAction() + " for event " + event); } @Inject  SimpleActionProcessor(WorkflowExecutor executor, ParametersUtils parametersUtils, JsonUtils jsonUtils); Map<String, Object> execute(Action action, Object payloadObject, String event, String messageId);  }
@Test public void testCompleteTaskByTaskId() throws Exception { TaskDetails taskDetails = new TaskDetails(); taskDetails.setWorkflowId("${workflowId}"); taskDetails.setTaskId("${taskId}"); Action action = new Action(); action.setAction(Type.complete_task); action.setComplete_task(taskDetails); Object payload = objectMapper.readValue("{\"workflowId\":\"workflow_1\", \"taskId\":\"task_1\"}", Object.class); Task task = new Task(); task.setTaskId("task_1"); task.setReferenceTaskName("testTask"); when(workflowExecutor.getTask(eq("task_1"))).thenReturn(task); actionProcessor.execute(action, payload, "testEvent", "testMessage"); ArgumentCaptor<TaskResult> argumentCaptor = ArgumentCaptor.forClass(TaskResult.class); verify(workflowExecutor).updateTask(argumentCaptor.capture()); assertEquals(Status.COMPLETED, argumentCaptor.getValue().getStatus()); assertEquals("testMessage", argumentCaptor.getValue().getOutputData().get("conductor.event.messageId")); assertEquals("testEvent", argumentCaptor.getValue().getOutputData().get("conductor.event.name")); assertEquals("workflow_1", argumentCaptor.getValue().getOutputData().get("workflowId")); assertEquals("task_1", argumentCaptor.getValue().getOutputData().get("taskId")); }