use of org.apache.inlong.manager.workflow.WorkflowContext in project incubator-inlong by apache.
the class WorkflowServiceImplTest method testRestartProcess.
@Test
public void testRestartProcess() {
InlongGroupInfo groupInfo = initGroupForm(Constant.MIDDLEWARE_PULSAR);
groupInfo.setStatus(GroupState.CONFIG_SUCCESSFUL.getCode());
groupService.update(groupInfo.genRequest(), OPERATOR);
groupInfo.setStatus(GroupState.SUSPENDED.getCode());
groupService.update(groupInfo.genRequest(), OPERATOR);
UpdateGroupProcessForm form = new UpdateGroupProcessForm();
form.setGroupInfo(groupInfo);
form.setOperateType(OperateType.RESTART);
taskListenerFactory.acceptPlugin(new MockPlugin());
WorkflowContext context = workflowEngine.processService().start(ProcessName.RESTART_GROUP_PROCESS.name(), applicant, form);
WorkflowResult result = WorkflowBeanUtils.result(context);
ProcessResponse response = result.getProcessInfo();
Assert.assertSame(response.getStatus(), ProcessStatus.COMPLETED);
WorkflowProcess process = context.getProcess();
WorkflowTask restartSort = process.getTaskByName("restartSort");
Assert.assertTrue(restartSort instanceof ServiceTask);
List<TaskEventListener> listeners = Lists.newArrayList(restartSort.getNameToListenerMap().values());
Assert.assertEquals(1, listeners.size());
Assert.assertTrue(listeners.get(0) instanceof MockRestartSortListener);
WorkflowTask restartSourceTask = process.getTaskByName("restartSource");
Assert.assertTrue(restartSourceTask instanceof ServiceTask);
listeners = Lists.newArrayList(restartSourceTask.getNameToListenerMap().values());
Assert.assertEquals(2, listeners.size());
}
use of org.apache.inlong.manager.workflow.WorkflowContext in project incubator-inlong by apache.
the class WorkflowServiceImplTest method testSuspendProcess.
@Test
public void testSuspendProcess() {
InlongGroupInfo groupInfo = initGroupForm(Constant.MIDDLEWARE_PULSAR);
groupInfo.setStatus(GroupState.CONFIG_SUCCESSFUL.getCode());
groupService.update(groupInfo.genRequest(), OPERATOR);
UpdateGroupProcessForm form = new UpdateGroupProcessForm();
form.setGroupInfo(groupInfo);
form.setOperateType(OperateType.SUSPEND);
taskListenerFactory.acceptPlugin(new MockPlugin());
WorkflowContext context = workflowEngine.processService().start(ProcessName.SUSPEND_GROUP_PROCESS.name(), applicant, form);
WorkflowResult result = WorkflowBeanUtils.result(context);
ProcessResponse response = result.getProcessInfo();
Assert.assertSame(response.getStatus(), ProcessStatus.COMPLETED);
WorkflowProcess process = context.getProcess();
WorkflowTask stopSortTask = process.getTaskByName("stopSort");
Assert.assertTrue(stopSortTask instanceof ServiceTask);
List<TaskEventListener> listeners = Lists.newArrayList(stopSortTask.getNameToListenerMap().values());
Assert.assertTrue(listeners.get(0) instanceof MockStopSortListener);
WorkflowTask stopSourceTask = process.getTaskByName("stopSource");
Assert.assertTrue(stopSourceTask instanceof ServiceTask);
listeners = Lists.newArrayList(stopSourceTask.getNameToListenerMap().values());
}
use of org.apache.inlong.manager.workflow.WorkflowContext in project incubator-inlong by apache.
the class WorkflowServiceImplTest method testStartCreatePulsarWorkflow.
@Test
public void testStartCreatePulsarWorkflow() {
initGroupForm(Constant.MIDDLEWARE_PULSAR);
mockTaskListenerFactory();
WorkflowContext context = workflowEngine.processService().start(processName.name(), applicant, form);
WorkflowResult result = WorkflowBeanUtils.result(context);
ProcessResponse view = result.getProcessInfo();
Assert.assertSame(view.getStatus(), ProcessStatus.COMPLETED);
WorkflowProcess process = context.getProcess();
WorkflowTask task = process.getTaskByName("initMQ");
Assert.assertTrue(task instanceof ServiceTask);
Assert.assertEquals(2, task.getNameToListenerMap().size());
List<TaskEventListener> listeners = Lists.newArrayList(task.getNameToListenerMap().values());
Assert.assertTrue(listeners.get(0) instanceof CreatePulsarGroupTaskListener);
Assert.assertTrue(listeners.get(1) instanceof CreatePulsarResourceTaskListener);
}
use of org.apache.inlong.manager.workflow.WorkflowContext in project incubator-inlong by apache.
the class TaskServiceImpl method transfer.
@Override
public WorkflowContext transfer(Integer taskId, String remark, List<String> to, String operator) {
WorkflowContext context = contextBuilder.buildContextForTask(taskId, WorkflowAction.TRANSFER, to, remark, operator);
processorExecutor.executeComplete(context.getActionContext().getTask(), context);
return context;
}
use of org.apache.inlong.manager.workflow.WorkflowContext in project incubator-inlong by apache.
the class TaskServiceImpl method approve.
@Override
public WorkflowContext approve(Integer taskId, String remark, TaskForm form, String operator) {
WorkflowContext context = contextBuilder.buildContextForTask(taskId, WorkflowAction.APPROVE, form, remark, operator);
processorExecutor.executeComplete(context.getActionContext().getTask(), context);
return context;
}
Aggregations