use of org.apache.inlong.manager.service.thirdparty.mq.CreatePulsarResourceTaskListener 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.service.thirdparty.mq.CreatePulsarResourceTaskListener 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.service.thirdparty.mq.CreatePulsarResourceTaskListener in project incubator-inlong by apache.
the class WorkflowServiceImplTest method mockTaskListenerFactory.
/**
* Mock the task listener factory
*/
public void mockTaskListenerFactory() {
CreateTubeGroupTaskListener createTubeGroupTaskListener = mock(CreateTubeGroupTaskListener.class);
when(createTubeGroupTaskListener.listen(any(WorkflowContext.class))).thenReturn(ListenerResult.success());
when(createTubeGroupTaskListener.name()).thenReturn(CreateHiveTableListener.class.getSimpleName());
when(createTubeGroupTaskListener.event()).thenReturn(TaskEvent.COMPLETE);
taskListenerFactory.setCreateTubeGroupTaskListener(createTubeGroupTaskListener);
CreateTubeTopicTaskListener createTubeTopicTaskListener = mock(CreateTubeTopicTaskListener.class);
when(createTubeTopicTaskListener.listen(any(WorkflowContext.class))).thenReturn(ListenerResult.success());
when(createTubeTopicTaskListener.name()).thenReturn(CreateTubeTopicTaskListener.class.getSimpleName());
when(createTubeTopicTaskListener.event()).thenReturn(TaskEvent.COMPLETE);
taskListenerFactory.setCreateTubeTopicTaskListener(createTubeTopicTaskListener);
CreatePulsarResourceTaskListener createPulsarResourceTaskListener = mock(CreatePulsarResourceTaskListener.class);
when(createPulsarResourceTaskListener.listen(any(WorkflowContext.class))).thenReturn(ListenerResult.success());
when(createPulsarResourceTaskListener.name()).thenReturn(CreatePulsarResourceTaskListener.class.getSimpleName());
when(createPulsarResourceTaskListener.event()).thenReturn(TaskEvent.COMPLETE);
taskListenerFactory.setCreatePulsarResourceTaskListener(createPulsarResourceTaskListener);
CreatePulsarGroupTaskListener createPulsarGroupTaskListener = mock(CreatePulsarGroupTaskListener.class);
when(createPulsarGroupTaskListener.listen(any(WorkflowContext.class))).thenReturn(ListenerResult.success());
when(createPulsarGroupTaskListener.name()).thenReturn(CreatePulsarGroupTaskListener.class.getSimpleName());
when(createPulsarGroupTaskListener.event()).thenReturn(TaskEvent.COMPLETE);
taskListenerFactory.setCreatePulsarGroupTaskListener(createPulsarGroupTaskListener);
CreateHiveTableListener createHiveTableListener = mock(CreateHiveTableListener.class);
when(createHiveTableListener.listen(any(WorkflowContext.class))).thenReturn(ListenerResult.success());
when(createHiveTableListener.name()).thenReturn(CreateHiveTableListener.class.getSimpleName());
when(createHiveTableListener.event()).thenReturn(TaskEvent.COMPLETE);
taskListenerFactory.setCreateHiveTableListener(createHiveTableListener);
PushSortConfigListener pushSortConfigListener = mock(PushSortConfigListener.class);
when(pushSortConfigListener.listen(any(WorkflowContext.class))).thenReturn(ListenerResult.success());
when(pushSortConfigListener.name()).thenReturn(PushSortConfigListener.class.getSimpleName());
when(pushSortConfigListener.event()).thenReturn(TaskEvent.COMPLETE);
taskListenerFactory.setPushSortConfigListener(pushSortConfigListener);
taskListenerFactory.clearListeners();
taskListenerFactory.init();
}
Aggregations