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);
}
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());
}
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);
}
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);
}
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);
}
Aggregations