Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[KOGITO-8652] Exception/Error thrown in a sub-process doesn't reach the boundary error in the parent Service Task #2803

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions jbpm/jbpm-bpmn2/src/test/java/org/jbpm/bpmn2/ErrorEventTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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<String> 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");
Expand Down