Search in sources :

Example 1 with MockRestartSortListener

use of org.apache.inlong.manager.service.mocks.MockRestartSortListener 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());
}
Also used : UpdateGroupProcessForm(org.apache.inlong.manager.common.pojo.workflow.form.UpdateGroupProcessForm) WorkflowResult(org.apache.inlong.manager.common.pojo.workflow.WorkflowResult) ServiceTask(org.apache.inlong.manager.workflow.definition.ServiceTask) TaskEventListener(org.apache.inlong.manager.workflow.event.task.TaskEventListener) MockPlugin(org.apache.inlong.manager.service.mocks.MockPlugin) MockRestartSortListener(org.apache.inlong.manager.service.mocks.MockRestartSortListener) WorkflowContext(org.apache.inlong.manager.workflow.WorkflowContext) InlongGroupInfo(org.apache.inlong.manager.common.pojo.group.InlongGroupInfo) WorkflowTask(org.apache.inlong.manager.workflow.definition.WorkflowTask) WorkflowProcess(org.apache.inlong.manager.workflow.definition.WorkflowProcess) ProcessResponse(org.apache.inlong.manager.common.pojo.workflow.ProcessResponse) Test(org.junit.Test) ServiceBaseTest(org.apache.inlong.manager.service.ServiceBaseTest)

Aggregations

InlongGroupInfo (org.apache.inlong.manager.common.pojo.group.InlongGroupInfo)1 ProcessResponse (org.apache.inlong.manager.common.pojo.workflow.ProcessResponse)1 WorkflowResult (org.apache.inlong.manager.common.pojo.workflow.WorkflowResult)1 UpdateGroupProcessForm (org.apache.inlong.manager.common.pojo.workflow.form.UpdateGroupProcessForm)1 ServiceBaseTest (org.apache.inlong.manager.service.ServiceBaseTest)1 MockPlugin (org.apache.inlong.manager.service.mocks.MockPlugin)1 MockRestartSortListener (org.apache.inlong.manager.service.mocks.MockRestartSortListener)1 WorkflowContext (org.apache.inlong.manager.workflow.WorkflowContext)1 ServiceTask (org.apache.inlong.manager.workflow.definition.ServiceTask)1 WorkflowProcess (org.apache.inlong.manager.workflow.definition.WorkflowProcess)1 WorkflowTask (org.apache.inlong.manager.workflow.definition.WorkflowTask)1 TaskEventListener (org.apache.inlong.manager.workflow.event.task.TaskEventListener)1 Test (org.junit.Test)1