use of org.kie.kogito.internal.process.event.KogitoProcessEventListener in project kogito-runtimes by kiegroup.
the class IntermediateEventTest method testEventSubprocessSignalInterrupting.
@Test
public void testEventSubprocessSignalInterrupting() throws Exception {
kruntime = createKogitoProcessRuntime("BPMN2-EventSubprocessSignalInterrupting.bpmn2");
final List<String> executednodes = new ArrayList<>();
KogitoProcessEventListener listener = new DefaultKogitoProcessEventListener() {
@Override
public void afterNodeLeft(ProcessNodeLeftEvent event) {
if (event.getNodeInstance().getNodeName().equals("Script Task 1")) {
executednodes.add(((KogitoNodeInstance) event.getNodeInstance()).getStringId());
}
}
};
kruntime.getProcessEventManager().addEventListener(listener);
TestWorkItemHandler workItemHandler = new TestWorkItemHandler();
kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Human Task", workItemHandler);
KogitoProcessInstance processInstance = kruntime.startProcess("BPMN2-EventSubprocessSignal");
assertProcessInstanceActive(processInstance);
kruntime.getProcessEventManager().addEventListener(listener);
kruntime.signalEvent("MySignal", null, processInstance.getStringId());
assertProcessInstanceFinished(processInstance, kruntime);
assertNodeTriggered(processInstance.getStringId(), "start", "User Task 1", "Sub Process 1", "start-sub", "Script Task 1", "end-sub");
assertThat(executednodes.size()).isEqualTo(1);
}
use of org.kie.kogito.internal.process.event.KogitoProcessEventListener in project kogito-runtimes by kiegroup.
the class IntermediateEventTest method testEventSubprocessSignalWithStateNode.
@Test
public void testEventSubprocessSignalWithStateNode() throws Exception {
kruntime = createKogitoProcessRuntime("BPMN2-EventSubprocessSignalWithStateNode.bpmn2");
final List<String> executednodes = new ArrayList<>();
KogitoProcessEventListener listener = new DefaultKogitoProcessEventListener() {
@Override
public void afterNodeLeft(ProcessNodeLeftEvent event) {
if (event.getNodeInstance().getNodeName().equals("User Task 2")) {
executednodes.add(((KogitoNodeInstance) event.getNodeInstance()).getStringId());
}
}
};
kruntime.getProcessEventManager().addEventListener(listener);
TestWorkItemHandler workItemHandler = new TestWorkItemHandler();
kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Human Task", workItemHandler);
KogitoProcessInstance processInstance = kruntime.startProcess("BPMN2-EventSubprocessSignal");
assertProcessInstanceActive(processInstance);
kruntime.getProcessEventManager().addEventListener(listener);
kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Human Task", workItemHandler);
KogitoWorkItem workItemTopProcess = workItemHandler.getWorkItem();
kruntime.signalEvent("MySignal", null, processInstance.getStringId());
assertProcessInstanceActive(processInstance);
KogitoWorkItem workItem = workItemHandler.getWorkItem();
assertThat(workItem).isNotNull();
kruntime.getKogitoWorkItemManager().completeWorkItem(workItem.getStringId(), null);
kruntime.signalEvent("MySignal", null);
assertProcessInstanceActive(processInstance);
workItem = workItemHandler.getWorkItem();
assertThat(workItem).isNotNull();
kruntime.getKogitoWorkItemManager().completeWorkItem(workItem.getStringId(), null);
kruntime.signalEvent("MySignal", null);
assertProcessInstanceActive(processInstance);
workItem = workItemHandler.getWorkItem();
assertThat(workItem).isNotNull();
kruntime.getKogitoWorkItemManager().completeWorkItem(workItem.getStringId(), null);
kruntime.signalEvent("MySignal", null);
assertProcessInstanceActive(processInstance);
workItem = workItemHandler.getWorkItem();
assertThat(workItem).isNotNull();
kruntime.getKogitoWorkItemManager().completeWorkItem(workItem.getStringId(), null);
assertThat(workItemTopProcess).isNotNull();
kruntime.getKogitoWorkItemManager().completeWorkItem(workItemTopProcess.getStringId(), null);
assertProcessInstanceFinished(processInstance, kruntime);
assertNodeTriggered(processInstance.getStringId(), "start", "User Task 1", "end", "Sub Process 1", "start-sub", "User Task 2", "end-sub");
assertThat(executednodes.size()).isEqualTo(4);
}
use of org.kie.kogito.internal.process.event.KogitoProcessEventListener in project kogito-runtimes by kiegroup.
the class EscalationEventTest method testEventSubprocessEscalation.
@Test
public void testEventSubprocessEscalation() throws Exception {
kruntime = createKogitoProcessRuntime("escalation/BPMN2-EventSubprocessEscalation.bpmn2");
final List<String> executednodes = new ArrayList<>();
KogitoProcessEventListener listener = new DefaultKogitoProcessEventListener() {
@Override
public void afterNodeLeft(ProcessNodeLeftEvent event) {
if (event.getNodeInstance().getNodeName().equals("Script Task 1")) {
executednodes.add(((KogitoNodeInstance) event.getNodeInstance()).getStringId());
}
}
};
kruntime.getProcessEventManager().addEventListener(listener);
TestWorkItemHandler workItemHandler = new TestWorkItemHandler();
kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Human Task", workItemHandler);
KogitoProcessInstance processInstance = kruntime.startProcess("BPMN2-EventSubprocessEscalation");
assertProcessInstanceActive(processInstance);
kruntime.getProcessEventManager().addEventListener(listener);
KogitoWorkItem workItem = workItemHandler.getWorkItem();
assertNotNull(workItem);
kruntime.getKogitoWorkItemManager().completeWorkItem(workItem.getStringId(), null);
assertProcessInstanceFinished(processInstance, kruntime);
assertNodeTriggered(processInstance.getStringId(), "start", "User Task 1", "end", "Sub Process 1", "start-sub", "Script Task 1", "end-sub");
assertEquals(1, executednodes.size());
}
Aggregations