You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kie.apache.org by pe...@apache.org on 2024/12/05 15:11:47 UTC
(incubator-kie-kogito-runtimes) branch main updated: [incubator-kie-issues-1131] v7 migration to code generation (#3649)
This is an automated email from the ASF dual-hosted git repository.
pefernan pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-kie-kogito-runtimes.git
The following commit(s) were added to refs/heads/main by this push:
new 68b91160b5 [incubator-kie-issues-1131] v7 migration to code generation (#3649)
68b91160b5 is described below
commit 68b91160b55a5e1219ac0a01a19ec04c07e34f47
Author: Abhiram Gundala <16...@users.noreply.github.com>
AuthorDate: Thu Dec 5 10:11:42 2024 -0500
[incubator-kie-issues-1131] v7 migration to code generation (#3649)
---
.../test/java/org/jbpm/bpmn2/ErrorEventTest.java | 15 ++++
.../src/test/java/org/jbpm/bpmn2/FlowTest.java | 79 +++++++++-------------
2 files changed, 46 insertions(+), 48 deletions(-)
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 6840a87d13..7d80ffd4b3 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
@@ -37,6 +37,8 @@ import org.jbpm.bpmn2.error.EndErrorModel;
import org.jbpm.bpmn2.error.EndErrorProcess;
import org.jbpm.bpmn2.error.EndErrorWithEventSubprocessModel;
import org.jbpm.bpmn2.error.EndErrorWithEventSubprocessProcess;
+import org.jbpm.bpmn2.error.ErrorBoundaryEventInterruptingModel;
+import org.jbpm.bpmn2.error.ErrorBoundaryEventInterruptingProcess;
import org.jbpm.bpmn2.error.ErrorBoundaryEventOnServiceTaskModel;
import org.jbpm.bpmn2.error.ErrorBoundaryEventOnServiceTaskProcess;
import org.jbpm.bpmn2.error.ErrorVariableModel;
@@ -64,6 +66,7 @@ import org.jbpm.bpmn2.service.ExceptionServiceProcessErrorSignallingProcess;
import org.jbpm.bpmn2.subprocess.ExceptionServiceProcessSignallingModel;
import org.jbpm.bpmn2.subprocess.ExceptionServiceProcessSignallingProcess;
import org.jbpm.process.instance.event.listeners.RuleAwareProcessEventListener;
+import org.jbpm.process.workitem.builtin.DoNothingWorkItemHandler;
import org.jbpm.process.workitem.builtin.SignallingTaskHandlerDecorator;
import org.jbpm.process.workitem.builtin.SystemOutWorkItemHandler;
import org.jbpm.test.utils.EventTrackerProcessListener;
@@ -89,6 +92,7 @@ import org.kie.kogito.internal.process.workitem.KogitoWorkItemHandler;
import org.kie.kogito.internal.process.workitem.KogitoWorkItemManager;
import org.kie.kogito.internal.process.workitem.WorkItemExecutionException;
import org.kie.kogito.internal.process.workitem.WorkItemTransition;
+import org.kie.kogito.process.Process;
import org.kie.kogito.process.ProcessInstance;
import org.kie.kogito.process.workitems.impl.DefaultKogitoWorkItemHandler;
@@ -231,6 +235,17 @@ public class ErrorEventTest extends JbpmBpmn2TestCase {
}
+ @Test
+ public void testErrorBoundaryEvent() {
+ Application application = ProcessTestHelper.newApplication();
+ ProcessTestHelper.registerHandler(application, "MyTask",
+ new DoNothingWorkItemHandler());
+ Process<ErrorBoundaryEventInterruptingModel> process = ErrorBoundaryEventInterruptingProcess.newProcess(application);
+ ProcessInstance<ErrorBoundaryEventInterruptingModel> instance = process.createInstance(process.createModel());
+ instance.start();
+ assertThat(instance.status()).isEqualTo(ProcessInstance.STATE_COMPLETED);
+ }
+
@Test
public void testErrorBoundaryEventOnTask() throws Exception {
kruntime = createKogitoProcessRuntime("org/jbpm/bpmn2/error/BPMN2-ErrorBoundaryEventOnTask.bpmn2");
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 ac63c266f8..4223c3ed32 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
@@ -27,6 +27,7 @@ import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Optional;
+import java.util.stream.Collectors;
import javax.xml.parsers.DocumentBuilderFactory;
@@ -82,6 +83,8 @@ import org.jbpm.bpmn2.flow.MultiConnEnabledModel;
import org.jbpm.bpmn2.flow.MultiConnEnabledProcess;
import org.jbpm.bpmn2.flow.MultiInstanceLoopCharacteristicsProcessModel;
import org.jbpm.bpmn2.flow.MultiInstanceLoopCharacteristicsProcessProcess;
+import org.jbpm.bpmn2.flow.MultiInstanceLoopCharacteristicsProcessWithORgatewayModel;
+import org.jbpm.bpmn2.flow.MultiInstanceLoopCharacteristicsProcessWithORgatewayProcess;
import org.jbpm.bpmn2.flow.MultiInstanceLoopCharacteristicsProcessWithOutputCmpCondModel;
import org.jbpm.bpmn2.flow.MultiInstanceLoopCharacteristicsProcessWithOutputCmpCondProcess;
import org.jbpm.bpmn2.flow.MultiInstanceLoopCharacteristicsProcessWithOutputModel;
@@ -104,10 +107,8 @@ import org.jbpm.test.util.NodeLeftCountDownProcessEventListener;
import org.jbpm.test.utils.EventTrackerProcessListener;
import org.jbpm.test.utils.ProcessTestHelper;
import org.jbpm.workflow.instance.impl.NodeInstanceImpl;
-import org.jbpm.workflow.instance.impl.WorkflowProcessInstanceImpl;
import org.jbpm.workflow.instance.node.CompositeContextNodeInstance;
import org.jbpm.workflow.instance.node.ForEachNodeInstance;
-import org.jbpm.workflow.instance.node.ForEachNodeInstance.ForEachJoinNodeInstance;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Disabled;
@@ -122,6 +123,7 @@ import org.kie.api.runtime.process.NodeInstance;
import org.kie.internal.command.RegistryContext;
import org.kie.kogito.Application;
import org.kie.kogito.internal.process.event.DefaultKogitoProcessEventListener;
+import org.kie.kogito.internal.process.runtime.KogitoNodeInstance;
import org.kie.kogito.internal.process.runtime.KogitoProcessInstance;
import org.kie.kogito.internal.process.runtime.KogitoProcessRuntime;
import org.kie.kogito.internal.process.workitem.KogitoWorkItem;
@@ -896,69 +898,50 @@ public class FlowTest extends JbpmBpmn2TestCase {
}
@Test
- public void testMultiInstanceLoopCharacteristicsProcessWithORGateway()
- throws Exception {
- kruntime = createKogitoProcessRuntime("org/jbpm/bpmn2/flow/BPMN2-MultiInstanceLoopCharacteristicsProcessWithORgateway.bpmn2");
-
+ public void testMultiInstanceLoopCharacteristicsProcessWithORGateway() {
+ Application app = ProcessTestHelper.newApplication();
TestWorkItemHandler workItemHandler = new TestWorkItemHandler();
- kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Human Task",
- workItemHandler);
- Map<String, Object> params = new HashMap<>();
+ ProcessTestHelper.registerHandler(app, "Human Task", workItemHandler);
+ org.kie.kogito.process.Process<MultiInstanceLoopCharacteristicsProcessWithORgatewayModel> definition = MultiInstanceLoopCharacteristicsProcessWithORgatewayProcess.newProcess(app);
+ MultiInstanceLoopCharacteristicsProcessWithORgatewayModel model = definition.createModel();
List<Integer> myList = new ArrayList<>();
myList.add(12);
myList.add(15);
- params.put("list", myList);
- KogitoProcessInstance processInstance = kruntime.startProcess(
- "MultiInstanceLoopCharacteristicsProcessWithORgateway", params);
-
+ model.setList(myList);
+ ProcessInstance<MultiInstanceLoopCharacteristicsProcessWithORgatewayModel> processInstance = definition.createInstance(model);
+ processInstance.start();
List<KogitoWorkItem> workItems = workItemHandler.getWorkItems();
assertThat(workItems).hasSize(4);
-
- Collection<NodeInstance> nodeInstances = ((WorkflowProcessInstanceImpl) processInstance)
- .getNodeInstances();
+ assertThat(processInstance.status()).isEqualTo(ProcessInstance.STATE_ACTIVE);
+ Collection<KogitoNodeInstance> nodeInstances = processInstance.findNodes(node -> node instanceof ForEachNodeInstance);
assertThat(nodeInstances).hasSize(1);
- NodeInstance nodeInstance = nodeInstances.iterator().next();
+ KogitoNodeInstance nodeInstance = nodeInstances.iterator().next();
assertThat(nodeInstance).isInstanceOf(ForEachNodeInstance.class);
-
- Collection<NodeInstance> nodeInstancesChild = ((ForEachNodeInstance) nodeInstance)
- .getNodeInstances();
+ Collection<KogitoNodeInstance> nodeInstancesChild = ((ForEachNodeInstance) nodeInstance).getNodeInstances().stream()
+ .map(n -> (KogitoNodeInstance) n)
+ .collect(Collectors.toList());
assertThat(nodeInstancesChild).hasSize(2);
-
- for (NodeInstance child : nodeInstancesChild) {
+ for (KogitoNodeInstance child : nodeInstancesChild) {
assertThat(child).isInstanceOf(CompositeContextNodeInstance.class);
- assertThat(((CompositeContextNodeInstance) child)
- .getNodeInstances()).hasSize(2);
+ assertThat(((CompositeContextNodeInstance) child).getNodeInstances()).hasSize(2);
}
- kruntime.getKogitoWorkItemManager().completeWorkItem(
- workItems.get(0).getStringId(), null);
- kruntime.getKogitoWorkItemManager().completeWorkItem(
- workItems.get(1).getStringId(), null);
-
- processInstance = kruntime.getProcessInstance(processInstance.getStringId());
- nodeInstances = ((WorkflowProcessInstanceImpl) processInstance)
- .getNodeInstances();
+ processInstance.completeWorkItem(workItems.get(0).getStringId(), null);
+ processInstance.completeWorkItem(workItems.get(1).getStringId(), null);
+ nodeInstances = processInstance.findNodes(node -> node instanceof ForEachNodeInstance);
assertThat(nodeInstances).hasSize(1);
nodeInstance = nodeInstances.iterator().next();
assertThat(nodeInstance).isInstanceOf(ForEachNodeInstance.class);
-
- nodeInstancesChild = ((ForEachNodeInstance) nodeInstance)
- .getNodeInstances();
+ nodeInstancesChild = ((ForEachNodeInstance) nodeInstance).getNodeInstances().stream()
+ .map(n -> (KogitoNodeInstance) n)
+ .collect(Collectors.toList());
assertThat(nodeInstancesChild).hasSize(2);
-
- Iterator<NodeInstance> childIterator = nodeInstancesChild
- .iterator();
-
+ Iterator<KogitoNodeInstance> childIterator = nodeInstancesChild.iterator();
assertThat(childIterator.next()).isInstanceOf(CompositeContextNodeInstance.class);
- assertThat(childIterator.next()).isInstanceOf(ForEachJoinNodeInstance.class);
-
- kruntime.getKogitoWorkItemManager().completeWorkItem(
- workItems.get(2).getStringId(), null);
- kruntime.getKogitoWorkItemManager().completeWorkItem(
- workItems.get(3).getStringId(), null);
-
- assertProcessInstanceFinished(processInstance, kruntime);
-
+ assertThat(childIterator.next()).isInstanceOf(ForEachNodeInstance.ForEachJoinNodeInstance.class);
+ processInstance.completeWorkItem(workItems.get(2).getStringId(), null);
+ processInstance.completeWorkItem(workItems.get(3).getStringId(), null);
+ assertThat(processInstance.status()).isEqualTo(ProcessInstance.STATE_COMPLETED);
}
@Test
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org