use of com.netflix.conductor.common.metadata.workflow.WorkflowTask in project conductor by Netflix.
the class SimpleTaskMapperTest method getMappedTasksException.
@Test
public void getMappedTasksException() throws Exception {
// Given
WorkflowTask taskToSchedule = new WorkflowTask();
taskToSchedule.setName("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();
// then
expectedException.expect(TerminateWorkflowException.class);
expectedException.expectMessage(String.format("Invalid task. Task %s does not have a definition", taskToSchedule.getName()));
// when
simpleTaskMapper.getMappedTasks(taskMapperContext);
}
use of com.netflix.conductor.common.metadata.workflow.WorkflowTask in project conductor by Netflix.
the class SubWorkflowTaskMapperTest method getSubWorkflowParams.
@Test
public void getSubWorkflowParams() {
WorkflowTask workflowTask = new WorkflowTask();
SubWorkflowParams subWorkflowParams = new SubWorkflowParams();
subWorkflowParams.setName("Foo");
subWorkflowParams.setVersion(2);
workflowTask.setSubWorkflowParam(subWorkflowParams);
assertEquals(subWorkflowParams, subWorkflowTaskMapper.getSubWorkflowParams(workflowTask));
}
use of com.netflix.conductor.common.metadata.workflow.WorkflowTask in project conductor by Netflix.
the class SubWorkflowTaskMapperTest method getMappedTasks.
@SuppressWarnings("unchecked")
@Test
public void getMappedTasks() {
// Given
WorkflowDef workflowDef = new WorkflowDef();
Workflow workflowInstance = new Workflow();
workflowInstance.setWorkflowDefinition(workflowDef);
WorkflowTask taskToSchedule = new WorkflowTask();
SubWorkflowParams subWorkflowParams = new SubWorkflowParams();
subWorkflowParams.setName("Foo");
subWorkflowParams.setVersion(2);
taskToSchedule.setSubWorkflowParam(subWorkflowParams);
Map<String, Object> taskInput = new HashMap<>();
Map<String, String> taskToDomain = new HashMap<String, String>() {
{
put("*", "unittest");
}
};
Map<String, Object> subWorkflowParamMap = new HashMap<>();
subWorkflowParamMap.put("name", "FooWorkFlow");
subWorkflowParamMap.put("version", 2);
subWorkflowParamMap.put("taskToDomain", taskToDomain);
when(parametersUtils.getTaskInputV2(anyMap(), any(Workflow.class), any(), any())).thenReturn(subWorkflowParamMap);
// When
TaskMapperContext taskMapperContext = TaskMapperContext.newBuilder().withWorkflowDefinition(workflowDef).withWorkflowInstance(workflowInstance).withTaskToSchedule(taskToSchedule).withTaskInput(taskInput).withRetryCount(0).withTaskId(IDGenerator.generate()).withDeciderService(deciderService).build();
List<Task> mappedTasks = subWorkflowTaskMapper.getMappedTasks(taskMapperContext);
// Then
assertTrue(!mappedTasks.isEmpty());
assertEquals(1, mappedTasks.size());
Task subWorkFlowTask = mappedTasks.get(0);
assertEquals(Task.Status.SCHEDULED, subWorkFlowTask.getStatus());
assertEquals(SubWorkflow.NAME, subWorkFlowTask.getTaskType());
assertEquals(taskToDomain, subWorkFlowTask.getInputData().get("subWorkflowTaskToDomain"));
}
use of com.netflix.conductor.common.metadata.workflow.WorkflowTask in project conductor by Netflix.
the class SubWorkflowTaskMapperTest method getExceptionWhenNoSubWorkflowParamsPassed.
@Test
public void getExceptionWhenNoSubWorkflowParamsPassed() {
WorkflowTask workflowTask = new WorkflowTask();
workflowTask.setName("FooWorkFLow");
expectedException.expect(TerminateWorkflowException.class);
expectedException.expectMessage(String.format("Task %s is defined as sub-workflow and is missing subWorkflowParams. " + "Please check the blueprint", workflowTask.getName()));
subWorkflowTaskMapper.getSubWorkflowParams(workflowTask);
}
use of com.netflix.conductor.common.metadata.workflow.WorkflowTask in project conductor by Netflix.
the class TerminateTaskMapperTest method getMappedTasks.
@Test
public void getMappedTasks() throws Exception {
WorkflowTask taskToSchedule = new WorkflowTask();
taskToSchedule.setType(TaskType.TASK_TYPE_TERMINATE);
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 TerminateTaskMapper(parametersUtils).getMappedTasks(taskMapperContext);
Assert.assertNotNull(mappedTasks);
Assert.assertEquals(1, mappedTasks.size());
Assert.assertEquals(TaskType.TASK_TYPE_TERMINATE, mappedTasks.get(0).getTaskType());
}
Aggregations