Search in sources :

Example 11 with WorkflowResult

use of org.apache.inlong.manager.common.pojo.workflow.WorkflowResult in project incubator-inlong by apache.

the class WorkflowBeanUtils method result.

/**
 * Get the workflow result from the given workflow context
 */
public static WorkflowResult result(WorkflowContext context) {
    if (context == null) {
        return null;
    }
    WorkflowResult workflowResult = new WorkflowResult();
    workflowResult.setProcessInfo(WorkflowBeanUtils.fromProcessEntity(context.getProcessEntity()));
    List<TaskResponse> taskList = context.getNewTaskList().stream().map(WorkflowBeanUtils::fromTaskEntity).collect(Collectors.toList());
    workflowResult.setNewTasks(taskList);
    return workflowResult;
}
Also used : WorkflowResult(org.apache.inlong.manager.common.pojo.workflow.WorkflowResult) TaskResponse(org.apache.inlong.manager.common.pojo.workflow.TaskResponse)

Example 12 with WorkflowResult

use of org.apache.inlong.manager.common.pojo.workflow.WorkflowResult in project incubator-inlong by apache.

the class InlongGroupProcessOperationTest method testStartProcess.

@Test
public void testStartProcess() {
    before(GroupState.TO_BE_SUBMIT.getCode());
    WorkflowResult result = groupProcessOperation.startProcess(GROUP_ID, OPERATOR);
    ProcessResponse response = result.getProcessInfo();
    Assert.assertSame(response.getStatus(), ProcessStatus.PROCESSING);
    InlongGroupInfo groupInfo = groupService.get(GROUP_ID);
    Assert.assertEquals(groupInfo.getStatus(), GroupState.TO_BE_APPROVAL.getCode());
}
Also used : WorkflowResult(org.apache.inlong.manager.common.pojo.workflow.WorkflowResult) InlongGroupInfo(org.apache.inlong.manager.common.pojo.group.InlongGroupInfo) ProcessResponse(org.apache.inlong.manager.common.pojo.workflow.ProcessResponse) Test(org.junit.Test) ServiceBaseTest(org.apache.inlong.manager.service.ServiceBaseTest)

Example 13 with WorkflowResult

use of org.apache.inlong.manager.common.pojo.workflow.WorkflowResult in project incubator-inlong by apache.

the class InlongGroupProcessOperationTest method testSuspendProcess.

@Test
public void testSuspendProcess() {
    testStartProcess();
    InlongGroupInfo groupInfo = groupService.get(GROUP_ID);
    groupInfo.setStatus(GroupState.APPROVE_PASSED.getCode());
    groupService.update(groupInfo.genRequest(), OPERATOR);
    groupInfo.setStatus(GroupState.CONFIG_ING.getCode());
    groupService.update(groupInfo.genRequest(), OPERATOR);
    groupInfo.setStatus(GroupState.CONFIG_SUCCESSFUL.getCode());
    groupService.update(groupInfo.genRequest(), OPERATOR);
    WorkflowResult result = groupProcessOperation.suspendProcess(GROUP_ID, OPERATOR);
    ProcessResponse response = result.getProcessInfo();
    Assert.assertSame(response.getStatus(), ProcessStatus.COMPLETED);
    groupInfo = groupService.get(GROUP_ID);
    Assert.assertEquals(groupInfo.getStatus(), GroupState.SUSPENDED.getCode());
}
Also used : WorkflowResult(org.apache.inlong.manager.common.pojo.workflow.WorkflowResult) InlongGroupInfo(org.apache.inlong.manager.common.pojo.group.InlongGroupInfo) ProcessResponse(org.apache.inlong.manager.common.pojo.workflow.ProcessResponse) Test(org.junit.Test) ServiceBaseTest(org.apache.inlong.manager.service.ServiceBaseTest)

Example 14 with WorkflowResult

use of org.apache.inlong.manager.common.pojo.workflow.WorkflowResult in project incubator-inlong by apache.

the class DataSourceListenerTest method testRestartSource.

@Test
public void testRestartSource() {
    // testFrozenSource();
    groupInfo = initGroupForm("PULSAR");
    groupInfo.setStatus(GroupState.CONFIG_SUCCESSFUL.getCode());
    groupService.update(groupInfo.genRequest(), OPERATOR);
    groupInfo.setStatus(GroupState.SUSPENDED.getCode());
    groupService.update(groupInfo.genRequest(), OPERATOR);
    final int sourceId = createBinlogSource(groupInfo);
    streamSourceService.updateStatus(groupInfo.getInlongGroupId(), null, SourceState.SOURCE_NORMAL.getCode(), OPERATOR);
    form = new UpdateGroupProcessForm();
    form.setGroupInfo(groupInfo);
    form.setOperateType(OperateType.RESTART);
    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 task = process.getTaskByName("restartSource");
    Assert.assertTrue(task instanceof ServiceTask);
    SourceResponse sourceResponse = streamSourceService.get(sourceId, SourceType.BINLOG.toString());
    Assert.assertSame(SourceState.forCode(sourceResponse.getStatus()), SourceState.TO_BE_ISSUED_ACTIVE);
}
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) SourceResponse(org.apache.inlong.manager.common.pojo.source.SourceResponse) WorkflowContext(org.apache.inlong.manager.workflow.WorkflowContext) 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) WorkflowServiceImplTest(org.apache.inlong.manager.service.workflow.WorkflowServiceImplTest)

Aggregations

WorkflowResult (org.apache.inlong.manager.common.pojo.workflow.WorkflowResult)14 ProcessResponse (org.apache.inlong.manager.common.pojo.workflow.ProcessResponse)13 Test (org.junit.Test)12 InlongGroupInfo (org.apache.inlong.manager.common.pojo.group.InlongGroupInfo)9 WorkflowContext (org.apache.inlong.manager.workflow.WorkflowContext)9 ServiceTask (org.apache.inlong.manager.workflow.definition.ServiceTask)9 WorkflowProcess (org.apache.inlong.manager.workflow.definition.WorkflowProcess)9 WorkflowTask (org.apache.inlong.manager.workflow.definition.WorkflowTask)9 ServiceBaseTest (org.apache.inlong.manager.service.ServiceBaseTest)8 UpdateGroupProcessForm (org.apache.inlong.manager.common.pojo.workflow.form.UpdateGroupProcessForm)7 TaskEventListener (org.apache.inlong.manager.workflow.event.task.TaskEventListener)7 MockPlugin (org.apache.inlong.manager.service.mocks.MockPlugin)4 WorkflowServiceImplTest (org.apache.inlong.manager.service.workflow.WorkflowServiceImplTest)4 SourceResponse (org.apache.inlong.manager.common.pojo.source.SourceResponse)2 InlongStreamInfo (org.apache.inlong.manager.common.pojo.stream.InlongStreamInfo)2 TaskResponse (org.apache.inlong.manager.common.pojo.workflow.TaskResponse)2 GroupResourceProcessForm (org.apache.inlong.manager.common.pojo.workflow.form.GroupResourceProcessForm)2 ProcessForm (org.apache.inlong.manager.common.pojo.workflow.form.ProcessForm)2 List (java.util.List)1 InlongGroupApproveRequest (org.apache.inlong.manager.common.pojo.group.InlongGroupApproveRequest)1