Search in sources :

Example 11 with ParametersUtils

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());
}
Also used : Task(com.netflix.conductor.common.metadata.tasks.Task) WorkflowTask(com.netflix.conductor.common.metadata.workflow.WorkflowTask) WorkflowDef(com.netflix.conductor.common.metadata.workflow.WorkflowDef) Configuration(com.netflix.conductor.core.config.Configuration) HashMap(java.util.HashMap) DeciderService(com.netflix.conductor.core.execution.DeciderService) Workflow(com.netflix.conductor.common.run.Workflow) ExternalPayloadStorageUtils(com.netflix.conductor.core.utils.ExternalPayloadStorageUtils) WorkflowTask(com.netflix.conductor.common.metadata.workflow.WorkflowTask) Input(com.netflix.conductor.contribs.http.HttpTask.Input) ParametersUtils(com.netflix.conductor.core.execution.ParametersUtils) MetadataDAO(com.netflix.conductor.dao.MetadataDAO) TaskMapper(com.netflix.conductor.core.execution.mapper.TaskMapper) Test(org.junit.Test)

Aggregations

ParametersUtils (com.netflix.conductor.core.execution.ParametersUtils)11 HashMap (java.util.HashMap)10 Task (com.netflix.conductor.common.metadata.tasks.Task)8 WorkflowDef (com.netflix.conductor.common.metadata.workflow.WorkflowDef)8 Workflow (com.netflix.conductor.common.run.Workflow)8 Before (org.junit.Before)8 Test (org.junit.Test)7 WorkflowTask (com.netflix.conductor.common.metadata.workflow.WorkflowTask)5 Message (com.netflix.conductor.core.events.queue.Message)5 ObservableQueue (com.netflix.conductor.core.events.queue.ObservableQueue)5 Map (java.util.Map)5 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)4 JsonMapperProvider (com.netflix.conductor.common.utils.JsonMapperProvider)4 TestConfiguration (com.netflix.conductor.core.execution.TestConfiguration)4 Collections (java.util.Collections)4 Assert.assertEquals (org.junit.Assert.assertEquals)4 Assert.assertNotNull (org.junit.Assert.assertNotNull)4 Assert.assertNull (org.junit.Assert.assertNull)4 Assert.assertTrue (org.junit.Assert.assertTrue)4 ArgumentMatchers.any (org.mockito.ArgumentMatchers.any)4