Search in sources :

Example 1 with WorkflowDef

use of com.netflix.conductor.common.metadata.workflow.WorkflowDef 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 2 with WorkflowDef

use of com.netflix.conductor.common.metadata.workflow.WorkflowDef 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 3 with WorkflowDef

use of com.netflix.conductor.common.metadata.workflow.WorkflowDef 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)

Example 4 with WorkflowDef

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

the class ConstraintParamUtilTest method testExtractParamPathComponentsWithInvalidEnv.

@Test
public void testExtractParamPathComponentsWithInvalidEnv() {
    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("TEST_ENV1", "${TEST_ENV1}");
    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(), 1);
}
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 WorkflowDef

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

the class ConstraintParamUtilTest method testExtractParamPathComponentsWithMissingEnvVariable.

@Test
public void testExtractParamPathComponentsWithMissingEnvVariable() {
    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} ${NETFLIX_STACK}");
    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

WorkflowDef (com.netflix.conductor.common.metadata.workflow.WorkflowDef)246 Test (org.junit.Test)185 WorkflowTask (com.netflix.conductor.common.metadata.workflow.WorkflowTask)172 Workflow (com.netflix.conductor.common.run.Workflow)128 HashMap (java.util.HashMap)122 Task (com.netflix.conductor.common.metadata.tasks.Task)100 TaskDef (com.netflix.conductor.common.metadata.tasks.TaskDef)71 SubWorkflow (com.netflix.conductor.core.execution.tasks.SubWorkflow)49 ArrayList (java.util.ArrayList)42 LinkedList (java.util.LinkedList)37 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)35 List (java.util.List)33 UserTask (com.netflix.conductor.tests.utils.UserTask)28 Map (java.util.Map)25 SubWorkflowParams (com.netflix.conductor.common.metadata.workflow.SubWorkflowParams)20 ConstraintViolation (javax.validation.ConstraintViolation)14 ApplicationException (com.netflix.conductor.core.execution.ApplicationException)13 ValidatorFactory (javax.validation.ValidatorFactory)13 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)12 DynamicForkJoinTaskList (com.netflix.conductor.common.metadata.workflow.DynamicForkJoinTaskList)12