use of com.netflix.conductor.core.execution.mapper.TaskMapper in project conductor by Netflix.
the class TestWorkflowExecutor method init.
@Before
public void init() {
TestConfiguration config = new TestConfiguration();
executionDAOFacade = mock(ExecutionDAOFacade.class);
metadataDAO = mock(MetadataDAO.class);
queueDAO = mock(QueueDAO.class);
workflowStatusListener = mock(WorkflowStatusListener.class);
ExternalPayloadStorageUtils externalPayloadStorageUtils = mock(ExternalPayloadStorageUtils.class);
executionLockService = mock(ExecutionLockService.class);
ObjectMapper objectMapper = new JsonMapperProvider().get();
ParametersUtils parametersUtils = new ParametersUtils();
Map<String, TaskMapper> taskMappers = new HashMap<>();
taskMappers.put("DECISION", new DecisionTaskMapper());
taskMappers.put("DYNAMIC", new DynamicTaskMapper(parametersUtils, metadataDAO));
taskMappers.put("FORK_JOIN", new ForkJoinTaskMapper());
taskMappers.put("JOIN", new JoinTaskMapper());
taskMappers.put("FORK_JOIN_DYNAMIC", new ForkJoinDynamicTaskMapper(parametersUtils, objectMapper, metadataDAO));
taskMappers.put("USER_DEFINED", new UserDefinedTaskMapper(parametersUtils, metadataDAO));
taskMappers.put("SIMPLE", new SimpleTaskMapper(parametersUtils));
taskMappers.put("SUB_WORKFLOW", new SubWorkflowTaskMapper(parametersUtils, metadataDAO));
taskMappers.put("EVENT", new EventTaskMapper(parametersUtils));
taskMappers.put("WAIT", new WaitTaskMapper(parametersUtils));
taskMappers.put("HTTP", new HTTPTaskMapper(parametersUtils, metadataDAO));
taskMappers.put("LAMBDA", new LambdaTaskMapper(parametersUtils, metadataDAO));
new SubWorkflow(new JsonMapperProvider().get());
new Lambda();
DeciderService deciderService = new DeciderService(parametersUtils, metadataDAO, externalPayloadStorageUtils, taskMappers, config);
MetadataMapperService metadataMapperService = new MetadataMapperService(metadataDAO);
workflowExecutor = new WorkflowExecutor(deciderService, metadataDAO, queueDAO, metadataMapperService, workflowStatusListener, executionDAOFacade, config, executionLockService, parametersUtils);
}
use of com.netflix.conductor.core.execution.mapper.TaskMapper in project conductor by Netflix.
the class TestDeciderOutcomes method init.
@Before
public void init() {
MetadataDAO metadataDAO = mock(MetadataDAO.class);
ExternalPayloadStorageUtils externalPayloadStorageUtils = mock(ExternalPayloadStorageUtils.class);
Configuration configuration = mock(Configuration.class);
when(configuration.getTaskInputPayloadSizeThresholdKB()).thenReturn(10L);
when(configuration.getMaxTaskInputPayloadSizeThresholdKB()).thenReturn(10240L);
TaskDef taskDef = new TaskDef();
taskDef.setRetryCount(1);
taskDef.setName("mockTaskDef");
taskDef.setResponseTimeoutSeconds(60 * 60);
when(metadataDAO.getTaskDef(anyString())).thenReturn(taskDef);
ParametersUtils parametersUtils = new ParametersUtils();
Map<String, TaskMapper> taskMappers = new HashMap<>();
taskMappers.put("DECISION", new DecisionTaskMapper());
taskMappers.put("DYNAMIC", new DynamicTaskMapper(parametersUtils, metadataDAO));
taskMappers.put("FORK_JOIN", new ForkJoinTaskMapper());
taskMappers.put("JOIN", new JoinTaskMapper());
taskMappers.put("FORK_JOIN_DYNAMIC", new ForkJoinDynamicTaskMapper(parametersUtils, objectMapper, metadataDAO));
taskMappers.put("USER_DEFINED", new UserDefinedTaskMapper(parametersUtils, metadataDAO));
taskMappers.put("SIMPLE", new SimpleTaskMapper(parametersUtils));
taskMappers.put("SUB_WORKFLOW", new SubWorkflowTaskMapper(parametersUtils, metadataDAO));
taskMappers.put("EVENT", new EventTaskMapper(parametersUtils));
taskMappers.put("WAIT", new WaitTaskMapper(parametersUtils));
taskMappers.put("HTTP", new HTTPTaskMapper(parametersUtils, metadataDAO));
this.deciderService = new DeciderService(parametersUtils, metadataDAO, externalPayloadStorageUtils, taskMappers, configuration);
}
use of com.netflix.conductor.core.execution.mapper.TaskMapper in project conductor by Netflix.
the class TestHttpTask method testOptional.
@Test
public void testOptional() {
Task task = new Task();
Input input = new Input();
input.setUri("http://localhost:7009/failure");
input.setMethod("GET");
task.getInputData().put(HttpTask.REQUEST_PARAMETER_NAME, input);
httpTask.start(workflow, task, workflowExecutor);
assertEquals("Task output: " + task.getOutputData(), Task.Status.FAILED, task.getStatus());
assertEquals(ERROR_RESPONSE, task.getReasonForIncompletion());
assertTrue(!task.getStatus().isSuccessful());
task.setStatus(Status.SCHEDULED);
task.getInputData().remove(HttpTask.REQUEST_PARAMETER_NAME);
task.setReferenceTaskName("t1");
httpTask.start(workflow, task, workflowExecutor);
assertEquals(Task.Status.FAILED, task.getStatus());
assertEquals(HttpTask.MISSING_REQUEST, task.getReasonForIncompletion());
assertTrue(!task.getStatus().isSuccessful());
WorkflowTask workflowTask = new WorkflowTask();
workflowTask.setOptional(true);
workflowTask.setName("HTTP");
workflowTask.setWorkflowTaskType(TaskType.USER_DEFINED);
workflowTask.setTaskReferenceName("t1");
WorkflowDef def = new WorkflowDef();
def.getTasks().add(workflowTask);
Workflow workflow = new Workflow();
workflow.setWorkflowDefinition(def);
workflow.getTasks().add(task);
MetadataDAO metadataDAO = mock(MetadataDAO.class);
ExternalPayloadStorageUtils externalPayloadStorageUtils = mock(ExternalPayloadStorageUtils.class);
ParametersUtils parametersUtils = mock(ParametersUtils.class);
Configuration configuration = mock(Configuration.class);
Map<String, TaskMapper> taskMappers = new HashMap<>();
new DeciderService(parametersUtils, metadataDAO, externalPayloadStorageUtils, taskMappers, configuration).decide(workflow);
System.out.println(workflow.getTasks());
System.out.println(workflow.getStatus());
}
Aggregations