Search in sources :

Example 1 with WorkflowTask

use of com.netflix.conductor.common.metadata.workflow.WorkflowTask in project conductor by Netflix.

the class TaskTest method testDeepCopyTask.

@Test
public void testDeepCopyTask() {
    final Task task = new Task();
    // In order to avoid forgetting putting inside the copy method the newly added fields check the number of declared fields.
    final int expectedTaskFieldsNumber = 40;
    final int declaredFieldsNumber = task.getClass().getDeclaredFields().length;
    assertEquals(expectedTaskFieldsNumber, declaredFieldsNumber);
    task.setCallbackAfterSeconds(111L);
    task.setCallbackFromWorker(false);
    task.setCorrelationId("correlation_id");
    task.setInputData(new HashMap<>());
    task.setOutputData(new HashMap<>());
    task.setReferenceTaskName("ref_task_name");
    task.setStartDelayInSeconds(1);
    task.setTaskDefName("task_def_name");
    task.setTaskType("dummy_task_type");
    task.setWorkflowInstanceId("workflowInstanceId");
    task.setWorkflowType("workflowType");
    task.setResponseTimeoutSeconds(11L);
    task.setStatus(Status.COMPLETED);
    task.setRetryCount(0);
    task.setPollCount(0);
    task.setTaskId("taskId");
    task.setWorkflowTask(new WorkflowTask());
    task.setDomain("domain");
    task.setInputMessage(Any.getDefaultInstance());
    task.setOutputMessage(Any.getDefaultInstance());
    task.setRateLimitPerFrequency(11);
    task.setRateLimitFrequencyInSeconds(11);
    task.setExternalInputPayloadStoragePath("externalInputPayloadStoragePath");
    task.setExternalOutputPayloadStoragePath("externalOutputPayloadStoragePath");
    task.setWorkflowPriority(0);
    task.setIteration(1);
    task.setExecutionNameSpace("name_space");
    task.setIsolationGroupId("groupId");
    task.setStartTime(12L);
    task.setEndTime(20L);
    task.setScheduledTime(7L);
    task.setRetried(false);
    task.setReasonForIncompletion("");
    task.setWorkerId("");
    task.setSubWorkflowId("");
    final Task copy = task.deepCopy();
    assertEquals(task, copy);
}
Also used : Task(com.netflix.conductor.common.metadata.tasks.Task) WorkflowTask(com.netflix.conductor.common.metadata.workflow.WorkflowTask) WorkflowTask(com.netflix.conductor.common.metadata.workflow.WorkflowTask) Test(org.junit.Test)

Example 2 with WorkflowTask

use of com.netflix.conductor.common.metadata.workflow.WorkflowTask in project conductor by Netflix.

the class TaskTest method testTaskDefinitionIfAvailable.

@Test
public void testTaskDefinitionIfAvailable() {
    Task task = new Task();
    task.setStatus(Status.FAILED);
    assertEquals(Status.FAILED, task.getStatus());
    assertNull(task.getWorkflowTask());
    assertFalse(task.getTaskDefinition().isPresent());
    WorkflowTask workflowTask = new WorkflowTask();
    TaskDef taskDefinition = new TaskDef();
    workflowTask.setTaskDefinition(taskDefinition);
    task.setWorkflowTask(workflowTask);
    assertTrue(task.getTaskDefinition().isPresent());
    assertEquals(taskDefinition, task.getTaskDefinition().get());
}
Also used : Task(com.netflix.conductor.common.metadata.tasks.Task) WorkflowTask(com.netflix.conductor.common.metadata.workflow.WorkflowTask) TaskDef(com.netflix.conductor.common.metadata.tasks.TaskDef) WorkflowTask(com.netflix.conductor.common.metadata.workflow.WorkflowTask) Test(org.junit.Test)

Example 3 with WorkflowTask

use of com.netflix.conductor.common.metadata.workflow.WorkflowTask in project conductor by Netflix.

the class ConstraintParamUtilTest method testExtractParamPathComponentsWithValidMap.

@Test
public void testExtractParamPathComponentsWithValidMap() {
    WorkflowDef workflowDef = constructWorkflowDef();
    WorkflowTask workflowTask_1 = new WorkflowTask();
    workflowTask_1.setName("task_1");
    workflowTask_1.setTaskReferenceName("task_1");
    workflowTask_1.setType(TaskType.TASK_TYPE_SIMPLE);
    Map<String, Object> inputParam = new HashMap<>();
    inputParam.put("taskId", "${CPEWF_TASK_ID}  ${workflow.input.status}");
    Map<String, Object> envInputParam = new HashMap<>();
    envInputParam.put("packageId", "${workflow.input.packageId}");
    envInputParam.put("taskId", "${CPEWF_TASK_ID}");
    envInputParam.put("NETFLIX_STACK", "${NETFLIX_STACK}");
    envInputParam.put("NETFLIX_ENVIRONMENT", "${NETFLIX_ENVIRONMENT}");
    envInputParam.put("TEST_ENV", "${TEST_ENV}");
    inputParam.put("env", envInputParam);
    workflowTask_1.setInputParameters(inputParam);
    List<WorkflowTask> tasks = new ArrayList<>();
    tasks.add(workflowTask_1);
    workflowDef.setTasks(tasks);
    List<String> results = ConstraintParamUtil.validateInputParam(inputParam, "task_1", workflowDef);
    assertEquals(results.size(), 0);
}
Also used : WorkflowDef(com.netflix.conductor.common.metadata.workflow.WorkflowDef) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) WorkflowTask(com.netflix.conductor.common.metadata.workflow.WorkflowTask) Test(org.junit.Test)

Example 4 with WorkflowTask

use of com.netflix.conductor.common.metadata.workflow.WorkflowTask in project conductor by Netflix.

the class ConstraintParamUtilTest method testExtractParamPathComponentsWithValidEnvVariable.

@Test
public void testExtractParamPathComponentsWithValidEnvVariable() {
    WorkflowDef workflowDef = constructWorkflowDef();
    WorkflowTask workflowTask_1 = new WorkflowTask();
    workflowTask_1.setName("task_1");
    workflowTask_1.setTaskReferenceName("task_1");
    workflowTask_1.setType(TaskType.TASK_TYPE_SIMPLE);
    Map<String, Object> inputParam = new HashMap<>();
    inputParam.put("taskId", "${CPEWF_TASK_ID}  ${workflow.input.status}");
    workflowTask_1.setInputParameters(inputParam);
    List<WorkflowTask> tasks = new ArrayList<>();
    tasks.add(workflowTask_1);
    workflowDef.setTasks(tasks);
    List<String> results = ConstraintParamUtil.validateInputParam(inputParam, "task_1", workflowDef);
    assertEquals(results.size(), 0);
}
Also used : WorkflowDef(com.netflix.conductor.common.metadata.workflow.WorkflowDef) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) WorkflowTask(com.netflix.conductor.common.metadata.workflow.WorkflowTask) Test(org.junit.Test)

Example 5 with WorkflowTask

use of com.netflix.conductor.common.metadata.workflow.WorkflowTask in project conductor by Netflix.

the class ConstraintParamUtilTest method testExtractParamPathComponentsWithListInputParamWithEmptyString.

@Test
public void testExtractParamPathComponentsWithListInputParamWithEmptyString() {
    WorkflowDef workflowDef = constructWorkflowDef();
    WorkflowTask workflowTask_1 = new WorkflowTask();
    workflowTask_1.setName("task_1");
    workflowTask_1.setTaskReferenceName("task_1");
    workflowTask_1.setType(TaskType.TASK_TYPE_SIMPLE);
    Map<String, Object> inputParam = new HashMap<>();
    inputParam.put("taskId", new String[] { "" });
    workflowTask_1.setInputParameters(inputParam);
    List<WorkflowTask> tasks = new ArrayList<>();
    tasks.add(workflowTask_1);
    workflowDef.setTasks(tasks);
    List<String> results = ConstraintParamUtil.validateInputParam(inputParam, "task_1", workflowDef);
    assertEquals(results.size(), 0);
}
Also used : WorkflowDef(com.netflix.conductor.common.metadata.workflow.WorkflowDef) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) WorkflowTask(com.netflix.conductor.common.metadata.workflow.WorkflowTask) Test(org.junit.Test)

Aggregations

WorkflowTask (com.netflix.conductor.common.metadata.workflow.WorkflowTask)240 Test (org.junit.Test)166 WorkflowDef (com.netflix.conductor.common.metadata.workflow.WorkflowDef)147 TaskDef (com.netflix.conductor.common.metadata.tasks.TaskDef)106 Workflow (com.netflix.conductor.common.run.Workflow)106 HashMap (java.util.HashMap)102 Task (com.netflix.conductor.common.metadata.tasks.Task)98 ArrayList (java.util.ArrayList)51 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)44 ConstraintViolation (javax.validation.ConstraintViolation)41 LinkedList (java.util.LinkedList)40 List (java.util.List)33 SubWorkflow (com.netflix.conductor.core.execution.tasks.SubWorkflow)32 Map (java.util.Map)25 SubWorkflowParams (com.netflix.conductor.common.metadata.workflow.SubWorkflowParams)24 DynamicForkJoinTaskList (com.netflix.conductor.common.metadata.workflow.DynamicForkJoinTaskList)18 WorkflowSystemTask (com.netflix.conductor.core.execution.tasks.WorkflowSystemTask)14 UserTask (com.netflix.conductor.tests.utils.UserTask)14 ValidatorFactory (javax.validation.ValidatorFactory)13 VisibleForTesting (com.google.common.annotations.VisibleForTesting)11