use of com.netflix.conductor.core.execution.WorkflowStatusListener in project conductor by Netflix.
the class DoWhileTest method setup.
@Before
public void setup() {
workflow = Mockito.mock(Workflow.class);
deciderService = Mockito.mock(DeciderService.class);
metadataDAO = Mockito.mock(MetadataDAO.class);
queueDAO = Mockito.mock(QueueDAO.class);
parametersUtils = Mockito.mock(ParametersUtils.class);
metadataMapperService = Mockito.mock(MetadataMapperService.class);
workflowStatusListener = Mockito.mock(WorkflowStatusListener.class);
executionDAOFacade = Mockito.mock(ExecutionDAOFacade.class);
executionLockService = Mockito.mock(ExecutionLockService.class);
config = Mockito.mock(Configuration.class);
provider = spy(new WorkflowExecutor(deciderService, metadataDAO, queueDAO, metadataMapperService, workflowStatusListener, executionDAOFacade, config, executionLockService, parametersUtils));
loopWorkflowTask1 = new WorkflowTask();
loopWorkflowTask1.setTaskReferenceName("task1");
loopWorkflowTask1.setName("task1");
loopWorkflowTask2 = new WorkflowTask();
loopWorkflowTask2.setTaskReferenceName("task2");
loopWorkflowTask2.setName("task2");
task1 = new Task();
task1.setWorkflowTask(loopWorkflowTask1);
task1.setReferenceTaskName("task1");
task1.setStatus(Task.Status.COMPLETED);
task1.setTaskType(TaskType.HTTP.name());
task1.setInputData(new HashMap<>());
task1.setIteration(1);
task2 = new Task();
task2.setWorkflowTask(loopWorkflowTask2);
task2.setReferenceTaskName("task2");
task2.setStatus(Task.Status.COMPLETED);
task2.setTaskType(TaskType.HTTP.name());
task2.setInputData(new HashMap<>());
task2.setIteration(1);
loopTask = new Task();
loopTask.setReferenceTaskName("loopTask");
loopTask.setTaskType(TaskType.DO_WHILE.name());
loopTask.setInputData(new HashMap<>());
loopTask.setIteration(1);
loopWorkflowTask = new WorkflowTask();
loopWorkflowTask.setTaskReferenceName("loopTask");
loopWorkflowTask.setType(TaskType.DO_WHILE.name());
loopWorkflowTask.setName("loopTask");
loopWorkflowTask.setLoopCondition("if ($.loopTask['iteration'] < 1) { false; } else { true; }");
loopWorkflowTask.setLoopOver(Arrays.asList(task1.getWorkflowTask(), task2.getWorkflowTask()));
loopTask.setWorkflowTask(loopWorkflowTask);
doWhile = new DoWhile();
loopTaskDef = Mockito.mock(TaskDef.class);
Mockito.doReturn(loopTaskDef).when(provider).getTaskDefinition(loopTask);
Mockito.doReturn(task1).when(workflow).getTaskByRefName(task1.getReferenceTaskName());
Mockito.doReturn(task2).when(workflow).getTaskByRefName(task2.getReferenceTaskName());
Mockito.doReturn(task1).when(workflow).getTaskByRefName("task1__2");
Mockito.doReturn(task2).when(workflow).getTaskByRefName("task2__2");
Mockito.doReturn(new HashMap<>()).when(parametersUtils).getTaskInputV2(isA(Map.class), isA(Workflow.class), isA(String.class), isA(TaskDef.class));
}
Aggregations