Search in sources :

Example 81 with WorkflowTask

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

the class WorkflowTaskTypeConstraintTest method testWorkflowTaskTypeForJoinDynamicWithForJoinTaskParamAndInputTaskParam.

@Test
public void testWorkflowTaskTypeForJoinDynamicWithForJoinTaskParamAndInputTaskParam() {
    WorkflowTask workflowTask = createSampleWorkflowTask();
    workflowTask.setType("FORK_JOIN_DYNAMIC");
    workflowTask.setDynamicForkJoinTasksParam("taskList");
    workflowTask.setDynamicForkTasksInputParamName("ForkTaskInputParam");
    workflowTask.setDynamicForkTasksParam("ForkTasksParam");
    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("dynamicForkJoinTasksParam or combination of dynamicForkTasksInputParamName and dynamicForkTasksParam cam be used for taskType: FORK_JOIN_DYNAMIC taskName: encode"));
}
Also used : TaskDef(com.netflix.conductor.common.metadata.tasks.TaskDef) ConstraintViolation(javax.validation.ConstraintViolation) ArrayList(java.util.ArrayList) WorkflowTask(com.netflix.conductor.common.metadata.workflow.WorkflowTask) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.junit.Test)

Example 82 with WorkflowTask

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

the class WorkflowTaskTypeConstraintTest method testWorkflowTaskTypeHTTPWithHttpParamMissing.

@Test
public void testWorkflowTaskTypeHTTPWithHttpParamMissing() {
    WorkflowTask workflowTask = createSampleWorkflowTask();
    workflowTask.setType("HTTP");
    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.http_request field is required for taskType: HTTP taskName: encode"));
}
Also used : TaskDef(com.netflix.conductor.common.metadata.tasks.TaskDef) ConstraintViolation(javax.validation.ConstraintViolation) ArrayList(java.util.ArrayList) WorkflowTask(com.netflix.conductor.common.metadata.workflow.WorkflowTask) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.junit.Test)

Example 83 with WorkflowTask

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

the class WorkflowTaskTypeConstraintTest method testWorkflowTaskTypeTerminateWithInvalidStatus.

@Test
public void testWorkflowTaskTypeTerminateWithInvalidStatus() {
    WorkflowTask workflowTask = createSampleWorkflowTask();
    workflowTask.setType(TaskType.TASK_TYPE_TERMINATE);
    workflowTask.setName("terminate_task");
    workflowTask.setInputParameters(Collections.singletonMap(Terminate.getTerminationStatusParameter(), "blah"));
    List<String> validationErrors = getErrorMessages(workflowTask);
    Assert.assertEquals(1, validationErrors.size());
    Assert.assertEquals("terminate task must have an terminationStatus parameter and must be set to COMPLETED or FAILED, taskName: terminate_task", validationErrors.get(0));
}
Also used : WorkflowTask(com.netflix.conductor.common.metadata.workflow.WorkflowTask) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.junit.Test)

Example 84 with WorkflowTask

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

the class WorkflowTaskTypeConstraintTest method createSampleWorkflowTask.

private WorkflowTask createSampleWorkflowTask() {
    WorkflowTask workflowTask = new WorkflowTask();
    workflowTask.setName("encode");
    workflowTask.setTaskReferenceName("encode");
    workflowTask.setType("FORK_JOIN_DYNAMIC");
    Map<String, Object> inputParam = new HashMap<>();
    inputParam.put("fileLocation", "${workflow.input.fileLocation}");
    workflowTask.setInputParameters(inputParam);
    return workflowTask;
}
Also used : HashMap(java.util.HashMap) WorkflowTask(com.netflix.conductor.common.metadata.workflow.WorkflowTask) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString)

Example 85 with WorkflowTask

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

the class WorkflowTaskTypeConstraintTest method testWorkflowTaskTypeEvent.

@Test
public void testWorkflowTaskTypeEvent() {
    WorkflowTask workflowTask = createSampleWorkflowTask();
    workflowTask.setType("EVENT");
    when(mockMetadataDao.getTaskDef(anyString())).thenReturn(new TaskDef());
    Set<ConstraintViolation<WorkflowTask>> result = validator.validate(workflowTask);
    assertEquals(1, result.size());
    assertEquals(result.iterator().next().getMessage(), "sink field is required for taskType: EVENT taskName: encode");
}
Also used : TaskDef(com.netflix.conductor.common.metadata.tasks.TaskDef) ConstraintViolation(javax.validation.ConstraintViolation) WorkflowTask(com.netflix.conductor.common.metadata.workflow.WorkflowTask) Test(org.junit.Test)

Aggregations

WorkflowTask (com.netflix.conductor.common.metadata.workflow.WorkflowTask)244 Test (org.junit.Test)166 WorkflowDef (com.netflix.conductor.common.metadata.workflow.WorkflowDef)148 TaskDef (com.netflix.conductor.common.metadata.tasks.TaskDef)106 Workflow (com.netflix.conductor.common.run.Workflow)106 HashMap (java.util.HashMap)103 Task (com.netflix.conductor.common.metadata.tasks.Task)98 ArrayList (java.util.ArrayList)52 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)44 ConstraintViolation (javax.validation.ConstraintViolation)41 LinkedList (java.util.LinkedList)40 List (java.util.List)36 SubWorkflow (com.netflix.conductor.core.execution.tasks.SubWorkflow)32 Map (java.util.Map)26 SubWorkflowParams (com.netflix.conductor.common.metadata.workflow.SubWorkflowParams)25 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