Skip to content

Commit 17da805

Browse files
Tihomir Surdilovicmswiderski
authored andcommitted
RHBPMS-1328 - business rule task supports boundary error event (#797)
1 parent b5ec6fe commit 17da805

10 files changed

+838
-78
lines changed

jbpm-bpmn2/src/test/java/org/jbpm/bpmn2/ActivityTest.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
import org.jbpm.process.instance.impl.demo.DoNothingWorkItemHandler;
3939
import org.jbpm.process.instance.impl.demo.SystemOutWorkItemHandler;
4040
import org.jbpm.test.util.CountDownProcessEventListener;
41+
import org.jbpm.workflow.instance.WorkflowRuntimeException;
4142
import org.jbpm.workflow.instance.node.DynamicNodeInstance;
4243
import org.jbpm.workflow.instance.node.DynamicUtils;
4344
import org.jbpm.workflow.instance.node.WorkItemNodeInstance;
@@ -1923,7 +1924,9 @@ public void testDMNBusinessRuleTaskInvalidExecution()throws Exception {
19231924
try {
19241925
ksession.startProcess("BPMN2-BusinessRuleTask", params);
19251926
} catch (Exception e) {
1926-
assertTrue(e.getMessage().contains("DMN result errors"));
1927+
assertTrue(e instanceof WorkflowRuntimeException);
1928+
assertTrue(e.getCause() instanceof RuntimeException);
1929+
assertTrue(e.getCause().getMessage().contains("DMN result errors"));
19271930
}
19281931
}
19291932

jbpm-bpmn2/src/test/java/org/jbpm/bpmn2/ErrorEventTest.java

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@
2626
import org.jbpm.bpmn2.handler.SignallingTaskHandlerDecorator;
2727
import org.jbpm.bpmn2.objects.ExceptionOnPurposeHandler;
2828
import org.jbpm.bpmn2.objects.MyError;
29+
import org.jbpm.bpmn2.objects.Person;
2930
import org.jbpm.bpmn2.objects.TestWorkItemHandler;
31+
import org.jbpm.process.instance.event.listeners.RuleAwareProcessEventLister;
3032
import org.jbpm.process.instance.impl.demo.DoNothingWorkItemHandler;
3133
import org.jbpm.process.instance.impl.demo.SystemOutWorkItemHandler;
3234
import org.jbpm.workflow.instance.WorkflowProcessInstance;
@@ -295,6 +297,47 @@ public void testErrorBoundaryEventOnServiceTask() throws Exception {
295297
assertProcessInstanceFinished(processInstance, ksession);
296298
assertNodeTriggered(processInstance.getId(), "start", "split", "User Task", "Service task error attached", "end0",
297299
"Script Task", "error2");
300+
301+
assertNotNodeTriggered(processInstance.getId(), "end");
302+
}
303+
304+
@Test
305+
public void testErrorBoundaryEventOnBusinessRuleTask() throws Exception {
306+
KieBase kbase = createKnowledgeBaseWithoutDumper("BPMN2-ErrorBoundaryEventOnBusinessRuleTask.bpmn2",
307+
"BPMN2-ErrorBoundaryEventOnBusinessRuleTask.drl");
308+
ksession = createKnowledgeSession(kbase);
309+
ksession.addEventListener(new RuleAwareProcessEventLister());
310+
ProcessInstance processInstance = ksession.startProcess("BPMN2-ErrorBoundaryEventOnBusinessRuleTask");
311+
312+
assertProcessInstanceFinished(processInstance, ksession);
313+
assertNodeTriggered(processInstance.getId(), "start", "business rule task error attached", "error1");
314+
}
315+
316+
@Test
317+
public void testMultiErrorBoundaryEventsOnBusinessRuleTask() throws Exception {
318+
KieBase kbase = createKnowledgeBaseWithoutDumper("BPMN2-MultiErrorBoundaryEventsOnBusinessRuleTask.bpmn2",
319+
"BPMN2-MultiErrorBoundaryEventsOnBusinessRuleTask.drl");
320+
ksession = createKnowledgeSession(kbase);
321+
ksession.addEventListener(new RuleAwareProcessEventLister());
322+
323+
Map<String, Object> params = new HashMap<String, Object>();
324+
params.put("person", new Person());
325+
ProcessInstance processInstance = ksession.startProcess("BPMN2-MultiErrorBoundaryEventeOnBusinessRuleTask", params);
326+
327+
assertProcessInstanceFinished(processInstance, ksession);
328+
assertNodeTriggered(processInstance.getId(), "start", "business rule task error attached",
329+
"NPE Script Task", "error1");
330+
331+
ksession.dispose();
332+
333+
ksession = createKnowledgeSession(kbase);
334+
ksession.addEventListener(new RuleAwareProcessEventLister());
335+
params = new HashMap<String, Object>();
336+
params.put("person", new Person("unsupported"));
337+
ProcessInstance processInstance2 = ksession.startProcess("BPMN2-MultiErrorBoundaryEventeOnBusinessRuleTask", params);
338+
assertProcessInstanceFinished(processInstance2, ksession);
339+
assertNodeTriggered(processInstance2.getId(), "start", "business rule task error attached",
340+
"UOE Script Task", "error2");
298341
}
299342

300343
@Test

jbpm-bpmn2/src/test/resources/BPMN2-ErrorBoundaryEventOnBusinessRuleTask.bpmn2

Lines changed: 203 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/*
2+
* Copyright 2015 Red Hat, Inc. and/or its affiliates.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
*
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* Unless required by applicable law or agreed to in writing, software
10+
* distributed under the License is distributed on an "AS IS" BASIS,
11+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
* See the License for the specific language governing permissions and
13+
* limitations under the License.
14+
*/
15+
16+
package defaultPackge;
17+
18+
import org.kie.api.runtime.process.WorkflowProcessInstance
19+
20+
rule ErrorBoundaryRule
21+
ruleflow-group "ErrorBoundaryRuleFlow"
22+
when
23+
WorkflowProcessInstance()
24+
then
25+
throw new NullPointerException("error");
26+
end

0 commit comments

Comments
 (0)