Search in sources :

Example 11 with WorkflowTask

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

the class WorkflowDefValidatorTest method testWorkflowDefConstraintsWithMultipleEnvVariable.

@Test
public void testWorkflowDefConstraintsWithMultipleEnvVariable() {
    WorkflowDef workflowDef = new WorkflowDef();
    workflowDef.setSchemaVersion(2);
    workflowDef.setName("test_env");
    workflowDef.setOwnerEmail("owner@test.com");
    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}");
    inputParam.put("entryPoint", "${NETFLIX_ENVIRONMENT} ${NETFLIX_STACK} ${CPEWF_TASK_ID} ${workflow.input.status}");
    workflowTask_1.setInputParameters(inputParam);
    WorkflowTask workflowTask_2 = new WorkflowTask();
    workflowTask_2.setName("task_2");
    workflowTask_2.setTaskReferenceName("task_2");
    workflowTask_2.setType(TaskType.TASK_TYPE_SIMPLE);
    Map<String, Object> inputParam2 = new HashMap<>();
    inputParam2.put("env", inputParam);
    workflowTask_2.setInputParameters(inputParam2);
    List<WorkflowTask> tasks = new ArrayList<>();
    tasks.add(workflowTask_1);
    tasks.add(workflowTask_2);
    workflowDef.setTasks(tasks);
    ValidatorFactory factory = Validation.buildDefaultValidatorFactory();
    Validator validator = factory.getValidator();
    Set<ConstraintViolation<Object>> result = validator.validate(workflowDef);
    assertEquals(0, result.size());
}
Also used : WorkflowDef(com.netflix.conductor.common.metadata.workflow.WorkflowDef) ValidatorFactory(javax.validation.ValidatorFactory) HashMap(java.util.HashMap) ConstraintViolation(javax.validation.ConstraintViolation) ArrayList(java.util.ArrayList) WorkflowTask(com.netflix.conductor.common.metadata.workflow.WorkflowTask) Validator(javax.validation.Validator) Test(org.junit.Test)

Example 12 with WorkflowTask

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

the class WorkflowDefValidatorTest method testWorkflowDefConstraintsDualEnvVariable.

@Test
public void testWorkflowDefConstraintsDualEnvVariable() {
    // name is null
    WorkflowDef workflowDef = new WorkflowDef();
    workflowDef.setSchemaVersion(2);
    workflowDef.setName("test_env");
    workflowDef.setOwnerEmail("owner@test.com");
    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} ${NETFLIX_STACK}");
    workflowTask_1.setInputParameters(inputParam);
    List<WorkflowTask> tasks = new ArrayList<>();
    tasks.add(workflowTask_1);
    workflowDef.setTasks(tasks);
    ValidatorFactory factory = Validation.buildDefaultValidatorFactory();
    Validator validator = factory.getValidator();
    Set<ConstraintViolation<Object>> result = validator.validate(workflowDef);
    assertEquals(0, result.size());
}
Also used : WorkflowDef(com.netflix.conductor.common.metadata.workflow.WorkflowDef) ValidatorFactory(javax.validation.ValidatorFactory) HashMap(java.util.HashMap) ConstraintViolation(javax.validation.ConstraintViolation) ArrayList(java.util.ArrayList) WorkflowTask(com.netflix.conductor.common.metadata.workflow.WorkflowTask) Validator(javax.validation.Validator) Test(org.junit.Test)

Example 13 with WorkflowTask

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

the class WorkflowDefValidatorTest method testWorkflowOwnerValidEmail.

@Test
public void testWorkflowOwnerValidEmail() {
    WorkflowDef workflowDef = new WorkflowDef();
    workflowDef.setName("test_env");
    workflowDef.setOwnerEmail("owner@test.com");
    WorkflowTask workflowTask = new WorkflowTask();
    workflowTask.setName("t1");
    workflowTask.setWorkflowTaskType(TaskType.SIMPLE);
    workflowTask.setTaskReferenceName("t1");
    Map<String, Object> map = new HashMap<>();
    map.put("blabla", "");
    workflowTask.setInputParameters(map);
    workflowDef.getTasks().add(workflowTask);
    ValidatorFactory factory = Validation.buildDefaultValidatorFactory();
    Validator validator = factory.getValidator();
    Set<ConstraintViolation<Object>> result = validator.validate(workflowDef);
    assertEquals(0, result.size());
}
Also used : WorkflowDef(com.netflix.conductor.common.metadata.workflow.WorkflowDef) ValidatorFactory(javax.validation.ValidatorFactory) HashMap(java.util.HashMap) ConstraintViolation(javax.validation.ConstraintViolation) WorkflowTask(com.netflix.conductor.common.metadata.workflow.WorkflowTask) Validator(javax.validation.Validator) Test(org.junit.Test)

Example 14 with WorkflowTask

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

the class WorkflowTaskTest method testOptional.

@Test
public void testOptional() {
    WorkflowTask task = new WorkflowTask();
    assertFalse(task.isOptional());
    task.setOptional(Boolean.FALSE);
    assertFalse(task.isOptional());
    task.setOptional(Boolean.TRUE);
    assertTrue(task.isOptional());
}
Also used : WorkflowTask(com.netflix.conductor.common.metadata.workflow.WorkflowTask) Test(org.junit.Test)

Example 15 with WorkflowTask

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

the class Task method copy.

public Task copy() {
    Task copy = new Task();
    copy.setCallbackAfterSeconds(callbackAfterSeconds);
    copy.setCallbackFromWorker(callbackFromWorker);
    copy.setCorrelationId(correlationId);
    copy.setInputData(inputData);
    copy.setOutputData(outputData);
    copy.setReferenceTaskName(referenceTaskName);
    copy.setStartDelayInSeconds(startDelayInSeconds);
    copy.setTaskDefName(taskDefName);
    copy.setTaskType(taskType);
    copy.setWorkflowInstanceId(workflowInstanceId);
    copy.setWorkflowType(workflowType);
    copy.setResponseTimeoutSeconds(responseTimeoutSeconds);
    copy.setStatus(status);
    copy.setRetryCount(retryCount);
    copy.setPollCount(pollCount);
    copy.setTaskId(taskId);
    copy.setWorkflowTask(workflowTask);
    copy.setDomain(domain);
    copy.setInputMessage(inputMessage);
    copy.setOutputMessage(outputMessage);
    copy.setRateLimitPerFrequency(rateLimitPerFrequency);
    copy.setRateLimitFrequencyInSeconds(rateLimitFrequencyInSeconds);
    copy.setExternalInputPayloadStoragePath(externalInputPayloadStoragePath);
    copy.setExternalOutputPayloadStoragePath(externalOutputPayloadStoragePath);
    copy.setWorkflowPriority(workflowPriority);
    copy.setIteration(iteration);
    copy.setExecutionNameSpace(executionNameSpace);
    copy.setIsolationGroupId(isolationGroupId);
    copy.setSubWorkflowId(getSubWorkflowId());
    return copy;
}
Also used : WorkflowTask(com.netflix.conductor.common.metadata.workflow.WorkflowTask)

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