use of org.apache.inlong.manager.common.pojo.group.InlongGroupInfo in project incubator-inlong by apache.
the class ServiceTaskListenerFactoryTest method testGetQueueOperateListener.
@Test
public void testGetQueueOperateListener() {
WorkflowContext context = new WorkflowContext();
GroupResourceProcessForm processForm = new GroupResourceProcessForm();
InlongGroupInfo groupInfo = new InlongGroupInfo();
// check pulsar listener
groupInfo.setMiddlewareType(Constant.MIDDLEWARE_PULSAR);
processForm.setGroupInfo(groupInfo);
context.setProcessForm(processForm);
List<QueueOperateListener> queueOperateListeners = serviceTaskListenerFactory.getQueueOperateListener(context);
Assert.assertEquals(2, queueOperateListeners.size());
Assert.assertTrue(queueOperateListeners.get(0) instanceof CreatePulsarResourceTaskListener);
Assert.assertTrue(queueOperateListeners.get(1) instanceof CreatePulsarGroupTaskListener);
// check tube listener
groupInfo.setMiddlewareType(Constant.MIDDLEWARE_TUBE);
queueOperateListeners = serviceTaskListenerFactory.getQueueOperateListener(context);
Assert.assertEquals(2, queueOperateListeners.size());
Assert.assertTrue(queueOperateListeners.get(0) instanceof CreateTubeTopicTaskListener);
Assert.assertTrue(queueOperateListeners.get(1) instanceof CreateTubeGroupTaskListener);
}
use of org.apache.inlong.manager.common.pojo.group.InlongGroupInfo in project incubator-inlong by apache.
the class WorkflowServiceImplTest method initGroupForm.
/**
* Init inlong group form
*/
public InlongGroupInfo initGroupForm(String middlewareType) {
processName = ProcessName.CREATE_GROUP_RESOURCE;
applicant = OPERATOR;
try {
streamService.logicDeleteAll(GROUP_ID, OPERATOR);
groupService.delete(GROUP_ID, OPERATOR);
} catch (Exception e) {
// ignore
}
InlongGroupInfo groupInfo = new InlongGroupInfo();
groupInfo.setName("test");
groupInfo.setInCharges(OPERATOR);
groupInfo.setInlongGroupId("b_test");
groupInfo.setMiddlewareType(middlewareType);
groupInfo.setMqExtInfo(new InlongGroupPulsarInfo());
groupInfo.setMqResourceObj("test-queue");
groupService.save(groupInfo.genRequest(), OPERATOR);
groupInfo.setStatus(GroupState.TO_BE_APPROVAL.getCode());
groupService.update(groupInfo.genRequest(), OPERATOR);
groupInfo.setStatus(GroupState.APPROVE_PASSED.getCode());
groupService.update(groupInfo.genRequest(), OPERATOR);
groupInfo.setStatus(GroupState.CONFIG_ING.getCode());
groupService.update(groupInfo.genRequest(), OPERATOR);
form = new GroupResourceProcessForm();
form.setInlongStreamId(STREAM_ID);
form.setGroupInfo(groupInfo);
return groupInfo;
}
use of org.apache.inlong.manager.common.pojo.group.InlongGroupInfo 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.common.pojo.group.InlongGroupInfo 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.common.pojo.group.InlongGroupInfo in project incubator-inlong by apache.
the class NewConsumptionWorkflowDefinition method bizOwnerUserTaskApprover.
private List<String> bizOwnerUserTaskApprover(WorkflowContext context) {
NewConsumptionProcessForm form = (NewConsumptionProcessForm) context.getProcessForm();
InlongGroupInfo groupInfo = groupService.get(form.getConsumptionInfo().getInlongGroupId());
if (groupInfo == null || groupInfo.getInCharges() == null) {
return Collections.emptyList();
}
return Arrays.asList(groupInfo.getInCharges().split(","));
}
Aggregations