use of com.netflix.conductor.common.metadata.workflow.WorkflowTask in project conductor by Netflix.
the class WorkflowDefConstraintTest method testWorkflowTaskInvalidInputParam.
@Test
public /*Testcase to check inputParam is not valid
*/
void testWorkflowTaskInvalidInputParam() {
WorkflowDef workflowDef = new WorkflowDef();
workflowDef.setName("sampleWorkflow");
workflowDef.setDescription("Sample workflow def");
workflowDef.setOwnerEmail("sample@test.com");
workflowDef.setVersion(2);
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("fileLocation", "${work.input.fileLocation}");
workflowTask_1.setInputParameters(inputParam);
List<WorkflowTask> tasks = new ArrayList<>();
tasks.add(workflowTask_1);
workflowDef.setTasks(tasks);
ValidatorFactory factory = Validation.buildDefaultValidatorFactory();
validator = factory.getValidator();
when(mockMetadataDao.getTaskDef("work1")).thenReturn(new TaskDef());
Set<ConstraintViolation<WorkflowDef>> result = validator.validate(workflowDef);
assertEquals(1, result.size());
assertEquals(result.iterator().next().getMessage(), "taskReferenceName: work for given task: task_1 input value: fileLocation of input parameter: ${work.input.fileLocation} is not defined in workflow definition.");
}
use of com.netflix.conductor.common.metadata.workflow.WorkflowTask in project conductor by Netflix.
the class WorkflowDefConstraintTest method testWorkflowTaskSimple.
@Test
public void testWorkflowTaskSimple() {
WorkflowDef workflowDef = new WorkflowDef();
workflowDef.setName("sampleWorkflow");
workflowDef.setDescription("Sample workflow def");
workflowDef.setOwnerEmail("sample@test.com");
workflowDef.setVersion(2);
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("fileLocation", "${workflow.input.fileLocation}");
workflowTask_1.setInputParameters(inputParam);
List<WorkflowTask> tasks = new ArrayList<>();
tasks.add(workflowTask_1);
workflowDef.setTasks(tasks);
Set<ConstraintViolation<WorkflowDef>> result = validator.validate(workflowDef);
assertEquals(0, result.size());
}
use of com.netflix.conductor.common.metadata.workflow.WorkflowTask in project conductor by Netflix.
the class WorkflowTaskTypeConstraintTest method testWorkflowTaskTypeDoWhileWithSubWorkflow.
@Test
public void testWorkflowTaskTypeDoWhileWithSubWorkflow() {
WorkflowTask workflowTask = createSampleWorkflowTask();
workflowTask.setType("DO_WHILE");
workflowTask.setLoopCondition("Test condition");
WorkflowTask workflowTask2 = createSampleWorkflowTask();
workflowTask2.setType("SUB_WORKFLOW");
workflowTask.setLoopOver(Collections.singletonList(workflowTask2));
when(mockMetadataDao.getTaskDef(anyString())).thenReturn(new TaskDef());
Set<ConstraintViolation<WorkflowTask>> result = validator.validate(workflowTask);
assertEquals(1, result.size());
List<String> validationErrors = new ArrayList<>();
result.forEach(e -> validationErrors.add(e.getMessage()));
assertTrue(validationErrors.contains("SUB_WORKFLOW task inside loopover task: encode is not supported."));
}
use of com.netflix.conductor.common.metadata.workflow.WorkflowTask in project conductor by Netflix.
the class WorkflowTaskTypeConstraintTest method testWorkflowTaskTestSetType.
@Test
public void testWorkflowTaskTestSetType() throws NoSuchMethodException {
WorkflowTask workflowTask = createSampleWorkflowTask();
Method method = WorkflowTask.class.getMethod("setType", String.class);
Object[] parameterValues = { "" };
ExecutableValidator executableValidator = validator.forExecutables();
Set<ConstraintViolation<Object>> result = executableValidator.validateParameters(workflowTask, method, parameterValues);
assertEquals(1, result.size());
assertEquals(result.iterator().next().getMessage(), "WorkTask type cannot be null or empty");
}
use of com.netflix.conductor.common.metadata.workflow.WorkflowTask in project conductor by Netflix.
the class MetadataMapperServiceTest method testNoVersionPopulationForSubworkflowTaskIfAvailable.
@Test
public void testNoVersionPopulationForSubworkflowTaskIfAvailable() {
String nameTaskDefinition = "taskSubworkflow7";
String workflowDefinitionName = "subworkflow";
Integer version = 2;
WorkflowTask workflowTask = createWorkflowTask(nameTaskDefinition);
workflowTask.setWorkflowTaskType(TaskType.SUB_WORKFLOW);
SubWorkflowParams subWorkflowParams = new SubWorkflowParams();
subWorkflowParams.setName(workflowDefinitionName);
subWorkflowParams.setVersion(version);
workflowTask.setSubWorkflowParam(subWorkflowParams);
WorkflowDef workflowDefinition = createWorkflowDefinition("testMetadataPopulation");
workflowDefinition.setTasks(ImmutableList.of(workflowTask));
metadataMapperService.populateTaskDefinitions(workflowDefinition);
assertEquals(1, workflowDefinition.getTasks().size());
List<WorkflowTask> workflowTasks = workflowDefinition.getTasks();
SubWorkflowParams params = workflowTasks.get(0).getSubWorkflowParam();
assertEquals(workflowDefinitionName, params.getName());
assertEquals(version, params.getVersion());
verify(metadataDAO).getTaskDef(nameTaskDefinition);
verifyNoMoreInteractions(metadataDAO);
}
Aggregations