use of com.netflix.conductor.common.metadata.tasks.TaskDef in project conductor by Netflix.
the class WorkflowDefConstraintTest method init.
@Before
public void init() {
validator = new ValidationModule().getValidator();
mockMetadataDao = Mockito.mock(MetadataDAO.class);
when(mockMetadataDao.getTaskDef(anyString())).thenReturn(new TaskDef());
ValidationContext.initialize(mockMetadataDao);
}
use of com.netflix.conductor.common.metadata.tasks.TaskDef 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.tasks.TaskDef 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.tasks.TaskDef in project conductor by Netflix.
the class WorkflowTaskTypeConstraintTest method testWorkflowTaskTypeDecision.
@Test
public void testWorkflowTaskTypeDecision() {
WorkflowTask workflowTask = createSampleWorkflowTask();
workflowTask.setType("DECISION");
when(mockMetadataDao.getTaskDef(anyString())).thenReturn(new TaskDef());
Set<ConstraintViolation<WorkflowTask>> result = validator.validate(workflowTask);
assertEquals(2, result.size());
List<String> validationErrors = new ArrayList<>();
result.forEach(e -> validationErrors.add(e.getMessage()));
assertTrue(validationErrors.contains("decisionCases should have atleast one task for taskType: DECISION taskName: encode"));
assertTrue(validationErrors.contains("caseValueParam or caseExpression field is required for taskType: DECISION taskName: encode"));
}
use of com.netflix.conductor.common.metadata.tasks.TaskDef in project conductor by Netflix.
the class WorkflowTaskTypeConstraintTest method testWorkflowTaskTypeKafkaPublishWithRequestParamMissing.
@Test
public void testWorkflowTaskTypeKafkaPublishWithRequestParamMissing() {
WorkflowTask workflowTask = createSampleWorkflowTask();
workflowTask.setType("KAFKA_PUBLISH");
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("inputParameters.kafka_request field is required for taskType: KAFKA_PUBLISH taskName: encode"));
}
Aggregations