Search in sources :

Example 46 with TaskDef

use of com.netflix.conductor.common.metadata.tasks.TaskDef in project conductor by Netflix.

the class WorkflowTaskTypeConstraintTest method testWorkflowTaskTypeDecisionWithCaseParam.

@Test
public void testWorkflowTaskTypeDecisionWithCaseParam() {
    WorkflowTask workflowTask = createSampleWorkflowTask();
    workflowTask.setType("DECISION");
    workflowTask.setCaseExpression("$.valueCheck == null ? 'true': 'false'");
    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("decisionCases should have atleast one task for taskType: DECISION 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 47 with TaskDef

use of com.netflix.conductor.common.metadata.tasks.TaskDef in project conductor by Netflix.

the class WorkflowTaskTypeConstraintTest method testWorkflowTaskTypeKafkaPublish.

@Test
public void testWorkflowTaskTypeKafkaPublish() {
    WorkflowTask workflowTask = createSampleWorkflowTask();
    workflowTask.setType("KAFKA_PUBLISH");
    workflowTask.getInputParameters().put("kafka_request", "testInput");
    when(mockMetadataDao.getTaskDef(anyString())).thenReturn(new TaskDef());
    Set<ConstraintViolation<WorkflowTask>> result = validator.validate(workflowTask);
    assertEquals(0, result.size());
}
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)

Example 48 with TaskDef

use of com.netflix.conductor.common.metadata.tasks.TaskDef 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 49 with TaskDef

use of com.netflix.conductor.common.metadata.tasks.TaskDef 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 50 with TaskDef

use of com.netflix.conductor.common.metadata.tasks.TaskDef 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

TaskDef (com.netflix.conductor.common.metadata.tasks.TaskDef)172 Test (org.junit.Test)128 WorkflowTask (com.netflix.conductor.common.metadata.workflow.WorkflowTask)121 Task (com.netflix.conductor.common.metadata.tasks.Task)77 Workflow (com.netflix.conductor.common.run.Workflow)76 WorkflowDef (com.netflix.conductor.common.metadata.workflow.WorkflowDef)73 HashMap (java.util.HashMap)56 ArrayList (java.util.ArrayList)32 ConstraintViolation (javax.validation.ConstraintViolation)31 SubWorkflow (com.netflix.conductor.core.execution.tasks.SubWorkflow)30 UserTask (com.netflix.conductor.tests.utils.UserTask)28 LinkedList (java.util.LinkedList)28 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)27 List (java.util.List)22 Map (java.util.Map)19 ApplicationException (com.netflix.conductor.core.execution.ApplicationException)18 Before (org.junit.Before)14 ExpectedException (org.junit.rules.ExpectedException)13 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)12 Collectors (java.util.stream.Collectors)11