use of com.netflix.conductor.core.execution.ParametersUtils 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