Search in sources :

Example 41 with Task

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

the class KafkaPublishTaskMapperTest method getMappedTasks.

@Test
public void getMappedTasks() {
    // Given
    WorkflowTask taskToSchedule = new WorkflowTask();
    taskToSchedule.setName("kafka_task");
    taskToSchedule.setType(TaskType.KAFKA_PUBLISH.name());
    taskToSchedule.setTaskDefinition(new TaskDef("kafka_task"));
    String taskId = IDGenerator.generate();
    String retriedTaskId = IDGenerator.generate();
    Workflow workflow = new Workflow();
    WorkflowDef workflowDef = new WorkflowDef();
    workflow.setWorkflowDefinition(workflowDef);
    TaskMapperContext taskMapperContext = TaskMapperContext.newBuilder().withWorkflowDefinition(workflowDef).withWorkflowInstance(workflow).withTaskDefinition(new TaskDef()).withTaskToSchedule(taskToSchedule).withTaskInput(new HashMap<>()).withRetryCount(0).withRetryTaskId(retriedTaskId).withTaskId(taskId).build();
    // when
    List<Task> mappedTasks = kafkaTaskMapper.getMappedTasks(taskMapperContext);
    // Then
    assertEquals(1, mappedTasks.size());
    assertEquals(TaskType.KAFKA_PUBLISH.name(), mappedTasks.get(0).getTaskType());
}
Also used : Task(com.netflix.conductor.common.metadata.tasks.Task) WorkflowTask(com.netflix.conductor.common.metadata.workflow.WorkflowTask) WorkflowDef(com.netflix.conductor.common.metadata.workflow.WorkflowDef) TaskDef(com.netflix.conductor.common.metadata.tasks.TaskDef) Workflow(com.netflix.conductor.common.run.Workflow) WorkflowTask(com.netflix.conductor.common.metadata.workflow.WorkflowTask) Test(org.junit.Test)

Example 42 with Task

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

the class KafkaPublishTaskMapperTest method getMappedTasks_WithoutTaskDef.

@Test
public void getMappedTasks_WithoutTaskDef() {
    // Given
    WorkflowTask taskToSchedule = new WorkflowTask();
    taskToSchedule.setName("kafka_task");
    taskToSchedule.setType(TaskType.KAFKA_PUBLISH.name());
    String taskId = IDGenerator.generate();
    String retriedTaskId = IDGenerator.generate();
    Workflow workflow = new Workflow();
    WorkflowDef workflowDef = new WorkflowDef();
    workflow.setWorkflowDefinition(workflowDef);
    TaskDef taskdefinition = new TaskDef();
    String testExecutionNameSpace = "testExecutionNameSpace";
    taskdefinition.setExecutionNameSpace(testExecutionNameSpace);
    String testIsolationGroupId = "testIsolationGroupId";
    taskdefinition.setIsolationGroupId(testIsolationGroupId);
    TaskMapperContext taskMapperContext = TaskMapperContext.newBuilder().withWorkflowDefinition(workflowDef).withWorkflowInstance(workflow).withTaskDefinition(taskdefinition).withTaskToSchedule(taskToSchedule).withTaskInput(new HashMap<>()).withRetryCount(0).withRetryTaskId(retriedTaskId).withTaskId(taskId).build();
    // when
    List<Task> mappedTasks = kafkaTaskMapper.getMappedTasks(taskMapperContext);
    // Then
    assertEquals(1, mappedTasks.size());
    assertEquals(TaskType.KAFKA_PUBLISH.name(), mappedTasks.get(0).getTaskType());
    assertEquals(testExecutionNameSpace, mappedTasks.get(0).getExecutionNameSpace());
    assertEquals(testIsolationGroupId, mappedTasks.get(0).getIsolationGroupId());
}
Also used : Task(com.netflix.conductor.common.metadata.tasks.Task) WorkflowTask(com.netflix.conductor.common.metadata.workflow.WorkflowTask) WorkflowDef(com.netflix.conductor.common.metadata.workflow.WorkflowDef) TaskDef(com.netflix.conductor.common.metadata.tasks.TaskDef) Workflow(com.netflix.conductor.common.run.Workflow) WorkflowTask(com.netflix.conductor.common.metadata.workflow.WorkflowTask) Test(org.junit.Test)

Example 43 with Task

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

the class SetVariableTaskMapperTest method getMappedTasks.

@Test
public void getMappedTasks() throws Exception {
    WorkflowTask taskToSchedule = new WorkflowTask();
    taskToSchedule.setType(TaskType.TASK_TYPE_SET_VARIABLE);
    String taskId = IDGenerator.generate();
    WorkflowDef workflowDef = new WorkflowDef();
    Workflow workflow = new Workflow();
    workflow.setWorkflowDefinition(workflowDef);
    TaskMapperContext taskMapperContext = TaskMapperContext.newBuilder().withWorkflowDefinition(workflowDef).withWorkflowInstance(workflow).withTaskDefinition(new TaskDef()).withTaskToSchedule(taskToSchedule).withRetryCount(0).withTaskId(taskId).build();
    List<Task> mappedTasks = new SetVariableTaskMapper().getMappedTasks(taskMapperContext);
    Assert.assertNotNull(mappedTasks);
    Assert.assertEquals(1, mappedTasks.size());
    Assert.assertEquals(TaskType.TASK_TYPE_SET_VARIABLE, mappedTasks.get(0).getTaskType());
}
Also used : Task(com.netflix.conductor.common.metadata.tasks.Task) WorkflowTask(com.netflix.conductor.common.metadata.workflow.WorkflowTask) WorkflowDef(com.netflix.conductor.common.metadata.workflow.WorkflowDef) TaskDef(com.netflix.conductor.common.metadata.tasks.TaskDef) Workflow(com.netflix.conductor.common.run.Workflow) WorkflowTask(com.netflix.conductor.common.metadata.workflow.WorkflowTask) Test(org.junit.Test)

Example 44 with Task

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

the class SimpleTaskMapperTest method getMappedTasks.

@Test
public void getMappedTasks() throws Exception {
    WorkflowTask taskToSchedule = new WorkflowTask();
    taskToSchedule.setName("simple_task");
    taskToSchedule.setTaskDefinition(new TaskDef("simple_task"));
    String taskId = IDGenerator.generate();
    String retriedTaskId = IDGenerator.generate();
    WorkflowDef wd = new WorkflowDef();
    Workflow w = new Workflow();
    w.setWorkflowDefinition(wd);
    TaskMapperContext taskMapperContext = TaskMapperContext.newBuilder().withWorkflowDefinition(wd).withWorkflowInstance(w).withTaskDefinition(new TaskDef()).withTaskToSchedule(taskToSchedule).withTaskInput(new HashMap<>()).withRetryCount(0).withRetryTaskId(retriedTaskId).withTaskId(taskId).build();
    List<Task> mappedTasks = simpleTaskMapper.getMappedTasks(taskMapperContext);
    assertNotNull(mappedTasks);
    assertEquals(1, mappedTasks.size());
}
Also used : Task(com.netflix.conductor.common.metadata.tasks.Task) WorkflowTask(com.netflix.conductor.common.metadata.workflow.WorkflowTask) WorkflowDef(com.netflix.conductor.common.metadata.workflow.WorkflowDef) TaskDef(com.netflix.conductor.common.metadata.tasks.TaskDef) Workflow(com.netflix.conductor.common.run.Workflow) WorkflowTask(com.netflix.conductor.common.metadata.workflow.WorkflowTask) Test(org.junit.Test)

Example 45 with Task

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

the class EventTaskMapperTest method getMappedTasks.

@Test
public void getMappedTasks() throws Exception {
    ParametersUtils parametersUtils = Mockito.mock(ParametersUtils.class);
    EventTaskMapper eventTaskMapper = new EventTaskMapper(parametersUtils);
    WorkflowTask taskToBeScheduled = new WorkflowTask();
    taskToBeScheduled.setSink("SQSSINK");
    String taskId = IDGenerator.generate();
    Map<String, Object> eventTaskInput = new HashMap<>();
    eventTaskInput.put("sink", "SQSSINK");
    when(parametersUtils.getTaskInput(anyMap(), any(Workflow.class), any(TaskDef.class), anyString())).thenReturn(eventTaskInput);
    WorkflowDef wd = new WorkflowDef();
    Workflow w = new Workflow();
    w.setWorkflowDefinition(wd);
    TaskMapperContext taskMapperContext = TaskMapperContext.newBuilder().withWorkflowDefinition(wd).withWorkflowInstance(w).withTaskDefinition(new TaskDef()).withTaskToSchedule(taskToBeScheduled).withRetryCount(0).withTaskId(taskId).build();
    List<Task> mappedTasks = eventTaskMapper.getMappedTasks(taskMapperContext);
    assertEquals(1, mappedTasks.size());
    Task eventTask = mappedTasks.get(0);
    assertEquals(taskId, eventTask.getTaskId());
}
Also used : Task(com.netflix.conductor.common.metadata.tasks.Task) WorkflowTask(com.netflix.conductor.common.metadata.workflow.WorkflowTask) WorkflowDef(com.netflix.conductor.common.metadata.workflow.WorkflowDef) HashMap(java.util.HashMap) Workflow(com.netflix.conductor.common.run.Workflow) WorkflowTask(com.netflix.conductor.common.metadata.workflow.WorkflowTask) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) TaskDef(com.netflix.conductor.common.metadata.tasks.TaskDef) ParametersUtils(com.netflix.conductor.core.execution.ParametersUtils) Test(org.junit.Test)

Aggregations

Task (com.netflix.conductor.common.metadata.tasks.Task)357 Workflow (com.netflix.conductor.common.run.Workflow)249 Test (org.junit.Test)248 WorkflowTask (com.netflix.conductor.common.metadata.workflow.WorkflowTask)227 HashMap (java.util.HashMap)147 WorkflowDef (com.netflix.conductor.common.metadata.workflow.WorkflowDef)121 SubWorkflow (com.netflix.conductor.core.execution.tasks.SubWorkflow)110 TaskDef (com.netflix.conductor.common.metadata.tasks.TaskDef)95 UserTask (com.netflix.conductor.tests.utils.UserTask)73 Map (java.util.Map)53 LinkedList (java.util.LinkedList)51 WorkflowSystemTask (com.netflix.conductor.core.execution.tasks.WorkflowSystemTask)45 List (java.util.List)45 ApplicationException (com.netflix.conductor.core.execution.ApplicationException)41 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)39 TaskResult (com.netflix.conductor.common.metadata.tasks.TaskResult)38 Status (com.netflix.conductor.common.metadata.tasks.Task.Status)32 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)29 Collectors (java.util.stream.Collectors)29 TaskType (com.netflix.conductor.common.metadata.workflow.TaskType)28