diff --git a/jbpm/jbpm-tests/src/test/bpmn/org/jbpm/bpmn2/activity/BPMN2-ScriptTaskFEEL.bpmn2 b/jbpm/jbpm-tests/src/test/bpmn/org/jbpm/bpmn2/activity/BPMN2-ScriptTaskFEEL.bpmn2
index 0b5aaca47c0..4a3ee8caf6d 100755
--- a/jbpm/jbpm-tests/src/test/bpmn/org/jbpm/bpmn2/activity/BPMN2-ScriptTaskFEEL.bpmn2
+++ b/jbpm/jbpm-tests/src/test/bpmn/org/jbpm/bpmn2/activity/BPMN2-ScriptTaskFEEL.bpmn2
@@ -33,6 +33,7 @@
+
@@ -41,6 +42,7 @@
+
diff --git a/jbpm/jbpm-tests/src/test/bpmn/org/jbpm/bpmn2/subprocess/BPMN2-DynamicSignalParent.bpmn2 b/jbpm/jbpm-tests/src/test/bpmn/org/jbpm/bpmn2/subprocess/BPMN2-DynamicSignalParent.bpmn2
index 5a373981527..a3e3717e44f 100755
--- a/jbpm/jbpm-tests/src/test/bpmn/org/jbpm/bpmn2/subprocess/BPMN2-DynamicSignalParent.bpmn2
+++ b/jbpm/jbpm-tests/src/test/bpmn/org/jbpm/bpmn2/subprocess/BPMN2-DynamicSignalParent.bpmn2
@@ -20,7 +20,7 @@
-
+
diff --git a/jbpm/jbpm-tests/src/test/java/org/jbpm/bpmn2/ActivityTest.java b/jbpm/jbpm-tests/src/test/java/org/jbpm/bpmn2/ActivityTest.java
index 4a8cca632c9..12a86a7b2ed 100755
--- a/jbpm/jbpm-tests/src/test/java/org/jbpm/bpmn2/ActivityTest.java
+++ b/jbpm/jbpm-tests/src/test/java/org/jbpm/bpmn2/ActivityTest.java
@@ -31,6 +31,8 @@
import java.util.stream.Collectors;
import org.drools.compiler.rule.builder.PackageBuildContext;
+import org.jbpm.bpmn2.activity.ScriptTaskFEELModel;
+import org.jbpm.bpmn2.activity.ScriptTaskFEELProcess;
import org.jbpm.bpmn2.activity.ScriptTaskModel;
import org.jbpm.bpmn2.activity.ScriptTaskProcess;
import org.jbpm.bpmn2.activity.ScriptTaskWithIOModel;
@@ -1805,28 +1807,27 @@ public void testBusinessRuleTaskFireLimitAsParameter() throws Exception {
}
@Test
- @Disabled("On Exit not supported, see https://issues.redhat.com/browse/KOGITO-2067")
- public void testScriptTaskFEEL() throws Exception {
- kruntime = createKogitoProcessRuntime("BPMN2-ScriptTaskFEEL.bpmn2");
-
- TestWorkItemHandler handler = new TestWorkItemHandler();
- kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Human Task", handler);
-
- Map params = new HashMap<>();
- params.put("name", "krisv");
+ public void testScriptTaskFEEL() {
+ Application app = ProcessTestHelper.newApplication();
+ TestWorkItemHandler workItemHandler = new TestWorkItemHandler();
+ EventTrackerProcessListener tracker = new EventTrackerProcessListener();
+ ProcessTestHelper.registerHandler(app, "Human Task", workItemHandler);
+ ProcessTestHelper.registerProcessEventListener(app, tracker);
+ org.kie.kogito.process.Process processDefinition = ScriptTaskFEELProcess.newProcess(app);
+ ScriptTaskFEELModel model = processDefinition.createModel();
+ model.setName("krisv");
Person person = new Person();
person.setName("krisv");
- params.put("person", person);
-
- KogitoProcessInstance processInstance = kruntime.startProcess("ScriptTask", params);
- assertThat(((org.jbpm.workflow.instance.WorkflowProcessInstance) processInstance).getVariable("x")).isEqualTo("Entry");
- assertThat(((org.jbpm.workflow.instance.WorkflowProcessInstance) processInstance).getVariable("y")).isNull();
-
- kruntime.getKogitoWorkItemManager().completeWorkItem(handler.getWorkItem().getStringId(), null);
- assertThat(getProcessVarValue(processInstance, "y")).isEqualTo("Exit");
- assertThat(((org.jbpm.workflow.instance.WorkflowProcessInstance) processInstance).getVariable("surname")).isEqualTo("tester");
-
- assertNodeTriggered(processInstance.getStringId(), "Script1");
+ model.setPerson(person);
+ ProcessInstance processInstance = processDefinition.createInstance(model);
+ processInstance.start();
+ assertThat(processInstance.variables().getX()).isEqualTo("Entry");
+ assertThat(processInstance.variables().getY()).isNull();
+ ProcessTestHelper.completeWorkItem(processInstance, Collections.emptyMap());
+ assertThat(processInstance.variables().getY()).isEqualTo("Exit");
+ assertThat(processInstance.variables().getSurname()).isEqualTo("tester");
+ Set nodes = tracker.tracked().stream().map(event -> event.getNodeInstance().getNodeName()).collect(Collectors.toSet());
+ assertThat(nodes.contains("Script1")).isTrue();
}
@Test
diff --git a/jbpm/jbpm-tests/src/test/java/org/jbpm/bpmn2/ErrorEventTest.java b/jbpm/jbpm-tests/src/test/java/org/jbpm/bpmn2/ErrorEventTest.java
index 7d80ffd4b3e..da9341b1bc3 100755
--- a/jbpm/jbpm-tests/src/test/java/org/jbpm/bpmn2/ErrorEventTest.java
+++ b/jbpm/jbpm-tests/src/test/java/org/jbpm/bpmn2/ErrorEventTest.java
@@ -25,6 +25,10 @@
import java.util.Map;
import java.util.Optional;
+import org.jbpm.bpmn2.error.BoundaryErrorEventCatchingOnEntryExceptionModel;
+import org.jbpm.bpmn2.error.BoundaryErrorEventCatchingOnEntryExceptionProcess;
+import org.jbpm.bpmn2.error.BoundaryErrorEventCatchingOnExitExceptionModel;
+import org.jbpm.bpmn2.error.BoundaryErrorEventCatchingOnExitExceptionProcess;
import org.jbpm.bpmn2.error.BoundaryErrorEventDefaultHandlerByErrorCodeModel;
import org.jbpm.bpmn2.error.BoundaryErrorEventDefaultHandlerByErrorCodeProcess;
import org.jbpm.bpmn2.error.BoundaryErrorEventDefaultHandlerWithErrorCodeWithStructureRefModel;
@@ -71,7 +75,6 @@
import org.jbpm.process.workitem.builtin.SystemOutWorkItemHandler;
import org.jbpm.test.utils.EventTrackerProcessListener;
import org.jbpm.test.utils.ProcessTestHelper;
-import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.kie.api.event.process.DefaultProcessEventListener;
import org.kie.api.event.process.ProcessNodeLeftEvent;
@@ -445,31 +448,31 @@ public void testEventSubProcessErrorWithScript() throws Exception {
}
@Test
- @Disabled("On Exit not supported, see https://issues.redhat.com/browse/KOGITO-2067")
- public void testErrorBoundaryEventOnEntry() throws Exception {
- kruntime = createKogitoProcessRuntime("BPMN2-BoundaryErrorEventCatchingOnEntryException.bpmn2");
- TestWorkItemHandler handler = new TestWorkItemHandler();
- kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Human Task", handler);
-
- KogitoProcessInstance processInstance = kruntime.startProcess("BoundaryErrorEventOnEntry");
-
- assertProcessInstanceActive(processInstance.getStringId(), kruntime);
- assertThat(handler.getWorkItems()).hasSize(1);
+ public void testErrorBoundaryEventOnEntry() {
+ Application app = ProcessTestHelper.newApplication();
+ TestWorkItemHandler workItemHandler = new TestWorkItemHandler();
+ ProcessTestHelper.registerHandler(app, "Human Task", workItemHandler);
+ org.kie.kogito.process.Process processDefinition = BoundaryErrorEventCatchingOnEntryExceptionProcess.newProcess(app);
+ BoundaryErrorEventCatchingOnEntryExceptionModel model = processDefinition.createModel();
+ ProcessInstance processInstance = processDefinition.createInstance(model);
+ processInstance.start();
+ assertThat(processInstance.status()).isEqualTo(ProcessInstance.STATE_ACTIVE);
+ assertThat(workItemHandler.getWorkItems()).hasSize(1);
}
@Test
- @Disabled("On Exit not supported, see https://issues.redhat.com/browse/KOGITO-2067")
- public void testErrorBoundaryEventOnExit() throws Exception {
- kruntime = createKogitoProcessRuntime("BPMN2-BoundaryErrorEventCatchingOnExitException.bpmn2");
- TestWorkItemHandler handler = new TestWorkItemHandler();
- kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Human Task", handler);
-
- KogitoProcessInstance processInstance = kruntime.startProcess("BoundaryErrorEventOnExit");
-
- assertProcessInstanceActive(processInstance.getStringId(), kruntime);
- KogitoWorkItem workItem = handler.getWorkItem();
- kruntime.getKogitoWorkItemManager().completeWorkItem(workItem.getStringId(), null);
- assertThat(handler.getWorkItems()).hasSize(1);
+ public void testErrorBoundaryEventOnExit() {
+ Application app = ProcessTestHelper.newApplication();
+ TestWorkItemHandler workItemHandler = new TestWorkItemHandler();
+ ProcessTestHelper.registerHandler(app, "Human Task", workItemHandler);
+ org.kie.kogito.process.Process processDefinition = BoundaryErrorEventCatchingOnExitExceptionProcess.newProcess(app);
+ BoundaryErrorEventCatchingOnExitExceptionModel model = processDefinition.createModel();
+ ProcessInstance processInstance = processDefinition.createInstance(model);
+ processInstance.start();
+ assertThat(processInstance.status()).isEqualTo(ProcessInstance.STATE_ACTIVE);
+ KogitoWorkItem workItem = workItemHandler.getWorkItem();
+ processInstance.completeWorkItem(workItem.getStringId(), Collections.emptyMap());
+ assertThat(workItemHandler.getWorkItems()).hasSize(1);
}
@Test
diff --git a/jbpm/jbpm-tests/src/test/java/org/jbpm/bpmn2/FlowTest.java b/jbpm/jbpm-tests/src/test/java/org/jbpm/bpmn2/FlowTest.java
index 4223c3ed323..5fd224e7f4e 100755
--- a/jbpm/jbpm-tests/src/test/java/org/jbpm/bpmn2/FlowTest.java
+++ b/jbpm/jbpm-tests/src/test/java/org/jbpm/bpmn2/FlowTest.java
@@ -55,6 +55,10 @@
import org.jbpm.bpmn2.flow.InclusiveGatewayWithDefaultProcess;
import org.jbpm.bpmn2.flow.InclusiveGatewayWithHumanTasksProcessModel;
import org.jbpm.bpmn2.flow.InclusiveGatewayWithHumanTasksProcessProcess;
+import org.jbpm.bpmn2.flow.InclusiveGatewayWithLoopInsideModel;
+import org.jbpm.bpmn2.flow.InclusiveGatewayWithLoopInsideProcess;
+import org.jbpm.bpmn2.flow.InclusiveGatewayWithLoopInsideSubprocessModel;
+import org.jbpm.bpmn2.flow.InclusiveGatewayWithLoopInsideSubprocessProcess;
import org.jbpm.bpmn2.flow.InclusiveNestedInParallelNestedInExclusiveModel;
import org.jbpm.bpmn2.flow.InclusiveNestedInParallelNestedInExclusiveProcess;
import org.jbpm.bpmn2.flow.InclusiveSplitAndJoinEmbeddedModel;
@@ -89,10 +93,14 @@
import org.jbpm.bpmn2.flow.MultiInstanceLoopCharacteristicsProcessWithOutputCmpCondProcess;
import org.jbpm.bpmn2.flow.MultiInstanceLoopCharacteristicsProcessWithOutputModel;
import org.jbpm.bpmn2.flow.MultiInstanceLoopCharacteristicsProcessWithOutputProcess;
+import org.jbpm.bpmn2.flow.MultiInstanceLoopCharacteristicsTaskWithOutputModel;
+import org.jbpm.bpmn2.flow.MultiInstanceLoopCharacteristicsTaskWithOutputProcess;
import org.jbpm.bpmn2.flow.MultiInstanceLoopNumberingModel;
import org.jbpm.bpmn2.flow.MultiInstanceLoopNumberingProcess;
import org.jbpm.bpmn2.flow.MultipleGatewaysProcessModel;
import org.jbpm.bpmn2.flow.MultipleGatewaysProcessProcess;
+import org.jbpm.bpmn2.loop.MultiInstanceLoopCharacteristicsProcessWithOutputAndScriptsModel;
+import org.jbpm.bpmn2.loop.MultiInstanceLoopCharacteristicsProcessWithOutputAndScriptsProcess;
import org.jbpm.bpmn2.loop.MultiInstanceLoopCharacteristicsTaskModel;
import org.jbpm.bpmn2.loop.MultiInstanceLoopCharacteristicsTaskProcess;
import org.jbpm.bpmn2.objects.TestUserTaskWorkItemHandler;
@@ -779,50 +787,55 @@ public void testInclusiveSplitNested() {
}
@Test
- @Disabled("On Exit not supported, see https://issues.redhat.com/browse/KOGITO-2067")
- public void testInclusiveSplitWithLoopInside() throws Exception {
- kruntime = createKogitoProcessRuntime("BPMN2-InclusiveGatewayWithLoopInside.bpmn2");
-
+ public void testInclusiveSplitWithLoopInside() {
+ Application app = ProcessTestHelper.newApplication();
final Map nodeInstanceExecutionCounter = new HashMap<>();
- kruntime.getProcessEventManager().addEventListener(new DefaultKogitoProcessEventListener() {
+ ProcessTestHelper.registerProcessEventListener(app, new DefaultKogitoProcessEventListener() {
@Override
public void beforeNodeTriggered(ProcessNodeTriggeredEvent event) {
logger.info("{} {}", event.getNodeInstance().getNodeName(), ((NodeInstanceImpl) event.getNodeInstance()).getLevel());
Integer value = nodeInstanceExecutionCounter.get(event.getNodeInstance().getNodeName());
if (value == null) {
- value = new Integer(0);
+ value = 0;
}
-
value++;
nodeInstanceExecutionCounter.put(event.getNodeInstance().getNodeName(), value);
}
-
});
+
TestWorkItemHandler handler = new TestWorkItemHandler();
TestWorkItemHandler handler2 = new TestWorkItemHandler();
- kruntime.getKogitoWorkItemManager().registerWorkItemHandler("testWI", handler);
- kruntime.getKogitoWorkItemManager().registerWorkItemHandler("testWI2", handler2);
- Map params = new HashMap<>();
- params.put("x", -1);
- KogitoProcessInstance processInstance = kruntime.startProcess("Process_1", params);
+ ProcessTestHelper.registerHandler(app, "testWI", handler);
+ ProcessTestHelper.registerHandler(app, "testWI2", handler2);
+
+ org.kie.kogito.process.Process processDefinition = InclusiveGatewayWithLoopInsideProcess.newProcess(app);
+ InclusiveGatewayWithLoopInsideModel model = processDefinition.createModel();
+ model.setX(-1);
+ ProcessInstance processInstance = processDefinition.createInstance(model);
+ processInstance.start();
+
+ assertThat(processInstance.status()).isEqualTo(ProcessInstance.STATE_ACTIVE);
- assertProcessInstanceActive(processInstance);
List workItems = handler.getWorkItems();
assertThat(workItems).isNotNull().hasSize(2);
for (KogitoWorkItem wi : workItems) {
- assertProcessInstanceActive(processInstance);
- kruntime.getKogitoWorkItemManager().completeWorkItem(wi.getStringId(), null);
+ assertThat(processInstance.status()).isEqualTo(ProcessInstance.STATE_ACTIVE);
+ processInstance.completeWorkItem(wi.getStringId(), null);
}
- assertProcessInstanceActive(processInstance);
- kruntime.getKogitoWorkItemManager().completeWorkItem(handler2.getWorkItem().getStringId(), null);
- assertProcessInstanceActive(processInstance);
- kruntime.getKogitoWorkItemManager().completeWorkItem(handler2.getWorkItem().getStringId(), null);
- assertProcessInstanceActive(processInstance);
- kruntime.getKogitoWorkItemManager().completeWorkItem(handler.getWorkItem().getStringId(), null);
- assertProcessInstanceCompleted(processInstance);
+ assertThat(processInstance.status()).isEqualTo(ProcessInstance.STATE_ACTIVE);
+ processInstance.completeWorkItem(handler2.getWorkItem().getStringId(), null);
+
+ assertThat(processInstance.status()).isEqualTo(ProcessInstance.STATE_ACTIVE);
+ processInstance.completeWorkItem(handler2.getWorkItem().getStringId(), null);
+
+ assertThat(processInstance.status()).isEqualTo(ProcessInstance.STATE_ACTIVE);
+ processInstance.completeWorkItem(handler.getWorkItem().getStringId(), null);
+
+ assertThat(processInstance.status()).isEqualTo(ProcessInstance.STATE_COMPLETED);
+
assertThat(nodeInstanceExecutionCounter).hasSize(10);
assertThat((int) nodeInstanceExecutionCounter.get("Start")).isEqualTo(1);
assertThat((int) nodeInstanceExecutionCounter.get("OR diverging")).isEqualTo(1);
@@ -1124,25 +1137,24 @@ public void testMultiInstanceLoopCharacteristicsProcessWithOutputCompletionCondi
}
@Test
- @Disabled("On Exit not supported, see https://issues.redhat.com/browse/KOGITO-2067")
- public void testMultiInstanceLoopCharacteristicsProcessWithOutputAndScripts()
- throws Exception {
- kruntime = createKogitoProcessRuntime("BPMN2-MultiInstanceLoopCharacteristicsProcessWithOutputAndScripts.bpmn2");
- Map params = new HashMap<>();
+ public void testMultiInstanceLoopCharacteristicsProcessWithOutputAndScripts() {
+ Application app = ProcessTestHelper.newApplication();
List myList = new ArrayList<>();
List myListOut = new ArrayList<>();
List scriptList = new ArrayList<>();
myList.add("First Item");
myList.add("Second Item");
- params.put("list", myList);
- params.put("listOut", myListOut);
- params.put("scriptList", scriptList);
assertThat(myListOut).isEmpty();
- KogitoProcessInstance processInstance = kruntime.startProcess("MultiInstanceLoopCharacteristicsProcessWithOutput", params);
- assertProcessInstanceCompleted(processInstance);
+ org.kie.kogito.process.Process processDefinition = MultiInstanceLoopCharacteristicsProcessWithOutputAndScriptsProcess.newProcess(app);
+ MultiInstanceLoopCharacteristicsProcessWithOutputAndScriptsModel model = processDefinition.createModel();
+ model.setList(myList);
+ model.setListOut(myListOut);
+ model.setScriptList(scriptList);
+ ProcessInstance processInstance = processDefinition.createInstance(model);
+ processInstance.start();
+ assertThat(processInstance.status()).isEqualTo(ProcessInstance.STATE_COMPLETED);
assertThat(myListOut).hasSize(2);
assertThat(scriptList).hasSize(2);
-
}
@Test
diff --git a/jbpm/jbpm-tests/src/test/java/org/jbpm/bpmn2/IntermediateEventTest.java b/jbpm/jbpm-tests/src/test/java/org/jbpm/bpmn2/IntermediateEventTest.java
index bace4169053..938ca3d29d3 100755
--- a/jbpm/jbpm-tests/src/test/java/org/jbpm/bpmn2/IntermediateEventTest.java
+++ b/jbpm/jbpm-tests/src/test/java/org/jbpm/bpmn2/IntermediateEventTest.java
@@ -116,6 +116,10 @@
import org.jbpm.bpmn2.objects.Person;
import org.jbpm.bpmn2.objects.TestUserTaskWorkItemHandler;
import org.jbpm.bpmn2.objects.TestWorkItemHandler;
+import org.jbpm.bpmn2.subprocess.DynamicSignalChildModel;
+import org.jbpm.bpmn2.subprocess.DynamicSignalChildProcess;
+import org.jbpm.bpmn2.subprocess.DynamicSignalParentModel;
+import org.jbpm.bpmn2.subprocess.DynamicSignalParentProcess;
import org.jbpm.bpmn2.subprocess.EventSubprocessConditionalModel;
import org.jbpm.bpmn2.subprocess.EventSubprocessConditionalProcess;
import org.jbpm.bpmn2.subprocess.EventSubprocessMessageModel;
@@ -167,6 +171,7 @@
import org.kie.kogito.process.EventDescription;
import org.kie.kogito.process.NamedDataType;
import org.kie.kogito.process.ProcessInstance;
+import org.kie.kogito.process.ProcessInstances;
import org.kie.kogito.process.impl.Sig;
import org.kie.kogito.process.workitems.impl.DefaultKogitoWorkItemHandler;
@@ -2644,45 +2649,23 @@ public void testSignalEndWithData() throws Exception {
}
@Test
- @Disabled("On Exit not supported, see https://issues.redhat.com/browse/KOGITO-2067")
- public void testDynamicCatchEventSignal() throws Exception {
- kruntime = createKogitoProcessRuntime("subprocess/dynamic-signal-parent.bpmn2",
- "subprocess/dynamic-signal-child.bpmn2");
- TestWorkItemHandler handler = new TestWorkItemHandler();
- kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Human Task", handler);
- final List instances = new ArrayList<>();
-
- kruntime.getProcessEventManager().addEventListener(new DefaultKogitoProcessEventListener() {
-
- @Override
- public void beforeProcessStarted(ProcessStartedEvent event) {
- instances.add(((KogitoProcessInstance) event.getProcessInstance()).getStringId());
- }
-
- });
-
- KogitoProcessInstance processInstance = kruntime.startProcess("src.father");
- assertProcessInstanceActive(processInstance);
- assertThat(instances).hasSize(4);
-
- // remove the parent process instance
- instances.remove(processInstance.getStringId());
-
- for (String id : instances) {
- KogitoProcessInstance child = kruntime.getProcessInstance(id);
- assertProcessInstanceActive(child);
- }
-
- // now complete user task to signal all child instances to stop
- KogitoWorkItem workItem = handler.getWorkItem();
+ void testDynamicCatchEventSignal() {
+ Application app = ProcessTestHelper.newApplication();
+ TestWorkItemHandler workItemHandler = new TestWorkItemHandler();
+ ProcessTestHelper.registerHandler(app, "Human Task", workItemHandler);
+ org.kie.kogito.process.Process processDefinition = DynamicSignalParentProcess.newProcess(app);
+ DynamicSignalParentModel model = processDefinition.createModel();
+ ProcessInstance processInstance = processDefinition.createInstance(model);
+ org.kie.kogito.process.Process childProcessDefinition = DynamicSignalChildProcess.newProcess(app);
+ processInstance.start();
+ assertThat(processInstance.status()).isEqualTo(ProcessInstance.STATE_ACTIVE);
+ List> childInstances = childProcessDefinition.instances().stream().toList();
+ assertThat(childInstances).hasSize(3);
+ childInstances.forEach(instance -> assertThat(instance.status()).isEqualTo(ProcessInstance.STATE_ACTIVE));
+ KogitoWorkItem workItem = workItemHandler.getWorkItem();
assertThat(workItem).isNotNull();
-
- kruntime.getKogitoWorkItemManager().completeWorkItem(workItem.getStringId(), null);
- assertProcessInstanceFinished(processInstance, kruntime);
-
- for (String id : instances) {
- assertThat(kruntime.getProcessInstance(id)).as("Child process instance has not been finished.").isNull();
- }
+ processInstance.completeWorkItem(workItem.getStringId(), Collections.emptyMap());
+ assertThat(processInstance.status()).isEqualTo(ProcessInstance.STATE_COMPLETED);
}
@Test