From 6da34e9995ea5f010258632e630e3e52651d0321 Mon Sep 17 00:00:00 2001 From: elguardian Date: Tue, 14 Feb 2023 09:23:03 +0100 Subject: [PATCH] [KOGITO-8652] Exception/Error thrown in a sub-process doesn't reach the boundary error in the parent Service Task --- .../java/org/jbpm/bpmn2/ErrorEventTest.java | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/jbpm/jbpm-bpmn2/src/test/java/org/jbpm/bpmn2/ErrorEventTest.java b/jbpm/jbpm-bpmn2/src/test/java/org/jbpm/bpmn2/ErrorEventTest.java index 968694f73af..14c88827998 100755 --- a/jbpm/jbpm-bpmn2/src/test/java/org/jbpm/bpmn2/ErrorEventTest.java +++ b/jbpm/jbpm-bpmn2/src/test/java/org/jbpm/bpmn2/ErrorEventTest.java @@ -22,6 +22,7 @@ import org.jbpm.bpmn2.handler.ServiceTaskHandler; import org.jbpm.bpmn2.handler.SignallingTaskHandlerDecorator; +import org.jbpm.bpmn2.handler.WorkItemHandlerRuntimeException; import org.jbpm.bpmn2.objects.ExceptionOnPurposeHandler; import org.jbpm.bpmn2.objects.MyError; import org.jbpm.bpmn2.objects.Person; @@ -30,9 +31,11 @@ import org.jbpm.process.instance.impl.demo.DoNothingWorkItemHandler; import org.jbpm.process.instance.impl.demo.SystemOutWorkItemHandler; import org.jbpm.workflow.instance.WorkflowProcessInstance; +import org.jbpm.workflow.instance.WorkflowRuntimeException; import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import org.kie.api.event.process.ProcessNodeLeftEvent; +import org.kie.api.event.process.ProcessNodeTriggeredEvent; import org.kie.kogito.internal.process.event.DefaultKogitoProcessEventListener; import org.kie.kogito.internal.process.event.KogitoProcessEventListener; import org.kie.kogito.internal.process.runtime.KogitoNodeInstance; @@ -79,6 +82,44 @@ public void afterNodeLeft(ProcessNodeLeftEvent event) { } + @Test + public void testEventSubprocessThrowError() throws Exception { + kruntime = createKogitoProcessRuntime( + "BPMN2-TerminateErrorEventSubprocessWithBoundaryError.bpmn2", "BPMN2-TerminateErrorSubprocess.bpmn2"); + final List executednodes = new ArrayList<>(); + KogitoProcessEventListener listener = new DefaultKogitoProcessEventListener() { + + @Override + public void beforeNodeTriggered(ProcessNodeTriggeredEvent event) { + System.out.println(event); + } + + }; + + kruntime.getProcessEventManager().addEventListener(listener); + kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Service Task", new KogitoWorkItemHandler() { + + @Override + public void executeWorkItem(KogitoWorkItem workItem, KogitoWorkItemManager manager) { + throw new RuntimeException("Adios! "); + + } + + @Override + public void abortWorkItem(KogitoWorkItem workItem, KogitoWorkItemManager manager) { + // TODO Auto-generated method stub + + } + }); + KogitoProcessInstance processInstance = kruntime.startProcess("TerminateErrorEventSubprocessWithBoundaryError"); + + + assertNodeTriggered(processInstance.getStringId(), "start", "User Task 1", + "end", "Sub Process 1", "start-sub", "Script Task 1", "end-sub"); + assertThat(executednodes).hasSize(1); + + } + @Test public void testEventSubprocessErrorThrowOnTask() throws Exception { kruntime = createKogitoProcessRuntime("BPMN2-EventSubprocessError.bpmn2");