diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 9c12041bf4a..4746a07e1b7 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -33,7 +33,7 @@ modified, such other license. ## Issues -Kogito uses [JIRA to manage and report issues](https://issues.redhat.com/projects/KOGITO/). +Kogito uses [Issues](https://github.com/apache/incubator-kie-kogito-runtimes/issues). If you believe you found a bug, please indicate a way to reproduce it, what you are seeing and what you would expect to see. Don't forget to indicate your Kogito, Java, Maven, Quarkus/Spring, GraalVM version. @@ -50,18 +50,18 @@ If you are interested in having more details, refer to the [Build section](#buil To contribute, use GitHub Pull Requests, from your **own** fork. -- PRs should be always related to an open JIRA issue. If there is none, you should create one. +- PRs should be always related to an open an [issue](https://github.com/apache/incubator-kie-kogito-runtimes/issues). If there is none, you should [create one](https://github.com/apache/incubator-kie-kogito-runtimes/issues/new) by describing what problem you see that we need to fix. - Try to fix only one issue per PR. -- Make sure to create a new branch. Usually branches are named after the JIRA ticket they are addressing. E.g. for ticket "KOGITO-XYZ An example issue" your branch should be at least prefixed with `KOGITO-XYZ`. E.g.: +- Make sure to create a new branch. Usually branches are named after the github issue they are addressing. E.g. for ticket "Fix_#issue An example issue". E.g.: - git checkout -b KOGITO-XYZ + git checkout -b Fix_#XYZ # or - git checkout -b KOGITO-XYZ-my-fix + git checkout -b Fix_#XYZ-my-fix -- When you submit your PR, make sure to include the ticket ID, and its title; e.g., "KOGITO-XYZ An example issue". -- The description of your PR should describe the code you wrote. The issue that is solved should be at least described properly in the corresponding JIRA ticket. +- When you submit your PR, make sure to include the ticket ID, and its title; e.g., "Fix_#XYZ An example issue". +- The description of your PR should describe the code you wrote. The issue that is solved should be at least described properly in the corresponding github issue. - If your contribution spans across multiple repositories, - use the same branch name (e.g. `KOGITO-XYZ`) in each PR so that our CI (Jenkins) can build them all at once. + use the same branch name (e.g. `Fix_#XYZ`) in each PR so that our CI (Jenkins) can build them all at once. - If your contribution spans across multiple repositories, make sure to list all the related PRs. ### Java Coding Guidelines diff --git a/addons/common/human-task-prediction/api/pom.xml b/addons/common/human-task-prediction/api/pom.xml index 817ed654aed..7731d01c457 100644 --- a/addons/common/human-task-prediction/api/pom.xml +++ b/addons/common/human-task-prediction/api/pom.xml @@ -55,7 +55,8 @@ org.kie.kogito - jbpm-flow + jbpm-deps-group-engine + pom @@ -80,11 +81,6 @@ drools-wiring-dynamic test - - org.kie.kogito - jbpm-flow-builder - test - org.mvel mvel2 @@ -92,9 +88,10 @@ org.kie.kogito - jbpm-bpmn2 + jbpm-deps-group-bpmn2-compiler + pom test - + \ No newline at end of file diff --git a/addons/common/human-task-prediction/smile/pom.xml b/addons/common/human-task-prediction/smile/pom.xml index 0ac57f042f1..df563c42791 100644 --- a/addons/common/human-task-prediction/smile/pom.xml +++ b/addons/common/human-task-prediction/smile/pom.xml @@ -78,11 +78,6 @@ drools-wiring-dynamic test - - org.kie.kogito - jbpm-flow-builder - test - org.mvel mvel2 @@ -90,7 +85,8 @@ org.kie.kogito - jbpm-bpmn2 + jbpm-deps-group-bpmn2-compiler + pom test diff --git a/addons/common/persistence/filesystem/pom.xml b/addons/common/persistence/filesystem/pom.xml index 748910aeb29..2b55e729d4f 100644 --- a/addons/common/persistence/filesystem/pom.xml +++ b/addons/common/persistence/filesystem/pom.xml @@ -53,10 +53,9 @@ org.kie.kogito - process-serialization-protobuf + jbpm-deps-group-engine + pom - - org.junit.jupiter @@ -85,7 +84,8 @@ org.kie.kogito - jbpm-flow-builder + jbpm-deps-group-bpmn2-compiler + pom test @@ -93,11 +93,6 @@ mvel2 test - - org.kie.kogito - jbpm-bpmn2 - test - org.mockito mockito-core diff --git a/addons/common/persistence/infinispan/pom.xml b/addons/common/persistence/infinispan/pom.xml index 82e4912fdb3..436eb882c18 100644 --- a/addons/common/persistence/infinispan/pom.xml +++ b/addons/common/persistence/infinispan/pom.xml @@ -48,17 +48,22 @@ - - org.kie.kogito - process-serialization-protobuf - - org.infinispan infinispan-client-hotrod-jakarta - + + org.kie.kogito + jbpm-deps-group-engine + pom + + + org.kie.kogito + jbpm-deps-group-bpmn2-compiler + pom + test + org.junit.jupiter junit-jupiter-engine @@ -84,11 +89,6 @@ kogito-drools test - - org.kie.kogito - jbpm-flow-builder - test - org.kie.kogito kogito-test-utils @@ -99,11 +99,6 @@ mvel2 test - - org.kie.kogito - jbpm-bpmn2 - test - org.mockito mockito-core diff --git a/addons/common/persistence/jdbc/pom.xml b/addons/common/persistence/jdbc/pom.xml index e6bdd17b503..aac9886605c 100644 --- a/addons/common/persistence/jdbc/pom.xml +++ b/addons/common/persistence/jdbc/pom.xml @@ -39,17 +39,21 @@ org.kie.kogito kogito-api - org.kie.kogito - process-serialization-protobuf + jbpm-deps-group-engine + pom - - io.quarkus - quarkus-jdbc-postgresql - ${version.io.quarkus} + org.kie.kogito + jbpm-deps-group-bpmn2-compiler + pom + test + + + org.postgresql + postgresql test @@ -73,16 +77,6 @@ assertj-core test - - org.kie.kogito - jbpm-flow-builder - test - - - org.kie.kogito - jbpm-bpmn2 - test - org.mockito mockito-core diff --git a/addons/common/persistence/mongodb/pom.xml b/addons/common/persistence/mongodb/pom.xml index 2fe3c34a9f3..9cbed6422a1 100644 --- a/addons/common/persistence/mongodb/pom.xml +++ b/addons/common/persistence/mongodb/pom.xml @@ -44,7 +44,8 @@ org.kie.kogito - process-serialization-protobuf + jbpm-deps-group-engine + pom org.mongodb diff --git a/addons/common/persistence/postgresql/pom.xml b/addons/common/persistence/postgresql/pom.xml index abb4fac0e49..ee2df9c829f 100644 --- a/addons/common/persistence/postgresql/pom.xml +++ b/addons/common/persistence/postgresql/pom.xml @@ -42,18 +42,24 @@ org.kie.kogito kogito-api - + + org.kie.kogito + jbpm-deps-group-engine + pom + io.vertx vertx-pg-client + + org.kie.kogito - process-serialization-protobuf + jbpm-deps-group-bpmn2-compiler + pom + test - - org.flywaydb flyway-core @@ -81,16 +87,6 @@ assertj-core test - - org.kie.kogito - jbpm-flow-builder - test - - - org.kie.kogito - jbpm-bpmn2 - test - org.mockito mockito-core diff --git a/addons/common/persistence/rocksdb/pom.xml b/addons/common/persistence/rocksdb/pom.xml index 6b3ec3be672..34c1a8bcc42 100644 --- a/addons/common/persistence/rocksdb/pom.xml +++ b/addons/common/persistence/rocksdb/pom.xml @@ -50,7 +50,8 @@ org.kie.kogito - process-serialization-protobuf + jbpm-deps-group-engine + pom org.rocksdb @@ -67,9 +68,10 @@ assertj-core test - + org.kie.kogito - jbpm-bpmn2 + jbpm-deps-group-bpmn2-compiler + pom test diff --git a/addons/common/process-management/pom.xml b/addons/common/process-management/pom.xml index 99bf2ff2ffb..4d21f22a42d 100644 --- a/addons/common/process-management/pom.xml +++ b/addons/common/process-management/pom.xml @@ -43,7 +43,8 @@ org.kie.kogito - jbpm-flow + jbpm-deps-group-engine + pom diff --git a/addons/common/task-management/pom.xml b/addons/common/task-management/pom.xml index c6bf8f964e8..402f68e9058 100644 --- a/addons/common/task-management/pom.xml +++ b/addons/common/task-management/pom.xml @@ -44,7 +44,8 @@ org.kie.kogito - jbpm-flow + jbpm-deps-group-engine + pom diff --git a/api/kogito-api-incubation-processes-services/src/main/java/org/kie/kogito/incubation/processes/services/humantask/HumanTaskService.java b/api/kogito-api-incubation-processes-services/src/main/java/org/kie/kogito/incubation/processes/services/humantask/HumanTaskService.java index 82ce67afb8b..cc8a7b33c25 100644 --- a/api/kogito-api-incubation-processes-services/src/main/java/org/kie/kogito/incubation/processes/services/humantask/HumanTaskService.java +++ b/api/kogito-api-incubation-processes-services/src/main/java/org/kie/kogito/incubation/processes/services/humantask/HumanTaskService.java @@ -26,7 +26,7 @@ public interface HumanTaskService { ExtendedDataContext get(LocalId id, MetaDataContext meta); - ExtendedDataContext create(LocalId taskId); + ExtendedDataContext create(LocalId taskId, DataContext dataContext); ExtendedDataContext abort(LocalId taskId, MetaDataContext meta); diff --git a/api/kogito-api/src/main/java/org/kie/kogito/process/ProcessService.java b/api/kogito-api/src/main/java/org/kie/kogito/process/ProcessService.java index 5708c0c1879..35ece13d195 100644 --- a/api/kogito-api/src/main/java/org/kie/kogito/process/ProcessService.java +++ b/api/kogito-api/src/main/java/org/kie/kogito/process/ProcessService.java @@ -77,7 +77,7 @@ ProcessInstance createProcessInstance(Process process, S Optional> getTasks(Process process, String id, SecurityPolicy policy); - Optional signalTask(Process process, String id, String taskNodeName); + Optional signalTask(Process process, String id, String taskNodeName, SecurityPolicy policy); Optional saveTask(Process process, String id, diff --git a/jbpm/jbpm-bpmn2/src/main/java/org/jbpm/bpmn2/xml/AbstractNodeHandler.java b/jbpm/jbpm-bpmn2/src/main/java/org/jbpm/bpmn2/xml/AbstractNodeHandler.java index e8429c2272c..50eb0f0f9ef 100755 --- a/jbpm/jbpm-bpmn2/src/main/java/org/jbpm/bpmn2/xml/AbstractNodeHandler.java +++ b/jbpm/jbpm-bpmn2/src/main/java/org/jbpm/bpmn2/xml/AbstractNodeHandler.java @@ -755,7 +755,13 @@ protected ForEachNode decorateMultiInstanceSpecification(NodeImpl nodeTarget, Mu } } // this is just an expression - forEachNode.setCompletionConditionExpression(multiInstanceSpecification.getCompletionCondition()); + ReturnValueEvaluator evaluator = null; + String completionConditionLang = multiInstanceSpecification.getCompletionConditionLang(); + if ((completionConditionLang == null || completionConditionLang.isBlank() || completionConditionLang.toLowerCase().contains("mvel")) + && multiInstanceSpecification.getCompletionCondition() != null) { + evaluator = new MVELInterpretedReturnValueEvaluator(multiInstanceSpecification.getCompletionCondition()); + } + forEachNode.setCompletionConditionExpression(evaluator); forEachNode.setMultiInstanceSpecification(multiInstanceSpecification); // This variable is used for adding items computed by each subcontext. @@ -825,6 +831,7 @@ protected MultiInstanceSpecification readMultiInstanceSpecification(Parser parse String completion = completeCondition.getTextContent(); if (completion != null && !completion.isEmpty()) { multiInstanceSpecification.setCompletionCondition(completion); + multiInstanceSpecification.setCompletionConditionLang(completeCondition.getAttribute("language")); } }); return multiInstanceSpecification; diff --git a/jbpm/jbpm-bpmn2/src/main/java/org/jbpm/bpmn2/xml/AdHocSubProcessHandler.java b/jbpm/jbpm-bpmn2/src/main/java/org/jbpm/bpmn2/xml/AdHocSubProcessHandler.java index 89a24f95137..764268219f4 100755 --- a/jbpm/jbpm-bpmn2/src/main/java/org/jbpm/bpmn2/xml/AdHocSubProcessHandler.java +++ b/jbpm/jbpm-bpmn2/src/main/java/org/jbpm/bpmn2/xml/AdHocSubProcessHandler.java @@ -23,7 +23,9 @@ import org.jbpm.bpmn2.core.SequenceFlow; import org.jbpm.compiler.xml.Parser; +import org.jbpm.compiler.xml.ProcessBuildData; import org.jbpm.process.core.context.variable.VariableScope; +import org.jbpm.ruleflow.core.RuleFlowProcess; import org.jbpm.workflow.core.Node; import org.jbpm.workflow.core.node.DynamicNode; import org.w3c.dom.Element; @@ -87,8 +89,9 @@ protected Node handleNode(final Node node, final Element element, final String u } xmlNode = xmlNode.getNextSibling(); } + RuleFlowProcess process = (RuleFlowProcess) ((ProcessBuildData) parser.getData()).getMetaData(ProcessHandler.CURRENT_PROCESS); List connections = (List) dynamicNode.getMetaData(ProcessHandler.CONNECTIONS); - ProcessHandler.linkConnections(dynamicNode, connections); + ProcessHandler.linkConnections(process, dynamicNode, connections); ProcessHandler.linkBoundaryEvents(dynamicNode); handleScript(dynamicNode, element, "onEntry"); diff --git a/jbpm/jbpm-bpmn2/src/main/java/org/jbpm/bpmn2/xml/ProcessHandler.java b/jbpm/jbpm-bpmn2/src/main/java/org/jbpm/bpmn2/xml/ProcessHandler.java index 210a59d2234..644f9fe25a7 100755 --- a/jbpm/jbpm-bpmn2/src/main/java/org/jbpm/bpmn2/xml/ProcessHandler.java +++ b/jbpm/jbpm-bpmn2/src/main/java/org/jbpm/bpmn2/xml/ProcessHandler.java @@ -208,7 +208,7 @@ public Object end(final String uri, final String localName, linkIntermediateLinks(process, throwLinks); List connections = (List) process.getMetaData(CONNECTIONS); - linkConnections(process, connections); + linkConnections(process, process, connections); linkBoundaryEvents(process); // This must be done *after* linkConnections(process, connections) @@ -384,7 +384,7 @@ public Class generateNodeFor() { return RuleFlowProcess.class; } - public static void linkConnections(NodeContainer nodeContainer, List connections) { + public static void linkConnections(RuleFlowProcess process, NodeContainer nodeContainer, List connections) { if (connections != null) { for (SequenceFlow connection : connections) { String sourceRef = connection.getSourceRef(); @@ -412,16 +412,14 @@ public static void linkConnections(NodeContainer nodeContainer, List connections = (List) forEachNode.getMetaData(ProcessHandler.CONNECTIONS); - ProcessHandler.linkConnections(forEachNode, connections); + ProcessHandler.linkConnections(process, forEachNode, connections); ProcessHandler.linkBoundaryEvents(forEachNode); // This must be done *after* linkConnections(process, connections) @@ -91,22 +95,23 @@ protected Node handleNode(Node node, Element element, String uri, String localNa ProcessHandler.linkAssociations((Definitions) forEachNode.getMetaData("Definitions"), forEachNode, associations); applyAsync(node, Boolean.parseBoolean((String) compositeNode.getMetaData().get("customAsync"))); outcome = forEachNode; + nodeContainer.addNode(outcome); } else { - handleCompositeContextNode(compositeNode); + nodeContainer.addNode(outcome); + RuleFlowProcess process = (RuleFlowProcess) ((ProcessBuildData) parser.getData()).getMetaData(ProcessHandler.CURRENT_PROCESS); + handleCompositeContextNode(process, compositeNode); } - NodeContainer nodeContainer = (NodeContainer) parser.getParent(); - nodeContainer.addNode(outcome); return outcome; } - protected void handleCompositeContextNode(CompositeContextNode compositeNode) throws SAXException { + protected void handleCompositeContextNode(RuleFlowProcess process, CompositeContextNode compositeNode) throws SAXException { List connections = (List) compositeNode.getMetaData(ProcessHandler.CONNECTIONS); List throwLinks = (List) compositeNode.getMetaData(ProcessHandler.LINKS); ProcessHandler.linkIntermediateLinks(compositeNode, throwLinks); - ProcessHandler.linkConnections(compositeNode, connections); + ProcessHandler.linkConnections(process, compositeNode, connections); ProcessHandler.linkBoundaryEvents(compositeNode); // This must be done *after* linkConnections(process, connections) diff --git a/jbpm/jbpm-deps-groups/jbpm-deps-group-bpmn2-compiler/pom.xml b/jbpm/jbpm-deps-groups/jbpm-deps-group-bpmn2-compiler/pom.xml new file mode 100644 index 00000000000..3b857f3744c --- /dev/null +++ b/jbpm/jbpm-deps-groups/jbpm-deps-group-bpmn2-compiler/pom.xml @@ -0,0 +1,53 @@ + + + 4.0.0 + + jbpm-deps-groups + org.kie.kogito + 999-SNAPSHOT + + + jbpm-deps-group-bpmn2-compiler + pom + + Kogito :: jBPM :: Dependencies Groups :: BPMN2 Compiler + jBPM Dependencies Group BPMN2 Compiler + + + + + org.kie.kogito + jbpm-bpmn2 + + + org.kie.kogito + jbpm-flow-builder + + + org.kie.kogito + jbpm-flow + + + org.kie.kogito + process-serialization-protobuf + + + org.kie.kogito + process-workitems + + + + + + + org.kie.kogito + kogito-kie-bom + ${project.version} + pom + import + + + + diff --git a/jbpm/jbpm-deps-groups/jbpm-deps-group-compiler/pom.xml b/jbpm/jbpm-deps-groups/jbpm-deps-group-compiler/pom.xml new file mode 100644 index 00000000000..e0dc237f2ae --- /dev/null +++ b/jbpm/jbpm-deps-groups/jbpm-deps-group-compiler/pom.xml @@ -0,0 +1,48 @@ + + + 4.0.0 + + jbpm-deps-groups + org.kie.kogito + 999-SNAPSHOT + + + jbpm-deps-group-compiler + pom + + Kogito :: jBPM :: Dependencies Groups :: Compiler + jBPM Dependencies Group Compiler + + + + org.kie.kogito + jbpm-flow + + + org.kie.kogito + jbpm-flow-builder + + + org.kie.kogito + process-serialization-protobuf + + + org.kie.kogito + process-workitems + + + + + + + org.kie.kogito + kogito-kie-bom + ${project.version} + pom + import + + + + diff --git a/jbpm/jbpm-deps-groups/jbpm-deps-group-engine/pom.xml b/jbpm/jbpm-deps-groups/jbpm-deps-group-engine/pom.xml new file mode 100644 index 00000000000..a369f256471 --- /dev/null +++ b/jbpm/jbpm-deps-groups/jbpm-deps-group-engine/pom.xml @@ -0,0 +1,49 @@ + + + 4.0.0 + + jbpm-deps-groups + org.kie.kogito + 999-SNAPSHOT + + + + jbpm-deps-group-engine + pom + + Kogito :: jBPM :: Dependencies Groups :: Engine + jBPM Dependencies Group Engine + + + + org.kie.kogito + jbpm-flow + + + org.kie.kogito + jbpm-flow-migration + + + org.kie.kogito + process-serialization-protobuf + + + org.kie.kogito + process-workitems + + + + + + + org.kie.kogito + kogito-kie-bom + ${project.version} + pom + import + + + + diff --git a/jbpm/jbpm-deps-groups/pom.xml b/jbpm/jbpm-deps-groups/pom.xml new file mode 100644 index 00000000000..6bcfa255cd8 --- /dev/null +++ b/jbpm/jbpm-deps-groups/pom.xml @@ -0,0 +1,26 @@ + + + + 4.0.0 + + + jbpm + org.kie.kogito + 999-SNAPSHOT + + + jbpm-deps-groups + pom + + Kogito :: jBPM :: Dependencies Groups + jBPM Dependencies Groups + + + jbpm-deps-group-engine + jbpm-deps-group-compiler + jbpm-deps-group-bpmn2-compiler + + + diff --git a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/ProcessBuilderImpl.java b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/ProcessBuilderImpl.java index 77e6a2c39f5..f711e30163d 100755 --- a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/ProcessBuilderImpl.java +++ b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/ProcessBuilderImpl.java @@ -252,7 +252,7 @@ private void processNodes( context); } - if ("true".equals(System.getProperty("jbpm.enable.multi.con"))) { + if (Boolean.parseBoolean((String) ((NodeImpl) node).getProcess().getMetaData().get("jbpm.enable.multi.con"))) { builder = ProcessNodeBuilderRegistry.INSTANCE.getNodeBuilder(NodeImpl.class); if (builder != null) { builder.build(process, processDescr, context, node); diff --git a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/AbstractCompositeNodeVisitor.java b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/AbstractCompositeNodeVisitor.java index b9143a9d762..fd7b95c4454 100644 --- a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/AbstractCompositeNodeVisitor.java +++ b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/AbstractCompositeNodeVisitor.java @@ -29,8 +29,9 @@ public abstract class AbstractCompositeNodeVisitor void visitNodes(String factoryField, U[] nodes, BlockStmt body, VariableScope variableScope, ProcessMetaData metadata) { diff --git a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/AbstractNodeVisitor.java b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/AbstractNodeVisitor.java index 1b21e056e78..a8ce5a76b8d 100644 --- a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/AbstractNodeVisitor.java +++ b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/AbstractNodeVisitor.java @@ -19,7 +19,9 @@ package org.jbpm.compiler.canonical; import java.util.ArrayList; +import java.util.Collection; import java.util.List; +import java.util.Map; import java.util.Objects; import java.util.function.Predicate; import java.util.stream.Collectors; @@ -33,13 +35,17 @@ import org.jbpm.process.core.context.variable.Variable; import org.jbpm.process.core.context.variable.VariableScope; import org.jbpm.process.core.datatype.DataTypeResolver; +import org.jbpm.process.instance.impl.ReturnValueConstraintEvaluator; +import org.jbpm.process.instance.impl.ReturnValueEvaluator; import org.jbpm.process.instance.impl.actions.HandleEscalationAction; import org.jbpm.process.instance.impl.actions.ProduceEventAction; import org.jbpm.process.instance.impl.actions.SignalProcessInstanceAction; import org.jbpm.ruleflow.core.Metadata; import org.jbpm.ruleflow.core.factory.MappableNodeFactory; import org.jbpm.util.JbpmClassLoaderUtil; +import org.jbpm.workflow.core.Constraint; import org.jbpm.workflow.core.impl.ConnectionImpl; +import org.jbpm.workflow.core.impl.ConnectionRef; import org.jbpm.workflow.core.impl.DataAssociation; import org.jbpm.workflow.core.impl.DataAssociation.DataAssociationType; import org.jbpm.workflow.core.impl.DataDefinition; @@ -57,10 +63,12 @@ import com.github.javaparser.ast.NodeList; import com.github.javaparser.ast.body.Parameter; import com.github.javaparser.ast.expr.AssignExpr; +import com.github.javaparser.ast.expr.BooleanLiteralExpr; import com.github.javaparser.ast.expr.CastExpr; import com.github.javaparser.ast.expr.ClassExpr; import com.github.javaparser.ast.expr.EnclosedExpr; import com.github.javaparser.ast.expr.Expression; +import com.github.javaparser.ast.expr.IntegerLiteralExpr; import com.github.javaparser.ast.expr.LambdaExpr; import com.github.javaparser.ast.expr.MethodCallExpr; import com.github.javaparser.ast.expr.NameExpr; @@ -82,6 +90,7 @@ import static org.drools.util.StringUtils.ucFirst; import static org.jbpm.ruleflow.core.Metadata.CUSTOM_AUTO_START; import static org.jbpm.ruleflow.core.Metadata.HIDDEN; +import static org.jbpm.ruleflow.core.factory.NodeFactory.METHOD_CONSTRAINT; import static org.jbpm.ruleflow.core.factory.NodeFactory.METHOD_DONE; import static org.jbpm.ruleflow.core.factory.NodeFactory.METHOD_NAME; import static org.kie.kogito.internal.utils.ConversionUtils.sanitizeString; @@ -90,6 +99,22 @@ public abstract class AbstractNodeVisitor extends AbstractVisito protected abstract String getNodeKey(); + private ReturnValueEvaluatorBuilderService returnValueEvaluatorBuilderService; + private ClassLoader classLoader; + + public AbstractNodeVisitor(ClassLoader classLoader) { + this.classLoader = classLoader; + this.returnValueEvaluatorBuilderService = ReturnValueEvaluatorBuilderService.instance(classLoader); + } + + public ClassLoader getClassLoader() { + return classLoader; + } + + public ReturnValueEvaluatorBuilderService getReturnValueEvaluatorBuilderService() { + return returnValueEvaluatorBuilderService; + } + public void visitNode(T node, BlockStmt body, VariableScope variableScope, ProcessMetaData metadata) { visitNode(FACTORY_FIELD_NAME, node, body, variableScope, metadata); if (isAdHocNode(node) && !(node instanceof HumanTaskNode)) { @@ -100,6 +125,8 @@ public void visitNode(T node, BlockStmt body, VariableScope variableScope, Proce addScript(extendedNodeImpl, body, ON_ACTION_SCRIPT_METHOD, ExtendedNodeImpl.EVENT_NODE_ENTER); addScript(extendedNodeImpl, body, ON_ACTION_SCRIPT_METHOD, ExtendedNodeImpl.EVENT_NODE_EXIT); } + + addConstraints(node, returnValueEvaluatorBuilderService, body); } private void addScript(ExtendedNodeImpl extendedNodeImpl, BlockStmt body, String factoryMethod, String actionType) { @@ -123,6 +150,41 @@ private void addScript(ExtendedNodeImpl extendedNodeImpl, BlockStmt body, String } } + public void addConstraints(T currentNode, ReturnValueEvaluatorBuilderService returnValueEvaluatorBuilderService, BlockStmt body) { + NodeImpl node = (NodeImpl) currentNode; + for (Map.Entry> entry : node.getConstraints().entrySet()) { + if (entry.getValue() == null || entry.getValue().isEmpty()) { + continue; + } + + for (Constraint constraint : entry.getValue().stream().filter(Predicate.not(Objects::isNull)).toList()) { + Expression returnValueEvaluator; + if (constraint instanceof ReturnValueConstraintEvaluator returnValueConstraintEvaluator) { + ReturnValueEvaluator evaluator = returnValueConstraintEvaluator.getReturnValueEvaluator(); + returnValueEvaluator = returnValueEvaluatorBuilderService.build(node, + evaluator.dialect(), + evaluator.expression(), + evaluator.type(), + evaluator.root()); + + } else { + returnValueEvaluator = returnValueEvaluatorBuilderService.build(node, + constraint.getDialect(), + constraint.getConstraint()); + } + body.addStatement(getFactoryMethod(getNodeId(currentNode), METHOD_CONSTRAINT, + getWorkflowElementConstructor(entry.getKey().getNodeId()), + new StringLiteralExpr(getOrDefault(entry.getKey().getConnectionId(), "")), + new StringLiteralExpr(entry.getKey().getToType()), + new StringLiteralExpr(constraint.getDialect()), + returnValueEvaluator, + new IntegerLiteralExpr(constraint.getPriority()), + new BooleanLiteralExpr(constraint.isDefault()))); + + } + } + } + private Expression buildDroolsConsequenceAction(ExtendedNodeImpl extendedNodeImpl, String dialect, String script) { if (script == null) { return new NullLiteralExpr(); diff --git a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/ActionNodeVisitor.java b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/ActionNodeVisitor.java index 415f67b873c..0028588d287 100644 --- a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/ActionNodeVisitor.java +++ b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/ActionNodeVisitor.java @@ -55,6 +55,10 @@ public class ActionNodeVisitor extends AbstractNodeVisitor { private static final String INTERMEDIATE_COMPENSATION_TYPE = "IntermediateThrowEvent-None"; + public ActionNodeVisitor(ClassLoader classLoader) { + super(classLoader); + } + @Override protected String getNodeKey() { return "actionNode"; diff --git a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/BoundaryEventNodeVisitor.java b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/BoundaryEventNodeVisitor.java index ab0051d501c..e15c223ce0f 100644 --- a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/BoundaryEventNodeVisitor.java +++ b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/BoundaryEventNodeVisitor.java @@ -39,6 +39,10 @@ public class BoundaryEventNodeVisitor extends AbstractNodeVisitor { + public BoundaryEventNodeVisitor(ClassLoader classLoader) { + super(classLoader); + } + @Override protected String getNodeKey() { return "boundaryEventNode"; diff --git a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/CatchLinkNodeVisitor.java b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/CatchLinkNodeVisitor.java index 04b521c9720..aa0d406e354 100644 --- a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/CatchLinkNodeVisitor.java +++ b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/CatchLinkNodeVisitor.java @@ -26,6 +26,10 @@ public class CatchLinkNodeVisitor extends AbstractNodeVisitor { + public CatchLinkNodeVisitor(ClassLoader classLoader) { + super(classLoader); + } + @Override protected String getNodeKey() { return "catchLinkNode"; diff --git a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/CompositeContextNodeVisitor.java b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/CompositeContextNodeVisitor.java index 7bb9c149d88..9449db2e86c 100644 --- a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/CompositeContextNodeVisitor.java +++ b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/CompositeContextNodeVisitor.java @@ -21,7 +21,6 @@ import java.util.HashSet; import java.util.stream.Stream; -import org.jbpm.compiler.canonical.node.NodeVisitorBuilderService; import org.jbpm.process.core.context.variable.VariableScope; import org.jbpm.ruleflow.core.factory.CompositeContextNodeFactory; import org.jbpm.workflow.core.node.CompositeContextNode; @@ -33,8 +32,8 @@ public class CompositeContextNodeVisitor extends AbstractCompositeNodeVisitor { - public CompositeContextNodeVisitor(NodeVisitorBuilderService nodeVisitorService) { - super(nodeVisitorService); + public CompositeContextNodeVisitor(ClassLoader classLoader) { + super(classLoader); } @Override diff --git a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/DynamicNodeVisitor.java b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/DynamicNodeVisitor.java index f2bd31f7b19..3c14fe1ec97 100644 --- a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/DynamicNodeVisitor.java +++ b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/DynamicNodeVisitor.java @@ -23,7 +23,6 @@ import java.util.stream.Stream; import org.jbpm.compiler.canonical.builtin.ReturnValueEvaluatorBuilderService; -import org.jbpm.compiler.canonical.node.NodeVisitorBuilderService; import org.jbpm.process.core.context.variable.VariableScope; import org.jbpm.ruleflow.core.factory.DynamicNodeFactory; import org.jbpm.workflow.core.node.DynamicNode; @@ -38,8 +37,8 @@ public class DynamicNodeVisitor extends CompositeContextNodeVisitor private ReturnValueEvaluatorBuilderService builder; - public DynamicNodeVisitor(NodeVisitorBuilderService nodeVisitorService, ClassLoader classLoader) { - super(nodeVisitorService); + public DynamicNodeVisitor(ClassLoader classLoader) { + super(classLoader); this.builder = ReturnValueEvaluatorBuilderService.instance(classLoader); } diff --git a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/EndNodeVisitor.java b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/EndNodeVisitor.java index 23f4edffed2..ba90ac3acae 100644 --- a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/EndNodeVisitor.java +++ b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/EndNodeVisitor.java @@ -49,6 +49,10 @@ public class EndNodeVisitor extends AbstractNodeVisitor { + public EndNodeVisitor(ClassLoader classLoader) { + super(classLoader); + } + @Override protected String getNodeKey() { return "endNode"; diff --git a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/EventNodeVisitor.java b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/EventNodeVisitor.java index 66051eb049f..fb79085ef54 100644 --- a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/EventNodeVisitor.java +++ b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/EventNodeVisitor.java @@ -37,6 +37,10 @@ public class EventNodeVisitor extends AbstractNodeVisitor { + public EventNodeVisitor(ClassLoader classLoader) { + super(classLoader); + } + @Override protected String getNodeKey() { return "eventNode"; diff --git a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/EventSubProcessNodeVisitor.java b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/EventSubProcessNodeVisitor.java index ef9c441e44f..5c468afc3c7 100644 --- a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/EventSubProcessNodeVisitor.java +++ b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/EventSubProcessNodeVisitor.java @@ -22,7 +22,6 @@ import java.util.Collection; import java.util.stream.Stream; -import org.jbpm.compiler.canonical.node.NodeVisitorBuilderService; import org.jbpm.process.core.context.variable.VariableScope; import org.jbpm.ruleflow.core.factory.EventSubProcessNodeFactory; import org.jbpm.workflow.core.node.EventSubProcessNode; @@ -36,8 +35,8 @@ public class EventSubProcessNodeVisitor extends CompositeContextNodeVisitor { - public EventSubProcessNodeVisitor(NodeVisitorBuilderService nodeVisitorService) { - super(nodeVisitorService); + public EventSubProcessNodeVisitor(ClassLoader classLoader) { + super(classLoader); } @Override diff --git a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/FaultNodeVisitor.java b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/FaultNodeVisitor.java index e7de77ff57f..d78deb1a72a 100644 --- a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/FaultNodeVisitor.java +++ b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/FaultNodeVisitor.java @@ -32,6 +32,10 @@ public class FaultNodeVisitor extends AbstractNodeVisitor { + public FaultNodeVisitor(ClassLoader classLoader) { + super(classLoader); + } + @Override protected String getNodeKey() { return "faultNode"; diff --git a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/ForEachNodeVisitor.java b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/ForEachNodeVisitor.java index 45e4ffdaa63..35b87f4159e 100644 --- a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/ForEachNodeVisitor.java +++ b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/ForEachNodeVisitor.java @@ -22,7 +22,6 @@ import java.util.Arrays; import java.util.List; -import org.jbpm.compiler.canonical.node.NodeVisitorBuilderService; import org.jbpm.process.core.context.variable.VariableScope; import org.jbpm.ruleflow.core.factory.ForEachNodeFactory; import org.jbpm.workflow.core.Node; @@ -45,8 +44,8 @@ public class ForEachNodeVisitor extends AbstractCompositeNodeVisitor { - public ForEachNodeVisitor(NodeVisitorBuilderService nodeVisitorService) { - super(nodeVisitorService); + public ForEachNodeVisitor(ClassLoader classLoader) { + super(classLoader); } @Override @@ -115,6 +114,12 @@ public void visitNode(String factoryField, ForEachNode node, BlockStmt body, Var filterNodes.removeIf(n -> n.getId().equals(outgoingNode.getNodeId())); } + if (node.hasCompletionCondition()) { + String completionConditionDialect = node.getCompletionConditionExpression().dialect(); + String completionConditionExpression = node.getCompletionConditionExpression().expression(); + body.addStatement(getFactoryMethod(getNodeId(node), ForEachNodeFactory.METHOD_COMPLETE_CONDITION, + getReturnValueEvaluatorBuilderService().build(node, completionConditionDialect, completionConditionExpression))); + } visitConnections(getNodeId(node), filterNodes.toArray(new Node[filterNodes.size()]), body); body.addStatement(getDoneMethod(getNodeId(node))); diff --git a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/JoinNodeVisitor.java b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/JoinNodeVisitor.java index c4a60011627..7a9e27df625 100644 --- a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/JoinNodeVisitor.java +++ b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/JoinNodeVisitor.java @@ -29,6 +29,10 @@ public class JoinNodeVisitor extends AbstractNodeVisitor { + public JoinNodeVisitor(ClassLoader classLoader) { + super(classLoader); + } + @Override protected String getNodeKey() { return "joinNode"; diff --git a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/LambdaSubProcessNodeVisitor.java b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/LambdaSubProcessNodeVisitor.java index 01722cf0e65..f05c4f0591d 100644 --- a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/LambdaSubProcessNodeVisitor.java +++ b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/LambdaSubProcessNodeVisitor.java @@ -61,6 +61,10 @@ public class LambdaSubProcessNodeVisitor extends AbstractNodeVisitor { + public LambdaSubProcessNodeVisitor(ClassLoader classLoader) { + super(classLoader); + } + @Override protected String getNodeKey() { return "subProcessNode"; diff --git a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/MilestoneNodeVisitor.java b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/MilestoneNodeVisitor.java index edab9d4d1ee..d38bd04b2d3 100644 --- a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/MilestoneNodeVisitor.java +++ b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/MilestoneNodeVisitor.java @@ -29,6 +29,10 @@ public class MilestoneNodeVisitor extends AbstractNodeVisitor { + public MilestoneNodeVisitor(ClassLoader classLoader) { + super(classLoader); + } + @Override protected String getNodeKey() { return "milestoneNode"; diff --git a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/RuleSetNodeVisitor.java b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/RuleSetNodeVisitor.java index 5028ee6b961..dca1632debb 100644 --- a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/RuleSetNodeVisitor.java +++ b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/RuleSetNodeVisitor.java @@ -64,11 +64,10 @@ public class RuleSetNodeVisitor extends AbstractNodeVisitor { public static final Logger logger = LoggerFactory.getLogger(ProcessToExecModelGenerator.class); - private final ClassLoader contextClassLoader; private final AssignableChecker assignableChecker; public RuleSetNodeVisitor(ClassLoader contextClassLoader) { - this.contextClassLoader = contextClassLoader; + super(contextClassLoader); this.assignableChecker = AssignableChecker.create(contextClassLoader); } @@ -144,7 +143,7 @@ private MethodCallExpr handleDecision(DecisionRuleType ruleType) { private MethodCallExpr handleRuleUnit(VariableScope variableScope, ProcessMetaData metadata, RuleSetNode ruleSetNode, String nodeName, RuleType ruleType) { String unitName = ruleType.getName(); - ProcessContextMetaModel processContext = new ProcessContextMetaModel(variableScope, contextClassLoader); + ProcessContextMetaModel processContext = new ProcessContextMetaModel(variableScope, getClassLoader()); RuleUnitDescription description; try { @@ -170,7 +169,7 @@ private MethodCallExpr handleRuleUnit(VariableScope variableScope, ProcessMetaDa } private GeneratedRuleUnitDescription generateRuleUnitDescription(String unitName, ProcessContextMetaModel processContext) { - GeneratedRuleUnitDescription d = new GeneratedRuleUnitDescription(unitName, contextClassLoader); + GeneratedRuleUnitDescription d = new GeneratedRuleUnitDescription(unitName, getClassLoader()); for (Variable variable : processContext.getVariables()) { d.putDatasourceVar( variable.getName(), @@ -214,7 +213,7 @@ private MethodCallExpr handleRuleFlowGroup(RuleType ruleType) { private Class loadUnitClass(String unitName, String packageName) throws ClassNotFoundException { ClassNotFoundException ex; try { - return contextClassLoader.loadClass(unitName); + return getClassLoader().loadClass(unitName); } catch (ClassNotFoundException e) { ex = e; } @@ -223,7 +222,7 @@ private Class loadUnitClass(String unitName, String packageName) throws Class } // maybe the name is not qualified. Let's try with tacking the packageName at the front try { - return contextClassLoader.loadClass(packageName + "." + unitName); + return getClassLoader().loadClass(packageName + "." + unitName); } catch (ClassNotFoundException e) { // throw the original error throw ex; diff --git a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/SplitNodeVisitor.java b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/SplitNodeVisitor.java index de434a17a77..49f3c9b5413 100644 --- a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/SplitNodeVisitor.java +++ b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/SplitNodeVisitor.java @@ -18,35 +18,19 @@ */ package org.jbpm.compiler.canonical; -import java.util.Collection; -import java.util.Map.Entry; -import java.util.Objects; -import java.util.function.Predicate; - -import org.jbpm.compiler.canonical.builtin.ReturnValueEvaluatorBuilderService; import org.jbpm.process.core.context.variable.VariableScope; -import org.jbpm.process.instance.impl.ReturnValueConstraintEvaluator; -import org.jbpm.process.instance.impl.ReturnValueEvaluator; import org.jbpm.ruleflow.core.factory.SplitFactory; -import org.jbpm.workflow.core.Constraint; -import org.jbpm.workflow.core.impl.ConnectionRef; import org.jbpm.workflow.core.node.Split; -import com.github.javaparser.ast.expr.BooleanLiteralExpr; -import com.github.javaparser.ast.expr.Expression; import com.github.javaparser.ast.expr.IntegerLiteralExpr; -import com.github.javaparser.ast.expr.StringLiteralExpr; import com.github.javaparser.ast.stmt.BlockStmt; -import static org.jbpm.ruleflow.core.factory.SplitFactory.METHOD_CONSTRAINT; import static org.jbpm.ruleflow.core.factory.SplitFactory.METHOD_TYPE; public class SplitNodeVisitor extends AbstractNodeVisitor { - ReturnValueEvaluatorBuilderService returnValueEvaluatorBuilderService; - - public SplitNodeVisitor(ReturnValueEvaluatorBuilderService returnValueEvaluatorBuilderService) { - this.returnValueEvaluatorBuilderService = returnValueEvaluatorBuilderService; + public SplitNodeVisitor(ClassLoader classLoader) { + super(classLoader); } @Override @@ -61,40 +45,7 @@ public void visitNode(String factoryField, Split node, BlockStmt body, VariableS .addStatement(getFactoryMethod(getNodeId(node), METHOD_TYPE, new IntegerLiteralExpr(node.getType()))); visitMetaData(node.getMetaData(), body, getNodeId(node)); - - if (node.getType() == Split.TYPE_OR || node.getType() == Split.TYPE_XOR) { - for (Entry> entry : node.getConstraints().entrySet()) { - if (entry.getValue() == null || entry.getValue().isEmpty()) { - continue; - } - - for (Constraint constraint : entry.getValue().stream().filter(Predicate.not(Objects::isNull)).toList()) { - Expression returnValueEvaluator; - if (constraint instanceof ReturnValueConstraintEvaluator) { - ReturnValueEvaluator evaluator = ((ReturnValueConstraintEvaluator) constraint).getReturnValueEvaluator(); - returnValueEvaluator = returnValueEvaluatorBuilderService.build(node, - evaluator.dialect(), - evaluator.expression(), - evaluator.type(), - evaluator.root()); - - } else { - returnValueEvaluator = returnValueEvaluatorBuilderService.build(node, - constraint.getDialect(), - constraint.getConstraint()); - } - body.addStatement(getFactoryMethod(getNodeId(node), METHOD_CONSTRAINT, - getWorkflowElementConstructor(entry.getKey().getNodeId()), - new StringLiteralExpr(getOrDefault(entry.getKey().getConnectionId(), "")), - new StringLiteralExpr(entry.getKey().getToType()), - new StringLiteralExpr(constraint.getDialect()), - returnValueEvaluator, - new IntegerLiteralExpr(constraint.getPriority()), - new BooleanLiteralExpr(constraint.isDefault()))); - - } - } - } + addConstraints(node, getReturnValueEvaluatorBuilderService(), body); body.addStatement(getDoneMethod(getNodeId(node))); } diff --git a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/StartNodeVisitor.java b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/StartNodeVisitor.java index 5bb88d149c8..42c0ceb3c89 100644 --- a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/StartNodeVisitor.java +++ b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/StartNodeVisitor.java @@ -21,6 +21,7 @@ import java.util.Map; import java.util.Optional; +import org.jbpm.compiler.canonical.builtin.ReturnValueEvaluatorBuilderService; import org.jbpm.process.core.context.variable.Variable; import org.jbpm.process.core.context.variable.VariableScope; import org.jbpm.process.core.timer.Timer; @@ -28,13 +29,15 @@ import org.jbpm.ruleflow.core.factory.StartNodeFactory; import org.jbpm.workflow.core.node.StartNode; +import com.github.javaparser.ast.NodeList; import com.github.javaparser.ast.expr.BooleanLiteralExpr; +import com.github.javaparser.ast.expr.Expression; import com.github.javaparser.ast.expr.IntegerLiteralExpr; import com.github.javaparser.ast.expr.StringLiteralExpr; import com.github.javaparser.ast.stmt.BlockStmt; import static org.jbpm.ruleflow.core.Metadata.EVENT_TYPE; -import static org.jbpm.ruleflow.core.Metadata.MESSAGE_TYPE; +import static org.jbpm.ruleflow.core.Metadata.TRIGGER_EXPRESSION; import static org.jbpm.ruleflow.core.Metadata.TRIGGER_MAPPING; import static org.jbpm.ruleflow.core.Metadata.TRIGGER_REF; import static org.jbpm.ruleflow.core.factory.StartNodeFactory.METHOD_INTERRUPTING; @@ -43,6 +46,13 @@ public class StartNodeVisitor extends AbstractNodeVisitor { + private ReturnValueEvaluatorBuilderService returnValueEvaluatorBuilderService; + + public StartNodeVisitor(ClassLoader classLoader) { + super(classLoader); + this.returnValueEvaluatorBuilderService = ReturnValueEvaluatorBuilderService.instance(classLoader); + } + @Override protected String getNodeKey() { return "startNode"; @@ -74,10 +84,10 @@ public void visitNode(String factoryField, StartNode startNode, BlockStmt body, metadata.addSignal((String) nodeMetaData.get(TRIGGER_REF), computePayloadType(startNode, variableScope).orElse(null)); break; } + case Metadata.EVENT_TYPE_CONDITIONAL: case Metadata.EVENT_TYPE_ERROR: case Metadata.EVENT_TYPE_ESCALATION: case Metadata.EVENT_TYPE_COMPENSATION: - case Metadata.EVENT_TYPE_CONDITIONAL: handleIO(startNode, startNode.getMetaData(), body, variableScope, metadata); metadata.addSignal((String) nodeMetaData.get(TRIGGER_REF), null); break; @@ -94,15 +104,17 @@ private TriggerMetaData buildTriggerMetadata(StartNode node) { } protected void handleIO(StartNode startNode, Map nodeMetaData, BlockStmt body, VariableScope variableScope, ProcessMetaData metadata) { - if (nodeMetaData.containsKey(MESSAGE_TYPE)) { - body.addStatement(getFactoryMethod(getNodeId(startNode), METHOD_TRIGGER, - new StringLiteralExpr((String) nodeMetaData.get(TRIGGER_REF)), - buildDataAssociationsExpression(startNode, startNode.getIoSpecification().getDataOutputAssociation()))); - } else if (nodeMetaData.containsKey(TRIGGER_REF)) { - body.addStatement(getFactoryMethod(getNodeId(startNode), METHOD_TRIGGER, - new StringLiteralExpr((String) nodeMetaData.get(TRIGGER_REF)), - buildDataAssociationsExpression(startNode, startNode.getIoSpecification().getDataOutputAssociation()))); + if (!nodeMetaData.containsKey(TRIGGER_REF)) { + return; + } + + NodeList arguments = new NodeList<>(); + arguments.add(new StringLiteralExpr((String) nodeMetaData.get(TRIGGER_REF))); + arguments.add(buildDataAssociationsExpression(startNode, startNode.getIoSpecification().getDataOutputAssociation())); + if (nodeMetaData.containsKey(TRIGGER_EXPRESSION)) { + arguments.add(returnValueEvaluatorBuilderService.build(startNode, (String) nodeMetaData.get(Metadata.TRIGGER_EXPRESSION_LANGUAGE), (String) nodeMetaData.get(TRIGGER_EXPRESSION))); } + body.addStatement(getFactoryMethod(getNodeId(startNode), METHOD_TRIGGER, arguments.toArray(Expression[]::new))); } public Optional computePayloadType(StartNode startNode, VariableScope variableScope) { diff --git a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/StateNodeVisitor.java b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/StateNodeVisitor.java index c800c3d65fc..f3f40325b9f 100644 --- a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/StateNodeVisitor.java +++ b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/StateNodeVisitor.java @@ -18,29 +18,13 @@ */ package org.jbpm.compiler.canonical; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Map; -import java.util.stream.Stream; - -import org.jbpm.compiler.canonical.node.NodeVisitorBuilderService; -import org.jbpm.process.core.context.variable.VariableScope; import org.jbpm.ruleflow.core.factory.StateNodeFactory; -import org.jbpm.workflow.core.Constraint; -import org.jbpm.workflow.core.impl.ConnectionRef; import org.jbpm.workflow.core.node.StateNode; -import com.github.javaparser.ast.expr.IntegerLiteralExpr; -import com.github.javaparser.ast.expr.MethodCallExpr; -import com.github.javaparser.ast.expr.StringLiteralExpr; -import com.github.javaparser.utils.StringEscapeUtils; - -import static org.jbpm.ruleflow.core.factory.StateNodeFactory.METHOD_CONSTRAINT; - public class StateNodeVisitor extends CompositeContextNodeVisitor { - public StateNodeVisitor(NodeVisitorBuilderService nodeVisitorService) { - super(nodeVisitorService); + public StateNodeVisitor(ClassLoader classLoader) { + super(classLoader); } @Override @@ -58,27 +42,4 @@ protected String getDefaultName() { return "State"; } - @Override - public Stream visitCustomFields(StateNode node, VariableScope variableScope) { - if (node.getConstraints() == null) { - return Stream.empty(); - } - - Collection result = new ArrayList<>(); - for (Map.Entry> entry : node.getConstraints().entrySet()) { - ConnectionRef ref = entry.getKey(); - for (Constraint constraint : entry.getValue()) { - if (constraint != null) { - result.add(getFactoryMethod(getNodeId(node), METHOD_CONSTRAINT, - getOrNullExpr(ref.getConnectionId()), - getWorkflowElementConstructor(ref.getNodeId()), - new StringLiteralExpr(ref.getToType()), - new StringLiteralExpr(constraint.getDialect()), - new StringLiteralExpr(StringEscapeUtils.escapeJava(constraint.getConstraint())), - new IntegerLiteralExpr(constraint.getPriority()))); - } - } - } - return result.stream(); - } } diff --git a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/ThrowLinkNodeVisitor.java b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/ThrowLinkNodeVisitor.java index 916cb0fe302..3505d46d70d 100644 --- a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/ThrowLinkNodeVisitor.java +++ b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/ThrowLinkNodeVisitor.java @@ -26,6 +26,10 @@ public class ThrowLinkNodeVisitor extends AbstractNodeVisitor { + public ThrowLinkNodeVisitor(ClassLoader classLoader) { + super(classLoader); + } + @Override protected String getNodeKey() { return "throwLinkNode"; diff --git a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/TimerNodeVisitor.java b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/TimerNodeVisitor.java index b80a7650a88..effc80bdac1 100644 --- a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/TimerNodeVisitor.java +++ b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/TimerNodeVisitor.java @@ -34,6 +34,10 @@ public class TimerNodeVisitor extends AbstractNodeVisitor { + public TimerNodeVisitor(ClassLoader classLoader) { + super(classLoader); + } + @Override protected String getNodeKey() { return "timerNode"; diff --git a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/WorkItemNodeVisitor.java b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/WorkItemNodeVisitor.java index 479e80775e1..4441f9d6163 100644 --- a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/WorkItemNodeVisitor.java +++ b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/WorkItemNodeVisitor.java @@ -71,10 +71,8 @@ public static ParamType fromString(String name) { } } - private final ClassLoader contextClassLoader; - public WorkItemNodeVisitor(ClassLoader contextClassLoader) { - this.contextClassLoader = contextClassLoader; + super(contextClassLoader); } @Override @@ -92,7 +90,7 @@ public void visitNode(String factoryField, T node, BlockStmt body, VariableScope final TaskDescriptor taskDescriptor = new TaskDescriptorBuilder(workName) .withProcessMetadata(metadata) .withWorkItemNode(node) - .withClassloader(contextClassLoader) + .withClassloader(getClassLoader()) .build(); workName = taskDescriptor.getName(); metadata.getGeneratedHandlers().put(workName, taskDescriptor.generateHandlerClassForService()); diff --git a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/ActionNodeVisitorBuilder.java b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/ActionNodeVisitorBuilder.java index 9349e5bc617..3aa93462c37 100644 --- a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/ActionNodeVisitorBuilder.java +++ b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/ActionNodeVisitorBuilder.java @@ -32,7 +32,7 @@ public Class type() { @Override public AbstractNodeVisitor visitor(NodeVisitorBuilderService nodeVisitorService, ClassLoader classLoader) { - return new ActionNodeVisitor(); + return new ActionNodeVisitor(classLoader); } } diff --git a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/BoundaryEventNodeVisitorBuilder.java b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/BoundaryEventNodeVisitorBuilder.java index 7380e2194be..c71d8f7a214 100644 --- a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/BoundaryEventNodeVisitorBuilder.java +++ b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/BoundaryEventNodeVisitorBuilder.java @@ -32,7 +32,7 @@ public Class type() { @Override public AbstractNodeVisitor visitor(NodeVisitorBuilderService nodeVisitorService, ClassLoader classLoader) { - return new BoundaryEventNodeVisitor(); + return new BoundaryEventNodeVisitor(classLoader); } } diff --git a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/CatchLinkNodeVisitorBuilder.java b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/CatchLinkNodeVisitorBuilder.java index aa5484ceab2..3ede076f7fa 100644 --- a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/CatchLinkNodeVisitorBuilder.java +++ b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/CatchLinkNodeVisitorBuilder.java @@ -32,7 +32,7 @@ public Class type() { @Override public AbstractNodeVisitor visitor(NodeVisitorBuilderService nodeVisitorService, ClassLoader classLoader) { - return new CatchLinkNodeVisitor(); + return new CatchLinkNodeVisitor(classLoader); } } diff --git a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/CompositeContextNodeVisitorBuilder.java b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/CompositeContextNodeVisitorBuilder.java index c30cbc98985..800183910c3 100644 --- a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/CompositeContextNodeVisitorBuilder.java +++ b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/CompositeContextNodeVisitorBuilder.java @@ -32,7 +32,7 @@ public Class type() { @Override public AbstractNodeVisitor visitor(NodeVisitorBuilderService nodeVisitorService, ClassLoader classLoader) { - return new CompositeContextNodeVisitor(nodeVisitorService); + return new CompositeContextNodeVisitor<>(classLoader); } } diff --git a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/DynamicNodeVisitorBuilder.java b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/DynamicNodeVisitorBuilder.java index fdf5f54821c..84562c0968a 100644 --- a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/DynamicNodeVisitorBuilder.java +++ b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/DynamicNodeVisitorBuilder.java @@ -32,7 +32,7 @@ public Class type() { @Override public AbstractNodeVisitor visitor(NodeVisitorBuilderService nodeVisitorService, ClassLoader classLoader) { - return new DynamicNodeVisitor(nodeVisitorService, classLoader); + return new DynamicNodeVisitor(classLoader); } } diff --git a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/EndNodeVisitorBuilder.java b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/EndNodeVisitorBuilder.java index 75c54c42146..7c41e3e60a3 100644 --- a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/EndNodeVisitorBuilder.java +++ b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/EndNodeVisitorBuilder.java @@ -32,7 +32,7 @@ public Class type() { @Override public AbstractNodeVisitor visitor(NodeVisitorBuilderService nodeVisitorService, ClassLoader classLoader) { - return new EndNodeVisitor(); + return new EndNodeVisitor(classLoader); } } diff --git a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/EventNodeVisitorBuilder.java b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/EventNodeVisitorBuilder.java index 030ef556756..1344c476341 100644 --- a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/EventNodeVisitorBuilder.java +++ b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/EventNodeVisitorBuilder.java @@ -32,7 +32,7 @@ public Class type() { @Override public AbstractNodeVisitor visitor(NodeVisitorBuilderService nodeVisitorService, ClassLoader classLoader) { - return new EventNodeVisitor(); + return new EventNodeVisitor(classLoader); } } diff --git a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/EventSubProcessNodeVisitorBuilder.java b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/EventSubProcessNodeVisitorBuilder.java index afae970aa51..6cff3773223 100644 --- a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/EventSubProcessNodeVisitorBuilder.java +++ b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/EventSubProcessNodeVisitorBuilder.java @@ -32,7 +32,7 @@ public Class type() { @Override public AbstractNodeVisitor visitor(NodeVisitorBuilderService nodeVisitorService, ClassLoader classLoader) { - return new EventSubProcessNodeVisitor(nodeVisitorService); + return new EventSubProcessNodeVisitor(classLoader); } } diff --git a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/FaultNodeVisitorBuilder.java b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/FaultNodeVisitorBuilder.java index 9c6dfe5f2dc..062cb48a4a7 100644 --- a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/FaultNodeVisitorBuilder.java +++ b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/FaultNodeVisitorBuilder.java @@ -32,7 +32,7 @@ public Class type() { @Override public AbstractNodeVisitor visitor(NodeVisitorBuilderService nodeVisitorService, ClassLoader classLoader) { - return new FaultNodeVisitor(); + return new FaultNodeVisitor(classLoader); } } diff --git a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/ForEachNodeVisitorBuilder.java b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/ForEachNodeVisitorBuilder.java index 0ddb803c05d..334fb63d4bd 100644 --- a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/ForEachNodeVisitorBuilder.java +++ b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/ForEachNodeVisitorBuilder.java @@ -32,7 +32,7 @@ public Class type() { @Override public AbstractNodeVisitor visitor(NodeVisitorBuilderService nodeVisitorService, ClassLoader classLoader) { - return new ForEachNodeVisitor(nodeVisitorService); + return new ForEachNodeVisitor(classLoader); } } diff --git a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/JoinNodeVisitorBuilder.java b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/JoinNodeVisitorBuilder.java index 6a14cbdb405..9a0d7e5d6ba 100644 --- a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/JoinNodeVisitorBuilder.java +++ b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/JoinNodeVisitorBuilder.java @@ -32,7 +32,7 @@ public Class type() { @Override public AbstractNodeVisitor visitor(NodeVisitorBuilderService nodeVisitorService, ClassLoader classLoader) { - return new JoinNodeVisitor(); + return new JoinNodeVisitor(classLoader); } } diff --git a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/MilestoneNodeVisitorBuilder.java b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/MilestoneNodeVisitorBuilder.java index 7d50d9d8597..43ed2ec813b 100644 --- a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/MilestoneNodeVisitorBuilder.java +++ b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/MilestoneNodeVisitorBuilder.java @@ -32,7 +32,7 @@ public Class type() { @Override public AbstractNodeVisitor visitor(NodeVisitorBuilderService nodeVisitorService, ClassLoader classLoader) { - return new MilestoneNodeVisitor(); + return new MilestoneNodeVisitor(classLoader); } } diff --git a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/SplitNodeVisitorBuilder.java b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/SplitNodeVisitorBuilder.java index ca874e76af6..48fe7eafca9 100644 --- a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/SplitNodeVisitorBuilder.java +++ b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/SplitNodeVisitorBuilder.java @@ -20,7 +20,6 @@ import org.jbpm.compiler.canonical.AbstractNodeVisitor; import org.jbpm.compiler.canonical.SplitNodeVisitor; -import org.jbpm.compiler.canonical.builtin.ReturnValueEvaluatorBuilderService; import org.jbpm.workflow.core.node.Split; import org.kie.api.definition.process.Node; @@ -33,7 +32,7 @@ public Class type() { @Override public AbstractNodeVisitor visitor(NodeVisitorBuilderService nodeVisitorService, ClassLoader classLoader) { - return new SplitNodeVisitor(ReturnValueEvaluatorBuilderService.instance(classLoader)); + return new SplitNodeVisitor(classLoader); } } diff --git a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/StartNodeVisitorBuilder.java b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/StartNodeVisitorBuilder.java index 76feb9af440..04183a2b428 100644 --- a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/StartNodeVisitorBuilder.java +++ b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/StartNodeVisitorBuilder.java @@ -32,7 +32,8 @@ public Class type() { @Override public AbstractNodeVisitor visitor(NodeVisitorBuilderService nodeVisitorService, ClassLoader classLoader) { - return new StartNodeVisitor(); + return new StartNodeVisitor(classLoader); + } } diff --git a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/StateNodeVisitorBuilder.java b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/StateNodeVisitorBuilder.java index 50a50b9b065..b61bc2c148f 100644 --- a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/StateNodeVisitorBuilder.java +++ b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/StateNodeVisitorBuilder.java @@ -32,7 +32,7 @@ public Class type() { @Override public AbstractNodeVisitor visitor(NodeVisitorBuilderService nodeVisitorService, ClassLoader classLoader) { - return new StateNodeVisitor(nodeVisitorService); + return new StateNodeVisitor(classLoader); } } diff --git a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/SubProcessNodeVisitorBuilder.java b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/SubProcessNodeVisitorBuilder.java index 671aff96b47..3abf43452d2 100644 --- a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/SubProcessNodeVisitorBuilder.java +++ b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/SubProcessNodeVisitorBuilder.java @@ -32,7 +32,7 @@ public Class type() { @Override public AbstractNodeVisitor visitor(NodeVisitorBuilderService nodeVisitorService, ClassLoader classLoader) { - return new LambdaSubProcessNodeVisitor(); + return new LambdaSubProcessNodeVisitor(classLoader); } } diff --git a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/ThrowLinkNodeVisitorBuilder.java b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/ThrowLinkNodeVisitorBuilder.java index df851519b78..72680887bb6 100644 --- a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/ThrowLinkNodeVisitorBuilder.java +++ b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/ThrowLinkNodeVisitorBuilder.java @@ -32,7 +32,7 @@ public Class type() { @Override public AbstractNodeVisitor visitor(NodeVisitorBuilderService nodeVisitorService, ClassLoader classLoader) { - return new ThrowLinkNodeVisitor(); + return new ThrowLinkNodeVisitor(classLoader); } } diff --git a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/TimerNodeVisitorBuilder.java b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/TimerNodeVisitorBuilder.java index 658e31c68fa..063df525bd7 100644 --- a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/TimerNodeVisitorBuilder.java +++ b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/TimerNodeVisitorBuilder.java @@ -32,7 +32,7 @@ public Class type() { @Override public AbstractNodeVisitor visitor(NodeVisitorBuilderService nodeVisitorService, ClassLoader classLoader) { - return new TimerNodeVisitor(); + return new TimerNodeVisitor(classLoader); } } diff --git a/jbpm/jbpm-flow/src/main/java/org/jbpm/process/core/event/BroadcastEventTypeFilter.java b/jbpm/jbpm-flow/src/main/java/org/jbpm/process/core/event/ExpressionEventTypeFilter.java old mode 100755 new mode 100644 similarity index 55% rename from jbpm/jbpm-flow/src/main/java/org/jbpm/process/core/event/BroadcastEventTypeFilter.java rename to jbpm/jbpm-flow/src/main/java/org/jbpm/process/core/event/ExpressionEventTypeFilter.java index d94444ae657..3c62a8e935d --- a/jbpm/jbpm-flow/src/main/java/org/jbpm/process/core/event/BroadcastEventTypeFilter.java +++ b/jbpm/jbpm-flow/src/main/java/org/jbpm/process/core/event/ExpressionEventTypeFilter.java @@ -18,34 +18,26 @@ */ package org.jbpm.process.core.event; -/** - * This variant of the {@link EventTypeFilter} can be used with structures such - * as Escalations, for which Intermediate (Catching) Events can be triggered - * by both - * - * - */ -public class BroadcastEventTypeFilter extends EventTypeFilter { +import java.util.function.Function; + +import org.jbpm.process.instance.impl.ReturnValueEvaluator; + +public class ExpressionEventTypeFilter extends EventTypeFilter { private static final long serialVersionUID = 510l; + private ReturnValueEvaluator returnValueEvaluator; - public boolean acceptsEvent(String type, Object event) { - if (type == null) { - return false; - } - boolean accepts = false; - if (this.type != null) { - if (this.type.equals(type)) { - accepts = true; - } else if (type != null && type.startsWith(this.type)) { - accepts = true; - } - } - return accepts; + public ExpressionEventTypeFilter(String type, ReturnValueEvaluator returnValueEvaluator) { + this.returnValueEvaluator = returnValueEvaluator; + this.type = type; } + /** + * Nodes that use this event filter should never be triggered by this event + */ @Override - public String toString() { - return "Broadcast Event filter: [" + this.type + "]"; + public boolean acceptsEvent(String type, Object event, Function resolver) { + return (Boolean) returnValueEvaluator.eval(resolver); } + } diff --git a/jbpm/jbpm-flow/src/main/java/org/jbpm/process/instance/KogitoProcessContextImpl.java b/jbpm/jbpm-flow/src/main/java/org/jbpm/process/instance/KogitoProcessContextImpl.java index 5258ea7e2ee..3411ce89754 100755 --- a/jbpm/jbpm-flow/src/main/java/org/jbpm/process/instance/KogitoProcessContextImpl.java +++ b/jbpm/jbpm-flow/src/main/java/org/jbpm/process/instance/KogitoProcessContextImpl.java @@ -53,6 +53,14 @@ public boolean isVariableResolvable(String variableId) { return getVariable(variableId) != null; } + @Override + public Object getVariable(String variableId) { + if (contextData.containsKey(variableId)) { + return contextData.get(variableId); + } + return super.getVariable(variableId); + } + @Override public KogitoProcessInstance getProcessInstance() { return (KogitoProcessInstance) super.getProcessInstance(); diff --git a/jbpm/jbpm-flow/src/main/java/org/jbpm/process/instance/LightProcessRuntime.java b/jbpm/jbpm-flow/src/main/java/org/jbpm/process/instance/LightProcessRuntime.java index 501b3bfccdc..d5721f743d9 100755 --- a/jbpm/jbpm-flow/src/main/java/org/jbpm/process/instance/LightProcessRuntime.java +++ b/jbpm/jbpm-flow/src/main/java/org/jbpm/process/instance/LightProcessRuntime.java @@ -242,27 +242,24 @@ private void removeProcessEventListener(Process process) { } private void initProcessEventListener(Process process) { - if (process instanceof RuleFlowProcess) { - for (Node node : ((RuleFlowProcess) process).getNodes()) { - if (node instanceof StartNode) { - StartNode startNode = (StartNode) node; - if (startNode != null) { - List triggers = startNode.getTriggers(); - if (triggers != null) { - for (Trigger trigger : triggers) { - if (trigger instanceof EventTrigger) { - final List filters = ((EventTrigger) trigger).getEventFilters(); - String type = null; - for (EventFilter filter : filters) { - if (filter instanceof EventTypeFilter) { - type = ((EventTypeFilter) filter).getType(); - } + if (process instanceof RuleFlowProcess ruleFlowProcess) { + for (Node node : ruleFlowProcess.getNodes()) { + if (node instanceof StartNode startNode) { + List triggers = startNode.getTriggers(); + if (triggers != null) { + for (Trigger trigger : triggers) { + if (trigger instanceof EventTrigger eventTrigger) { + final List filters = eventTrigger.getEventFilters(); + String type = null; + for (EventFilter filter : filters) { + if (filter instanceof EventTypeFilter eventTypeFilter) { + type = eventTypeFilter.getType(); } - StartProcessEventListener listener = new StartProcessEventListener(startNode, trigger, process.getId(), filters); - signalManager.addEventListener(type, listener); - ((RuleFlowProcess) process).getRuntimeMetaData().put("StartProcessEventType", type); - ((RuleFlowProcess) process).getRuntimeMetaData().put("StartProcessEventListener", listener); } + StartProcessEventListener listener = new StartProcessEventListener(startNode, trigger, process.getId(), filters); + signalManager.addEventListener(type, listener); + ruleFlowProcess.getRuntimeMetaData().put("StartProcessEventType", type); + ruleFlowProcess.getRuntimeMetaData().put("StartProcessEventListener", listener); } } } diff --git a/jbpm/jbpm-flow/src/main/java/org/jbpm/process/instance/context/variable/VariableScopeInstance.java b/jbpm/jbpm-flow/src/main/java/org/jbpm/process/instance/context/variable/VariableScopeInstance.java index 7c1c5189865..5499cc309fe 100755 --- a/jbpm/jbpm-flow/src/main/java/org/jbpm/process/instance/context/variable/VariableScopeInstance.java +++ b/jbpm/jbpm-flow/src/main/java/org/jbpm/process/instance/context/variable/VariableScopeInstance.java @@ -28,6 +28,7 @@ import org.jbpm.process.instance.ContextInstanceContainer; import org.jbpm.process.instance.InternalProcessRuntime; import org.jbpm.process.instance.context.AbstractContextInstance; +import org.jbpm.ruleflow.core.Metadata; import org.jbpm.workflow.core.Node; import org.jbpm.workflow.instance.node.CompositeContextNodeInstance; import org.kie.kogito.internal.process.event.KogitoObjectListenerAware; @@ -114,6 +115,10 @@ oldValue, clonedValue, getVariableScope().tags(name), getProcessInstance(), nodeInstance, getProcessInstance().getKnowledgeRuntime()); } + + if (getProcessInstance().getProcess().getMetaData().containsKey(Metadata.CONDITION)) { + getProcessInstance().signalEvent("Conditional", null); + } } private Object clone(String name, Object newValue) { diff --git a/jbpm/jbpm-flow/src/main/java/org/jbpm/process/instance/impl/humantask/HumanTaskWorkItemImpl.java b/jbpm/jbpm-flow/src/main/java/org/jbpm/process/instance/impl/humantask/HumanTaskWorkItemImpl.java index a1c1a77c39b..0679e9ba66e 100644 --- a/jbpm/jbpm-flow/src/main/java/org/jbpm/process/instance/impl/humantask/HumanTaskWorkItemImpl.java +++ b/jbpm/jbpm-flow/src/main/java/org/jbpm/process/instance/impl/humantask/HumanTaskWorkItemImpl.java @@ -191,10 +191,6 @@ protected void checkAssignedOwners(String user, Collection roles) { throw new NotAuthorizedException("User " + user + " is not authorized to access task instance with id " + getStringId()); } - // if there are no assignments means open to everyone - if (getPotentialUsers().isEmpty() && getPotentialGroups().isEmpty()) { - return; - } // check if user is in potential users or groups if (!getPotentialUsers().contains(user) && getPotentialGroups().stream().noneMatch(roles::contains)) { diff --git a/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/Metadata.java b/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/Metadata.java index bb3e9d71d5b..6bca5445bf4 100644 --- a/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/Metadata.java +++ b/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/Metadata.java @@ -32,6 +32,8 @@ public class Metadata { public static final String CONSUME_MESSAGE = "ConsumeMessage"; public static final String NODE_TYPE = "NodeType"; public static final String TRIGGER_TYPE = "TriggerType"; + public static final String TRIGGER_EXPRESSION = "TriggerExpression"; + public static final String TRIGGER_EXPRESSION_LANGUAGE = "TriggerExpressionLanguage"; public static final String TRIGGER_MAPPING = "TriggerMapping"; public static final String TRIGGER_MAPPING_INPUT = "TriggerMappingInput"; public static final String MAPPING_VARIABLE = "MappingVariable"; diff --git a/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/RuleFlowProcess.java b/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/RuleFlowProcess.java index 8bb2aad0f11..226ee366334 100755 --- a/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/RuleFlowProcess.java +++ b/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/RuleFlowProcess.java @@ -60,6 +60,8 @@ public RuleFlowProcess() { ExceptionScope exceptionScope = new ExceptionScope(); addContext(exceptionScope); setDefaultContext(exceptionScope); + // backward compatibility. + setMetaData("jbpm.enable.multi.con", System.getProperty("jbpm.enable.multi.con")); } public VariableScope getVariableScope() { diff --git a/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/RuleFlowProcessFactory.java b/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/RuleFlowProcessFactory.java index 3c6089e19ae..ea9a67f0a9f 100755 --- a/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/RuleFlowProcessFactory.java +++ b/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/RuleFlowProcessFactory.java @@ -420,20 +420,28 @@ protected DroolsAction timerAction(String type) { } protected Node findNodeByIdOrUniqueIdInMetadata(NodeContainer nodeContainer, final String nodeRef, String errorMsg) { - Node node = null; - // try looking for a node with same "UniqueId" (in metadata) - for (Node containerNode : nodeContainer.getNodes()) { - if (nodeRef.equals(containerNode.getUniqueId())) { - node = containerNode; - break; - } - } + Node node = findNodeByUniqueId(nodeContainer, nodeRef); if (node == null) { throw new IllegalArgumentException(errorMsg); } return node; } + private Node findNodeByUniqueId(NodeContainer nodeContainer, final String nodeRef) { + for (Node containedNode : nodeContainer.getNodes()) { + if (nodeRef.equals(containedNode.getUniqueId())) { + return containedNode; + } + if (containedNode instanceof NodeContainer) { + Node result = findNodeByUniqueId((NodeContainer) containedNode, nodeRef); + if (result != null) { + return result; + } + } + } + return null; + } + private void postProcessNodes(RuleFlowProcess process, NodeContainer container) { for (Node node : container.getNodes()) { diff --git a/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/WorkflowElementIdentifierFactory.java b/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/WorkflowElementIdentifierFactory.java index 9c0e016f5f6..434b4fdc832 100644 --- a/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/WorkflowElementIdentifierFactory.java +++ b/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/WorkflowElementIdentifierFactory.java @@ -81,7 +81,7 @@ public boolean equals(Object obj) { @Override public String toSanitizeString() { - return toExternalFormat().replaceAll("-", "_"); + return toExternalFormat().replaceAll("-", "_").replaceAll("\\.", "_"); } } diff --git a/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/factory/ForEachNodeFactory.java b/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/factory/ForEachNodeFactory.java index 501499530e2..d32b223a426 100755 --- a/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/factory/ForEachNodeFactory.java +++ b/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/factory/ForEachNodeFactory.java @@ -21,6 +21,7 @@ import org.jbpm.process.core.context.variable.Variable; import org.jbpm.process.core.datatype.DataType; import org.jbpm.process.instance.impl.Action; +import org.jbpm.process.instance.impl.ReturnValueEvaluator; import org.jbpm.ruleflow.core.Metadata; import org.jbpm.ruleflow.core.RuleFlowNodeContainerFactory; import org.jbpm.workflow.core.NodeContainer; @@ -38,6 +39,7 @@ public class ForEachNodeFactory> ex public static final String METHOD_OUTPUT_VARIABLE = "outputVariable"; public static final String METHOD_OUTPUT_TEMP = "tempVariable"; public static final String METHOD_SEQUENTIAL = "sequential"; + public static final String METHOD_COMPLETE_CONDITION = "completionCondition"; public ForEachNodeFactory(T nodeContainerFactory, NodeContainer nodeContainer, WorkflowElementIdentifier id) { super(nodeContainerFactory, nodeContainer, new ForEachNode(id), id); @@ -75,6 +77,11 @@ public ForEachNodeFactory outputCollectionExpression(String collectionExpress return this; } + public ForEachNodeFactory completionCondition(ReturnValueEvaluator completionConditionExpression) { + getForEachNode().setCompletionConditionExpression(completionConditionExpression); + return this; + } + public ForEachNodeFactory completionAction(Action completionAction) { getForEachNode().setCompletionAction(completionAction); return this; diff --git a/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/factory/NodeFactory.java b/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/factory/NodeFactory.java index bcbfb1f475f..e29f367f70a 100755 --- a/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/factory/NodeFactory.java +++ b/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/factory/NodeFactory.java @@ -19,13 +19,17 @@ package org.jbpm.ruleflow.core.factory; import org.jbpm.process.core.context.variable.Mappable; +import org.jbpm.process.instance.impl.ReturnValueConstraintEvaluator; +import org.jbpm.process.instance.impl.ReturnValueEvaluator; import org.jbpm.ruleflow.core.RuleFlowNodeContainerFactory; import org.jbpm.workflow.core.Node; import org.jbpm.workflow.core.NodeContainer; +import org.jbpm.workflow.core.impl.ConnectionRef; +import org.jbpm.workflow.core.impl.NodeImpl; import org.kie.api.definition.process.WorkflowElementIdentifier; public abstract class NodeFactory, P extends RuleFlowNodeContainerFactory> implements MappableNodeFactory { - + public static final String METHOD_CONSTRAINT = "constraint"; public static final String METHOD_NAME = "name"; public static final String METHOD_METADATA = "metaData"; public static final String METHOD_DONE = "done"; @@ -71,4 +75,20 @@ public Mappable getMappableNode() { return (Mappable) node; } + public T constraint(WorkflowElementIdentifier toNodeId, String name, String type, String dialect, ReturnValueEvaluator evaluator, int priority) { + return constraint(toNodeId, name, type, dialect, evaluator, priority, false); + } + + public T constraint(WorkflowElementIdentifier toNodeId, String name, String type, String dialect, ReturnValueEvaluator evaluator, int priority, boolean isDefault) { + ReturnValueConstraintEvaluator constraintImpl = new ReturnValueConstraintEvaluator(); + constraintImpl.setName(name); + constraintImpl.setType(type); + constraintImpl.setDialect(dialect); + constraintImpl.setPriority(priority); + constraintImpl.setEvaluator(evaluator); + constraintImpl.setConstraint("expression already given as evaluator"); + constraintImpl.setDefault(isDefault); + ((NodeImpl) node).addConstraint(new ConnectionRef(name, toNodeId, Node.CONNECTION_DEFAULT_TYPE), constraintImpl); + return (T) this; + } } diff --git a/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/factory/SplitFactory.java b/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/factory/SplitFactory.java index 63228ad23e0..75f4507f00b 100755 --- a/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/factory/SplitFactory.java +++ b/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/factory/SplitFactory.java @@ -18,19 +18,14 @@ */ package org.jbpm.ruleflow.core.factory; -import org.jbpm.process.instance.impl.ReturnValueConstraintEvaluator; -import org.jbpm.process.instance.impl.ReturnValueEvaluator; import org.jbpm.ruleflow.core.RuleFlowNodeContainerFactory; -import org.jbpm.workflow.core.Node; import org.jbpm.workflow.core.NodeContainer; -import org.jbpm.workflow.core.impl.ConnectionRef; import org.jbpm.workflow.core.node.Split; import org.kie.api.definition.process.WorkflowElementIdentifier; public class SplitFactory> extends NodeFactory, T> { public static final String METHOD_TYPE = "type"; - public static final String METHOD_CONSTRAINT = "constraint"; public SplitFactory(T nodeContainerFactory, NodeContainer nodeContainer, WorkflowElementIdentifier id) { super(nodeContainerFactory, nodeContainer, new Split(), id); @@ -60,22 +55,4 @@ public SplitFactory constraint(WorkflowElementIdentifier toNodeId, String nam public ConstraintFactory> constraintBuilder(WorkflowElementIdentifier toNodeId, String name, String type, String dialect, String constraint) { return new ConstraintFactory<>(this, toNodeId, name, type, dialect, constraint); } - - public SplitFactory constraint(WorkflowElementIdentifier toNodeId, String name, String type, String dialect, ReturnValueEvaluator evaluator, int priority) { - return constraint(toNodeId, name, type, dialect, evaluator, priority, false); - } - - public SplitFactory constraint(WorkflowElementIdentifier toNodeId, String name, String type, String dialect, ReturnValueEvaluator evaluator, int priority, boolean isDefault) { - ReturnValueConstraintEvaluator constraintImpl = new ReturnValueConstraintEvaluator(); - constraintImpl.setName(name); - constraintImpl.setType(type); - constraintImpl.setDialect(dialect); - constraintImpl.setPriority(priority); - constraintImpl.setEvaluator(evaluator); - constraintImpl.setConstraint("expression already given as evaluator"); - constraintImpl.setDefault(isDefault); - getSplit().addConstraint( - new ConnectionRef(name, toNodeId, Node.CONNECTION_DEFAULT_TYPE), constraintImpl); - return this; - } } diff --git a/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/factory/StartNodeFactory.java b/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/factory/StartNodeFactory.java index 3aa38c4b33a..2bd804707b9 100755 --- a/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/factory/StartNodeFactory.java +++ b/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/factory/StartNodeFactory.java @@ -18,21 +18,26 @@ */ package org.jbpm.ruleflow.core.factory; +import java.util.ArrayList; import java.util.List; import org.jbpm.process.core.event.EventTypeFilter; +import org.jbpm.process.core.event.ExpressionEventTypeFilter; import org.jbpm.process.core.timer.Timer; +import org.jbpm.process.instance.impl.ReturnValueEvaluator; import org.jbpm.ruleflow.core.RuleFlowNodeContainerFactory; import org.jbpm.ruleflow.core.RuleFlowProcess; import org.jbpm.workflow.core.NodeContainer; import org.jbpm.workflow.core.impl.DataAssociation; +import org.jbpm.workflow.core.impl.DataDefinition; import org.jbpm.workflow.core.node.EventTrigger; import org.jbpm.workflow.core.node.StartNode; import org.kie.api.definition.process.WorkflowElementIdentifier; import static org.jbpm.ruleflow.core.Metadata.MESSAGE_REF; -public class StartNodeFactory> extends NodeFactory, T> { +public class StartNodeFactory> + extends NodeFactory, T> { public static final String METHOD_INTERRUPTING = "interrupting"; public static final String METHOD_TRIGGER = "trigger"; @@ -51,16 +56,25 @@ public StartNodeFactory interrupting(boolean interrupting) { return this; } - public StartNodeFactory trigger(String triggerEventType, List dataAssociations) { + public StartNodeFactory trigger(String triggerEventType, List dataAssociations, ReturnValueEvaluator returnValueEvaluator) { + ExpressionEventTypeFilter eventFilter = new ExpressionEventTypeFilter(triggerEventType, returnValueEvaluator); + return this.trigger(eventFilter, dataAssociations); + } + + public StartNodeFactory trigger(EventTypeFilter eventTypeFilter, List dataAssociations) { EventTrigger trigger = new EventTrigger(); + trigger.addEventFilter(eventTypeFilter); + dataAssociations.forEach(trigger::addInAssociation); + getStartNode().addTrigger(trigger); + return this; + } + + public StartNodeFactory trigger(String triggerEventType, List dataAssociations) { EventTypeFilter eventFilter = new EventTypeFilter(); eventFilter.setCorrelationManager(((RuleFlowProcess) getStartNode().getProcess()).getCorrelationManager()); eventFilter.setType(triggerEventType); eventFilter.setMessageRef((String) getNode().getMetaData().get(MESSAGE_REF)); - trigger.addEventFilter(eventFilter); - dataAssociations.forEach(trigger::addInAssociation); - getStartNode().addTrigger(trigger); - return this; + return this.trigger(eventFilter, dataAssociations); } public StartNodeFactory trigger(String triggerEventType, String target) { @@ -68,17 +82,12 @@ public StartNodeFactory trigger(String triggerEventType, String target) { } public StartNodeFactory trigger(String triggerEventType, String source, String target) { - EventTrigger trigger = new EventTrigger(); - EventTypeFilter eventFilter = new EventTypeFilter(); - eventFilter.setCorrelationManager(((RuleFlowProcess) getStartNode().getProcess()).getCorrelationManager()); - eventFilter.setMessageRef((String) getNode().getMetaData().get(MESSAGE_REF)); - eventFilter.setType(triggerEventType); - trigger.addEventFilter(eventFilter); + List dataAssociations = new ArrayList<>(); if (source != null) { - trigger.addInMapping(source, target); + dataAssociations.add(new DataAssociation(DataDefinition.toSimpleDefinition(source), + DataDefinition.toSimpleDefinition(target), null, null)); } - getStartNode().addTrigger(trigger); - return this; + return this.trigger(triggerEventType, dataAssociations); } public StartNodeFactory timer(String delay, String period, String date, int timeType) { diff --git a/jbpm/jbpm-flow/src/main/java/org/jbpm/workflow/core/impl/MultiInstanceSpecification.java b/jbpm/jbpm-flow/src/main/java/org/jbpm/workflow/core/impl/MultiInstanceSpecification.java index 45f16168210..b5fae80fca4 100644 --- a/jbpm/jbpm-flow/src/main/java/org/jbpm/workflow/core/impl/MultiInstanceSpecification.java +++ b/jbpm/jbpm-flow/src/main/java/org/jbpm/workflow/core/impl/MultiInstanceSpecification.java @@ -31,6 +31,8 @@ public class MultiInstanceSpecification implements Serializable { private String completionCondition; private boolean isSequential = false; + private String completionConditionLang; + public boolean hasMultiInstanceInput() { return loopDataInputRef != null; } @@ -67,6 +69,14 @@ public DataDefinition getLoopDataInputRef() { return loopDataInputRef; } + public void setCompletionConditionLang(String completionConditionLang) { + this.completionConditionLang = completionConditionLang; + } + + public String getCompletionConditionLang() { + return completionConditionLang; + } + public void setCompletionCondition(String completionCondition) { this.completionCondition = completionCondition; } diff --git a/jbpm/jbpm-flow/src/main/java/org/jbpm/workflow/core/impl/NodeImpl.java b/jbpm/jbpm-flow/src/main/java/org/jbpm/workflow/core/impl/NodeImpl.java index 4410c19d6d3..0ea5dee5509 100755 --- a/jbpm/jbpm-flow/src/main/java/org/jbpm/workflow/core/impl/NodeImpl.java +++ b/jbpm/jbpm-flow/src/main/java/org/jbpm/workflow/core/impl/NodeImpl.java @@ -297,7 +297,7 @@ public Connection getFrom() { if (list.size() == 1) { return list.get(0); } - if ("true".equals(System.getProperty("jbpm.enable.multi.con"))) { + if (Boolean.parseBoolean((String) getProcess().getMetaData().get("jbpm.enable.multi.con"))) { return list.get(0); } else { throw new IllegalArgumentException( @@ -317,7 +317,7 @@ public Connection getTo() { if (list.size() == 1) { return list.get(0); } - if ("true".equals(System.getProperty("jbpm.enable.multi.con"))) { + if (Boolean.parseBoolean((String) getProcess().getMetaData().get("jbpm.enable.multi.con"))) { return list.get(0); } else { throw new IllegalArgumentException( diff --git a/jbpm/jbpm-flow/src/main/java/org/jbpm/workflow/core/node/ActionNode.java b/jbpm/jbpm-flow/src/main/java/org/jbpm/workflow/core/node/ActionNode.java index aff798ca7f7..9144d42833a 100755 --- a/jbpm/jbpm-flow/src/main/java/org/jbpm/workflow/core/node/ActionNode.java +++ b/jbpm/jbpm-flow/src/main/java/org/jbpm/workflow/core/node/ActionNode.java @@ -53,7 +53,7 @@ public void validateAddIncomingConnection(final String type, final Connection co "This type of node [" + connection.getTo().getUniqueId() + ", " + connection.getTo().getName() + "] only accepts default incoming connection type!"); } - if (getFrom() != null && !"true".equals(System.getProperty("jbpm.enable.multi.con"))) { + if (getFrom() != null && !Boolean.parseBoolean((String) getProcess().getMetaData().get("jbpm.enable.multi.con"))) { throw new IllegalArgumentException( "This type of node [" + connection.getTo().getUniqueId() + ", " + connection.getTo().getName() + "] cannot have more than one incoming connection!"); @@ -68,7 +68,7 @@ public void validateAddOutgoingConnection(final String type, final Connection co "This type of node [" + connection.getFrom().getUniqueId() + ", " + connection.getFrom().getName() + "] only accepts default outgoing connection type!"); } - if (getTo() != null && !"true".equals(System.getProperty("jbpm.enable.multi.con"))) { + if (getTo() != null && !Boolean.parseBoolean((String) getProcess().getMetaData().get("jbpm.enable.multi.con"))) { throw new IllegalArgumentException( "This type of node [" + connection.getFrom().getUniqueId() + ", " + connection.getFrom().getName() + "] cannot have more than one outgoing connection!"); diff --git a/jbpm/jbpm-flow/src/main/java/org/jbpm/workflow/core/node/EndNode.java b/jbpm/jbpm-flow/src/main/java/org/jbpm/workflow/core/node/EndNode.java index eb45e405908..ae88f439561 100755 --- a/jbpm/jbpm-flow/src/main/java/org/jbpm/workflow/core/node/EndNode.java +++ b/jbpm/jbpm-flow/src/main/java/org/jbpm/workflow/core/node/EndNode.java @@ -58,7 +58,7 @@ public void validateAddIncomingConnection(final String type, final Connection co "This type of node [" + connection.getTo().getUniqueId() + ", " + connection.getTo().getName() + "] only accepts default incoming connection type!"); } - if (getFrom() != null && !"true".equals(System.getProperty("jbpm.enable.multi.con"))) { + if (getFrom() != null && !Boolean.parseBoolean((String) getProcess().getMetaData().get("jbpm.enable.multi.con"))) { throw new IllegalArgumentException( "This type of node [" + connection.getTo().getUniqueId() + ", " + connection.getTo().getName() + "] cannot have more than one incoming connection!"); diff --git a/jbpm/jbpm-flow/src/main/java/org/jbpm/workflow/core/node/EventNode.java b/jbpm/jbpm-flow/src/main/java/org/jbpm/workflow/core/node/EventNode.java index 968ecb96df1..42d216f4835 100755 --- a/jbpm/jbpm-flow/src/main/java/org/jbpm/workflow/core/node/EventNode.java +++ b/jbpm/jbpm-flow/src/main/java/org/jbpm/workflow/core/node/EventNode.java @@ -104,7 +104,7 @@ public void validateAddIncomingConnection(final String type, final Connection co "This type of node [" + connection.getTo().getUniqueId() + ", " + connection.getTo().getName() + "] only accepts default incoming connection type!"); } - if (getFrom() != null && !"true".equals(System.getProperty("jbpm.enable.multi.con"))) { + if (getFrom() != null && !Boolean.parseBoolean((String) getProcess().getMetaData().get("jbpm.enable.multi.con"))) { throw new IllegalArgumentException( "This type of node [" + connection.getTo().getUniqueId() + ", " + connection.getTo().getName() + "] cannot have more than one incoming connection!"); @@ -119,7 +119,7 @@ public void validateAddOutgoingConnection(final String type, final Connection co "This type of node [" + connection.getFrom().getUniqueId() + ", " + connection.getFrom().getName() + "] only accepts default outgoing connection type!"); } - if (getTo() != null && !"true".equals(System.getProperty("jbpm.enable.multi.con"))) { + if (getTo() != null && !Boolean.parseBoolean((String) getProcess().getMetaData().get("jbpm.enable.multi.con"))) { throw new IllegalArgumentException( "This type of node [" + connection.getFrom().getUniqueId() + ", " + connection.getFrom().getName() + "] cannot have more than one outgoing connection!"); diff --git a/jbpm/jbpm-flow/src/main/java/org/jbpm/workflow/core/node/ForEachNode.java b/jbpm/jbpm-flow/src/main/java/org/jbpm/workflow/core/node/ForEachNode.java index a53a6aff11a..2bacf604303 100755 --- a/jbpm/jbpm-flow/src/main/java/org/jbpm/workflow/core/node/ForEachNode.java +++ b/jbpm/jbpm-flow/src/main/java/org/jbpm/workflow/core/node/ForEachNode.java @@ -27,6 +27,7 @@ import org.jbpm.process.core.context.variable.VariableScope; import org.jbpm.process.core.datatype.DataType; import org.jbpm.process.instance.impl.Action; +import org.jbpm.process.instance.impl.ReturnValueEvaluator; import org.jbpm.ruleflow.core.WorkflowElementIdentifierFactory; import org.jbpm.workflow.core.Node; import org.jbpm.workflow.core.impl.ConnectionImpl; @@ -51,7 +52,7 @@ public class ForEachNode extends CompositeContextNode { private String outputVariableName; private String collectionExpression; private String outputCollectionExpression; - private String completionConditionExpression; + private ReturnValueEvaluator completionConditionExpression; private Action finishAction; private boolean waitForCompletion = true; @@ -345,12 +346,12 @@ public Context getContext(String contextType, long id) { return ctx; } - public String getCompletionConditionExpression() { + public ReturnValueEvaluator getCompletionConditionExpression() { return completionConditionExpression; } public void setCompletionConditionExpression( - String completionConditionExpression) { + ReturnValueEvaluator completionConditionExpression) { this.completionConditionExpression = completionConditionExpression; } @@ -361,4 +362,8 @@ public boolean isSequential() { public void setSequential(boolean sequential) { this.getMultiInstanceSpecification().setSequential(sequential); } + + public boolean hasCompletionCondition() { + return completionConditionExpression != null; + } } diff --git a/jbpm/jbpm-flow/src/main/java/org/jbpm/workflow/core/node/MilestoneNode.java b/jbpm/jbpm-flow/src/main/java/org/jbpm/workflow/core/node/MilestoneNode.java index ddac709244c..7ffabedcda2 100755 --- a/jbpm/jbpm-flow/src/main/java/org/jbpm/workflow/core/node/MilestoneNode.java +++ b/jbpm/jbpm-flow/src/main/java/org/jbpm/workflow/core/node/MilestoneNode.java @@ -59,7 +59,7 @@ public void validateAddIncomingConnection(final String type, final Connection co if (!Node.CONNECTION_DEFAULT_TYPE.equals(type)) { throwValidationException(connection, "only accepts default incoming connection type!"); } - if (getFrom() != null && !Boolean.parseBoolean(System.getProperty("jbpm.enable.multi.con"))) { + if (getFrom() != null && !Boolean.parseBoolean((String) getProcess().getMetaData().get("jbpm.enable.multi.con"))) { throwValidationException(connection, "cannot have more than one incoming connection!"); } } @@ -70,7 +70,7 @@ public void validateAddOutgoingConnection(final String type, final Connection co if (!Node.CONNECTION_DEFAULT_TYPE.equals(type)) { throwValidationException(connection, "only accepts default outgoing connection type!"); } - if (getTo() != null && !Boolean.parseBoolean(System.getProperty("jbpm.enable.multi.con"))) { + if (getTo() != null && !Boolean.parseBoolean((String) getProcess().getMetaData().get("jbpm.enable.multi.con"))) { throwValidationException(connection, "cannot have more than one outgoing connection!"); } } diff --git a/jbpm/jbpm-flow/src/main/java/org/jbpm/workflow/core/node/RuleSetNode.java b/jbpm/jbpm-flow/src/main/java/org/jbpm/workflow/core/node/RuleSetNode.java index 5f3a242dd85..3d129f3b228 100755 --- a/jbpm/jbpm-flow/src/main/java/org/jbpm/workflow/core/node/RuleSetNode.java +++ b/jbpm/jbpm-flow/src/main/java/org/jbpm/workflow/core/node/RuleSetNode.java @@ -105,7 +105,7 @@ public void validateAddIncomingConnection(final String type, final Connection co "This type of node [" + connection.getTo().getUniqueId() + ", " + connection.getTo().getName() + "] only accepts default incoming connection type!"); } - if (getFrom() != null && !"true".equals(System.getProperty("jbpm.enable.multi.con"))) { + if (getFrom() != null && !Boolean.parseBoolean((String) getProcess().getMetaData().get("jbpm.enable.multi.con"))) { throw new IllegalArgumentException( "This type of node [" + connection.getTo().getUniqueId() + ", " + connection.getTo().getName() + "] cannot have more than one incoming connection!"); @@ -120,7 +120,7 @@ public void validateAddOutgoingConnection(final String type, final Connection co "This type of node [" + connection.getFrom().getUniqueId() + ", " + connection.getFrom().getName() + "] only accepts default outgoing connection type!"); } - if (getTo() != null && !"true".equals(System.getProperty("jbpm.enable.multi.con"))) { + if (getTo() != null && !Boolean.parseBoolean((String) getProcess().getMetaData().get("jbpm.enable.multi.con"))) { throw new IllegalArgumentException( "This type of node [" + connection.getFrom().getUniqueId() + ", " + connection.getFrom().getName() + "] cannot have more than one outgoing connection!"); diff --git a/jbpm/jbpm-flow/src/main/java/org/jbpm/workflow/core/node/Split.java b/jbpm/jbpm-flow/src/main/java/org/jbpm/workflow/core/node/Split.java index 20f90546da1..fe2114905c0 100755 --- a/jbpm/jbpm-flow/src/main/java/org/jbpm/workflow/core/node/Split.java +++ b/jbpm/jbpm-flow/src/main/java/org/jbpm/workflow/core/node/Split.java @@ -143,7 +143,7 @@ public void validateAddIncomingConnection(final String type, final Connection co + "] only accepts default incoming connection type!"); } - if (!getIncomingConnections(Node.CONNECTION_DEFAULT_TYPE).isEmpty() && !"true".equals(System.getProperty("jbpm.enable.multi.con"))) { + if (!getIncomingConnections(Node.CONNECTION_DEFAULT_TYPE).isEmpty() && !Boolean.parseBoolean((String) getProcess().getMetaData().get("jbpm.enable.multi.con"))) { throw new IllegalArgumentException( "This type of node [" + connection.getTo().getUniqueId() + ", " + connection.getTo().getName() + "] cannot have more than one incoming connection!"); diff --git a/jbpm/jbpm-flow/src/main/java/org/jbpm/workflow/core/node/StartNode.java b/jbpm/jbpm-flow/src/main/java/org/jbpm/workflow/core/node/StartNode.java index cfc91ddeec9..3743bbd1573 100755 --- a/jbpm/jbpm-flow/src/main/java/org/jbpm/workflow/core/node/StartNode.java +++ b/jbpm/jbpm-flow/src/main/java/org/jbpm/workflow/core/node/StartNode.java @@ -92,7 +92,7 @@ public void validateAddOutgoingConnection(final String type, final Connection co throw new IllegalArgumentException( "A start node [" + this.getUniqueId() + ", " + this.getName() + "] only accepts default outgoing connection type!"); } - if (getTo() != null && !"true".equals(System.getProperty("jbpm.enable.multi.con"))) { + if (getTo() != null && !Boolean.parseBoolean((String) getProcess().getMetaData().get("jbpm.enable.multi.con"))) { throw new IllegalArgumentException( "A start node [" + this.getUniqueId() + ", " + this.getName() + "] cannot have more than one outgoing connection!"); } diff --git a/jbpm/jbpm-flow/src/main/java/org/jbpm/workflow/core/node/SubProcessNode.java b/jbpm/jbpm-flow/src/main/java/org/jbpm/workflow/core/node/SubProcessNode.java index 80b6f75f873..77f873ddc76 100755 --- a/jbpm/jbpm-flow/src/main/java/org/jbpm/workflow/core/node/SubProcessNode.java +++ b/jbpm/jbpm-flow/src/main/java/org/jbpm/workflow/core/node/SubProcessNode.java @@ -77,7 +77,7 @@ public void validateAddIncomingConnection(final String type, final Connection co "This type of node [" + connection.getTo().getUniqueId() + ", " + connection.getTo().getName() + "] only accepts default incoming connection type!"); } - if (getFrom() != null && !"true".equals(System.getProperty("jbpm.enable.multi.con"))) { + if (getFrom() != null && !Boolean.parseBoolean((String) getProcess().getMetaData().get("jbpm.enable.multi.con"))) { throw new IllegalArgumentException( "This type of node [" + connection.getTo().getUniqueId() + ", " + connection.getTo().getName() + "] cannot have more than one incoming connection!"); @@ -92,7 +92,7 @@ public void validateAddOutgoingConnection(final String type, final Connection co "This type of node [" + connection.getFrom().getUniqueId() + ", " + connection.getFrom().getName() + "] only accepts default outgoing connection type!"); } - if (getTo() != null && !"true".equals(System.getProperty("jbpm.enable.multi.con"))) { + if (getTo() != null && !Boolean.parseBoolean((String) getProcess().getMetaData().get("jbpm.enable.multi.con"))) { throw new IllegalArgumentException( "This type of node [" + connection.getFrom().getUniqueId() + ", " + connection.getFrom().getName() + "] cannot have more than one outgoing connection!"); diff --git a/jbpm/jbpm-flow/src/main/java/org/jbpm/workflow/core/node/TimerNode.java b/jbpm/jbpm-flow/src/main/java/org/jbpm/workflow/core/node/TimerNode.java index a3a4e29d95e..e8ce9a54957 100755 --- a/jbpm/jbpm-flow/src/main/java/org/jbpm/workflow/core/node/TimerNode.java +++ b/jbpm/jbpm-flow/src/main/java/org/jbpm/workflow/core/node/TimerNode.java @@ -45,7 +45,7 @@ public void validateAddIncomingConnection(final String type, final Connection co "This type of node [" + connection.getTo().getUniqueId() + ", " + connection.getTo().getName() + "] only accepts default incoming connection type!"); } - if (getFrom() != null && !"true".equals(System.getProperty("jbpm.enable.multi.con"))) { + if (getFrom() != null && !Boolean.parseBoolean((String) getProcess().getMetaData().get("jbpm.enable.multi.con"))) { throw new IllegalArgumentException( "This type of node [" + connection.getTo().getUniqueId() + ", " + connection.getTo().getName() + "] cannot have more than one incoming connection!"); @@ -60,7 +60,7 @@ public void validateAddOutgoingConnection(final String type, final Connection co "This type of node [" + connection.getFrom().getUniqueId() + ", " + connection.getFrom().getName() + "] only accepts default outgoing connection type!"); } - if (getTo() != null && !"true".equals(System.getProperty("jbpm.enable.multi.con"))) { + if (getTo() != null && !Boolean.parseBoolean((String) getProcess().getMetaData().get("jbpm.enable.multi.con"))) { throw new IllegalArgumentException( "This type of node [" + connection.getFrom().getUniqueId() + ", " + connection.getFrom().getName() + "] cannot have more than one outgoing connection!"); diff --git a/jbpm/jbpm-flow/src/main/java/org/jbpm/workflow/core/node/WorkItemNode.java b/jbpm/jbpm-flow/src/main/java/org/jbpm/workflow/core/node/WorkItemNode.java index dd1357b5ff7..d7cd3c06c19 100755 --- a/jbpm/jbpm-flow/src/main/java/org/jbpm/workflow/core/node/WorkItemNode.java +++ b/jbpm/jbpm-flow/src/main/java/org/jbpm/workflow/core/node/WorkItemNode.java @@ -66,7 +66,7 @@ public void validateAddIncomingConnection(final String type, final Connection co "This type of node [" + connection.getTo().getUniqueId() + ", " + connection.getTo().getName() + "] only accepts default incoming connection type!"); } - if (getFrom() != null && !"true".equals(System.getProperty("jbpm.enable.multi.con"))) { + if (getFrom() != null && !Boolean.parseBoolean((String) getProcess().getMetaData().get("jbpm.enable.multi.con"))) { throw new IllegalArgumentException( "This type of node [" + connection.getTo().getUniqueId() + ", " + connection.getTo().getName() + "] cannot have more than one incoming connection!"); @@ -81,7 +81,7 @@ public void validateAddOutgoingConnection(final String type, final Connection co "This type of node [" + connection.getFrom().getUniqueId() + ", " + connection.getFrom().getName() + "] only accepts default outgoing connection type!"); } - if (getTo() != null && !"true".equals(System.getProperty("jbpm.enable.multi.con"))) { + if (getTo() != null && !Boolean.parseBoolean((String) getProcess().getMetaData().get("jbpm.enable.multi.con"))) { throw new IllegalArgumentException( "This type of node [" + connection.getFrom().getUniqueId() + ", " + connection.getFrom().getName() + "] cannot have more than one outgoing connection!"); diff --git a/jbpm/jbpm-flow/src/main/java/org/jbpm/workflow/instance/impl/NodeInstanceImpl.java b/jbpm/jbpm-flow/src/main/java/org/jbpm/workflow/instance/impl/NodeInstanceImpl.java index f71a5ef44f4..a5e452a24a0 100755 --- a/jbpm/jbpm-flow/src/main/java/org/jbpm/workflow/instance/impl/NodeInstanceImpl.java +++ b/jbpm/jbpm-flow/src/main/java/org/jbpm/workflow/instance/impl/NodeInstanceImpl.java @@ -314,7 +314,7 @@ public void triggerCompleted(String type, boolean remove) { List connections = null; if (node != null) { - if ("true".equals(System.getProperty("jbpm.enable.multi.con")) && !((NodeImpl) node).getConstraints().isEmpty()) { + if (Boolean.parseBoolean((String) getProcessInstance().getProcess().getMetaData().get("jbpm.enable.multi.con")) && !((NodeImpl) node).getConstraints().isEmpty()) { int priority; connections = ((NodeImpl) node).getDefaultOutgoingConnections(); boolean found = false; diff --git a/jbpm/jbpm-flow/src/main/java/org/jbpm/workflow/instance/impl/WorkflowProcessInstanceImpl.java b/jbpm/jbpm-flow/src/main/java/org/jbpm/workflow/instance/impl/WorkflowProcessInstanceImpl.java index 434aca19b33..5f67bf1957b 100755 --- a/jbpm/jbpm-flow/src/main/java/org/jbpm/workflow/instance/impl/WorkflowProcessInstanceImpl.java +++ b/jbpm/jbpm-flow/src/main/java/org/jbpm/workflow/instance/impl/WorkflowProcessInstanceImpl.java @@ -602,6 +602,9 @@ private void registerExternalEventNodeListeners() { if (getWorkflowProcess().getMetaData().containsKey(COMPENSATION)) { addEventListener("Compensation", new CompensationEventListener(this), true); } + if (getWorkflowProcess().getMetaData().containsKey(COMPENSATION)) { + + } } private void unregisterExternalEventNodeListeners() { diff --git a/jbpm/jbpm-flow/src/main/java/org/jbpm/workflow/instance/node/ForEachNodeInstance.java b/jbpm/jbpm-flow/src/main/java/org/jbpm/workflow/instance/node/ForEachNodeInstance.java index 0b5df806ffd..339f48d3f2a 100755 --- a/jbpm/jbpm-flow/src/main/java/org/jbpm/workflow/instance/node/ForEachNodeInstance.java +++ b/jbpm/jbpm-flow/src/main/java/org/jbpm/workflow/instance/node/ForEachNodeInstance.java @@ -31,8 +31,10 @@ import org.jbpm.process.core.context.variable.VariableScope; import org.jbpm.process.instance.ContextInstance; import org.jbpm.process.instance.ContextableInstance; +import org.jbpm.process.instance.KogitoProcessContextImpl; import org.jbpm.process.instance.context.variable.VariableScopeInstance; import org.jbpm.process.instance.impl.Action; +import org.jbpm.process.instance.impl.ReturnValueEvaluator; import org.jbpm.ruleflow.core.Metadata; import org.jbpm.util.ContextFactory; import org.jbpm.workflow.core.Node; @@ -239,22 +241,18 @@ public void internalTrigger(KogitoNodeInstance from, String type) { Map tempVariables = new HashMap<>(); if (getForEachNode().getOutputVariableName() != null) { + Object outputVariable = from.getVariable(getForEachNode().getOutputVariableName()); Collection outputCollection = (Collection) this.getVariable(TEMP_OUTPUT_VAR); if (outputCollection == null) { outputCollection = new ArrayList<>(); - - } - Object outputVariable = from.getVariable(getForEachNode().getOutputVariableName()); - if (outputVariable != null) { - outputCollection.add(outputVariable); } + outputCollection.add(outputVariable); + setVariable(TEMP_OUTPUT_VAR, outputCollection); - if (getForEachNode().getOutputVariableName() != null) { - // add temp collection under actual output name for completion condition evaluation - tempVariables.put(getForEachNode().getOutputVariableName(), outputVariable); - } + tempVariables.put(getForEachNode().getOutputVariableName(), outputVariable); + String outputCollectionName = getForEachNode().getOutputCollectionExpression(); if (outputCollectionName != null) { tempVariables.put(outputCollectionName, outputCollection); @@ -262,7 +260,7 @@ public void internalTrigger(KogitoNodeInstance from, String type) { } - boolean isCompletionConditionMet = evaluateCompletionCondition(getForEachNode().getCompletionConditionExpression(), tempVariables); + boolean isCompletionConditionMet = getForEachNode().hasCompletionCondition() && evaluateCompletionCondition(getForEachNode().getCompletionConditionExpression(), tempVariables); if (isSequential() && !isCompletionConditionMet && !areNodeInstancesCompleted()) { getFirstCompositeNodeInstance() .ifPresent(nodeInstance -> { @@ -295,7 +293,7 @@ public void internalTrigger(KogitoNodeInstance from, String type) { ((NodeInstanceContainer) getNodeInstanceContainer()).removeNodeInstance(this); if (getForEachNode().isWaitForCompletion()) { - if (!"true".equals(System.getProperty("jbpm.enable.multi.con"))) { + if (!Boolean.parseBoolean((String) getForEachNode().getProcess().getMetaData().get("jbpm.enable.multi.con"))) { triggerConnection(getForEachJoinNode().getTo()); } else { List connections = getForEachJoinNode().getOutgoingConnections(Node.CONNECTION_DEFAULT_TYPE); @@ -319,21 +317,13 @@ private boolean areNodeInstancesCompleted() { return getNodeInstanceContainer().getNodeInstances().size() == 1; } - private boolean evaluateCompletionCondition(String expression, Map tempVariables) { - if (expression == null || expression.isEmpty()) { - return false; - } else { - try { - Object result = MVELProcessHelper.evaluator().eval(expression, - new ForEachNodeInstanceResolverFactory(this, tempVariables)); - if (!(result instanceof Boolean)) { - throw new IllegalArgumentException("Completion condition expression must return boolean values: " + - result + " for expression " + expression); - } - return ((Boolean) result).booleanValue(); - } catch (Exception t) { - throw new IllegalArgumentException("Could not evaluate completion condition " + expression, t); - } + private boolean evaluateCompletionCondition(ReturnValueEvaluator completeConditionEvaluator, Map tempVariables) { + try { + KogitoProcessContextImpl context = (KogitoProcessContextImpl) ContextFactory.fromNode(this); + context.setContextData(tempVariables); + return (Boolean) completeConditionEvaluator.evaluate(context); + } catch (Exception t) { + throw new IllegalArgumentException("Could not evaluate completion condition " + completeConditionEvaluator, t); } } diff --git a/jbpm/jbpm-flow/src/main/java/org/kie/kogito/process/impl/AbstractProcess.java b/jbpm/jbpm-flow/src/main/java/org/kie/kogito/process/impl/AbstractProcess.java index 2d09b5b141e..4c763d85931 100644 --- a/jbpm/jbpm-flow/src/main/java/org/kie/kogito/process/impl/AbstractProcess.java +++ b/jbpm/jbpm-flow/src/main/java/org/kie/kogito/process/impl/AbstractProcess.java @@ -28,7 +28,6 @@ import java.util.concurrent.locks.ReentrantLock; import java.util.function.Predicate; import java.util.stream.Collectors; -import java.util.stream.Stream; import org.jbpm.process.core.ProcessSupplier; import org.jbpm.process.core.timer.DateTimeUtils; @@ -172,9 +171,6 @@ public CorrelationService correlations() { @Override public void send(Signal signal) { getProcessRuntime().signalEvent(signal.channel(), signal.payload()); - try (Stream> stream = instances.stream()) { - stream.forEach(pi -> pi.send(signal)); - } } public Process configure() { diff --git a/jbpm/jbpm-flow/src/main/java/org/kie/kogito/process/impl/ProcessServiceImpl.java b/jbpm/jbpm-flow/src/main/java/org/kie/kogito/process/impl/ProcessServiceImpl.java index 3a59ab4569b..12620be4b29 100644 --- a/jbpm/jbpm-flow/src/main/java/org/kie/kogito/process/impl/ProcessServiceImpl.java +++ b/jbpm/jbpm-flow/src/main/java/org/kie/kogito/process/impl/ProcessServiceImpl.java @@ -170,7 +170,7 @@ public Optional> getTasks(Process process, S } @Override - public Optional signalTask(Process process, String id, String taskName) { + public Optional signalTask(Process process, String id, String taskName, SecurityPolicy policy) { return UnitOfWorkExecutor.executeInUnitOfWork(application.unitOfWorkManager(), () -> process .instances() .findById(id) @@ -183,13 +183,13 @@ public Optional signalTask(Process process, Strin String taskNodeName = node.getName(); pi.send(Sig.of(taskNodeName, Collections.emptyMap())); - return getTaskByName(pi, taskName).orElse(null); + return getTaskByName(pi, taskName, policy).orElse(null); })); } - public Optional getTaskByName(ProcessInstance pi, String taskName) { + private Optional getTaskByName(ProcessInstance pi, String taskName, SecurityPolicy... policies) { return pi - .workItems() + .workItems(policies) .stream() .filter(wi -> wi.getName().equals(taskName)) .findFirst(); diff --git a/jbpm/jbpm-flow/src/main/java/org/kie/kogito/process/impl/Sig.java b/jbpm/jbpm-flow/src/main/java/org/kie/kogito/process/impl/Sig.java index 7024ca3e986..c83f38499ef 100644 --- a/jbpm/jbpm-flow/src/main/java/org/kie/kogito/process/impl/Sig.java +++ b/jbpm/jbpm-flow/src/main/java/org/kie/kogito/process/impl/Sig.java @@ -26,6 +26,10 @@ public final class Sig implements Signal { private final T payload; private String referenceId; + public static org.kie.kogito.process.Signal of(String channel) { + return new Sig<>(channel, null); + } + public static org.kie.kogito.process.Signal of(String channel, T payload) { return new Sig<>(channel, payload); } diff --git a/jbpm/jbpm-tests/src/test/bpmn/org/jbpm/bpmn2/activity/BPMN2-UserTaskAssignmentActor.bpmn b/jbpm/jbpm-tests/src/test/bpmn/org/jbpm/bpmn2/activity/BPMN2-UserTaskAssignmentActor.bpmn new file mode 100644 index 00000000000..6b34d02f0a1 --- /dev/null +++ b/jbpm/jbpm-tests/src/test/bpmn/org/jbpm/bpmn2/activity/BPMN2-UserTaskAssignmentActor.bpmn @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + _37E3A306-1ECB-4937-A5DD-CEA62F29A4D5 + + + + + + + + _0D2B7D7C-D753-4CCF-94D6-C4BFD669A192 + _37E3A306-1ECB-4937-A5DD-CEA62F29A4D5 + + + + + _7349D0A9-C99C-44C1-A0FA-11E21DC45046_TaskNameInputX + _7349D0A9-C99C-44C1-A0FA-11E21DC45046_SkippableInputX + + + + _7349D0A9-C99C-44C1-A0FA-11E21DC45046_TaskNameInputX + + + + + + + _7349D0A9-C99C-44C1-A0FA-11E21DC45046_SkippableInputX + + + + + + + + john + + + + + _0D2B7D7C-D753-4CCF-94D6-C4BFD669A192 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + _TfEFMCWmED20cJveoGveWg + _TfEFMCWmED20cJveoGveWg + + \ No newline at end of file diff --git a/jbpm/jbpm-tests/src/test/bpmn/org/jbpm/bpmn2/activity/BPMN2-UserTaskAssignmentActorGroup.bpmn b/jbpm/jbpm-tests/src/test/bpmn/org/jbpm/bpmn2/activity/BPMN2-UserTaskAssignmentActorGroup.bpmn new file mode 100644 index 00000000000..1b11d2f4e48 --- /dev/null +++ b/jbpm/jbpm-tests/src/test/bpmn/org/jbpm/bpmn2/activity/BPMN2-UserTaskAssignmentActorGroup.bpmn @@ -0,0 +1,132 @@ + + + + + + + + + + + + + + + + + + + + + + _37E3A306-1ECB-4937-A5DD-CEA62F29A4D5 + + + + + + + + _0D2B7D7C-D753-4CCF-94D6-C4BFD669A192 + _37E3A306-1ECB-4937-A5DD-CEA62F29A4D5 + + + + + + _7349D0A9-C99C-44C1-A0FA-11E21DC45046_TaskNameInputX + _7349D0A9-C99C-44C1-A0FA-11E21DC45046_SkippableInputX + _7349D0A9-C99C-44C1-A0FA-11E21DC45046_GroupIdInputX + + + + _7349D0A9-C99C-44C1-A0FA-11E21DC45046_TaskNameInputX + + + + + + + _7349D0A9-C99C-44C1-A0FA-11E21DC45046_SkippableInputX + + + + + + + _7349D0A9-C99C-44C1-A0FA-11E21DC45046_GroupIdInputX + + + + + + + + john + + + + + _0D2B7D7C-D753-4CCF-94D6-C4BFD669A192 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + _pWcEECZJED2HF6GPCl7V2w + _pWcEECZJED2HF6GPCl7V2w + + \ No newline at end of file diff --git a/jbpm/jbpm-tests/src/test/bpmn/org/jbpm/bpmn2/activity/BPMN2-UserTaskAssignmentGroup.bpmn b/jbpm/jbpm-tests/src/test/bpmn/org/jbpm/bpmn2/activity/BPMN2-UserTaskAssignmentGroup.bpmn new file mode 100644 index 00000000000..3f8dd4c29d9 --- /dev/null +++ b/jbpm/jbpm-tests/src/test/bpmn/org/jbpm/bpmn2/activity/BPMN2-UserTaskAssignmentGroup.bpmn @@ -0,0 +1,127 @@ + + + + + + + + + + + + + + + + + + + + + + _37E3A306-1ECB-4937-A5DD-CEA62F29A4D5 + + + + + + + + _0D2B7D7C-D753-4CCF-94D6-C4BFD669A192 + _37E3A306-1ECB-4937-A5DD-CEA62F29A4D5 + + + + + + _7349D0A9-C99C-44C1-A0FA-11E21DC45046_TaskNameInputX + _7349D0A9-C99C-44C1-A0FA-11E21DC45046_SkippableInputX + _7349D0A9-C99C-44C1-A0FA-11E21DC45046_GroupIdInputX + + + + _7349D0A9-C99C-44C1-A0FA-11E21DC45046_TaskNameInputX + + + + + + + _7349D0A9-C99C-44C1-A0FA-11E21DC45046_SkippableInputX + + + + + + + _7349D0A9-C99C-44C1-A0FA-11E21DC45046_GroupIdInputX + + + + + + + + _0D2B7D7C-D753-4CCF-94D6-C4BFD669A192 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + _d4DSQCWmED2ahP2mOJbdtw + _d4DSQCWmED2ahP2mOJbdtw + + \ No newline at end of file diff --git a/jbpm/jbpm-tests/src/test/bpmn/org/jbpm/bpmn2/activity/BPMN2-UserTaskAssignmentNone.bpmn b/jbpm/jbpm-tests/src/test/bpmn/org/jbpm/bpmn2/activity/BPMN2-UserTaskAssignmentNone.bpmn new file mode 100644 index 00000000000..f73402a78db --- /dev/null +++ b/jbpm/jbpm-tests/src/test/bpmn/org/jbpm/bpmn2/activity/BPMN2-UserTaskAssignmentNone.bpmn @@ -0,0 +1,118 @@ + + + + + + + + + + + + + + + + + + + + + + _37E3A306-1ECB-4937-A5DD-CEA62F29A4D5 + + + + + + + + _0D2B7D7C-D753-4CCF-94D6-C4BFD669A192 + _37E3A306-1ECB-4937-A5DD-CEA62F29A4D5 + + + + + _7349D0A9-C99C-44C1-A0FA-11E21DC45046_TaskNameInputX + _7349D0A9-C99C-44C1-A0FA-11E21DC45046_SkippableInputX + + + + _7349D0A9-C99C-44C1-A0FA-11E21DC45046_TaskNameInputX + + + + + + + _7349D0A9-C99C-44C1-A0FA-11E21DC45046_SkippableInputX + + + + + + + + _0D2B7D7C-D753-4CCF-94D6-C4BFD669A192 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + _o5pXcCWmED2be5qkMK_U7g + _o5pXcCWmED2be5qkMK_U7g + + \ No newline at end of file diff --git a/jbpm/jbpm-tests/src/test/bpmn/org/jbpm/bpmn2/adhoc/BPMN2-AdHocSubProcessAutoComplete.bpmn2 b/jbpm/jbpm-tests/src/test/bpmn/org/jbpm/bpmn2/adhoc/BPMN2-AdHocSubProcessAutoComplete.bpmn2 index b2dd1c612b6..e53735546d9 100755 --- a/jbpm/jbpm-tests/src/test/bpmn/org/jbpm/bpmn2/adhoc/BPMN2-AdHocSubProcessAutoComplete.bpmn2 +++ b/jbpm/jbpm-tests/src/test/bpmn/org/jbpm/bpmn2/adhoc/BPMN2-AdHocSubProcessAutoComplete.bpmn2 @@ -48,6 +48,11 @@ + + + john + + getActivityInstanceAttribute("numberOfActiveInstances") == 0 diff --git a/jbpm/jbpm-tests/src/test/bpmn/org/jbpm/bpmn2/adhoc/BPMN2-AdHocSubProcessAutoCompleteExpression.bpmn2 b/jbpm/jbpm-tests/src/test/bpmn/org/jbpm/bpmn2/adhoc/BPMN2-AdHocSubProcessAutoCompleteExpression.bpmn2 index 06ebccda424..3e4656adc5b 100755 --- a/jbpm/jbpm-tests/src/test/bpmn/org/jbpm/bpmn2/adhoc/BPMN2-AdHocSubProcessAutoCompleteExpression.bpmn2 +++ b/jbpm/jbpm-tests/src/test/bpmn/org/jbpm/bpmn2/adhoc/BPMN2-AdHocSubProcessAutoCompleteExpression.bpmn2 @@ -51,6 +51,11 @@ _2_testHTOutput counter + + + john + + counter == 0 diff --git a/jbpm/jbpm-tests/src/test/bpmn/org/jbpm/bpmn2/adhoc/BPMN2-AdHocTerminateEndEvent.bpmn2 b/jbpm/jbpm-tests/src/test/bpmn/org/jbpm/bpmn2/adhoc/BPMN2-AdHocTerminateEndEvent.bpmn2 index 319d62e9052..9fa6ea3c097 100755 --- a/jbpm/jbpm-tests/src/test/bpmn/org/jbpm/bpmn2/adhoc/BPMN2-AdHocTerminateEndEvent.bpmn2 +++ b/jbpm/jbpm-tests/src/test/bpmn/org/jbpm/bpmn2/adhoc/BPMN2-AdHocTerminateEndEvent.bpmn2 @@ -1,175 +1,223 @@ - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + _29F48C6F-FEEE-4C1E-BFFC-1C9665E57CA7 - - autocomplete + - + + _93941A9D-70A3-44F4-A0DE-86F4A99E7BF3 + _60142D30-8511-49B6-8B80-AC2A3FD4CD55 + System.out.println("Ad hoc subprocess completed"); + + + _60142D30-8511-49B6-8B80-AC2A3FD4CD55 + + _29F48C6F-FEEE-4C1E-BFFC-1C9665E57CA7 _93941A9D-70A3-44F4-A0DE-86F4A99E7BF3 - + + + _08AC695D-4603-406E-B973-E99512E1E4F0 - - - + + + + + _AA02F0B1-3BCF-4723-8C33-A8F32375CB0F_TaskNameInputX _AA02F0B1-3BCF-4723-8C33-A8F32375CB0F_SkippableInputX - + + _AA02F0B1-3BCF-4723-8C33-A8F32375CB0F_TaskNameInputX + + + + + + _AA02F0B1-3BCF-4723-8C33-A8F32375CB0F_SkippableInputX - - true - _AA02F0B1-3BCF-4723-8C33-A8F32375CB0F_SkippableInputX + + + + + + john + + - - - - - - + _08AC695D-4603-406E-B973-E99512E1E4F0 - + _EDD0F033-077C-4D6C-ADC8-17A785A74D85 - - - + + + + + _560E157E-3173-4CFD-9CC6-26676D8B0A02_TaskNameInputX _560E157E-3173-4CFD-9CC6-26676D8B0A02_SkippableInputX - + + _560E157E-3173-4CFD-9CC6-26676D8B0A02_TaskNameInputX + + + + + + _560E157E-3173-4CFD-9CC6-26676D8B0A02_SkippableInputX - - true - _560E157E-3173-4CFD-9CC6-26676D8B0A02_SkippableInputX + + + + + + john + + - - - - - - + _EDD0F033-077C-4D6C-ADC8-17A785A74D85 - + - - - + - - - - - - - - _93941A9D-70A3-44F4-A0DE-86F4A99E7BF3 - _60142D30-8511-49B6-8B80-AC2A3FD4CD55 - - - - - - - - - - _60142D30-8511-49B6-8B80-AC2A3FD4CD55 - - - - - - - - - + + + + - - + + - - + + - - + + - - + + - - - + + + - - - + + + - - - - - - + + - - - - - - + + + + + - - - + + + + + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + _dQ3_sCW1ED24y9N0a84cQQ + _dQ3_sCW1ED24y9N0a84cQQ + + \ No newline at end of file diff --git a/jbpm/jbpm-tests/src/test/bpmn/org/jbpm/bpmn2/escalation/BPMN2-EscalationBoundaryEvent.bpmn2 b/jbpm/jbpm-tests/src/test/bpmn/org/jbpm/bpmn2/escalation/BPMN2-EscalationBoundaryEvent.bpmn2 index 92490e0dc40..391ca22f199 100755 --- a/jbpm/jbpm-tests/src/test/bpmn/org/jbpm/bpmn2/escalation/BPMN2-EscalationBoundaryEvent.bpmn2 +++ b/jbpm/jbpm-tests/src/test/bpmn/org/jbpm/bpmn2/escalation/BPMN2-EscalationBoundaryEvent.bpmn2 @@ -1,4 +1,4 @@ - + - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + SequenceFlow_2 - + + + + + SequenceFlow_1 - + + + + + + SequenceFlow_2 SequenceFlow_1 + + + + + UserTask_1_TaskNameInputX + UserTask_1_SkippableInputX + + + + UserTask_1_TaskNameInputX + + + + + + + UserTask_1_SkippableInputX + + + + + + + + john + + - - + + + + + + + + + + + + + SequenceFlow_3 - + - + + + + + + SequenceFlow_3 SequenceFlow_4 - System.out.println("Event sub process triggered"); + System.out.println("Event sub process triggered"); - + + + + + SequenceFlow_4 - - - - - + + + + - - + + - - - - - - + + + + + - - - + + + - - + + + + + + - - + + - - + + - - - + + + - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + _sB2hsCWqED2iQNEOxA1sPg + _sB2hsCWqED2iQNEOxA1sPg + \ No newline at end of file diff --git a/jbpm/jbpm-tests/src/test/resources/BPMN2-ConditionalStart.bpmn2 b/jbpm/jbpm-tests/src/test/bpmn/org/jbpm/bpmn2/event/BPMN2-ConditionalStart.bpmn2 similarity index 90% rename from jbpm/jbpm-tests/src/test/resources/BPMN2-ConditionalStart.bpmn2 rename to jbpm/jbpm-tests/src/test/bpmn/org/jbpm/bpmn2/event/BPMN2-ConditionalStart.bpmn2 index 441c7c6741b..d0f0fc7a736 100755 --- a/jbpm/jbpm-tests/src/test/resources/BPMN2-ConditionalStart.bpmn2 +++ b/jbpm/jbpm-tests/src/test/bpmn/org/jbpm/bpmn2/event/BPMN2-ConditionalStart.bpmn2 @@ -29,17 +29,19 @@ xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:tns="http://www.jboss.org/drools"> - - + + + + - Person(name == "john") + "john".equals(person.getName()) diff --git a/jbpm/jbpm-tests/src/test/bpmn/org/jbpm/bpmn2/flow/BPMN2-BooleanStructureRef.bpmn2 b/jbpm/jbpm-tests/src/test/bpmn/org/jbpm/bpmn2/flow/BPMN2-BooleanStructureRef.bpmn2 index f0c429f79dd..4f1a5f4cf1c 100755 --- a/jbpm/jbpm-tests/src/test/bpmn/org/jbpm/bpmn2/flow/BPMN2-BooleanStructureRef.bpmn2 +++ b/jbpm/jbpm-tests/src/test/bpmn/org/jbpm/bpmn2/flow/BPMN2-BooleanStructureRef.bpmn2 @@ -1,99 +1,183 @@ - - - - - - - - - - - - - - - - - - - - - _2_testHTOutput - - - - _2_testHTOutput - test - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + _1-_2 + + + + + + + + _1-_2 + _2-_3 + + + + + + _2_TaskNameInputX + _2_SkippableInputX + + + _2_testHTOutputX + + + + _2_TaskNameInputX + + + + + + + _2_SkippableInputX + + + + + + + _2_testHTOutputX + test + + + + john + + + + + + + + + + _2-_3 + _3-_4 + System.out.println("Result "+test); + + + + + + + + _3-_4 + + + - - - + + + - - + + - - + + - - + + - - - + + + - - - + + + - - - + + + - - \ No newline at end of file + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + _8Q9sQCW4ED2JqL4kdJLjeg + _8Q9sQCW4ED2JqL4kdJLjeg + + \ No newline at end of file diff --git a/jbpm/jbpm-tests/src/test/bpmn/org/jbpm/bpmn2/flow/BPMN2-BrokenStructureRef.bpmn2 b/jbpm/jbpm-tests/src/test/bpmn/org/jbpm/bpmn2/flow/BPMN2-BrokenStructureRef.bpmn2 index b96b93bb7ab..d3e534a9a0a 100755 --- a/jbpm/jbpm-tests/src/test/bpmn/org/jbpm/bpmn2/flow/BPMN2-BrokenStructureRef.bpmn2 +++ b/jbpm/jbpm-tests/src/test/bpmn/org/jbpm/bpmn2/flow/BPMN2-BrokenStructureRef.bpmn2 @@ -1,99 +1,183 @@ - - - - - - - - - - - - - - - - - - - - - _2_testHTOutput - - - - _2_testHTOutput - test - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + _1-_2 + + + + + + + + _1-_2 + _2-_3 + + + + + + _2_TaskNameInputX + _2_SkippableInputX + + + _2_testHTOutputX + + + + _2_TaskNameInputX + + + + + + + _2_SkippableInputX + + + + + + + _2_testHTOutputX + test + + + + john + + + + + + + + + + _2-_3 + _3-_4 + System.out.println("Result "+test); + + + + + + + + _3-_4 + + + - - - + + + - - + + - - + + - - + + - - - + + + - - - + + + - - - + + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + _AuwtQCW5ED2B-7aqGG3h5Q + _AuwtQCW5ED2B-7aqGG3h5Q + + \ No newline at end of file diff --git a/jbpm/jbpm-tests/src/test/resources/BPMN2-ConditionalFlowWithoutGateway.bpmn2 b/jbpm/jbpm-tests/src/test/bpmn/org/jbpm/bpmn2/flow/BPMN2-ConditionalFlowWithoutGateway.bpmn2 similarity index 88% rename from jbpm/jbpm-tests/src/test/resources/BPMN2-ConditionalFlowWithoutGateway.bpmn2 rename to jbpm/jbpm-tests/src/test/bpmn/org/jbpm/bpmn2/flow/BPMN2-ConditionalFlowWithoutGateway.bpmn2 index f6816308fa7..63a64e43fa0 100755 --- a/jbpm/jbpm-tests/src/test/resources/BPMN2-ConditionalFlowWithoutGateway.bpmn2 +++ b/jbpm/jbpm-tests/src/test/bpmn/org/jbpm/bpmn2/flow/BPMN2-ConditionalFlowWithoutGateway.bpmn2 @@ -18,9 +18,19 @@ ~ under the License. --> - + - + + + + + + _1897CC4D-9026-42F4-A3E9-663EBD1B00F3 diff --git a/jbpm/jbpm-tests/src/test/bpmn/org/jbpm/bpmn2/flow/BPMN2-DefaultObjectStructureRef.bpmn2 b/jbpm/jbpm-tests/src/test/bpmn/org/jbpm/bpmn2/flow/BPMN2-DefaultObjectStructureRef.bpmn2 index f2229bf8d42..fa9f4215e59 100755 --- a/jbpm/jbpm-tests/src/test/bpmn/org/jbpm/bpmn2/flow/BPMN2-DefaultObjectStructureRef.bpmn2 +++ b/jbpm/jbpm-tests/src/test/bpmn/org/jbpm/bpmn2/flow/BPMN2-DefaultObjectStructureRef.bpmn2 @@ -1,99 +1,183 @@ - - - - - - - - - - - - - - - - - - - - - _2_testHTOutput - - - - _2_testHTOutput - test - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + _1-_2 + + + + + + + + _1-_2 + _2-_3 + + + + + + _2_TaskNameInputX + _2_SkippableInputX + + + _2_testHTOutputX + + + + _2_TaskNameInputX + + + + + + + _2_SkippableInputX + + + + + + + _2_testHTOutputX + test + + + + john + + + + + + + + + + _2-_3 + _3-_4 + System.out.println("Result "+test); + + + + + + + + _3-_4 + + + - - - + + + - - + + - - + + - - + + - - - + + + - - - + + + - - - + + + - - \ No newline at end of file + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + _1YWZMCW5ED2GXMgJRorQqw + _1YWZMCW5ED2GXMgJRorQqw + + \ No newline at end of file diff --git a/jbpm/jbpm-tests/src/test/resources/BPMN2-ExclusiveGatewayWithNoConditionsDefined.bpmn2 b/jbpm/jbpm-tests/src/test/bpmn/org/jbpm/bpmn2/flow/BPMN2-ExclusiveGatewayWithNoConditionsDefined.bpmn2 similarity index 97% rename from jbpm/jbpm-tests/src/test/resources/BPMN2-ExclusiveGatewayWithNoConditionsDefined.bpmn2 rename to jbpm/jbpm-tests/src/test/bpmn/org/jbpm/bpmn2/flow/BPMN2-ExclusiveGatewayWithNoConditionsDefined.bpmn2 index 1e249fe6141..6ec613905b3 100755 --- a/jbpm/jbpm-tests/src/test/resources/BPMN2-ExclusiveGatewayWithNoConditionsDefined.bpmn2 +++ b/jbpm/jbpm-tests/src/test/bpmn/org/jbpm/bpmn2/flow/BPMN2-ExclusiveGatewayWithNoConditionsDefined.bpmn2 @@ -19,7 +19,7 @@ --> - + SequenceFlow_3 diff --git a/jbpm/jbpm-tests/src/test/resources/BPMN2-ExclusiveSplitDefault.bpmn2 b/jbpm/jbpm-tests/src/test/bpmn/org/jbpm/bpmn2/flow/BPMN2-ExclusiveSplitDefault.bpmn2 similarity index 100% rename from jbpm/jbpm-tests/src/test/resources/BPMN2-ExclusiveSplitDefault.bpmn2 rename to jbpm/jbpm-tests/src/test/bpmn/org/jbpm/bpmn2/flow/BPMN2-ExclusiveSplitDefault.bpmn2 diff --git a/jbpm/jbpm-tests/src/test/resources/BPMN2-ExclusiveSplitDefaultNoCondition.bpmn2 b/jbpm/jbpm-tests/src/test/bpmn/org/jbpm/bpmn2/flow/BPMN2-ExclusiveSplitDefaultNoCondition.bpmn2 similarity index 95% rename from jbpm/jbpm-tests/src/test/resources/BPMN2-ExclusiveSplitDefaultNoCondition.bpmn2 rename to jbpm/jbpm-tests/src/test/bpmn/org/jbpm/bpmn2/flow/BPMN2-ExclusiveSplitDefaultNoCondition.bpmn2 index 4592a473cb4..2edb8324320 100755 --- a/jbpm/jbpm-tests/src/test/resources/BPMN2-ExclusiveSplitDefaultNoCondition.bpmn2 +++ b/jbpm/jbpm-tests/src/test/bpmn/org/jbpm/bpmn2/flow/BPMN2-ExclusiveSplitDefaultNoCondition.bpmn2 @@ -31,7 +31,7 @@ - + diff --git a/jbpm/jbpm-tests/src/test/resources/BPMN2-ExclusiveSplitXPath.bpmn2 b/jbpm/jbpm-tests/src/test/bpmn/org/jbpm/bpmn2/flow/BPMN2-ExclusiveSplitXPath.bpmn2 similarity index 100% rename from jbpm/jbpm-tests/src/test/resources/BPMN2-ExclusiveSplitXPath.bpmn2 rename to jbpm/jbpm-tests/src/test/bpmn/org/jbpm/bpmn2/flow/BPMN2-ExclusiveSplitXPath.bpmn2 diff --git a/jbpm/jbpm-tests/src/test/resources/BPMN2-ExclusiveSplitXPath-advanced.bpmn2 b/jbpm/jbpm-tests/src/test/bpmn/org/jbpm/bpmn2/flow/BPMN2-ExclusiveSplitXPathAdvanced.bpmn2 similarity index 98% rename from jbpm/jbpm-tests/src/test/resources/BPMN2-ExclusiveSplitXPath-advanced.bpmn2 rename to jbpm/jbpm-tests/src/test/bpmn/org/jbpm/bpmn2/flow/BPMN2-ExclusiveSplitXPathAdvanced.bpmn2 index 3d874d87148..af73961bdae 100755 --- a/jbpm/jbpm-tests/src/test/resources/BPMN2-ExclusiveSplitXPath-advanced.bpmn2 +++ b/jbpm/jbpm-tests/src/test/bpmn/org/jbpm/bpmn2/flow/BPMN2-ExclusiveSplitXPathAdvanced.bpmn2 @@ -32,7 +32,7 @@ - + diff --git a/jbpm/jbpm-tests/src/test/resources/BPMN2-ExclusiveSplitXPath-advanced-vars-not-signaled.bpmn2 b/jbpm/jbpm-tests/src/test/bpmn/org/jbpm/bpmn2/flow/BPMN2-ExclusiveSplitXPathAdvancedVarsNotSignaled.bpmn2 similarity index 97% rename from jbpm/jbpm-tests/src/test/resources/BPMN2-ExclusiveSplitXPath-advanced-vars-not-signaled.bpmn2 rename to jbpm/jbpm-tests/src/test/bpmn/org/jbpm/bpmn2/flow/BPMN2-ExclusiveSplitXPathAdvancedVarsNotSignaled.bpmn2 index b00347d6a71..ed6781736ab 100755 --- a/jbpm/jbpm-tests/src/test/resources/BPMN2-ExclusiveSplitXPath-advanced-vars-not-signaled.bpmn2 +++ b/jbpm/jbpm-tests/src/test/bpmn/org/jbpm/bpmn2/flow/BPMN2-ExclusiveSplitXPathAdvancedVarsNotSignaled.bpmn2 @@ -32,7 +32,7 @@ - + diff --git a/jbpm/jbpm-tests/src/test/resources/BPMN2-ExclusiveSplitXPath-advanced-with-vars.bpmn2 b/jbpm/jbpm-tests/src/test/bpmn/org/jbpm/bpmn2/flow/BPMN2-ExclusiveSplitXPathAdvancedWithVars.bpmn2 similarity index 97% rename from jbpm/jbpm-tests/src/test/resources/BPMN2-ExclusiveSplitXPath-advanced-with-vars.bpmn2 rename to jbpm/jbpm-tests/src/test/bpmn/org/jbpm/bpmn2/flow/BPMN2-ExclusiveSplitXPathAdvancedWithVars.bpmn2 index 53ac83b9767..473d81c9983 100755 --- a/jbpm/jbpm-tests/src/test/resources/BPMN2-ExclusiveSplitXPath-advanced-with-vars.bpmn2 +++ b/jbpm/jbpm-tests/src/test/bpmn/org/jbpm/bpmn2/flow/BPMN2-ExclusiveSplitXPathAdvancedWithVars.bpmn2 @@ -32,7 +32,7 @@ - + diff --git a/jbpm/jbpm-tests/src/test/bpmn/org/jbpm/bpmn2/flow/BPMN2-FloatStructureRef.bpmn2 b/jbpm/jbpm-tests/src/test/bpmn/org/jbpm/bpmn2/flow/BPMN2-FloatStructureRef.bpmn2 index 9bafb0d064a..6adad3b6485 100755 --- a/jbpm/jbpm-tests/src/test/bpmn/org/jbpm/bpmn2/flow/BPMN2-FloatStructureRef.bpmn2 +++ b/jbpm/jbpm-tests/src/test/bpmn/org/jbpm/bpmn2/flow/BPMN2-FloatStructureRef.bpmn2 @@ -1,99 +1,183 @@ - - - - - - - - - - - - - - - - - - - - - _2_testHTOutput - - - - _2_testHTOutput - test - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + _1-_2 + + + + + + + + _1-_2 + _2-_3 + + + + + + _2_TaskNameInputX + _2_SkippableInputX + + + _2_testHTOutputX + + + + _2_TaskNameInputX + + + + + + + _2_SkippableInputX + + + + + + + _2_testHTOutputX + test + + + + john + + + + + + + + + + _2-_3 + _3-_4 + System.out.println("Result "+test); + + + + + + + + _3-_4 + + + - - - + + + - - + + - - + + - - + + - - - + + + - - - + + + - - - + + + - - \ No newline at end of file + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + _Ef6qsCW5ED2kqaHSwjBfKg + _Ef6qsCW5ED2kqaHSwjBfKg + + \ No newline at end of file diff --git a/jbpm/jbpm-tests/src/test/resources/BPMN2-GatewaySplit-SequenceConditions.bpmn2 b/jbpm/jbpm-tests/src/test/bpmn/org/jbpm/bpmn2/flow/BPMN2-GatewaySplitSequenceConditions.bpmn2 similarity index 98% rename from jbpm/jbpm-tests/src/test/resources/BPMN2-GatewaySplit-SequenceConditions.bpmn2 rename to jbpm/jbpm-tests/src/test/bpmn/org/jbpm/bpmn2/flow/BPMN2-GatewaySplitSequenceConditions.bpmn2 index b5b98479dee..1e3f71617e9 100755 --- a/jbpm/jbpm-tests/src/test/resources/BPMN2-GatewaySplit-SequenceConditions.bpmn2 +++ b/jbpm/jbpm-tests/src/test/bpmn/org/jbpm/bpmn2/flow/BPMN2-GatewaySplitSequenceConditions.bpmn2 @@ -31,7 +31,7 @@ xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:tns="http://www.jboss.org/drools"> - + diff --git a/jbpm/jbpm-tests/src/test/resources/BPMN2-gatewayTest.bpmn2 b/jbpm/jbpm-tests/src/test/bpmn/org/jbpm/bpmn2/flow/BPMN2-GatewayTest.bpmn2 similarity index 91% rename from jbpm/jbpm-tests/src/test/resources/BPMN2-gatewayTest.bpmn2 rename to jbpm/jbpm-tests/src/test/bpmn/org/jbpm/bpmn2/flow/BPMN2-GatewayTest.bpmn2 index 78a3574a6a2..8daceb73887 100755 --- a/jbpm/jbpm-tests/src/test/resources/BPMN2-gatewayTest.bpmn2 +++ b/jbpm/jbpm-tests/src/test/bpmn/org/jbpm/bpmn2/flow/BPMN2-GatewayTest.bpmn2 @@ -17,11 +17,15 @@ ~ under the License. --> - + - + diff --git a/jbpm/jbpm-tests/src/test/resources/BPMN2-InclusiveSplitDefault.bpmn2 b/jbpm/jbpm-tests/src/test/bpmn/org/jbpm/bpmn2/flow/BPMN2-InclusiveSplitDefault.bpmn2 similarity index 100% rename from jbpm/jbpm-tests/src/test/resources/BPMN2-InclusiveSplitDefault.bpmn2 rename to jbpm/jbpm-tests/src/test/bpmn/org/jbpm/bpmn2/flow/BPMN2-InclusiveSplitDefault.bpmn2 diff --git a/jbpm/jbpm-tests/src/test/bpmn/org/jbpm/bpmn2/flow/BPMN2-IntegerStructureRef.bpmn2 b/jbpm/jbpm-tests/src/test/bpmn/org/jbpm/bpmn2/flow/BPMN2-IntegerStructureRef.bpmn2 index 3395dbb2d39..b3897ef2253 100755 --- a/jbpm/jbpm-tests/src/test/bpmn/org/jbpm/bpmn2/flow/BPMN2-IntegerStructureRef.bpmn2 +++ b/jbpm/jbpm-tests/src/test/bpmn/org/jbpm/bpmn2/flow/BPMN2-IntegerStructureRef.bpmn2 @@ -1,99 +1,183 @@ - - - - - - - - - - - - - - - - - - - - - _2_testHTOutput - - - - _2_testHTOutput - test - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + _1-_2 + + + + + + + + _1-_2 + _2-_3 + + + + + + _2_TaskNameInputX + _2_SkippableInputX + + + _2_testHTOutputX + + + + _2_TaskNameInputX + + + + + + + _2_SkippableInputX + + + + + + + _2_testHTOutputX + test + + + + john + + + + + + + + + + _2-_3 + _3-_4 + System.out.println("Result "+test); + + + + + + + + _3-_4 + + + - - - + + + - - + + - - + + - - + + - - - + + + - - - + + + - - - + + + - - \ No newline at end of file + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + _ISbTACW5ED2lG5gYh56IOg + _ISbTACW5ED2lG5gYh56IOg + + \ No newline at end of file diff --git a/jbpm/jbpm-tests/src/test/bpmn/org/jbpm/bpmn2/flow/BPMN2-ObjectStructureRef.bpmn2 b/jbpm/jbpm-tests/src/test/bpmn/org/jbpm/bpmn2/flow/BPMN2-ObjectStructureRef.bpmn2 index f8cd0a03e42..103d1d5156b 100755 --- a/jbpm/jbpm-tests/src/test/bpmn/org/jbpm/bpmn2/flow/BPMN2-ObjectStructureRef.bpmn2 +++ b/jbpm/jbpm-tests/src/test/bpmn/org/jbpm/bpmn2/flow/BPMN2-ObjectStructureRef.bpmn2 @@ -1,99 +1,183 @@ - - - - - - - - - - - - - - - - - - - - - _2_testHTOutput - - - - _2_testHTOutput - test - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + _1-_2 + + + + + + + + _1-_2 + _2-_3 + + + + + + _2_TaskNameInputX + _2_SkippableInputX + + + _2_testHTOutputX + + + + _2_TaskNameInputX + + + + + + + _2_SkippableInputX + + + + + + + _2_testHTOutputX + test + + + + john + + + + + + + + + + _2-_3 + _3-_4 + System.out.println("Result "+test); + + + + + + + + _3-_4 + + + - - - + + + - - + + - - + + - - + + - - - + + + - - - + + + - - - + + + - - \ No newline at end of file + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + _MTswECW5ED2lY6_ultl44A + _MTswECW5ED2lY6_ultl44A + + \ No newline at end of file diff --git a/jbpm/jbpm-tests/src/test/resources/BPMN2-MultiInstanceLoopBoundaryTimer.bpmn2 b/jbpm/jbpm-tests/src/test/bpmn/org/jbpm/bpmn2/loop/BPMN2-MultiInstanceLoopBoundaryTimer.bpmn2 similarity index 99% rename from jbpm/jbpm-tests/src/test/resources/BPMN2-MultiInstanceLoopBoundaryTimer.bpmn2 rename to jbpm/jbpm-tests/src/test/bpmn/org/jbpm/bpmn2/loop/BPMN2-MultiInstanceLoopBoundaryTimer.bpmn2 index 6e64db33701..979afdd569a 100755 --- a/jbpm/jbpm-tests/src/test/resources/BPMN2-MultiInstanceLoopBoundaryTimer.bpmn2 +++ b/jbpm/jbpm-tests/src/test/bpmn/org/jbpm/bpmn2/loop/BPMN2-MultiInstanceLoopBoundaryTimer.bpmn2 @@ -36,7 +36,7 @@ + name="BoundaryTimerMultipleInstances" tns:packageName="org.jbpm.bpmn2.loop" tns:version="1.0" > diff --git a/jbpm/jbpm-tests/src/test/resources/BPMN2-MultiInstanceLoopCharacteristicsProcessSequential.bpmn2 b/jbpm/jbpm-tests/src/test/bpmn/org/jbpm/bpmn2/loop/BPMN2-MultiInstanceLoopCharacteristicsProcessSequential.bpmn2 similarity index 97% rename from jbpm/jbpm-tests/src/test/resources/BPMN2-MultiInstanceLoopCharacteristicsProcessSequential.bpmn2 rename to jbpm/jbpm-tests/src/test/bpmn/org/jbpm/bpmn2/loop/BPMN2-MultiInstanceLoopCharacteristicsProcessSequential.bpmn2 index 6247abfc0b7..0e274b0f33c 100644 --- a/jbpm/jbpm-tests/src/test/resources/BPMN2-MultiInstanceLoopCharacteristicsProcessSequential.bpmn2 +++ b/jbpm/jbpm-tests/src/test/bpmn/org/jbpm/bpmn2/loop/BPMN2-MultiInstanceLoopCharacteristicsProcessSequential.bpmn2 @@ -34,7 +34,8 @@ - + diff --git a/jbpm/jbpm-tests/src/test/resources/BPMN2-MultiInstanceLoopCharacteristicsProcessWithOutputAndScripts.bpmn2 b/jbpm/jbpm-tests/src/test/bpmn/org/jbpm/bpmn2/loop/BPMN2-MultiInstanceLoopCharacteristicsProcessWithOutputAndScripts.bpmn2 similarity index 98% rename from jbpm/jbpm-tests/src/test/resources/BPMN2-MultiInstanceLoopCharacteristicsProcessWithOutputAndScripts.bpmn2 rename to jbpm/jbpm-tests/src/test/bpmn/org/jbpm/bpmn2/loop/BPMN2-MultiInstanceLoopCharacteristicsProcessWithOutputAndScripts.bpmn2 index 187d0f8d1a9..c3b954cc952 100755 --- a/jbpm/jbpm-tests/src/test/resources/BPMN2-MultiInstanceLoopCharacteristicsProcessWithOutputAndScripts.bpmn2 +++ b/jbpm/jbpm-tests/src/test/bpmn/org/jbpm/bpmn2/loop/BPMN2-MultiInstanceLoopCharacteristicsProcessWithOutputAndScripts.bpmn2 @@ -23,7 +23,7 @@ - + @@ -77,7 +77,7 @@ diff --git a/jbpm/jbpm-tests/src/test/resources/BPMN2-MultiInstanceLoopCharacteristicsTask.bpmn2 b/jbpm/jbpm-tests/src/test/bpmn/org/jbpm/bpmn2/loop/BPMN2-MultiInstanceLoopCharacteristicsTask.bpmn2 similarity index 96% rename from jbpm/jbpm-tests/src/test/resources/BPMN2-MultiInstanceLoopCharacteristicsTask.bpmn2 rename to jbpm/jbpm-tests/src/test/bpmn/org/jbpm/bpmn2/loop/BPMN2-MultiInstanceLoopCharacteristicsTask.bpmn2 index e0d7802b44a..75d89de2c4e 100755 --- a/jbpm/jbpm-tests/src/test/resources/BPMN2-MultiInstanceLoopCharacteristicsTask.bpmn2 +++ b/jbpm/jbpm-tests/src/test/bpmn/org/jbpm/bpmn2/loop/BPMN2-MultiInstanceLoopCharacteristicsTask.bpmn2 @@ -34,7 +34,8 @@ - + diff --git a/jbpm/jbpm-tests/src/test/resources/BPMN2-MultiInstanceLoopCharacteristicsTaskSequential.bpmn2 b/jbpm/jbpm-tests/src/test/bpmn/org/jbpm/bpmn2/loop/BPMN2-MultiInstanceLoopCharacteristicsTaskSequential.bpmn2 similarity index 96% rename from jbpm/jbpm-tests/src/test/resources/BPMN2-MultiInstanceLoopCharacteristicsTaskSequential.bpmn2 rename to jbpm/jbpm-tests/src/test/bpmn/org/jbpm/bpmn2/loop/BPMN2-MultiInstanceLoopCharacteristicsTaskSequential.bpmn2 index c18ad7c8025..5a61046d049 100644 --- a/jbpm/jbpm-tests/src/test/resources/BPMN2-MultiInstanceLoopCharacteristicsTaskSequential.bpmn2 +++ b/jbpm/jbpm-tests/src/test/bpmn/org/jbpm/bpmn2/loop/BPMN2-MultiInstanceLoopCharacteristicsTaskSequential.bpmn2 @@ -34,7 +34,7 @@ - + diff --git a/jbpm/jbpm-tests/src/test/bpmn/org/jbpm/bpmn2/loop/BPMN2-MultiInstanceLoopCharacteristicsTaskWithOutputCmpCondSequential.bpmn2 b/jbpm/jbpm-tests/src/test/bpmn/org/jbpm/bpmn2/loop/BPMN2-MultiInstanceLoopCharacteristicsTaskWithOutputCmpCondSequential.bpmn2 new file mode 100644 index 00000000000..0b8a32113a4 --- /dev/null +++ b/jbpm/jbpm-tests/src/test/bpmn/org/jbpm/bpmn2/loop/BPMN2-MultiInstanceLoopCharacteristicsTaskWithOutputCmpCondSequential.bpmn2 @@ -0,0 +1,125 @@ + + + + + + + + + + + + + + + + + + + + + + System.out.println("Hello");context.setVariable("itemOut", "test"); + + + + + + + + + _2_item + + + _2_listOutOutput + + + + item + _2_item + + + list + _2_input + + + _2_listOutOutput + listOut + + + _2_itemOut + itemOut + + + + john + + + + _2_input + _2_listOutOutput + + + listOut.size == 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/jbpm/jbpm-tests/src/test/resources/BPMN2-EventSubprocessConditional.bpmn2 b/jbpm/jbpm-tests/src/test/bpmn/org/jbpm/bpmn2/subprocess/BPMN2-EventSubprocessConditional.bpmn2 similarity index 89% rename from jbpm/jbpm-tests/src/test/resources/BPMN2-EventSubprocessConditional.bpmn2 rename to jbpm/jbpm-tests/src/test/bpmn/org/jbpm/bpmn2/subprocess/BPMN2-EventSubprocessConditional.bpmn2 index d259c8b3473..b99c255f61e 100755 --- a/jbpm/jbpm-tests/src/test/resources/BPMN2-EventSubprocessConditional.bpmn2 +++ b/jbpm/jbpm-tests/src/test/bpmn/org/jbpm/bpmn2/subprocess/BPMN2-EventSubprocessConditional.bpmn2 @@ -19,7 +19,9 @@ --> - + + + SequenceFlow_2 @@ -30,13 +32,18 @@ SequenceFlow_2 SequenceFlow_1 + + + john + + SequenceFlow_3 - org.jbpm.bpmn2.objects.Person(name == "john") + "john".equals(person.getName()) diff --git a/jbpm/jbpm-tests/src/test/resources/BPMN2-EventSubprocessMessage.bpmn2 b/jbpm/jbpm-tests/src/test/bpmn/org/jbpm/bpmn2/subprocess/BPMN2-EventSubprocessMessage.bpmn2 similarity index 92% rename from jbpm/jbpm-tests/src/test/resources/BPMN2-EventSubprocessMessage.bpmn2 rename to jbpm/jbpm-tests/src/test/bpmn/org/jbpm/bpmn2/subprocess/BPMN2-EventSubprocessMessage.bpmn2 index 130b499d879..e3b4980dd09 100755 --- a/jbpm/jbpm-tests/src/test/resources/BPMN2-EventSubprocessMessage.bpmn2 +++ b/jbpm/jbpm-tests/src/test/bpmn/org/jbpm/bpmn2/subprocess/BPMN2-EventSubprocessMessage.bpmn2 @@ -21,7 +21,7 @@ - + SequenceFlow_2 @@ -31,7 +31,11 @@ SequenceFlow_2 - SequenceFlow_1 + SequenceFlow_1 + + john + + diff --git a/jbpm/jbpm-tests/src/test/bpmn/org/jbpm/bpmn2/subprocess/BPMN2-EventSubprocessSignalWithTransformation.bpmn2 b/jbpm/jbpm-tests/src/test/bpmn/org/jbpm/bpmn2/subprocess/BPMN2-EventSubprocessSignalWithTransformation.bpmn2 new file mode 100755 index 00000000000..2ab6c3e11f1 --- /dev/null +++ b/jbpm/jbpm-tests/src/test/bpmn/org/jbpm/bpmn2/subprocess/BPMN2-EventSubprocessSignalWithTransformation.bpmn2 @@ -0,0 +1,104 @@ + + + + + + + + + SequenceFlow_2 + + + + SequenceFlow_1 + + + SequenceFlow_2 + SequenceFlow_1 + + + + + SequenceFlow_3 + + + _B3F307E0-B1CA-4DF5-B348-6588C9E78112_param + x + param.toUpperCase() + + + _B3F307E0-B1CA-4DF5-B348-6588C9E78112_param + + + + + SequenceFlow_3 + SequenceFlow_4 + System.out.println("Event sub process triggered " + x); + + + + SequenceFlow_4 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/jbpm/jbpm-tests/src/test/bpmn/org/jbpm/bpmn2/subprocess/BPMN2-SubProcessWithEntryExitScripts.bpmn2 b/jbpm/jbpm-tests/src/test/bpmn/org/jbpm/bpmn2/subprocess/BPMN2-SubProcessWithEntryExitScripts.bpmn2 index 82c335553bc..0f9b4dc9e88 100755 --- a/jbpm/jbpm-tests/src/test/bpmn/org/jbpm/bpmn2/subprocess/BPMN2-SubProcessWithEntryExitScripts.bpmn2 +++ b/jbpm/jbpm-tests/src/test/bpmn/org/jbpm/bpmn2/subprocess/BPMN2-SubProcessWithEntryExitScripts.bpmn2 @@ -1,196 +1,282 @@ - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + _1-_2 SequenceFlow_11 - System.err.println("Task 1, var1 = 10"); -kcontext.setVariable("var1", new Integer(10)); + System.err.println("Task 1, var1 = 10"); +kcontext.setVariable("var1", new Integer(10)); - + _1-_2 - - + + + + + + SequenceFlow_12 SequenceFlow_7 - System.err.println("Task 3, var3 = 30"); -kcontext.setVariable("var3",30); + System.err.println("Task 3, var3 = 30"); +kcontext.setVariable("var3",30); - - + SequenceFlow_8 - + + + + + + SequenceFlow_7 SequenceFlow_8 - - - - - - - - - - _DataInput_150 - _DataInput_151 - _DataInput_152 - _DataInput_153 - _DataInput_154 - _DataInput_155 - _DataInput_156 + + + + + UserTask_2_TaskNameInputX + UserTask_2_SkippableInputX - - - _DataInput_150 - - - _DataInput_151 - - - _DataInput_152 + + UserTask_2_TaskNameInputX + + + + - - _DataInput_153 - - - _DataInput_154 - - - _DataInput_155 - - - _DataInput_156 + + UserTask_2_SkippableInputX + + + + + + + john + + - - - System.err.println("SubProcess, var4 = 40"); -kcontext.setVariable("var4",40); - - - - System.err.println("SubProcess, var5 = 50"); -kcontext.setVariable("var5",50); - - + + + + + + + + + SequenceFlow_11 SequenceFlow_12 - + + + SequenceFlow_10 - + + + + + SequenceFlow_10 SequenceFlow_9 - System.err.println("Task 2, var2 = 20"); -kcontext.setVariable("var2",20); + System.err.println("Task 2, var2 = 20"); +kcontext.setVariable("var2",20); - - + SequenceFlow_9 - - - - - - + + + + - - + + - - + + - - + + - - + + + + + + + + + + + + + + - - + + - - + + - - + + - - + + - - - - - - - - - - - + + + - - - - - + + + - - - - - + + + - - - + + + - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + _nPz2YCWnED24qrDb9miHmg + _nPz2YCWnED24qrDb9miHmg + \ No newline at end of file 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 c6a71ea45bf..7d96c0e56c6 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 @@ -35,32 +35,17 @@ import org.jbpm.bpmn2.activity.ScriptTaskProcess; import org.jbpm.bpmn2.activity.ScriptTaskWithIOModel; import org.jbpm.bpmn2.activity.ScriptTaskWithIOProcess; +import org.jbpm.bpmn2.activity.UserTaskWithBooleanOutputModel; +import org.jbpm.bpmn2.activity.UserTaskWithBooleanOutputProcess; +import org.jbpm.bpmn2.activity.UserTaskWithIOexpressionModel; +import org.jbpm.bpmn2.activity.UserTaskWithIOexpressionProcess; import org.jbpm.bpmn2.activity.UserTaskWithParametrizedInputModel; import org.jbpm.bpmn2.activity.UserTaskWithParametrizedInputProcess; import org.jbpm.bpmn2.activity.UserTaskWithSimulationMetaDataModel; import org.jbpm.bpmn2.activity.UserTaskWithSimulationMetaDataProcess; import org.jbpm.bpmn2.adhoc.SubProcessInAdHocProcessModel; import org.jbpm.bpmn2.adhoc.SubProcessInAdHocProcessProcess; -import org.jbpm.bpmn2.flow.CompositeWithDIGraphicalModel; -import org.jbpm.bpmn2.flow.CompositeWithDIGraphicalProcess; -import org.jbpm.bpmn2.flow.MinimalImplicitModel; -import org.jbpm.bpmn2.flow.MinimalImplicitProcess; -import org.jbpm.bpmn2.flow.MinimalModel; -import org.jbpm.bpmn2.flow.MinimalProcess; -import org.jbpm.bpmn2.flow.MinimalWithDIGraphicalModel; -import org.jbpm.bpmn2.flow.MinimalWithDIGraphicalProcess; -import org.jbpm.bpmn2.flow.MinimalWithGraphicalModel; -import org.jbpm.bpmn2.flow.MinimalWithGraphicalProcess; -import org.jbpm.bpmn2.flow.ProcessCustomDescriptionMetaDataModel; -import org.jbpm.bpmn2.flow.ProcessCustomDescriptionMetaDataProcess; -import org.jbpm.bpmn2.flow.ProcessVariableCustomDescriptionMetaDataModel; -import org.jbpm.bpmn2.flow.ProcessVariableCustomDescriptionMetaDataProcess; -import org.jbpm.bpmn2.flow.ProcessWithVariableNameModel; -import org.jbpm.bpmn2.flow.ProcessWithVariableNameProcess; -import org.jbpm.bpmn2.flow.UserTaskModel; -import org.jbpm.bpmn2.flow.UserTaskProcess; -import org.jbpm.bpmn2.flow.XORSameTargetModel; -import org.jbpm.bpmn2.flow.XORSameTargetProcess; +import org.jbpm.bpmn2.flow.*; import org.jbpm.bpmn2.handler.ReceiveTaskHandler; import org.jbpm.bpmn2.handler.SendTaskHandler; import org.jbpm.bpmn2.objects.Account; @@ -92,6 +77,8 @@ import org.jbpm.bpmn2.subprocess.CallActivityProcess; import org.jbpm.bpmn2.subprocess.CallActivityProcessBoundaryErrorModel; import org.jbpm.bpmn2.subprocess.CallActivityProcessBoundaryErrorProcess; +import org.jbpm.bpmn2.subprocess.CallActivityProcessWithBoundaryEventModel; +import org.jbpm.bpmn2.subprocess.CallActivityProcessWithBoundaryEventProcess; import org.jbpm.bpmn2.subprocess.CallActivitySubProcessBoundaryErrorModel; import org.jbpm.bpmn2.subprocess.CallActivitySubProcessBoundaryErrorProcess; import org.jbpm.bpmn2.subprocess.CallActivitySubProcessModel; @@ -481,6 +468,223 @@ public void testUserTask() { assertThat(instance).extracting(ProcessInstance::status).isEqualTo(ProcessInstance.STATE_COMPLETED); } + @Test + public void testUserTaskActorAssignment() { + Application app = ProcessTestHelper.newApplication(); + TestWorkItemHandler workItemHandler = new TestWorkItemHandler(); + ProcessTestHelper.registerHandler(app, "Human Task", workItemHandler); + org.kie.kogito.process.Process processDefinition = UserTaskActorProcess.newProcess(app); + UserTaskActorModel model = processDefinition.createModel(); + org.kie.kogito.process.ProcessInstance instance = processDefinition.createInstance(model); + instance.start(); + assertThat(instance).extracting(ProcessInstance::status).isEqualTo(ProcessInstance.STATE_ACTIVE); + KogitoWorkItem workItem = workItemHandler.getWorkItem(); + assertThat(workItem).isNotNull(); + assertThat(workItem.getParameter("ActorId")).isEqualTo("john"); + + ProcessTestHelper.completeWorkItem(instance, Collections.emptyMap(), "john"); + + assertThat(instance).extracting(ProcessInstance::status).isEqualTo(ProcessInstance.STATE_COMPLETED); + } + + @Test + public void testUserTaskActorAssignmentActorFailure() { + Application app = ProcessTestHelper.newApplication(); + TestWorkItemHandler workItemHandler = new TestWorkItemHandler(); + ProcessTestHelper.registerHandler(app, "Human Task", workItemHandler); + org.kie.kogito.process.Process processDefinition = UserTaskActorProcess.newProcess(app); + UserTaskActorModel model = processDefinition.createModel(); + org.kie.kogito.process.ProcessInstance instance = processDefinition.createInstance(model); + instance.start(); + assertThat(instance).extracting(ProcessInstance::status).isEqualTo(ProcessInstance.STATE_ACTIVE); + KogitoWorkItem workItem = workItemHandler.getWorkItem(); + assertThat(workItem).isNotNull(); + + ProcessTestHelper.completeWorkItem(instance, Collections.emptyMap(), "mary"); + + assertThat(instance).extracting(ProcessInstance::status).isEqualTo(ProcessInstance.STATE_ACTIVE); + } + + @Test + public void testUserTaskActorAssignmentNoPolicyFailure() { + Application app = ProcessTestHelper.newApplication(); + TestWorkItemHandler workItemHandler = new TestWorkItemHandler(); + ProcessTestHelper.registerHandler(app, "Human Task", workItemHandler); + org.kie.kogito.process.Process processDefinition = UserTaskActorProcess.newProcess(app); + UserTaskActorModel model = processDefinition.createModel(); + org.kie.kogito.process.ProcessInstance instance = processDefinition.createInstance(model); + instance.start(); + assertThat(instance).extracting(ProcessInstance::status).isEqualTo(ProcessInstance.STATE_ACTIVE); + KogitoWorkItem workItem = workItemHandler.getWorkItem(); + assertThat(workItem).isNotNull(); + + ProcessTestHelper.completeWorkItem(instance, Collections.emptyMap()); + + assertThat(instance).extracting(ProcessInstance::status).isEqualTo(ProcessInstance.STATE_ACTIVE); + } + + @Test + public void testUserTaskGroupAssignment() { + Application app = ProcessTestHelper.newApplication(); + TestWorkItemHandler workItemHandler = new TestWorkItemHandler(); + ProcessTestHelper.registerHandler(app, "Human Task", workItemHandler); + org.kie.kogito.process.Process processDefinition = UserTaskGroupProcess.newProcess(app); + UserTaskGroupModel model = processDefinition.createModel(); + org.kie.kogito.process.ProcessInstance instance = processDefinition.createInstance(model); + instance.start(); + assertThat(instance).extracting(ProcessInstance::status).isEqualTo(ProcessInstance.STATE_ACTIVE); + KogitoWorkItem workItem = workItemHandler.getWorkItem(); + assertThat(workItem).isNotNull(); + + ProcessTestHelper.completeWorkItem(instance, Collections.emptyMap(), "john", "IT"); + + assertThat(instance).extracting(ProcessInstance::status).isEqualTo(ProcessInstance.STATE_COMPLETED); + } + + @Test + public void testUserTaskGroupAssignmentFailure() { + Application app = ProcessTestHelper.newApplication(); + TestWorkItemHandler workItemHandler = new TestWorkItemHandler(); + ProcessTestHelper.registerHandler(app, "Human Task", workItemHandler); + org.kie.kogito.process.Process processDefinition = UserTaskGroupProcess.newProcess(app); + UserTaskGroupModel model = processDefinition.createModel(); + org.kie.kogito.process.ProcessInstance instance = processDefinition.createInstance(model); + instance.start(); + assertThat(instance).extracting(ProcessInstance::status).isEqualTo(ProcessInstance.STATE_ACTIVE); + KogitoWorkItem workItem = workItemHandler.getWorkItem(); + assertThat(workItem).isNotNull(); + + ProcessTestHelper.completeWorkItem(instance, Collections.emptyMap(), "john", "HR"); + + assertThat(instance).extracting(ProcessInstance::status).isEqualTo(ProcessInstance.STATE_ACTIVE); + } + + @Test + public void testUserTaskGroupAssignmentNoPolicyFailure() { + Application app = ProcessTestHelper.newApplication(); + TestWorkItemHandler workItemHandler = new TestWorkItemHandler(); + ProcessTestHelper.registerHandler(app, "Human Task", workItemHandler); + org.kie.kogito.process.Process processDefinition = UserTaskGroupProcess.newProcess(app); + UserTaskGroupModel model = processDefinition.createModel(); + org.kie.kogito.process.ProcessInstance instance = processDefinition.createInstance(model); + instance.start(); + assertThat(instance).extracting(ProcessInstance::status).isEqualTo(ProcessInstance.STATE_ACTIVE); + KogitoWorkItem workItem = workItemHandler.getWorkItem(); + assertThat(workItem).isNotNull(); + + ProcessTestHelper.completeWorkItem(instance, Collections.emptyMap()); + + assertThat(instance).extracting(ProcessInstance::status).isEqualTo(ProcessInstance.STATE_ACTIVE); + } + + @Test + public void testUserTaskNoneAssignmentFailure() { + Application app = ProcessTestHelper.newApplication(); + TestWorkItemHandler workItemHandler = new TestWorkItemHandler(); + ProcessTestHelper.registerHandler(app, "Human Task", workItemHandler); + org.kie.kogito.process.Process processDefinition = UserTaskNoneProcess.newProcess(app); + UserTaskNoneModel model = processDefinition.createModel(); + ProcessInstance instance = processDefinition.createInstance(model); + instance.start(); + assertThat(instance).extracting(ProcessInstance::status).isEqualTo(ProcessInstance.STATE_ACTIVE); + KogitoWorkItem workItem = workItemHandler.getWorkItem(); + assertThat(workItem).isNotNull(); + + ProcessTestHelper.completeWorkItem(instance, Collections.emptyMap(), "john", "HR"); + + assertThat(instance).extracting(ProcessInstance::status).isEqualTo(ProcessInstance.STATE_ACTIVE); + } + + @Test + public void testUserTaskNoneAssignmentNoPolicyFailure() { + Application app = ProcessTestHelper.newApplication(); + TestWorkItemHandler workItemHandler = new TestWorkItemHandler(); + ProcessTestHelper.registerHandler(app, "Human Task", workItemHandler); + org.kie.kogito.process.Process processDefinition = UserTaskNoneProcess.newProcess(app); + UserTaskNoneModel model = processDefinition.createModel(); + ProcessInstance instance = processDefinition.createInstance(model); + instance.start(); + assertThat(instance).extracting(ProcessInstance::status).isEqualTo(ProcessInstance.STATE_ACTIVE); + KogitoWorkItem workItem = workItemHandler.getWorkItem(); + assertThat(workItem).isNotNull(); + + ProcessTestHelper.completeWorkItem(instance, Collections.emptyMap()); + + assertThat(instance).extracting(ProcessInstance::status).isEqualTo(ProcessInstance.STATE_ACTIVE); + } + + @Test + public void testUserTaskActorAndGroupAssignmentWithActor() { + Application app = ProcessTestHelper.newApplication(); + TestWorkItemHandler workItemHandler = new TestWorkItemHandler(); + ProcessTestHelper.registerHandler(app, "Human Task", workItemHandler); + org.kie.kogito.process.Process processDefinition = UserTaskActorGroupProcess.newProcess(app); + UserTaskActorGroupModel model = processDefinition.createModel(); + ProcessInstance instance = processDefinition.createInstance(model); + instance.start(); + assertThat(instance).extracting(ProcessInstance::status).isEqualTo(ProcessInstance.STATE_ACTIVE); + KogitoWorkItem workItem = workItemHandler.getWorkItem(); + assertThat(workItem).isNotNull(); + + ProcessTestHelper.completeWorkItem(instance, Collections.emptyMap(), "john"); + + assertThat(instance).extracting(ProcessInstance::status).isEqualTo(ProcessInstance.STATE_COMPLETED); + } + + @Test + public void testUserTaskActorAndGroupAssignmentWithGroup() { + Application app = ProcessTestHelper.newApplication(); + TestWorkItemHandler workItemHandler = new TestWorkItemHandler(); + ProcessTestHelper.registerHandler(app, "Human Task", workItemHandler); + org.kie.kogito.process.Process processDefinition = UserTaskActorGroupProcess.newProcess(app); + UserTaskActorGroupModel model = processDefinition.createModel(); + ProcessInstance instance = processDefinition.createInstance(model); + instance.start(); + assertThat(instance).extracting(ProcessInstance::status).isEqualTo(ProcessInstance.STATE_ACTIVE); + KogitoWorkItem workItem = workItemHandler.getWorkItem(); + assertThat(workItem).isNotNull(); + + ProcessTestHelper.completeWorkItem(instance, Collections.emptyMap(), "mary", "IT"); + + assertThat(instance).extracting(ProcessInstance::status).isEqualTo(ProcessInstance.STATE_COMPLETED); + } + + @Test + public void testUserTaskActorAndGroupAssignmentFailure() { + Application app = ProcessTestHelper.newApplication(); + TestWorkItemHandler workItemHandler = new TestWorkItemHandler(); + ProcessTestHelper.registerHandler(app, "Human Task", workItemHandler); + org.kie.kogito.process.Process processDefinition = UserTaskActorGroupProcess.newProcess(app); + UserTaskActorGroupModel model = processDefinition.createModel(); + ProcessInstance instance = processDefinition.createInstance(model); + instance.start(); + assertThat(instance).extracting(ProcessInstance::status).isEqualTo(ProcessInstance.STATE_ACTIVE); + KogitoWorkItem workItem = workItemHandler.getWorkItem(); + assertThat(workItem).isNotNull(); + + ProcessTestHelper.completeWorkItem(instance, Collections.emptyMap(), "mary", "HR"); + + assertThat(instance).extracting(ProcessInstance::status).isEqualTo(ProcessInstance.STATE_ACTIVE); + } + + @Test + public void testUserTaskActorAndGroupAssignmentNoPolicyFailure() { + Application app = ProcessTestHelper.newApplication(); + TestWorkItemHandler workItemHandler = new TestWorkItemHandler(); + ProcessTestHelper.registerHandler(app, "Human Task", workItemHandler); + org.kie.kogito.process.Process processDefinition = UserTaskActorGroupProcess.newProcess(app); + UserTaskActorGroupModel model = processDefinition.createModel(); + ProcessInstance instance = processDefinition.createInstance(model); + instance.start(); + assertThat(instance).extracting(ProcessInstance::status).isEqualTo(ProcessInstance.STATE_ACTIVE); + KogitoWorkItem workItem = workItemHandler.getWorkItem(); + assertThat(workItem).isNotNull(); + + ProcessTestHelper.completeWorkItem(instance, Collections.emptyMap()); + + assertThat(instance).extracting(ProcessInstance::status).isEqualTo(ProcessInstance.STATE_ACTIVE); + } + @Test public void testUserTaskVerifyParameters() { Application app = ProcessTestHelper.newApplication(); @@ -559,7 +763,7 @@ public void testSubProcessWithEntryExitScripts() throws Exception { assertThat(processInstance.variables().getVar4()).isNotNull().hasToString("40"); assertThat(processInstance.variables().getVar5()).isNotNull().hasToString("50"); - ProcessTestHelper.completeWorkItem(processInstance, "john", Collections.emptyMap()); + ProcessTestHelper.completeWorkItem(processInstance, Collections.emptyMap(), "john"); assertThat(processInstance).extracting(ProcessInstance::status).isEqualTo(ProcessInstance.STATE_COMPLETED); } @@ -882,7 +1086,7 @@ public void testReceiveTask() throws Exception { assertThat(instance).extracting(ProcessInstance::status).isEqualTo(ProcessInstance.STATE_ACTIVE); receiveTaskHandler.setKnowledgeRuntime(kruntime); receiveTaskHandler.messageReceived("HelloMessage", "Hello john!"); - ProcessTestHelper.completeWorkItem(instance, "john", Collections.emptyMap()); + ProcessTestHelper.completeWorkItem(instance, Collections.emptyMap(), "john"); assertThat(instance.status()).isEqualTo(org.kie.kogito.process.ProcessInstance.STATE_COMPLETED); } @@ -1004,48 +1208,52 @@ public void testCallActivityWithBoundaryEvent() { } @Test - public void testCallActivityWithSubProcessWaitState() throws Exception { - kruntime = createKogitoProcessRuntime( - "org/jbpm/bpmn2/subprocess/BPMN2-CallActivityProcessWithBoundaryEvent.bpmn2", - "org/jbpm/bpmn2/subprocess/BPMN2-CallActivitySubProcessWithBoundaryEvent.bpmn2"); - + public void testCallActivityWithSubProcessWaitState() { + Application app = ProcessTestHelper.newApplication(); TestWorkItemHandler workItemHandler = new TestWorkItemHandler(); - kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Human Task", - workItemHandler); - Map params = new HashMap<>(); - KogitoProcessInstance processInstance = kruntime.startProcess("CallActivityProcessWithBoundaryEvent", params); - assertProcessInstanceActive(processInstance.getStringId(), kruntime); - - org.kie.kogito.internal.process.runtime.KogitoWorkItem wi = workItemHandler.getWorkItem(); - assertThat(wi).isNotNull(); + EventTrackerProcessListener listener = new EventTrackerProcessListener(); + ProcessTestHelper.registerHandler(app, "Human Task", workItemHandler); + ProcessTestHelper.registerProcessEventListener(app, listener); - kruntime.getKogitoWorkItemManager().completeWorkItem(wi.getStringId(), null); + org.kie.kogito.process.Process callActivitySubProcessWithBoundaryEventProcess = CallActivitySubProcessWithBoundaryEventProcess.newProcess(app); + ProcessInstance subProcessInstance = + callActivitySubProcessWithBoundaryEventProcess.createInstance(callActivitySubProcessWithBoundaryEventProcess.createModel()); + org.kie.kogito.process.Process process = CallActivityProcessWithBoundaryEventProcess.newProcess(app); + CallActivityProcessWithBoundaryEventModel model = process.createModel(); + ProcessInstance processInstance = process.createInstance(model); + processInstance.start(); - assertProcessInstanceFinished(processInstance, kruntime); - // first check the parent process executed nodes - assertNodeTriggered(processInstance.getStringId(), "StartProcess", "Call Activity 1", "EndProcess"); - // then check child process executed nodes - is there better way to get child process id than simply increment? - assertNodeTriggered(processInstance.getStringId() + 1, "StartProcess2", "User Task", "EndProcess"); + assertThat(processInstance).extracting(ProcessInstance::status).isEqualTo(ProcessInstance.STATE_ACTIVE); + org.kie.kogito.internal.process.runtime.KogitoWorkItem workItem = workItemHandler.getWorkItem(); + assertThat(workItem).isNotNull(); + subProcessInstance.completeWorkItem(workItem.getStringId(), Collections.emptyMap()); + assertThat(processInstance).extracting(ProcessInstance::status).isEqualTo(ProcessInstance.STATE_COMPLETED); + assertThat(listener.tracked()).anyMatch(ProcessTestHelper.triggered("Call Activity 1")); + assertThat(listener.tracked()).anyMatch(ProcessTestHelper.triggered("StartProcess")); + assertThat(listener.tracked()).anyMatch(ProcessTestHelper.triggered("EndProcess")); + assertThat(listener.tracked()).anyMatch(ProcessTestHelper.triggered("StartProcess2")); + assertThat(listener.tracked()).anyMatch(ProcessTestHelper.triggered("User Task")); } @Test - public void testUserTaskWithBooleanOutput() throws Exception { - kruntime = createKogitoProcessRuntime("org/jbpm/bpmn2/activity/BPMN2-UserTaskWithBooleanOutput.bpmn2"); + public void testUserTaskWithBooleanOutput() { + Application app = ProcessTestHelper.newApplication(); TestWorkItemHandler workItemHandler = new TestWorkItemHandler(); + ProcessTestHelper.registerHandler(app, "Human Task", workItemHandler); + org.kie.kogito.process.Process process = UserTaskWithBooleanOutputProcess.newProcess(app); + UserTaskWithBooleanOutputModel model = process.createModel(); + model.setIsChecked(true); + ProcessInstance processInstance = process.createInstance(model); + processInstance.start(); - kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Human Task", - workItemHandler); - KogitoProcessInstance processInstance = kruntime - .startProcess("UserTaskWithBooleanOutput"); - assertProcessInstanceActive(processInstance); + assertThat(processInstance).extracting(ProcessInstance::status).isEqualTo(ProcessInstance.STATE_ACTIVE); org.kie.kogito.internal.process.runtime.KogitoWorkItem workItem = workItemHandler.getWorkItem(); assertThat(workItem).isNotNull(); assertThat(workItem.getParameter("ActorId")).isEqualTo("john"); HashMap output = new HashMap<>(); - output.put("isCheckedCheckbox", "true"); - kruntime.getKogitoWorkItemManager() - .completeWorkItem(workItem.getStringId(), output); - assertProcessInstanceFinished(processInstance, kruntime); + output.put("isCheckedCheckbox", true); + processInstance.completeWorkItem(workItem.getStringId(), output); + assertThat(processInstance).extracting(ProcessInstance::status).isEqualTo(ProcessInstance.STATE_COMPLETED); } @Test @@ -1609,25 +1817,25 @@ public void testXORWithSameTargetProcess() { } @Test - public void testUserTaskWithExpressionsForIO() throws Exception { - kruntime = createKogitoProcessRuntime("org/jbpm/bpmn2/activity/BPMN2-UserTaskWithIOexpression.bpmn2"); - + public void testUserTaskWithExpressionsForIO() { + Application app = ProcessTestHelper.newApplication(); TestWorkItemHandler workItemHandler = new TestWorkItemHandler(); - kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Human Task", workItemHandler); - Map parameters = new HashMap<>(); - parameters.put("person", new Person("john")); + ProcessTestHelper.registerHandler(app, "Human Task", workItemHandler); + org.kie.kogito.process.Process processDefinition = UserTaskWithIOexpressionProcess.newProcess(app); + UserTaskWithIOexpressionModel model = processDefinition.createModel(); + model.setPerson(new Person("john")); + org.kie.kogito.process.ProcessInstance instance = processDefinition.createInstance(model); + instance.start(); - KogitoProcessInstance processInstance = kruntime.startProcess("UserTaskWithIOexpression", parameters); - assertThat(processInstance.getState()).isEqualTo(KogitoProcessInstance.STATE_ACTIVE); + assertThat(instance).extracting(ProcessInstance::status).isEqualTo(ProcessInstance.STATE_ACTIVE); org.kie.kogito.internal.process.runtime.KogitoWorkItem workItem = workItemHandler.getWorkItem(); assertThat(workItem).isNotNull(); assertThat(workItem.getParameter("ActorId")).isEqualTo("john"); assertThat(workItem.getParameter("personName")).isEqualTo("john"); - - kruntime.getKogitoWorkItemManager().completeWorkItem(workItem.getStringId(), Collections.singletonMap("personAge", 50)); - Person person = (Person) processInstance.getVariables().get("person"); + instance.completeWorkItem(workItem.getStringId(), Collections.singletonMap("personAge", 50)); + Person person = instance.variables().getPerson(); assertThat(person.getAge()).isEqualTo(50); - assertProcessInstanceFinished(processInstance, kruntime); + assertThat(instance).extracting(ProcessInstance::status).isEqualTo(org.kie.kogito.process.ProcessInstance.STATE_COMPLETED); } @Test diff --git a/jbpm/jbpm-tests/src/test/java/org/jbpm/bpmn2/CompilationTest.java b/jbpm/jbpm-tests/src/test/java/org/jbpm/bpmn2/CompilationTest.java index 0235d3158c1..32d68050305 100755 --- a/jbpm/jbpm-tests/src/test/java/org/jbpm/bpmn2/CompilationTest.java +++ b/jbpm/jbpm-tests/src/test/java/org/jbpm/bpmn2/CompilationTest.java @@ -46,7 +46,7 @@ public void testReturnValueDescrCreation() throws Exception { TestJavaProcessDialect javaProcessDialect = new TestJavaProcessDialect(); ProcessDialectRegistry.setDialect("java", javaProcessDialect); - String filename = "BPMN2-GatewaySplit-SequenceConditions.bpmn2"; + String filename = "org/jbpm/bpmn2/flow/BPMN2-GatewaySplitSequenceConditions.bpmn2"; kruntime = createKogitoProcessRuntime(filename); assertThat(javaProcessDialect.getActionDescrs()).as("No " + ActionDescr.class.getSimpleName() + " instances caught for testing!").isNotEmpty(); 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 98611a1f179..d73e2b92bd3 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 @@ -253,7 +253,7 @@ public void testErrorBoundaryEventOnServiceTask() throws Exception { List workItems = handler.getWorkItems(); assertThat(workItems).hasSize(1); - ProcessTestHelper.completeWorkItem(instance, "john", Collections.emptyMap()); + ProcessTestHelper.completeWorkItem(instance, Collections.emptyMap(), "john"); assertThat(instance.status()).isEqualTo(org.kie.kogito.process.ProcessInstance.STATE_COMPLETED); @@ -357,7 +357,7 @@ public void testErrorSignallingExceptionServiceTask() throws Exception { org.kie.kogito.process.ProcessInstance instance = definition.createInstance(model); instance.start(); - ProcessTestHelper.completeWorkItem(instance, "john", Collections.emptyMap()); + ProcessTestHelper.completeWorkItem(instance, Collections.emptyMap(), "john"); assertThat(instance.status()).isEqualTo(org.kie.kogito.process.ProcessInstance.STATE_ABORTED); assertThat(caughtEventObjectHolder[0] != null && caughtEventObjectHolder[0] instanceof KogitoWorkItem).withFailMessage("Event was not passed to Event Subprocess.").isTrue(); } @@ -382,7 +382,7 @@ public void testSignallingExceptionServiceTask() throws Exception { org.kie.kogito.process.ProcessInstance instance = definition.createInstance(model); instance.start(); - ProcessTestHelper.completeWorkItem(instance, "john", Collections.emptyMap()); + ProcessTestHelper.completeWorkItem(instance, Collections.emptyMap(), "john"); assertThat(instance.status()).isEqualTo(org.kie.kogito.process.ProcessInstance.STATE_COMPLETED); assertThat(caughtEventObjectHolder[0] != null && caughtEventObjectHolder[0] instanceof KogitoWorkItem).withFailMessage("Event was not passed to Event Subprocess.").isTrue(); diff --git a/jbpm/jbpm-tests/src/test/java/org/jbpm/bpmn2/EscalationEventTest.java b/jbpm/jbpm-tests/src/test/java/org/jbpm/bpmn2/EscalationEventTest.java index f2f8c232be3..5193317975b 100755 --- a/jbpm/jbpm-tests/src/test/java/org/jbpm/bpmn2/EscalationEventTest.java +++ b/jbpm/jbpm-tests/src/test/java/org/jbpm/bpmn2/EscalationEventTest.java @@ -145,7 +145,7 @@ public void afterNodeLeft(ProcessNodeLeftEvent event) { KogitoWorkItem workItem = workItemHandler.getWorkItem(); assertThat(workItem).isNotNull(); - ProcessTestHelper.completeWorkItem(instance, "john", Collections.emptyMap()); + ProcessTestHelper.completeWorkItem(instance, Collections.emptyMap(), "john"); assertThat(instance.status()).isEqualTo(ProcessInstance.STATE_COMPLETED); assertThat(executednodes).hasSize(1); @@ -210,7 +210,7 @@ public void testGeneralEscalationBoundaryEventWithTask() throws Exception { model.setX("0"); org.kie.kogito.process.ProcessInstance instance = processDefinition.createInstance(model); instance.start(); - ProcessTestHelper.completeWorkItem(instance, "john", Collections.emptyMap()); + ProcessTestHelper.completeWorkItem(instance, Collections.emptyMap(), "john"); assertThat(instance.status()).isEqualTo(ProcessInstance.STATE_COMPLETED); assertThat(instance.variables().getX()).isEqualTo("1"); 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 3e9e883feb1..a9a088329fb 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 @@ -21,6 +21,7 @@ import java.io.ByteArrayInputStream; import java.util.ArrayList; import java.util.Collection; +import java.util.Collections; import java.util.HashMap; import java.util.Iterator; import java.util.List; @@ -28,6 +29,24 @@ import javax.xml.parsers.DocumentBuilderFactory; +import org.jbpm.bpmn2.flow.ConditionalFlowWithoutGatewayModel; +import org.jbpm.bpmn2.flow.ConditionalFlowWithoutGatewayProcess; +import org.jbpm.bpmn2.flow.ExclusiveSplitDefaultModel; +import org.jbpm.bpmn2.flow.ExclusiveSplitDefaultNoConditionModel; +import org.jbpm.bpmn2.flow.ExclusiveSplitDefaultNoConditionProcess; +import org.jbpm.bpmn2.flow.ExclusiveSplitDefaultProcess; +import org.jbpm.bpmn2.flow.ExclusiveSplitXPathAdvancedModel; +import org.jbpm.bpmn2.flow.ExclusiveSplitXPathAdvancedProcess; +import org.jbpm.bpmn2.flow.ExclusiveSplitXPathAdvancedVarsNotSignaledModel; +import org.jbpm.bpmn2.flow.ExclusiveSplitXPathAdvancedVarsNotSignaledProcess; +import org.jbpm.bpmn2.flow.ExclusiveSplitXPathAdvancedWithVarsModel; +import org.jbpm.bpmn2.flow.ExclusiveSplitXPathAdvancedWithVarsProcess; +import org.jbpm.bpmn2.flow.GatewayTestModel; +import org.jbpm.bpmn2.flow.GatewayTestProcess; +import org.jbpm.bpmn2.flow.InclusiveSplitDefaultModel; +import org.jbpm.bpmn2.flow.InclusiveSplitDefaultProcess; +import org.jbpm.bpmn2.loop.MultiInstanceLoopCharacteristicsTaskModel; +import org.jbpm.bpmn2.loop.MultiInstanceLoopCharacteristicsTaskProcess; import org.jbpm.bpmn2.objects.TestWorkItemHandler; import org.jbpm.process.core.context.variable.VariableScope; import org.jbpm.process.instance.InternalProcessRuntime; @@ -35,6 +54,8 @@ import org.jbpm.process.instance.impl.demo.SystemOutWorkItemHandler; import org.jbpm.process.instance.impl.humantask.InternalHumanTaskWorkItem; 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; @@ -53,11 +74,14 @@ import org.kie.api.runtime.KieSession; 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.KogitoProcessInstance; import org.kie.kogito.internal.process.runtime.KogitoProcessRuntime; import org.kie.kogito.internal.process.runtime.KogitoWorkItem; import org.kie.kogito.internal.process.runtime.KogitoWorkItemManager; +import org.kie.kogito.process.Process; +import org.kie.kogito.process.ProcessInstance; import org.w3c.dom.Attr; import org.w3c.dom.Document; import org.w3c.dom.Element; @@ -80,7 +104,7 @@ public void clearProperties() { @Test public void testExclusiveSplitWithNoConditions() throws Exception { try { - createKogitoProcessRuntime("BPMN2-ExclusiveGatewayWithNoConditionsDefined.bpmn2"); + createKogitoProcessRuntime("org/jbpm/bpmn2/flow/BPMN2-ExclusiveGatewayWithNoConditionsDefined.bpmn2"); fail("Should fail as XOR gateway does not have conditions defined"); } catch (RuntimeException e) { assertThat(e.getMessage()).contains("does not have a constraint for Connection"); @@ -104,10 +128,12 @@ public void testExclusiveSplit() throws Exception { @Test public void testExclusiveSplitXPathAdvanced() throws Exception { - kruntime = createKogitoProcessRuntime("BPMN2-ExclusiveSplitXPath-advanced.bpmn2"); - kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Email", - new SystemOutWorkItemHandler()); - Map params = new HashMap<>(); + Application app = ProcessTestHelper.newApplication(); + ProcessTestHelper.registerHandler(app, "Email", new SystemOutWorkItemHandler()); + + Process definition = ExclusiveSplitXPathAdvancedProcess.newProcess(app); + ExclusiveSplitXPathAdvancedModel model = definition.createModel(); + Document doc = DocumentBuilderFactory.newInstance() .newDocumentBuilder().newDocument(); Element hi = doc.createElement("hi"); @@ -116,20 +142,26 @@ public void testExclusiveSplitXPathAdvanced() throws Exception { Attr attr = doc.createAttribute("value"); ho.setAttributeNode(attr); attr.setValue("a"); - params.put("x", hi); - params.put("y", "Second"); - KogitoProcessInstance processInstance = kruntime.startProcess( - "com.sample.test", params); - assertProcessInstanceCompleted(processInstance); + + model.setX(hi); + model.setY("Second"); + + ProcessInstance instance = definition.createInstance(model); + instance.start(); + + assertThat(instance.status()).isEqualTo(ProcessInstance.STATE_COMPLETED); } @Test public void testExclusiveSplitXPathAdvanced2() throws Exception { - kruntime = createKogitoProcessRuntime("BPMN2-ExclusiveSplitXPath-advanced-vars-not-signaled.bpmn2"); - kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Email", - new SystemOutWorkItemHandler()); - Map params = new HashMap<>(); + + Application app = ProcessTestHelper.newApplication(); + ProcessTestHelper.registerHandler(app, "Email", new SystemOutWorkItemHandler()); + + Process definition = ExclusiveSplitXPathAdvancedVarsNotSignaledProcess.newProcess(app); + ExclusiveSplitXPathAdvancedVarsNotSignaledModel model = definition.createModel(); + Document doc = DocumentBuilderFactory.newInstance() .newDocumentBuilder().newDocument(); Element hi = doc.createElement("hi"); @@ -138,20 +170,25 @@ public void testExclusiveSplitXPathAdvanced2() throws Exception { Attr attr = doc.createAttribute("value"); ho.setAttributeNode(attr); attr.setValue("a"); - params.put("x", hi); - params.put("y", "Second"); - KogitoProcessInstance processInstance = kruntime.startProcess( - "com.sample.test", params); - assertProcessInstanceCompleted(processInstance); + + model.setX(hi); + model.setY("Second"); + + ProcessInstance instance = definition.createInstance(model); + instance.start(); + + assertThat(instance.status()).isEqualTo(ProcessInstance.STATE_COMPLETED); } @Test public void testExclusiveSplitXPathAdvancedWithVars() throws Exception { - kruntime = createKogitoProcessRuntime("BPMN2-ExclusiveSplitXPath-advanced-with-vars.bpmn2"); - kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Email", - new SystemOutWorkItemHandler()); - Map params = new HashMap<>(); + Application app = ProcessTestHelper.newApplication(); + ProcessTestHelper.registerHandler(app, "Email", new SystemOutWorkItemHandler()); + + Process definition = ExclusiveSplitXPathAdvancedWithVarsProcess.newProcess(app); + ExclusiveSplitXPathAdvancedWithVarsModel model = definition.createModel(); + Document doc = DocumentBuilderFactory.newInstance() .newDocumentBuilder().newDocument(); Element hi = doc.createElement("hi"); @@ -160,11 +197,14 @@ public void testExclusiveSplitXPathAdvancedWithVars() throws Exception { Attr attr = doc.createAttribute("value"); ho.setAttributeNode(attr); attr.setValue("a"); - params.put("x", hi); - params.put("y", "Second"); - KogitoProcessInstance processInstance = kruntime.startProcess( - "com.sample.test", params); - assertProcessInstanceCompleted(processInstance); + + model.setX(hi); + model.setY("Second"); + + ProcessInstance instance = definition.createInstance(model); + instance.start(); + + assertThat(instance.status()).isEqualTo(ProcessInstance.STATE_COMPLETED); } @@ -184,40 +224,45 @@ public void testExclusiveSplitPriority() throws Exception { @Test public void testExclusiveSplitDefault() throws Exception { - kruntime = createKogitoProcessRuntime("BPMN2-ExclusiveSplitDefault.bpmn2"); - kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Email", - new SystemOutWorkItemHandler()); - Map params = new HashMap<>(); - params.put("x", "NotFirst"); - params.put("y", "Second"); - KogitoProcessInstance processInstance = kruntime.startProcess( - "ExclusiveSplitDefault", params); - assertProcessInstanceCompleted(processInstance); + + Application app = ProcessTestHelper.newApplication(); + + ProcessTestHelper.registerHandler(app, "Email", new SystemOutWorkItemHandler()); + org.kie.kogito.process.Process definition = ExclusiveSplitDefaultProcess.newProcess(app); + ExclusiveSplitDefaultModel model = definition.createModel(); + model.setX("NotFirst"); + model.setY("Second"); + org.kie.kogito.process.ProcessInstance instance = definition.createInstance(model); + instance.start(); + + assertThat(instance.status()).isEqualTo(org.kie.kogito.process.ProcessInstance.STATE_COMPLETED); } @Test public void testExclusiveXORGateway() throws Exception { - kruntime = createKogitoProcessRuntime("BPMN2-gatewayTest.bpmn2"); Document document = DocumentBuilderFactory .newInstance() .newDocumentBuilder() .parse(new ByteArrayInputStream( "" .getBytes())); - Map params = new HashMap<>(); - params.put("instanceMetadata", document); - params.put( - "startMessage", - DocumentBuilderFactory - .newInstance() - .newDocumentBuilder() - .parse(new ByteArrayInputStream( - "".getBytes())) - .getFirstChild()); - KogitoProcessInstance processInstance = kruntime.startProcess("process", - params); - assertProcessInstanceCompleted(processInstance); + + Application app = ProcessTestHelper.newApplication(); + + org.kie.kogito.process.Process definition = GatewayTestProcess.newProcess(app); + GatewayTestModel model = definition.createModel(); + model.setInstanceMetadata(document); + model.setStartMessage(DocumentBuilderFactory + .newInstance() + .newDocumentBuilder() + .parse(new ByteArrayInputStream( + "".getBytes())) + .getFirstChild()); + org.kie.kogito.process.ProcessInstance instance = definition.createInstance(model); + instance.start(); + + assertThat(instance.status()).isEqualTo(org.kie.kogito.process.ProcessInstance.STATE_COMPLETED); } @@ -485,12 +530,14 @@ public void testInclusiveSplitAndJoinExtraPath() throws Exception { @Test public void testInclusiveSplitDefault() throws Exception { - kruntime = createKogitoProcessRuntime("BPMN2-InclusiveSplitDefault.bpmn2"); - Map params = new HashMap<>(); - params.put("x", -5); - KogitoProcessInstance processInstance = kruntime.startProcess( - "InclusiveSplitDefault", params); - assertProcessInstanceCompleted(processInstance); + Application app = ProcessTestHelper.newApplication(); + + org.kie.kogito.process.Process definition = InclusiveSplitDefaultProcess.newProcess(app); + InclusiveSplitDefaultModel model = definition.createModel(); + model.setX(-5); + org.kie.kogito.process.ProcessInstance instance = definition.createInstance(model); + instance.start(); + assertThat(instance.status()).isEqualTo(org.kie.kogito.process.ProcessInstance.STATE_COMPLETED); } @@ -1241,17 +1288,25 @@ public void testMultiInstanceLoopCharacteristicsTaskWithOutputCompletionConditio @Test public void testMultiInstanceLoopCharacteristicsTask() throws Exception { - kruntime = createKogitoProcessRuntime("BPMN2-MultiInstanceLoopCharacteristicsTask.bpmn2"); - kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Human Task", - new SystemOutWorkItemHandler()); - Map params = new HashMap<>(); - List myList = new ArrayList<>(); - myList.add("First Item"); - myList.add("Second Item"); - params.put("list", myList); - KogitoProcessInstance processInstance = kruntime.startProcess( - "MultiInstanceLoopCharacteristicsTask", params); - assertProcessInstanceCompleted(processInstance); + Application app = ProcessTestHelper.newApplication(); + TestWorkItemHandler handler = new TestWorkItemHandler(); + ProcessTestHelper.registerHandler(app, "Human Task", handler); + + org.kie.kogito.process.Process definition = MultiInstanceLoopCharacteristicsTaskProcess.newProcess(app); + MultiInstanceLoopCharacteristicsTaskModel model = definition.createModel(); + model.setList(new ArrayList<>(List.of("First Item", "Second Item"))); + + org.kie.kogito.process.ProcessInstance instance = definition.createInstance(model); + instance.start(); + + List workItems = handler.getWorkItems(); + assertThat(workItems).isNotNull().hasSize(2); + assertThat(workItems.get(0).getParameter("Item")).isEqualTo("First Item"); + assertThat(workItems.get(1).getParameter("Item")).isEqualTo("Second Item"); + ProcessTestHelper.completeWorkItem(instance, "john", Collections.emptyMap()); + ProcessTestHelper.completeWorkItem(instance, "john", Collections.emptyMap()); + + assertThat(instance.status()).isEqualTo(org.kie.kogito.process.ProcessInstance.STATE_COMPLETED); } @@ -1325,17 +1380,20 @@ public void testMultipleInOutgoingSequenceFlowsDisable() throws Exception { @Test public void testConditionalFlow() throws Exception { - System.setProperty("jbpm.enable.multi.con", "true"); - String processId = "designer.conditional-flow"; - - kruntime = createKogitoProcessRuntime("BPMN2-ConditionalFlowWithoutGateway.bpmn2"); - - KogitoProcessInstance wpi = kruntime.startProcess(processId); - - assertProcessInstanceFinished(wpi, kruntime); - assertNodeTriggered(wpi.getStringId(), "start", "script", "end1"); - System.clearProperty("jbpm.enable.multi.con"); - + Application app = ProcessTestHelper.newApplication(); + EventTrackerProcessListener listener = new EventTrackerProcessListener(); + ProcessTestHelper.registerProcessEventListener(app, listener); + org.kie.kogito.process.Process definition = ConditionalFlowWithoutGatewayProcess.newProcess(app); + org.kie.kogito.process.ProcessInstance instance = definition.createInstance(definition.createModel()); + instance.start(); + + assertThat(instance.status()).isEqualTo(org.kie.kogito.process.ProcessInstance.STATE_COMPLETED); + assertThat(listener.tracked()) + .anyMatch(ProcessTestHelper.triggered("start")) + .anyMatch(ProcessTestHelper.triggered("script")) + .anyMatch(ProcessTestHelper.triggered("end1")); + assertThat(listener.tracked()) + .noneMatch(ProcessTestHelper.triggered("end2")); } @Test @@ -1367,9 +1425,13 @@ public void testLane() throws Exception { @Test public void testExclusiveSplitDefaultNoCondition() throws Exception { - kruntime = createKogitoProcessRuntime("BPMN2-ExclusiveSplitDefaultNoCondition.bpmn2"); - KogitoProcessInstance processInstance = kruntime.startProcess("com.sample.test"); - assertProcessInstanceFinished(processInstance, kruntime); + Application app = ProcessTestHelper.newApplication(); + org.kie.kogito.process.Process definition = ExclusiveSplitDefaultNoConditionProcess.newProcess(app); + org.kie.kogito.process.ProcessInstance instance = definition.createInstance(definition.createModel()); + + instance.start(); + + assertThat(instance.status()).isEqualTo(org.kie.kogito.process.ProcessInstance.STATE_COMPLETED); } @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 6cf41494546..1d24ef1aa49 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 @@ -64,10 +64,28 @@ import org.jbpm.bpmn2.intermediate.IntermediateThrowEventMessageProcess; import org.jbpm.bpmn2.intermediate.IntermediateThrowEventMessageWithTransformationModel; import org.jbpm.bpmn2.intermediate.IntermediateThrowEventMessageWithTransformationProcess; -import org.jbpm.bpmn2.intermediate.IntermediateThrowEventSignalModel; -import org.jbpm.bpmn2.intermediate.IntermediateThrowEventSignalProcess; +import org.jbpm.bpmn2.loop.MultiInstanceLoopBoundaryTimerModel; +import org.jbpm.bpmn2.loop.MultiInstanceLoopBoundaryTimerProcess; +import org.jbpm.bpmn2.loop.MultiInstanceLoopCharacteristicsProcessSequentialModel; +import org.jbpm.bpmn2.loop.MultiInstanceLoopCharacteristicsProcessSequentialProcess; +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.loop.MultiInstanceLoopCharacteristicsTaskSequentialModel; +import org.jbpm.bpmn2.loop.MultiInstanceLoopCharacteristicsTaskSequentialProcess; +import org.jbpm.bpmn2.loop.MultiInstanceLoopCharacteristicsTaskWithOutputCmpCondSequentialModel; +import org.jbpm.bpmn2.loop.MultiInstanceLoopCharacteristicsTaskWithOutputCmpCondSequentialProcess; import org.jbpm.bpmn2.objects.Person; import org.jbpm.bpmn2.objects.TestWorkItemHandler; +import org.jbpm.bpmn2.start.IntermediateThrowEventSignalModel; +import org.jbpm.bpmn2.start.IntermediateThrowEventSignalProcess; +import org.jbpm.bpmn2.subprocess.EventSubprocessConditionalModel; +import org.jbpm.bpmn2.subprocess.EventSubprocessConditionalProcess; +import org.jbpm.bpmn2.subprocess.EventSubprocessMessageModel; +import org.jbpm.bpmn2.subprocess.EventSubprocessMessageProcess; +import org.jbpm.bpmn2.subprocess.EventSubprocessSignalWithTransformationModel; +import org.jbpm.bpmn2.subprocess.EventSubprocessSignalWithTransformationProcess; import org.jbpm.bpmn2.test.RequirePersistence; import org.jbpm.process.core.datatype.impl.type.StringDataType; import org.jbpm.process.instance.event.listeners.RuleAwareProcessEventListener; @@ -138,55 +156,51 @@ public void beforeNodeTriggered(ProcessNodeTriggeredEvent event) { @Test public void testBoundaryTimerCycleISO() { Application app = ProcessTestHelper.newApplication(); - NodeLeftCountDownProcessEventListener listener = new NodeLeftCountDownProcessEventListener("Send Update Timer", 3); + NodeLeftCountDownProcessEventListener listener = new NodeLeftCountDownProcessEventListener("Send Update Timer", + 3); ProcessTestHelper.registerProcessEventListener(app, listener); - org.kie.kogito.process.Process definition = BoundaryTimerCycleISOProcess.newProcess(app); - org.kie.kogito.process.ProcessInstance instance = definition.createInstance(definition.createModel()); + org.kie.kogito.process.Process definition = BoundaryTimerCycleISOProcess + .newProcess(app); + org.kie.kogito.process.ProcessInstance instance = definition + .createInstance(definition.createModel()); instance.start(); listener.waitTillCompleted(); - ProcessTestHelper.completeWorkItem(instance, "john", Collections.emptyMap()); + ProcessTestHelper.completeWorkItem(instance, Collections.emptyMap(), "john"); assertThat(instance.status()).isEqualTo(org.kie.kogito.process.ProcessInstance.STATE_COMPLETED); } @Test public void testBoundaryTimerCycleISOVariable() { Application app = ProcessTestHelper.newApplication(); - NodeLeftCountDownProcessEventListener listener = new NodeLeftCountDownProcessEventListener("Send Update Timer", 3); + NodeLeftCountDownProcessEventListener listener = new NodeLeftCountDownProcessEventListener("Send Update Timer", + 3); ProcessTestHelper.registerProcessEventListener(app, listener); - org.kie.kogito.process.Process definition = BoundaryTimerCycleISOVariableProcess.newProcess(app); + org.kie.kogito.process.Process definition = BoundaryTimerCycleISOVariableProcess + .newProcess(app); BoundaryTimerCycleISOVariableModel model = definition.createModel(); model.setCronStr("R3/PT0.1S"); - org.kie.kogito.process.ProcessInstance instance = definition.createInstance(model); + org.kie.kogito.process.ProcessInstance instance = definition + .createInstance(model); instance.start(); listener.waitTillCompleted(); - ProcessTestHelper.completeWorkItem(instance, "john", Collections.emptyMap()); + ProcessTestHelper.completeWorkItem(instance, Collections.emptyMap(), "john"); assertThat(instance.status()).isEqualTo(org.kie.kogito.process.ProcessInstance.STATE_COMPLETED); } @Test public void testSignalBoundaryEvent() throws Exception { - kruntime = createKogitoProcessRuntime( - "org/jbpm/bpmn2/intermediate/BPMN2-BoundarySignalEventOnTask.bpmn", + kruntime = createKogitoProcessRuntime("org/jbpm/bpmn2/intermediate/BPMN2-BoundarySignalEventOnTask.bpmn", "org/jbpm/bpmn2/intermediate/BPMN2-IntermediateThrowEventSignal.bpmn2"); TestWorkItemHandler handler = new TestWorkItemHandler(); - kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Human Task", - handler); - KogitoProcessInstance processInstance = kruntime - .startProcess("BoundarySignalEventOnTask"); + kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Human Task", handler); + KogitoProcessInstance processInstance = kruntime.startProcess("BoundarySignalEventOnTask"); Set> eventDescriptions = processInstance.getEventDescriptions(); - assertThat(eventDescriptions) - .hasSize(2) - .extracting("event").contains("MySignal"); - assertThat(eventDescriptions) - .extracting("eventType").contains("signal"); - assertThat(eventDescriptions) - .extracting("processInstanceId").contains(processInstance.getStringId()); - assertThat(eventDescriptions) - .filteredOn("eventType", "signal") - .hasSize(1) - .extracting("properties", Map.class) + assertThat(eventDescriptions).hasSize(2).extracting("event").contains("MySignal"); + assertThat(eventDescriptions).extracting("eventType").contains("signal"); + assertThat(eventDescriptions).extracting("processInstanceId").contains(processInstance.getStringId()); + assertThat(eventDescriptions).filteredOn("eventType", "signal").hasSize(1).extracting("properties", Map.class) .anyMatch(m -> m.containsKey("AttachedToID") && m.containsKey("AttachedToName")); KogitoProcessInstance processInstance2 = kruntime.startProcess("IntermediateThrowEventSignal"); @@ -203,8 +217,7 @@ public void testSignalBoundaryNonEffectiveEvent() throws Exception { "org/jbpm/bpmn2/intermediate/BPMN2-BoundaryEventWithNonEffectiveSignal.bpmn2"); TestWorkItemHandler handler = new TestWorkItemHandler(); - kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Human Task", - handler); + kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Human Task", handler); kruntime.getProcessEventManager().addEventListener(new DefaultKogitoProcessEventListener() { @Override @@ -215,18 +228,15 @@ public void afterNodeLeft(ProcessNodeLeftEvent event) { } } }); - KogitoProcessInstance processInstance = kruntime - .startProcess("BoundaryEventWithNonEffectiveSignal"); + KogitoProcessInstance processInstance = kruntime.startProcess("BoundaryEventWithNonEffectiveSignal"); // outer human work - kruntime.getKogitoWorkItemManager().completeWorkItem( - handler.getWorkItem().getStringId(), null); + kruntime.getKogitoWorkItemManager().completeWorkItem(handler.getWorkItem().getStringId(), null); kruntime.signalEvent(signal, signal); // inner human task - kruntime.getKogitoWorkItemManager().completeWorkItem( - handler.getWorkItem().getStringId(), null); + kruntime.getKogitoWorkItemManager().completeWorkItem(handler.getWorkItem().getStringId(), null); assertProcessInstanceFinished(processInstance, kruntime); assertThat(eventAfterNodeLeftTriggered).isTrue(); @@ -236,36 +246,22 @@ public void afterNodeLeft(ProcessNodeLeftEvent event) { public void testSignalBoundaryEventOnTask() throws Exception { kruntime = createKogitoProcessRuntime("org/jbpm/bpmn2/intermediate/BPMN2-BoundarySignalEventOnTask.bpmn"); - kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Human Task", - new TestWorkItemHandler()); + kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Human Task", new TestWorkItemHandler()); kruntime.getProcessEventManager().addEventListener(LOGGING_EVENT_LISTENER); - KogitoProcessInstance processInstance = kruntime - .startProcess("BoundarySignalEventOnTask"); + KogitoProcessInstance processInstance = kruntime.startProcess("BoundarySignalEventOnTask"); Set> eventDescriptions = processInstance.getEventDescriptions(); - assertThat(eventDescriptions) - .hasSize(2) - .extracting("event").contains("MySignal", "workItemCompleted"); - assertThat(eventDescriptions) - .extracting("eventType").contains("signal", "workItem"); - assertThat(eventDescriptions) - .extracting("nodeId").contains("BoundaryEvent_2", "UserTask_1"); - assertThat(eventDescriptions) - .extracting("processInstanceId").contains(processInstance.getStringId()); - assertThat(eventDescriptions) - .filteredOn("eventType", "signal") - .hasSize(1) - .extracting("properties", Map.class) + assertThat(eventDescriptions).hasSize(2).extracting("event").contains("MySignal", "workItemCompleted"); + assertThat(eventDescriptions).extracting("eventType").contains("signal", "workItem"); + assertThat(eventDescriptions).extracting("nodeId").contains("BoundaryEvent_2", "UserTask_1"); + assertThat(eventDescriptions).extracting("processInstanceId").contains(processInstance.getStringId()); + assertThat(eventDescriptions).filteredOn("eventType", "signal").hasSize(1).extracting("properties", Map.class) .anyMatch(m -> m.containsKey("AttachedToID") && m.containsKey("AttachedToName")); - assertThat(eventDescriptions) - .filteredOn("eventType", "signal") - .hasSize(1) - .extracting("nodeInstanceId").containsOnlyNulls(); + assertThat(eventDescriptions).filteredOn("eventType", "signal").hasSize(1).extracting("nodeInstanceId") + .containsOnlyNulls(); - assertThat(eventDescriptions) - .filteredOn("eventType", "workItem") - .hasSize(1) - .extracting("nodeInstanceId").doesNotContainNull(); + assertThat(eventDescriptions).filteredOn("eventType", "workItem").hasSize(1).extracting("nodeInstanceId") + .doesNotContainNull(); kruntime.signalEvent("MySignal", "value"); assertProcessInstanceFinished(processInstance, kruntime); @@ -279,9 +275,10 @@ public void testSignalBoundaryEventOnTaskWithSignalName() throws Exception { ProcessTestHelper.registerHandler(app, "Human Task", new TestWorkItemHandler()); ProcessTestHelper.registerProcessEventListener(app, LOGGING_EVENT_LISTENER); - org.kie.kogito.process.Process definition = - BoundarySignalWithNameEventOnTaskProcess.newProcess(app); - org.kie.kogito.process.ProcessInstance instance = definition.createInstance(definition.createModel()); + org.kie.kogito.process.Process definition = BoundarySignalWithNameEventOnTaskProcess + .newProcess(app); + org.kie.kogito.process.ProcessInstance instance = definition + .createInstance(definition.createModel()); instance.start(); instance.send(Sig.of("MySignal", "value")); @@ -294,41 +291,30 @@ public void testSignalBoundaryEventOnTaskComplete() throws Exception { kruntime = createKogitoProcessRuntime("org/jbpm/bpmn2/intermediate/BPMN2-BoundarySignalEventOnTask.bpmn"); TestWorkItemHandler handler = new TestWorkItemHandler(); - kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Human Task", - handler); + kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Human Task", handler); kruntime.getProcessEventManager().addEventListener(LOGGING_EVENT_LISTENER); KogitoProcessInstance processInstance = kruntime.startProcess("BoundarySignalEventOnTask"); - kruntime.getKogitoWorkItemManager().completeWorkItem( - handler.getWorkItem().getStringId(), null); + kruntime.getKogitoWorkItemManager().completeWorkItem(handler.getWorkItem().getStringId(), null); kruntime.signalEvent("MySignal", "value"); - kruntime.getKogitoWorkItemManager().completeWorkItem( - handler.getWorkItem().getStringId(), null); + kruntime.getKogitoWorkItemManager().completeWorkItem(handler.getWorkItem().getStringId(), null); assertProcessInstanceFinished(processInstance, kruntime); } @Test public void testSignalBoundaryEventInterrupting() throws Exception { - kruntime = createKogitoProcessRuntime("org/jbpm/bpmn2/intermediate/BPMN2-SignalBoundaryEventInterrupting.bpmn2"); + kruntime = createKogitoProcessRuntime( + "org/jbpm/bpmn2/intermediate/BPMN2-SignalBoundaryEventInterrupting.bpmn2"); - kruntime.getKogitoWorkItemManager().registerWorkItemHandler("MyTask", - new DoNothingWorkItemHandler()); - KogitoProcessInstance processInstance = kruntime - .startProcess("SignalBoundaryEventInterrupting"); + kruntime.getKogitoWorkItemManager().registerWorkItemHandler("MyTask", new DoNothingWorkItemHandler()); + KogitoProcessInstance processInstance = kruntime.startProcess("SignalBoundaryEventInterrupting"); assertProcessInstanceActive(processInstance); Set> eventDescriptions = processInstance.getEventDescriptions(); - assertThat(eventDescriptions) - .hasSize(2) - .extracting("event").contains("MyMessage", "workItemCompleted"); - assertThat(eventDescriptions) - .extracting("eventType").contains("signal", "workItem"); - assertThat(eventDescriptions) - .extracting("processInstanceId").contains(processInstance.getStringId()); - assertThat(eventDescriptions) - .filteredOn("eventType", "signal") - .hasSize(1) - .extracting("properties", Map.class) + assertThat(eventDescriptions).hasSize(2).extracting("event").contains("MyMessage", "workItemCompleted"); + assertThat(eventDescriptions).extracting("eventType").contains("signal", "workItem"); + assertThat(eventDescriptions).extracting("processInstanceId").contains(processInstance.getStringId()); + assertThat(eventDescriptions).filteredOn("eventType", "signal").hasSize(1).extracting("properties", Map.class) .anyMatch(m -> m.containsKey("AttachedToID") && m.containsKey("AttachedToName")); kruntime.signalEvent("MyMessage", null); @@ -342,25 +328,21 @@ public void testSignalIntermediateThrow() throws Exception { Map params = new HashMap<>(); params.put("x", "MyValue"); - KogitoProcessInstance processInstance = kruntime.startProcess( - "IntermediateThrowEventSignal", params); + KogitoProcessInstance processInstance = kruntime.startProcess("IntermediateThrowEventSignal", params); assertThat(processInstance.getState()).isEqualTo(KogitoProcessInstance.STATE_COMPLETED); } @Test public void testSignalBetweenProcesses() throws Exception { - kruntime = createKogitoProcessRuntime( - "org/jbpm/bpmn2/intermediate/BPMN2-IntermediateCatchSignalSingle.bpmn2", + kruntime = createKogitoProcessRuntime("org/jbpm/bpmn2/intermediate/BPMN2-IntermediateCatchSignalSingle.bpmn2", "org/jbpm/bpmn2/intermediate/BPMN2-IntermediateThrowEventSignal.bpmn2"); TestWorkItemHandler handler = new TestWorkItemHandler(); - kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Human Task", - handler); + kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Human Task", handler); KogitoProcessInstance processInstance = kruntime.startProcess("IntermediateCatchSignalSingle"); - kruntime.getKogitoWorkItemManager().completeWorkItem( - handler.getWorkItem().getStringId(), null); + kruntime.getKogitoWorkItemManager().completeWorkItem(handler.getWorkItem().getStringId(), null); KogitoProcessInstance processInstance2 = kruntime.startProcess("IntermediateThrowEventSignal"); assertProcessInstanceFinished(processInstance2, kruntime); @@ -372,41 +354,29 @@ public void testSignalBetweenProcesses() throws Exception { public void testEventBasedSplit() throws Exception { kruntime = createKogitoProcessRuntime("org/jbpm/bpmn2/intermediate/BPMN2-EventBasedSplit.bpmn2"); - kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Email1", - new SystemOutWorkItemHandler()); - kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Email2", - new SystemOutWorkItemHandler()); + kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Email1", new SystemOutWorkItemHandler()); + kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Email2", new SystemOutWorkItemHandler()); // Yes - KogitoProcessInstance processInstance = kruntime - .startProcess("EventBasedSplit"); + KogitoProcessInstance processInstance = kruntime.startProcess("EventBasedSplit"); assertProcessInstanceActive(processInstance); - kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Email1", - new SystemOutWorkItemHandler()); - kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Email2", - new SystemOutWorkItemHandler()); + kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Email1", new SystemOutWorkItemHandler()); + kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Email2", new SystemOutWorkItemHandler()); Set> eventDescriptions = processInstance.getEventDescriptions(); - assertThat(eventDescriptions) - .hasSize(2) - .extracting("event").contains("Yes", "No"); - assertThat(eventDescriptions) - .extracting("eventType").contains("signal"); - assertThat(eventDescriptions) - .extracting("dataType").hasOnlyElementsOfType(NamedDataType.class).extracting("dataType").hasOnlyElementsOfType(StringDataType.class); - assertThat(eventDescriptions) - .extracting("processInstanceId").contains(processInstance.getStringId()); - assertThat(eventDescriptions) - .extracting("nodeInstanceId").doesNotContainNull(); + assertThat(eventDescriptions).hasSize(2).extracting("event").contains("Yes", "No"); + assertThat(eventDescriptions).extracting("eventType").contains("signal"); + assertThat(eventDescriptions).extracting("dataType").hasOnlyElementsOfType(NamedDataType.class) + .extracting("dataType").hasOnlyElementsOfType(StringDataType.class); + assertThat(eventDescriptions).extracting("processInstanceId").contains(processInstance.getStringId()); + assertThat(eventDescriptions).extracting("nodeInstanceId").doesNotContainNull(); kruntime.signalEvent("Yes", "YesValue", processInstance.getStringId()); assertProcessInstanceFinished(processInstance, kruntime); // No processInstance = kruntime.startProcess("EventBasedSplit"); assertProcessInstanceActive(processInstance); - kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Email1", - new SystemOutWorkItemHandler()); - kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Email2", - new SystemOutWorkItemHandler()); + kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Email1", new SystemOutWorkItemHandler()); + kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Email2", new SystemOutWorkItemHandler()); kruntime.signalEvent("No", "NoValue", processInstance.getStringId()); assertProcessInstanceFinished(processInstance, kruntime); @@ -417,26 +387,20 @@ public void testEventBasedSplitBefore() throws Exception { // signaling before the split is reached should have no effect kruntime = createKogitoProcessRuntime("org/jbpm/bpmn2/intermediate/BPMN2-EventBasedSplit.bpmn2"); - kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Email1", - new DoNothingWorkItemHandler()); - kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Email2", - new DoNothingWorkItemHandler()); + kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Email1", new DoNothingWorkItemHandler()); + kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Email2", new DoNothingWorkItemHandler()); // Yes KogitoProcessInstance processInstance = kruntime.startProcess("EventBasedSplit"); assertProcessInstanceActive(processInstance); - kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Email1", - new DoNothingWorkItemHandler()); - kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Email2", - new DoNothingWorkItemHandler()); + kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Email1", new DoNothingWorkItemHandler()); + kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Email2", new DoNothingWorkItemHandler()); kruntime.signalEvent("Yes", "YesValue", processInstance.getStringId()); assertProcessInstanceActive(processInstance); // No processInstance = kruntime.startProcess("EventBasedSplit"); assertProcessInstanceActive(processInstance); - kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Email1", - new DoNothingWorkItemHandler()); - kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Email2", - new DoNothingWorkItemHandler()); + kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Email1", new DoNothingWorkItemHandler()); + kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Email2", new DoNothingWorkItemHandler()); kruntime.signalEvent("No", "NoValue", processInstance.getStringId()); assertProcessInstanceActive(processInstance); @@ -448,23 +412,17 @@ public void testEventBasedSplitAfter() throws Exception { // have no effect kruntime = createKogitoProcessRuntime("org/jbpm/bpmn2/intermediate/BPMN2-EventBasedSplit.bpmn2"); - kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Email1", - new SystemOutWorkItemHandler()); - kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Email2", - new DoNothingWorkItemHandler()); + kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Email1", new SystemOutWorkItemHandler()); + kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Email2", new DoNothingWorkItemHandler()); // Yes KogitoProcessInstance processInstance = kruntime.startProcess("EventBasedSplit"); assertProcessInstanceActive(processInstance); - kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Email1", - new SystemOutWorkItemHandler()); - kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Email2", - new DoNothingWorkItemHandler()); + kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Email1", new SystemOutWorkItemHandler()); + kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Email2", new DoNothingWorkItemHandler()); kruntime.signalEvent("Yes", "YesValue", processInstance.getStringId()); assertProcessInstanceActive(processInstance); - kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Email1", - new SystemOutWorkItemHandler()); - kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Email2", - new DoNothingWorkItemHandler()); + kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Email1", new SystemOutWorkItemHandler()); + kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Email2", new DoNothingWorkItemHandler()); // No kruntime.signalEvent("No", "NoValue", processInstance.getStringId()); @@ -472,33 +430,25 @@ public void testEventBasedSplitAfter() throws Exception { @Test public void testEventBasedSplit2() throws Exception { - ProcessCompletedCountDownProcessEventListener countDownListener = new ProcessCompletedCountDownProcessEventListener(2); + ProcessCompletedCountDownProcessEventListener countDownListener = new ProcessCompletedCountDownProcessEventListener( + 2); kruntime = createKogitoProcessRuntime("org/jbpm/bpmn2/intermediate/BPMN2-EventBasedSplit2.bpmn2"); - kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Email1", - new SystemOutWorkItemHandler()); - kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Email2", - new SystemOutWorkItemHandler()); + kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Email1", new SystemOutWorkItemHandler()); + kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Email2", new SystemOutWorkItemHandler()); kruntime.getProcessEventManager().addEventListener(countDownListener); // Yes - KogitoProcessInstance processInstance = kruntime - .startProcess("EventBasedSplit2"); + KogitoProcessInstance processInstance = kruntime.startProcess("EventBasedSplit2"); assertProcessInstanceActive(processInstance); Set> eventDescriptions = processInstance.getEventDescriptions(); - assertThat(eventDescriptions) - .hasSize(2) - .extracting("event").contains("Yes", TIMER_TRIGGERED_EVENT); - assertThat(eventDescriptions) - .extracting("eventType").contains("signal", "timer"); - assertThat(eventDescriptions).filteredOn(i -> i.getDataType() != null) - .extracting("dataType").hasOnlyElementsOfType(NamedDataType.class).extracting("dataType").hasOnlyElementsOfType(StringDataType.class); - assertThat(eventDescriptions) - .extracting("processInstanceId").contains(processInstance.getStringId()); - assertThat(eventDescriptions) - .filteredOn("eventType", "timer") - .hasSize(1) - .extracting("properties", Map.class) + assertThat(eventDescriptions).hasSize(2).extracting("event").contains("Yes", TIMER_TRIGGERED_EVENT); + assertThat(eventDescriptions).extracting("eventType").contains("signal", "timer"); + assertThat(eventDescriptions).filteredOn(i -> i.getDataType() != null).extracting("dataType") + .hasOnlyElementsOfType(NamedDataType.class).extracting("dataType") + .hasOnlyElementsOfType(StringDataType.class); + assertThat(eventDescriptions).extracting("processInstanceId").contains(processInstance.getStringId()); + assertThat(eventDescriptions).filteredOn("eventType", "timer").hasSize(1).extracting("properties", Map.class) .anyMatch(m -> m.containsKey("TimerID") && m.containsKey("Delay")); kruntime.signalEvent("Yes", "YesValue", processInstance.getStringId()); @@ -517,41 +467,31 @@ public void testEventBasedSplit2() throws Exception { public void testEventBasedSplit3() throws Exception { kruntime = createKogitoProcessRuntime("org/jbpm/bpmn2/intermediate/BPMN2-EventBasedSplit3.bpmn2"); - kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Email1", - new SystemOutWorkItemHandler()); - kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Email2", - new SystemOutWorkItemHandler()); + kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Email1", new SystemOutWorkItemHandler()); + kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Email2", new SystemOutWorkItemHandler()); Person jack = new Person(); jack.setName("Jack"); // Yes - KogitoProcessInstance processInstance = kruntime - .startProcess("EventBasedSplit3"); + KogitoProcessInstance processInstance = kruntime.startProcess("EventBasedSplit3"); assertProcessInstanceActive(processInstance); Set> eventDescriptions = processInstance.getEventDescriptions(); - assertThat(eventDescriptions) - .hasSize(2) - .extracting("event").contains("Yes"); - assertThat(eventDescriptions) - .extracting("eventType").contains("signal", "conditional"); - assertThat(eventDescriptions).filteredOn(i -> i.getDataType() != null) - .extracting("dataType").hasOnlyElementsOfType(NamedDataType.class).extracting("dataType").hasOnlyElementsOfType(StringDataType.class); - assertThat(eventDescriptions) - .extracting("processInstanceId").contains(processInstance.getStringId()); - - kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Email1", - new SystemOutWorkItemHandler()); - kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Email2", - new SystemOutWorkItemHandler()); + assertThat(eventDescriptions).hasSize(2).extracting("event").contains("Yes"); + assertThat(eventDescriptions).extracting("eventType").contains("signal", "conditional"); + assertThat(eventDescriptions).filteredOn(i -> i.getDataType() != null).extracting("dataType") + .hasOnlyElementsOfType(NamedDataType.class).extracting("dataType") + .hasOnlyElementsOfType(StringDataType.class); + assertThat(eventDescriptions).extracting("processInstanceId").contains(processInstance.getStringId()); + + kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Email1", new SystemOutWorkItemHandler()); + kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Email2", new SystemOutWorkItemHandler()); kruntime.signalEvent("Yes", "YesValue", processInstance.getStringId()); assertProcessInstanceFinished(processInstance, kruntime); // Condition processInstance = kruntime.startProcess("EventBasedSplit3"); assertProcessInstanceActive(processInstance); - kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Email1", - new SystemOutWorkItemHandler()); - kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Email2", - new SystemOutWorkItemHandler()); + kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Email1", new SystemOutWorkItemHandler()); + kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Email2", new SystemOutWorkItemHandler()); kruntime.getKieSession().insert(jack); assertProcessInstanceFinished(processInstance, kruntime); @@ -562,41 +502,29 @@ public void testEventBasedSplit3() throws Exception { public void testEventBasedSplit4() throws Exception { kruntime = createKogitoProcessRuntime("org/jbpm/bpmn2/intermediate/BPMN2-EventBasedSplit4.bpmn2"); - kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Email1", - new SystemOutWorkItemHandler()); - kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Email2", - new SystemOutWorkItemHandler()); + kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Email1", new SystemOutWorkItemHandler()); + kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Email2", new SystemOutWorkItemHandler()); // Yes - KogitoProcessInstance processInstance = kruntime - .startProcess("EventBasedSplit4"); + KogitoProcessInstance processInstance = kruntime.startProcess("EventBasedSplit4"); assertProcessInstanceActive(processInstance); Set> eventDescriptions = processInstance.getEventDescriptions(); - assertThat(eventDescriptions) - .hasSize(2) - .extracting("event").contains("Message-YesMessage", "Message-NoMessage"); - assertThat(eventDescriptions) - .extracting("eventType").contains("message", "message"); - assertThat(eventDescriptions) - .extracting("dataType").hasOnlyElementsOfType(NamedDataType.class).extracting("dataType").hasOnlyElementsOfType(StringDataType.class); - assertThat(eventDescriptions) - .extracting("processInstanceId").contains(processInstance.getStringId()); - - kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Email1", - new SystemOutWorkItemHandler()); - kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Email2", - new SystemOutWorkItemHandler()); - kruntime.signalEvent("Message-YesMessage", "YesValue", - processInstance.getStringId()); - assertProcessInstanceFinished(processInstance, kruntime); - kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Email1", - new SystemOutWorkItemHandler()); - kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Email2", - new SystemOutWorkItemHandler()); + assertThat(eventDescriptions).hasSize(2).extracting("event").contains("Message-YesMessage", + "Message-NoMessage"); + assertThat(eventDescriptions).extracting("eventType").contains("message", "message"); + assertThat(eventDescriptions).extracting("dataType").hasOnlyElementsOfType(NamedDataType.class) + .extracting("dataType").hasOnlyElementsOfType(StringDataType.class); + assertThat(eventDescriptions).extracting("processInstanceId").contains(processInstance.getStringId()); + + kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Email1", new SystemOutWorkItemHandler()); + kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Email2", new SystemOutWorkItemHandler()); + kruntime.signalEvent("Message-YesMessage", "YesValue", processInstance.getStringId()); + assertProcessInstanceFinished(processInstance, kruntime); + kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Email1", new SystemOutWorkItemHandler()); + kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Email2", new SystemOutWorkItemHandler()); // No processInstance = kruntime.startProcess("EventBasedSplit4"); - kruntime.signalEvent("Message-NoMessage", "NoValue", - processInstance.getStringId()); + kruntime.signalEvent("Message-NoMessage", "NoValue", processInstance.getStringId()); assertProcessInstanceFinished(processInstance, kruntime); } @@ -605,33 +533,24 @@ public void testEventBasedSplit4() throws Exception { public void testEventBasedSplit5() throws Exception { kruntime = createKogitoProcessRuntime("org/jbpm/bpmn2/intermediate/BPMN2-EventBasedSplit5.bpmn2"); - kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Email1", - new SystemOutWorkItemHandler()); - kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Email2", - new SystemOutWorkItemHandler()); + kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Email1", new SystemOutWorkItemHandler()); + kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Email2", new SystemOutWorkItemHandler()); ReceiveTaskHandler receiveTaskHandler = new ReceiveTaskHandler(kruntime); - kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Receive Task", - receiveTaskHandler); + kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Receive Task", receiveTaskHandler); // Yes KogitoProcessInstance processInstance = kruntime.startProcess("EventBasedSplit5"); assertProcessInstanceActive(processInstance); - kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Email1", - new SystemOutWorkItemHandler()); - kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Email2", - new SystemOutWorkItemHandler()); + kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Email1", new SystemOutWorkItemHandler()); + kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Email2", new SystemOutWorkItemHandler()); receiveTaskHandler.setKnowledgeRuntime(kruntime); - kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Receive Task", - receiveTaskHandler); + kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Receive Task", receiveTaskHandler); receiveTaskHandler.messageReceived("YesMessage", "YesValue"); assertProcessInstanceFinished(processInstance, kruntime); receiveTaskHandler.messageReceived("NoMessage", "NoValue"); - kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Email1", - new SystemOutWorkItemHandler()); - kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Email2", - new SystemOutWorkItemHandler()); + kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Email1", new SystemOutWorkItemHandler()); + kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Email2", new SystemOutWorkItemHandler()); receiveTaskHandler.setKnowledgeRuntime(kruntime); - kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Receive Task", - receiveTaskHandler); + kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Receive Task", receiveTaskHandler); // No processInstance = kruntime.startProcess("EventBasedSplit5"); receiveTaskHandler.messageReceived("NoMessage", "NoValue"); @@ -642,7 +561,8 @@ public void testEventBasedSplit5() throws Exception { @Test public void testEventBasedSplitWithSubprocess() throws Exception { - kruntime = createKogitoProcessRuntime("org/jbpm/bpmn2/intermediate/BPMN2-ExclusiveEventBasedGatewayInSubprocess.bpmn2"); + kruntime = createKogitoProcessRuntime( + "org/jbpm/bpmn2/intermediate/BPMN2-ExclusiveEventBasedGatewayInSubprocess.bpmn2"); // Stop KogitoProcessInstance processInstance = kruntime.startProcess("ExclusiveEventBasedGatewayInSubprocess"); @@ -665,46 +585,32 @@ public void testEventBasedSplitWithSubprocess() throws Exception { @Test public void testEventSubprocessSignal() throws Exception { - String[] nodes = { - "start", "User Task 1", - "end", "Sub Process 1", "start-sub", "sub-script", "end-sub" - }; - runTestEventSubprocessSignal("org/jbpm/bpmn2/intermediate/BPMN2-EventSubprocessSignal.bpmn2", "EventSubprocessSignal", nodes); + String[] nodes = { "start", "User Task 1", "end", "Sub Process 1", "start-sub", "sub-script", "end-sub" }; + runTestEventSubprocessSignal("org/jbpm/bpmn2/intermediate/BPMN2-EventSubprocessSignal.bpmn2", + "EventSubprocessSignal", nodes); } @Test public void testEventSubprocessSignalNested() throws Exception { - String[] nodes = { - "Start", - "Sub Process", - "Sub Start", - "Sub Sub Process", - "Sub Sub Start", - "Sub Sub User Task", - "Sub Sub Sub Process", - "start-sub", - "sub-script", - "end-sub", - "Sub Sub End", - "Sub End", - "End" - }; - runTestEventSubprocessSignal("org/jbpm/bpmn2/intermediate/BPMN2-EventSubprocessSignalNested.bpmn2", "EventSubprocessSignalNested", nodes); + String[] nodes = { "Start", "Sub Process", "Sub Start", "Sub Sub Process", "Sub Sub Start", "Sub Sub User Task", + "Sub Sub Sub Process", "start-sub", "sub-script", "end-sub", "Sub Sub End", "Sub End", "End" }; + runTestEventSubprocessSignal("org/jbpm/bpmn2/intermediate/BPMN2-EventSubprocessSignalNested.bpmn2", + "EventSubprocessSignalNested", nodes); } public void runTestEventSubprocessSignal(String processFile, String[] completedNodes) throws Exception { runTestEventSubprocessSignal(processFile, processFile, completedNodes); } - public void runTestEventSubprocessSignal(String processFile, String processId, String[] completedNodes) throws Exception { + public void runTestEventSubprocessSignal(String processFile, String processId, String[] completedNodes) + throws Exception { kruntime = createKogitoProcessRuntime(processFile); final List executednodes = new ArrayList<>(); KogitoProcessEventListener listener = new DefaultKogitoProcessEventListener() { @Override public void afterNodeLeft(ProcessNodeLeftEvent event) { - if (event.getNodeInstance().getNodeName() - .equals("sub-script")) { + if (event.getNodeInstance().getNodeName().equals("sub-script")) { executednodes.add(((KogitoNodeInstance) event.getNodeInstance()).getStringId()); } } @@ -713,21 +619,15 @@ public void afterNodeLeft(ProcessNodeLeftEvent event) { kruntime.getProcessEventManager().addEventListener(listener); TestWorkItemHandler workItemHandler = new TestWorkItemHandler(); - kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Human Task", - workItemHandler); - KogitoProcessInstance processInstance = kruntime - .startProcess(processId); + kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Human Task", workItemHandler); + KogitoProcessInstance processInstance = kruntime.startProcess(processId); assertProcessInstanceActive(processInstance); kruntime.getProcessEventManager().addEventListener(listener); Set> eventDescriptions = processInstance.getEventDescriptions(); - assertThat(eventDescriptions) - .hasSize(2) - .extracting("event").contains("MySignal", "workItemCompleted"); - assertThat(eventDescriptions) - .extracting("eventType").contains("signal", "workItem"); - assertThat(eventDescriptions) - .extracting("processInstanceId").contains(processInstance.getStringId()); + assertThat(eventDescriptions).hasSize(2).extracting("event").contains("MySignal", "workItemCompleted"); + assertThat(eventDescriptions).extracting("eventType").contains("signal", "workItem"); + assertThat(eventDescriptions).extracting("processInstanceId").contains(processInstance.getStringId()); kruntime.signalEvent("MySignal", null, processInstance.getStringId()); assertProcessInstanceActive(processInstance); @@ -750,7 +650,8 @@ public void afterNodeLeft(ProcessNodeLeftEvent event) { @Test public void testEventSubprocessSignalWithStateNode() throws Exception { - kruntime = createKogitoProcessRuntime("org/jbpm/bpmn2/intermediate/BPMN2-EventSubprocessSignalWithStateNode.bpmn2"); + kruntime = createKogitoProcessRuntime( + "org/jbpm/bpmn2/intermediate/BPMN2-EventSubprocessSignalWithStateNode.bpmn2"); final List executednodes = new ArrayList<>(); KogitoProcessEventListener listener = new DefaultKogitoProcessEventListener() { @@ -765,14 +666,11 @@ public void afterNodeLeft(ProcessNodeLeftEvent event) { kruntime.getProcessEventManager().addEventListener(listener); TestWorkItemHandler workItemHandler = new TestWorkItemHandler(); - kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Human Task", - workItemHandler); - KogitoProcessInstance processInstance = kruntime - .startProcess("EventSubprocessSignalWithStateNode"); + kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Human Task", workItemHandler); + KogitoProcessInstance processInstance = kruntime.startProcess("EventSubprocessSignalWithStateNode"); assertProcessInstanceActive(processInstance); kruntime.getProcessEventManager().addEventListener(listener); - kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Human Task", - workItemHandler); + kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Human Task", workItemHandler); KogitoWorkItem workItemTopProcess = workItemHandler.getWorkItem(); @@ -801,25 +699,24 @@ public void afterNodeLeft(ProcessNodeLeftEvent event) { kruntime.getKogitoWorkItemManager().completeWorkItem(workItem.getStringId(), null); assertThat(workItemTopProcess).isNotNull(); - kruntime.getKogitoWorkItemManager().completeWorkItem( - workItemTopProcess.getStringId(), null); + kruntime.getKogitoWorkItemManager().completeWorkItem(workItemTopProcess.getStringId(), null); assertProcessInstanceFinished(processInstance, kruntime); - assertNodeTriggered(processInstance.getStringId(), "start", "User Task 1", - "end", "Sub Process 1", "start-sub", "User Task 2", "end-sub"); + assertNodeTriggered(processInstance.getStringId(), "start", "User Task 1", "end", "Sub Process 1", "start-sub", + "User Task 2", "end-sub"); assertThat(executednodes).hasSize(4); } @Test public void testEventSubprocessSignalInterrupting() throws Exception { - kruntime = createKogitoProcessRuntime("org/jbpm/bpmn2/intermediate/BPMN2-EventSubprocessSignalInterrupting.bpmn2"); + kruntime = createKogitoProcessRuntime( + "org/jbpm/bpmn2/intermediate/BPMN2-EventSubprocessSignalInterrupting.bpmn2"); final List executednodes = new ArrayList<>(); KogitoProcessEventListener listener = new DefaultKogitoProcessEventListener() { @Override public void afterNodeLeft(ProcessNodeLeftEvent event) { - if (event.getNodeInstance().getNodeName() - .equals("Script Task 1")) { + if (event.getNodeInstance().getNodeName().equals("Script Task 1")) { executednodes.add(((KogitoNodeInstance) event.getNodeInstance()).getStringId()); } } @@ -828,8 +725,7 @@ public void afterNodeLeft(ProcessNodeLeftEvent event) { kruntime.getProcessEventManager().addEventListener(listener); TestWorkItemHandler workItemHandler = new TestWorkItemHandler(); - kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Human Task", - workItemHandler); + kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Human Task", workItemHandler); KogitoProcessInstance processInstance = kruntime.startProcess("EventSubprocessSignalInterrupting"); assertProcessInstanceActive(processInstance); kruntime.getProcessEventManager().addEventListener(listener); @@ -837,113 +733,109 @@ public void afterNodeLeft(ProcessNodeLeftEvent event) { kruntime.signalEvent("MySignal", null, processInstance.getStringId()); assertProcessInstanceFinished(processInstance, kruntime); - assertNodeTriggered(processInstance.getStringId(), "start", "User Task 1", - "Sub Process 1", "start-sub", "Script Task 1", "end-sub"); + assertNodeTriggered(processInstance.getStringId(), "start", "User Task 1", "Sub Process 1", "start-sub", + "Script Task 1", "end-sub"); assertThat(executednodes).hasSize(1); } @Test public void testEventSubprocessMessage() throws Exception { - kruntime = createKogitoProcessRuntime("BPMN2-EventSubprocessMessage.bpmn2"); - final List executednodes = new ArrayList<>(); + Application app = ProcessTestHelper.newApplication(); + + TestWorkItemHandler workItemHandler = new TestWorkItemHandler(); + ProcessTestHelper.registerHandler(app, "Human Task", workItemHandler); + List executednodes = new ArrayList<>(); KogitoProcessEventListener listener = new DefaultKogitoProcessEventListener() { @Override public void afterNodeLeft(ProcessNodeLeftEvent event) { - if (event.getNodeInstance().getNodeName() - .equals("Script Task 1")) { - executednodes.add(((KogitoNodeInstance) event.getNodeInstance()).getStringId()); + if (event.getNodeInstance().getNodeName().equals("Script Task 1")) { + executednodes.add(((KogitoNodeInstance) event.getNodeInstance()).getNodeId().toExternalFormat()); } } }; + ProcessTestHelper.registerProcessEventListener(app, listener); - kruntime.getProcessEventManager().addEventListener(listener); + EventTrackerProcessListener trackerListener = new EventTrackerProcessListener(); + ProcessTestHelper.registerProcessEventListener(app, trackerListener); - TestWorkItemHandler workItemHandler = new TestWorkItemHandler(); - kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Human Task", - workItemHandler); - KogitoProcessInstance processInstance = kruntime.startProcess("BPMN2-EventSubprocessMessage"); - assertProcessInstanceActive(processInstance); - Set> eventDescriptions = processInstance.getEventDescriptions(); - assertThat(eventDescriptions) - .hasSize(2) - .extracting("event").contains("Message-HelloMessage", "workItemCompleted"); - assertThat(eventDescriptions) - .extracting("eventType").contains("signal", "workItem"); - assertThat(eventDescriptions) - .extracting("processInstanceId").contains(processInstance.getStringId()); - kruntime.getProcessEventManager().addEventListener(listener); + org.kie.kogito.process.Process definition = EventSubprocessMessageProcess + .newProcess(app); + org.kie.kogito.process.ProcessInstance instance = definition + .createInstance(definition.createModel()); + + instance.start(); + Set> eventDescriptions = instance.events(); + assertThat(eventDescriptions).hasSize(3).extracting("event").contains("Message-HelloMessage", + "workItemCompleted", "HelloMessage"); + assertThat(eventDescriptions).extracting("eventType").contains("signal", "workItem"); + assertThat(eventDescriptions).extracting("processInstanceId").contains(instance.id()); + + instance.send(Sig.of("Message-HelloMessage")); + definition.send(Sig.of("Message-HelloMessage")); + definition.send(Sig.of("Message-HelloMessage")); + definition.send(Sig.of("Message-HelloMessage")); - kruntime.signalEvent("Message-HelloMessage", null, processInstance.getStringId()); - kruntime.signalEvent("Message-HelloMessage", null); - kruntime.signalEvent("Message-HelloMessage", null); - kruntime.signalEvent("Message-HelloMessage", null); - kruntime.getProcessInstance(processInstance.getStringId()); - kruntime.getProcessInstance(processInstance.getStringId()); - kruntime.getProcessInstance(processInstance.getStringId()); - kruntime.getProcessInstance(processInstance.getStringId()); KogitoWorkItem workItem = workItemHandler.getWorkItem(); assertThat(workItem).isNotNull(); - kruntime.getKogitoWorkItemManager().completeWorkItem(workItem.getStringId(), null); - assertProcessInstanceFinished(processInstance, kruntime); - assertNodeTriggered(processInstance.getStringId(), "start", "User Task 1", - "end", "Sub Process 1", "start-sub", "Script Task 1", "end-sub"); + ProcessTestHelper.completeWorkItem(instance, Collections.emptyMap(), "john"); + + assertThat(instance.status()).isEqualTo(org.kie.kogito.process.ProcessInstance.STATE_COMPLETED); + + assertThat(trackerListener.tracked()).anyMatch(ProcessTestHelper.triggered("start")) + .anyMatch(ProcessTestHelper.triggered("User Task 1")).anyMatch(ProcessTestHelper.triggered("end")) + .anyMatch(ProcessTestHelper.left("Sub Process 1")) + .anyMatch(ProcessTestHelper.left("start-sub")) + .anyMatch(ProcessTestHelper.triggered("Script Task 1")) + .anyMatch(ProcessTestHelper.triggered("end-sub")); + assertThat(executednodes).hasSize(4); } @Test public void testEventSubprocessTimer() throws Exception { - NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("Script Task 1", 1); + NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener( + "Script Task 1", 1); kruntime = createKogitoProcessRuntime("org/jbpm/bpmn2/intermediate/BPMN2-EventSubprocessTimer.bpmn2"); kruntime.getProcessEventManager().addEventListener(countDownListener); TestWorkItemHandler workItemHandler = new TestWorkItemHandler(); - kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Human Task", - workItemHandler); + kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Human Task", workItemHandler); KogitoProcessInstance processInstance = kruntime.startProcess("EventSubprocessTimer"); assertProcessInstanceActive(processInstance); Set> eventDescriptions = processInstance.getEventDescriptions(); - assertThat(eventDescriptions) - .hasSize(2) - .extracting("event").contains("workItemCompleted", TIMER_TRIGGERED_EVENT); - assertThat(eventDescriptions) - .extracting("eventType").contains("workItem", "timer"); - assertThat(eventDescriptions) - .extracting("processInstanceId").contains(processInstance.getStringId()); - assertThat(eventDescriptions) - .filteredOn("eventType", "timer") - .hasSize(1) - .extracting("properties", Map.class) + assertThat(eventDescriptions).hasSize(2).extracting("event").contains("workItemCompleted", + TIMER_TRIGGERED_EVENT); + assertThat(eventDescriptions).extracting("eventType").contains("workItem", "timer"); + assertThat(eventDescriptions).extracting("processInstanceId").contains(processInstance.getStringId()); + assertThat(eventDescriptions).filteredOn("eventType", "timer").hasSize(1).extracting("properties", Map.class) .anyMatch(m -> m.containsKey("TimerID") && m.containsKey("Delay")); countDownListener.waitTillCompleted(); eventDescriptions = processInstance.getEventDescriptions(); - assertThat(eventDescriptions) - .hasSize(1) - .extracting("event").contains("workItemCompleted"); - assertThat(eventDescriptions) - .extracting("eventType").contains("workItem"); - assertThat(eventDescriptions) - .extracting("processInstanceId").contains(processInstance.getStringId()); + assertThat(eventDescriptions).hasSize(1).extracting("event").contains("workItemCompleted"); + assertThat(eventDescriptions).extracting("eventType").contains("workItem"); + assertThat(eventDescriptions).extracting("processInstanceId").contains(processInstance.getStringId()); KogitoWorkItem workItem = workItemHandler.getWorkItem(); assertThat(workItem).isNotNull(); kruntime.getKogitoWorkItemManager().completeWorkItem(workItem.getStringId(), null); assertProcessInstanceFinished(processInstance, kruntime); - assertNodeTriggered(processInstance.getStringId(), "start", "User Task 1", - "end", "Sub Process 1", "start-sub", "Script Task 1", "end-sub"); + assertNodeTriggered(processInstance.getStringId(), "start", "User Task 1", "end", "Sub Process 1", "start-sub", + "Script Task 1", "end-sub"); } @Test @RequirePersistence public void testEventSubprocessTimerCycle() throws Exception { - NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("Script Task 1", 4); + NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener( + "Script Task 1", 4); kruntime = createKogitoProcessRuntime("org/jbpm/bpmn2/intermediate/BPMN2-EventSubprocessTimerCycle.bpmn2"); kruntime.getProcessEventManager().addEventListener(countDownListener); @@ -954,17 +846,11 @@ public void testEventSubprocessTimerCycle() throws Exception { assertProcessInstanceActive(processInstance); Set> eventDescriptions = processInstance.getEventDescriptions(); - assertThat(eventDescriptions) - .hasSize(2) - .extracting("event").contains("workItemCompleted", TIMER_TRIGGERED_EVENT); - assertThat(eventDescriptions) - .extracting("eventType").contains("workItem", "timer"); - assertThat(eventDescriptions) - .extracting("processInstanceId").contains(processInstance.getStringId()); - assertThat(eventDescriptions) - .filteredOn("eventType", "timer") - .hasSize(1) - .extracting("properties", Map.class) + assertThat(eventDescriptions).hasSize(2).extracting("event").contains("workItemCompleted", + TIMER_TRIGGERED_EVENT); + assertThat(eventDescriptions).extracting("eventType").contains("workItem", "timer"); + assertThat(eventDescriptions).extracting("processInstanceId").contains(processInstance.getStringId()); + assertThat(eventDescriptions).filteredOn("eventType", "timer").hasSize(1).extracting("properties", Map.class) .anyMatch(m -> m.containsKey("TimerID") && m.containsKey("Period")); countDownListener.waitTillCompleted(); @@ -973,45 +859,61 @@ public void testEventSubprocessTimerCycle() throws Exception { assertThat(workItem).isNotNull(); kruntime.getKogitoWorkItemManager().completeWorkItem(workItem.getStringId(), null); assertProcessInstanceFinished(processInstance, kruntime); - assertNodeTriggered(processInstance.getStringId(), "start", "User Task 1", - "end", "start-sub", "Script Task 1", "end-sub"); + assertNodeTriggered(processInstance.getStringId(), "start", "User Task 1", "end", "start-sub", "Script Task 1", + "end-sub"); } @Test public void testEventSubprocessConditional() throws Exception { - kruntime = createKogitoProcessRuntime("BPMN2-EventSubprocessConditional.bpmn2"); - final List executednodes = new ArrayList<>(); + Application app = ProcessTestHelper.newApplication(); + + List executednodes = new ArrayList<>(); KogitoProcessEventListener listener = new DefaultKogitoProcessEventListener() { @Override public void afterNodeLeft(ProcessNodeLeftEvent event) { - if (event.getNodeInstance().getNodeName() - .equals("Script Task 1")) { + if (event.getNodeInstance().getNodeName().equals("Script Task 1")) { executednodes.add(((KogitoNodeInstance) event.getNodeInstance()).getStringId()); } } }; - kruntime.getProcessEventManager().addEventListener(listener); - + ProcessTestHelper.registerProcessEventListener(app, listener); + EventTrackerProcessListener trackerListener = new EventTrackerProcessListener(); + ProcessTestHelper.registerProcessEventListener(app, trackerListener); TestWorkItemHandler workItemHandler = new TestWorkItemHandler(); - kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Human Task", - workItemHandler); - KogitoProcessInstance processInstance = kruntime - .startProcess("BPMN2-EventSubprocessConditional"); - assertProcessInstanceActive(processInstance); + ProcessTestHelper.registerHandler(app, "Human Task", workItemHandler); - Person person = new Person(); - person.setName("john"); - kruntime.getKieSession().insert(person); + org.kie.kogito.process.Process definition = EventSubprocessConditionalProcess + .newProcess(app); + org.kie.kogito.process.ProcessInstance instance = definition + .createInstance(definition.createModel()); + + instance.start(); + + assertThat(instance.status()).isEqualTo(org.kie.kogito.process.ProcessInstance.STATE_ACTIVE); + + Person person = new Person("john"); + EventSubprocessConditionalModel model = definition.createModel(); + model.setPerson(person); + instance.updateVariables(model); KogitoWorkItem workItem = workItemHandler.getWorkItem(); assertThat(workItem).isNotNull(); - kruntime.getKogitoWorkItemManager().completeWorkItem(workItem.getStringId(), null); - assertProcessInstanceFinished(processInstance, kruntime); - assertNodeTriggered(processInstance.getStringId(), "start", "User Task 1", - "end", "Sub Process 1", "start-sub", "Script Task 1", "end-sub"); + + ProcessTestHelper.completeWorkItem(instance, Collections.emptyMap(), "john"); + + assertThat(instance.status()).isEqualTo(org.kie.kogito.process.ProcessInstance.STATE_COMPLETED); + + assertThat(trackerListener.tracked()).anyMatch(ProcessTestHelper.triggered("start")) + .anyMatch(ProcessTestHelper.triggered("User Task 1")) + .anyMatch(ProcessTestHelper.triggered("end")) + .anyMatch(ProcessTestHelper.left("Sub Process 1")) + .anyMatch(ProcessTestHelper.left("start-sub")) + .anyMatch(ProcessTestHelper.triggered("Script Task 1")) + .anyMatch(ProcessTestHelper.triggered("end-sub")); + assertThat(executednodes).hasSize(1); } @@ -1020,7 +922,8 @@ public void afterNodeLeft(ProcessNodeLeftEvent event) { public void testEventSubprocessMessageWithLocalVars() throws Exception { NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("timer", 1); - kruntime = createKogitoProcessRuntime("org/jbpm/bpmn2/intermediate/BPMN2-EventSubProcessWithLocalVariables.bpmn2"); + kruntime = createKogitoProcessRuntime( + "org/jbpm/bpmn2/intermediate/BPMN2-EventSubProcessWithLocalVariables.bpmn2"); final Set variablevalues = new HashSet(); KogitoProcessEventListener listener = new DefaultKogitoProcessEventListener() { @@ -1053,7 +956,8 @@ public void testMessageIntermediateThrow() throws Exception { Application app = ProcessTestHelper.newApplication(); ProcessTestHelper.registerHandler(app, "Send Task", new SendTaskHandler()); - IntermediateThrowEventMessageProcess definition = (IntermediateThrowEventMessageProcess) IntermediateThrowEventMessageProcess.newProcess(app); + IntermediateThrowEventMessageProcess definition = (IntermediateThrowEventMessageProcess) IntermediateThrowEventMessageProcess + .newProcess(app); StringBuilder builder = new StringBuilder(); definition.setProducer__2(new MessageProducer() { @Override @@ -1065,7 +969,8 @@ public void produce(KogitoProcessInstance pi, String eventData) { model.setX("MyValue"); - org.kie.kogito.process.ProcessInstance instance = definition.createInstance(model); + org.kie.kogito.process.ProcessInstance instance = definition + .createInstance(model); instance.start(); assertThat(builder.toString()).isEqualTo("MyValue"); @@ -1081,8 +986,8 @@ public void testMessageBoundaryEventOnTask() throws Exception { KogitoProcessInstance processInstance = kruntime.startProcess("BoundaryMessageEventOnTask"); kruntime.signalEvent("Message-HelloMessage", "message data"); assertProcessInstanceFinished(processInstance, kruntime); - assertNodeTriggered(processInstance.getStringId(), "StartProcess", - "User Task", "Boundary event", "Condition met", "End2"); + assertNodeTriggered(processInstance.getStringId(), "StartProcess", "User Task", "Boundary event", + "Condition met", "End2"); } @@ -1090,18 +995,14 @@ public void testMessageBoundaryEventOnTask() throws Exception { public void testMessageBoundaryEventOnTaskComplete() throws Exception { kruntime = createKogitoProcessRuntime("org/jbpm/bpmn2/intermediate/BPMN2-BoundaryMessageEventOnTask.bpmn2"); TestWorkItemHandler handler = new TestWorkItemHandler(); - kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Human Task", - handler); + kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Human Task", handler); KogitoProcessInstance processInstance = kruntime.startProcess("BoundaryMessageEventOnTask"); - kruntime.getKogitoWorkItemManager().completeWorkItem( - handler.getWorkItem().getStringId(), null); + kruntime.getKogitoWorkItemManager().completeWorkItem(handler.getWorkItem().getStringId(), null); kruntime.signalEvent("Message-HelloMessage", "message data"); - kruntime.getKogitoWorkItemManager().completeWorkItem( - handler.getWorkItem().getStringId(), null); + kruntime.getKogitoWorkItemManager().completeWorkItem(handler.getWorkItem().getStringId(), null); assertProcessInstanceFinished(processInstance, kruntime); - assertNodeTriggered(processInstance.getStringId(), "StartProcess", - "User Task", "User Task2", "End1"); + assertNodeTriggered(processInstance.getStringId(), "StartProcess", "User Task", "User Task2", "End1"); } @@ -1115,17 +1016,11 @@ public void testTimerBoundaryEventDuration() throws Exception { assertProcessInstanceActive(processInstance); Set> eventDescriptions = processInstance.getEventDescriptions(); - assertThat(eventDescriptions) - .hasSize(2) - .extracting("event").contains("workItemCompleted", TIMER_TRIGGERED_EVENT); - assertThat(eventDescriptions) - .extracting("eventType").contains("workItem", "timer"); - assertThat(eventDescriptions) - .extracting("processInstanceId").contains(processInstance.getStringId()); - assertThat(eventDescriptions) - .filteredOn("eventType", "timer") - .hasSize(1) - .extracting("properties", Map.class) + assertThat(eventDescriptions).hasSize(2).extracting("event").contains("workItemCompleted", + TIMER_TRIGGERED_EVENT); + assertThat(eventDescriptions).extracting("eventType").contains("workItem", "timer"); + assertThat(eventDescriptions).extracting("processInstanceId").contains(processInstance.getStringId()); + assertThat(eventDescriptions).filteredOn("eventType", "timer").hasSize(1).extracting("properties", Map.class) .anyMatch(m -> m.containsKey("TimerID") && m.containsKey("Period")); countDownListener.waitTillCompleted(); @@ -1183,7 +1078,8 @@ public void testTimerBoundaryEventCycle1() throws Exception { @Test public void testTimerBoundaryEventCycle2() throws Exception { - NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("TimerEvent", 3); + NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener( + "TimerEvent", 3); kruntime = createKogitoProcessRuntime("org/jbpm/bpmn2/timer/BPMN2-TimerBoundaryEventCycle2.bpmn2"); kruntime.getKogitoWorkItemManager().registerWorkItemHandler("MyTask", new DoNothingWorkItemHandler()); @@ -1200,7 +1096,8 @@ public void testTimerBoundaryEventCycle2() throws Exception { @Test @RequirePersistence(false) public void testTimerBoundaryEventCycleISO() throws Exception { - NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("TimerEvent", 2); + NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener( + "TimerEvent", 2); kruntime = createKogitoProcessRuntime("org/jbpm/bpmn2/timer/BPMN2-TimerBoundaryEventCycleISO.bpmn2"); kruntime.getProcessEventManager().addEventListener(countDownListener); kruntime.getKogitoWorkItemManager().registerWorkItemHandler("MyTask", new DoNothingWorkItemHandler()); @@ -1249,10 +1146,12 @@ public void testTimerBoundaryEventInterruptingOnTask() throws Exception { @Test public void testTimerBoundaryEventInterruptingOnTaskCancelTimer() throws Exception { - kruntime = createKogitoProcessRuntime("org/jbpm/bpmn2/timer/BPMN2-TimerBoundaryEventInterruptingOnTaskCancelTimer.bpmn2"); + kruntime = createKogitoProcessRuntime( + "org/jbpm/bpmn2/timer/BPMN2-TimerBoundaryEventInterruptingOnTaskCancelTimer.bpmn2"); TestWorkItemHandler handler = new TestWorkItemHandler(); kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Human Task", handler); - KogitoProcessInstance processInstance = kruntime.startProcess("TimerBoundaryEventInterruptingOnTaskCancelTimer"); + KogitoProcessInstance processInstance = kruntime + .startProcess("TimerBoundaryEventInterruptingOnTaskCancelTimer"); assertProcessInstanceActive(processInstance); kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Human Task", handler); @@ -1271,8 +1170,7 @@ public void testTimerBoundaryEventInterruptingOnTaskCancelTimer() throws Excepti @Test public void testIntermediateCatchEventSignal() throws Exception { kruntime = createKogitoProcessRuntime("org/jbpm/bpmn2/intermediate/BPMN2-IntermediateCatchEventSignal.bpmn2"); - kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Human Task", - new SystemOutWorkItemHandler()); + kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Human Task", new SystemOutWorkItemHandler()); KogitoProcessInstance processInstance = kruntime.startProcess("IntermediateCatchEventSignal"); assertProcessInstanceActive(processInstance); @@ -1286,27 +1184,24 @@ public void testIntermediateCatchEventSignal() throws Exception { @Test public void testIntermediateCatchEventMessage() throws Exception { kruntime = createKogitoProcessRuntime("org/jbpm/bpmn2/intermediate/BPMN2-IntermediateCatchEventMessage.bpmn2"); - kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Human Task", - new SystemOutWorkItemHandler()); + kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Human Task", new SystemOutWorkItemHandler()); KogitoProcessInstance processInstance = kruntime.startProcess("IntermediateCatchEventMessage"); assertProcessInstanceActive(processInstance); // now signal process instance - kruntime.signalEvent("Message-HelloMessage", "SomeValue", - processInstance.getStringId()); + kruntime.signalEvent("Message-HelloMessage", "SomeValue", processInstance.getStringId()); assertProcessInstanceFinished(processInstance, kruntime); } @Test public void testIntermediateCatchEventMessageWithRef() throws Exception { - kruntime = createKogitoProcessRuntime("org/jbpm/bpmn2/intermediate/BPMN2-IntermediateCatchEventMessageWithRef.bpmn2"); - kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Human Task", - new SystemOutWorkItemHandler()); + kruntime = createKogitoProcessRuntime( + "org/jbpm/bpmn2/intermediate/BPMN2-IntermediateCatchEventMessageWithRef.bpmn2"); + kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Human Task", new SystemOutWorkItemHandler()); KogitoProcessInstance processInstance = kruntime.startProcess("IntermediateCatchEventMessageWithRef"); assertProcessInstanceActive(processInstance); // now signal process instance - kruntime.signalEvent("Message-HelloMessage", "SomeValue", - processInstance.getStringId()); + kruntime.signalEvent("Message-HelloMessage", "SomeValue", processInstance.getStringId()); assertProcessInstanceFinished(processInstance, kruntime); } @@ -1315,7 +1210,8 @@ public void testIntermediateCatchEventMessageWithRef() throws Exception { public void testIntermediateCatchEventTimerDuration() throws Exception { ProcessCompletedCountDownProcessEventListener countDownListener = new ProcessCompletedCountDownProcessEventListener(); - kruntime = createKogitoProcessRuntime("org/jbpm/bpmn2/intermediate/BPMN2-IntermediateCatchEventTimerDuration.bpmn2"); + kruntime = createKogitoProcessRuntime( + "org/jbpm/bpmn2/intermediate/BPMN2-IntermediateCatchEventTimerDuration.bpmn2"); kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Human Task", new DoNothingWorkItemHandler()); kruntime.getProcessEventManager().addEventListener(countDownListener); KogitoProcessInstance processInstance = kruntime.startProcess("IntermediateCatchEventTimerDuration"); @@ -1331,7 +1227,8 @@ public void testIntermediateCatchEventTimerDuration() throws Exception { public void testIntermediateCatchEventTimerDateISO() throws Exception { ProcessCompletedCountDownProcessEventListener countDownListener = new ProcessCompletedCountDownProcessEventListener(); - kruntime = createKogitoProcessRuntime("org/jbpm/bpmn2/intermediate/BPMN2-IntermediateCatchEventTimerDateISO.bpmn2"); + kruntime = createKogitoProcessRuntime( + "org/jbpm/bpmn2/intermediate/BPMN2-IntermediateCatchEventTimerDateISO.bpmn2"); kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Human Task", new DoNothingWorkItemHandler()); kruntime.getProcessEventManager().addEventListener(countDownListener); @@ -1351,7 +1248,8 @@ public void testIntermediateCatchEventTimerDateISO() throws Exception { public void testIntermediateCatchEventTimerDurationISO() throws Exception { ProcessCompletedCountDownProcessEventListener countDownListener = new ProcessCompletedCountDownProcessEventListener(); - kruntime = createKogitoProcessRuntime("org/jbpm/bpmn2/intermediate/BPMN2-IntermediateCatchEventTimerDurationISO.bpmn2"); + kruntime = createKogitoProcessRuntime( + "org/jbpm/bpmn2/intermediate/BPMN2-IntermediateCatchEventTimerDurationISO.bpmn2"); kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Human Task", new DoNothingWorkItemHandler()); kruntime.getProcessEventManager().addEventListener(countDownListener); @@ -1367,7 +1265,8 @@ public void testIntermediateCatchEventTimerDurationISO() throws Exception { public void testIntermediateCatchEventTimerCycle1() throws Exception { ProcessCompletedCountDownProcessEventListener countDownListener = new ProcessCompletedCountDownProcessEventListener(); - kruntime = createKogitoProcessRuntime("org/jbpm/bpmn2/intermediate/BPMN2-IntermediateCatchEventTimerCycle1.bpmn2"); + kruntime = createKogitoProcessRuntime( + "org/jbpm/bpmn2/intermediate/BPMN2-IntermediateCatchEventTimerCycle1.bpmn2"); kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Human Task", new DoNothingWorkItemHandler()); kruntime.getProcessEventManager().addEventListener(countDownListener); @@ -1383,7 +1282,8 @@ public void testIntermediateCatchEventTimerCycle1() throws Exception { public void testIntermediateCatchEventTimerCycleISO() throws Exception { NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("timer", 5); - kruntime = createKogitoProcessRuntime("org/jbpm/bpmn2/intermediate/BPMN2-IntermediateCatchEventTimerCycleISO.bpmn2"); + kruntime = createKogitoProcessRuntime( + "org/jbpm/bpmn2/intermediate/BPMN2-IntermediateCatchEventTimerCycleISO.bpmn2"); kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Human Task", new DoNothingWorkItemHandler()); kruntime.getProcessEventManager().addEventListener(countDownListener); @@ -1400,7 +1300,8 @@ public void testIntermediateCatchEventTimerCycleISO() throws Exception { public void testIntermediateCatchEventTimerCycle2() throws Exception { NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("timer", 3); - kruntime = createKogitoProcessRuntime("org/jbpm/bpmn2/intermediate/BPMN2-IntermediateCatchEventTimerCycle2.bpmn2"); + kruntime = createKogitoProcessRuntime( + "org/jbpm/bpmn2/intermediate/BPMN2-IntermediateCatchEventTimerCycle2.bpmn2"); kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Human Task", new DoNothingWorkItemHandler()); kruntime.getProcessEventManager().addEventListener(countDownListener); @@ -1415,7 +1316,8 @@ public void testIntermediateCatchEventTimerCycle2() throws Exception { @Test public void testIntermediateCatchEventCondition() throws Exception { - kruntime = createKogitoProcessRuntime("org/jbpm/bpmn2/intermediate/BPMN2-IntermediateCatchEventCondition.bpmn2"); + kruntime = createKogitoProcessRuntime( + "org/jbpm/bpmn2/intermediate/BPMN2-IntermediateCatchEventCondition.bpmn2"); KogitoProcessInstance processInstance = kruntime.startProcess("IntermediateCatchEventCondition"); assertProcessInstanceActive(processInstance); @@ -1428,18 +1330,16 @@ public void testIntermediateCatchEventCondition() throws Exception { } @Test - public void testIntermediateCatchEventConditionFilterByProcessInstance() - throws Exception { - kruntime = createKogitoProcessRuntime("org/jbpm/bpmn2/intermediate/BPMN2-IntermediateCatchEventConditionFilterByProcessInstance.bpmn2"); + public void testIntermediateCatchEventConditionFilterByProcessInstance() throws Exception { + kruntime = createKogitoProcessRuntime( + "org/jbpm/bpmn2/intermediate/BPMN2-IntermediateCatchEventConditionFilterByProcessInstance.bpmn2"); Map params1 = new HashMap<>(); params1.put("personId", Long.valueOf(1L)); Person person1 = new Person(); person1.setId(1L); KogitoProcessInstance pi1 = kruntime - .createProcessInstance( - "IntermediateCatchEventConditionFilterByProcessInstance", - params1); + .createProcessInstance("IntermediateCatchEventConditionFilterByProcessInstance", params1); String pi1id = pi1.getStringId(); kruntime.getKieSession().insert(pi1); @@ -1453,9 +1353,7 @@ public void testIntermediateCatchEventConditionFilterByProcessInstance() person2.setId(2L); KogitoProcessInstance pi2 = kruntime - .createProcessInstance( - "IntermediateCatchEventConditionFilterByProcessInstance", - params2); + .createProcessInstance("IntermediateCatchEventConditionFilterByProcessInstance", params2); String pi2id = pi2.getStringId(); kruntime.getKieSession().insert(pi2); @@ -1475,16 +1373,17 @@ public void testIntermediateCatchEventConditionFilterByProcessInstance() @Test @RequirePersistence(false) - public void testIntermediateCatchEventTimerCycleWithError() - throws Exception { + public void testIntermediateCatchEventTimerCycleWithError() throws Exception { NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("timer", 3); - kruntime = createKogitoProcessRuntime("org/jbpm/bpmn2/intermediate/BPMN2-IntermediateCatchEventTimerCycleWithError.bpmn2"); + kruntime = createKogitoProcessRuntime( + "org/jbpm/bpmn2/intermediate/BPMN2-IntermediateCatchEventTimerCycleWithError.bpmn2"); kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Human Task", new DoNothingWorkItemHandler()); kruntime.getProcessEventManager().addEventListener(countDownListener); Map params = new HashMap<>(); params.put("x", 0); - KogitoProcessInstance processInstance = kruntime.startProcess("IntermediateCatchEventTimerCycleWithError", params); + KogitoProcessInstance processInstance = kruntime.startProcess("IntermediateCatchEventTimerCycleWithError", + params); assertProcessInstanceActive(processInstance); // now wait for 1 second for timer to trigger countDownListener.waitTillCompleted(); @@ -1504,7 +1403,8 @@ public void testIntermediateCatchEventTimerCycleWithError() public void testIntermediateCatchEventTimerCycleWithErrorWithPersistence() throws Exception { NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("timer", 2); - kruntime = createKogitoProcessRuntime("org/jbpm/bpmn2/intermediate/BPMN2-IntermediateCatchEventTimerCycleWithError.bpmn2"); + kruntime = createKogitoProcessRuntime( + "org/jbpm/bpmn2/intermediate/BPMN2-IntermediateCatchEventTimerCycleWithError.bpmn2"); kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Human Task", new DoNothingWorkItemHandler()); kruntime.getProcessEventManager().addEventListener(countDownListener); KogitoProcessInstance processInstance = kruntime.startProcess("IntermediateCatchEventTimerCycleWithError"); @@ -1512,7 +1412,8 @@ public void testIntermediateCatchEventTimerCycleWithErrorWithPersistence() throw final String piId = processInstance.getStringId(); kruntime.getKieSession().execute((ExecutableCommand) context -> { - KogitoWorkflowProcessInstance processInstance1 = (KogitoWorkflowProcessInstance) kruntime.getProcessInstance(piId); + KogitoWorkflowProcessInstance processInstance1 = (KogitoWorkflowProcessInstance) kruntime + .getProcessInstance(piId); processInstance1.setVariable("x", 0); return null; }); @@ -1522,7 +1423,8 @@ public void testIntermediateCatchEventTimerCycleWithErrorWithPersistence() throw assertProcessInstanceActive(processInstance); Integer xValue = kruntime.getKieSession().execute((ExecutableCommand) context -> { - KogitoWorkflowProcessInstance processInstance2 = (KogitoWorkflowProcessInstance) kruntime.getProcessInstance(piId); + KogitoWorkflowProcessInstance processInstance2 = (KogitoWorkflowProcessInstance) kruntime + .getProcessInstance(piId); return (Integer) processInstance2.getVariable("x"); }); @@ -1534,8 +1436,7 @@ public void testIntermediateCatchEventTimerCycleWithErrorWithPersistence() throw @Test public void testNoneIntermediateThrow() throws Exception { kruntime = createKogitoProcessRuntime("org/jbpm/bpmn2/intermediate/BPMN2-IntermediateThrowEventNone.bpmn2"); - KogitoProcessInstance processInstance = kruntime.startProcess( - "IntermediateThrowEventNone"); + KogitoProcessInstance processInstance = kruntime.startProcess("IntermediateThrowEventNone"); assertProcessInstanceCompleted(processInstance); } @@ -1559,8 +1460,7 @@ public void testLinkEventCompositeProcess() throws Exception { @Test public void testConditionalBoundaryEventOnTask() throws Exception { kruntime = createKogitoProcessRuntime("org/jbpm/bpmn2/intermediate/BPMN2-BoundaryConditionalEventOnTask.bpmn2"); - kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Human Task", - new TestWorkItemHandler()); + kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Human Task", new TestWorkItemHandler()); KogitoProcessInstance processInstance = kruntime.startProcess("BoundaryConditionalEventOnTask"); Person person = new Person(); @@ -1568,8 +1468,8 @@ public void testConditionalBoundaryEventOnTask() throws Exception { kruntime.getKieSession().insert(person); assertProcessInstanceFinished(processInstance, kruntime); - assertNodeTriggered(processInstance.getStringId(), "StartProcess", - "User Task", "Boundary event", "Condition met", "End2"); + assertNodeTriggered(processInstance.getStringId(), "StartProcess", "User Task", "Boundary event", + "Condition met", "End2"); } @@ -1577,30 +1477,25 @@ public void testConditionalBoundaryEventOnTask() throws Exception { public void testConditionalBoundaryEventOnTaskComplete() throws Exception { kruntime = createKogitoProcessRuntime("org/jbpm/bpmn2/intermediate/BPMN2-BoundaryConditionalEventOnTask.bpmn2"); TestWorkItemHandler handler = new TestWorkItemHandler(); - kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Human Task", - handler); + kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Human Task", handler); KogitoProcessInstance processInstance = kruntime.startProcess("BoundaryConditionalEventOnTask"); - kruntime.getKogitoWorkItemManager().completeWorkItem( - handler.getWorkItem().getStringId(), null); + kruntime.getKogitoWorkItemManager().completeWorkItem(handler.getWorkItem().getStringId(), null); Person person = new Person(); person.setName("john"); - // as the node that boundary event is attached to has been completed insert will not have any effect + // as the node that boundary event is attached to has been completed insert will + // not have any effect kruntime.getKieSession().insert(person); - kruntime.getKogitoWorkItemManager().completeWorkItem( - handler.getWorkItem().getStringId(), null); + kruntime.getKogitoWorkItemManager().completeWorkItem(handler.getWorkItem().getStringId(), null); assertProcessInstanceFinished(processInstance, kruntime); - assertNodeTriggered(processInstance.getStringId(), "StartProcess", - "User Task", "User Task2", "End1"); + assertNodeTriggered(processInstance.getStringId(), "StartProcess", "User Task", "User Task2", "End1"); } @Test - public void testConditionalBoundaryEventOnTaskActiveOnStartup() - throws Exception { + public void testConditionalBoundaryEventOnTaskActiveOnStartup() throws Exception { kruntime = createKogitoProcessRuntime("org/jbpm/bpmn2/intermediate/BPMN2-BoundaryConditionalEventOnTask.bpmn2"); - kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Human Task", - new TestWorkItemHandler()); + kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Human Task", new TestWorkItemHandler()); KogitoProcessInstance processInstance = kruntime.startProcess("BoundaryConditionalEventOnTask"); Person person = new Person(); @@ -1608,16 +1503,16 @@ public void testConditionalBoundaryEventOnTaskActiveOnStartup() kruntime.getKieSession().insert(person); assertProcessInstanceCompleted(processInstance); - assertNodeTriggered(processInstance.getStringId(), "StartProcess", - "User Task", "Boundary event", "Condition met", "End2"); + assertNodeTriggered(processInstance.getStringId(), "StartProcess", "User Task", "Boundary event", + "Condition met", "End2"); } @Test public void testConditionalBoundaryEventInterrupting() throws Exception { - kruntime = createKogitoProcessRuntime("org/jbpm/bpmn2/intermediate/BPMN2-ConditionalBoundaryEventInterrupting.bpmn2"); - kruntime.getKogitoWorkItemManager().registerWorkItemHandler("MyTask", - new DoNothingWorkItemHandler()); + kruntime = createKogitoProcessRuntime( + "org/jbpm/bpmn2/intermediate/BPMN2-ConditionalBoundaryEventInterrupting.bpmn2"); + kruntime.getKogitoWorkItemManager().registerWorkItemHandler("MyTask", new DoNothingWorkItemHandler()); KogitoProcessInstance processInstance = kruntime.startProcess("ConditionalBoundaryEventInterrupting"); assertProcessInstanceActive(processInstance); @@ -1626,16 +1521,14 @@ public void testConditionalBoundaryEventInterrupting() throws Exception { kruntime.getKieSession().insert(person); assertProcessInstanceFinished(processInstance, kruntime); - assertNodeTriggered(processInstance.getStringId(), "StartProcess", "Hello", - "StartSubProcess", "Task", "BoundaryEvent", "Goodbye", - "EndProcess"); + assertNodeTriggered(processInstance.getStringId(), "StartProcess", "Hello", "StartSubProcess", "Task", + "BoundaryEvent", "Goodbye", "EndProcess"); } @Test public void testSignalBoundaryEventOnSubprocessTakingDifferentPaths() throws Exception { - kruntime = createKogitoProcessRuntime( - "org/jbpm/bpmn2/intermediate/BPMN2-SignalBoundaryOnSubProcess.bpmn"); + kruntime = createKogitoProcessRuntime("org/jbpm/bpmn2/intermediate/BPMN2-SignalBoundaryOnSubProcess.bpmn"); KogitoProcessInstance processInstance = kruntime.startProcess("SignalBoundaryOnSubProcess"); assertProcessInstanceActive(processInstance); @@ -1655,11 +1548,15 @@ public void testIntermediateCatchEventSameSignalOnTwokruntimes() throws Exceptio Application app = ProcessTestHelper.newApplication(); ProcessTestHelper.registerHandler(app, "Human Task", new SystemOutWorkItemHandler()); - org.kie.kogito.process.Process definition1 = IntermediateCatchEventSignalProcess.newProcess(app); - org.kie.kogito.process.Process definition2 = IntermediateCatchEventSignal2Process.newProcess(app); + org.kie.kogito.process.Process definition1 = IntermediateCatchEventSignalProcess + .newProcess(app); + org.kie.kogito.process.Process definition2 = IntermediateCatchEventSignal2Process + .newProcess(app); - org.kie.kogito.process.ProcessInstance instance1 = definition1.createInstance(definition1.createModel()); - org.kie.kogito.process.ProcessInstance instance2 = definition2.createInstance(definition2.createModel()); + org.kie.kogito.process.ProcessInstance instance1 = definition1 + .createInstance(definition1.createModel()); + org.kie.kogito.process.ProcessInstance instance2 = definition2 + .createInstance(definition2.createModel()); instance1.start(); instance2.start(); @@ -1703,7 +1600,8 @@ public void testSignalBoundaryEventOnMultiInstanceSubprocess() throws Exception params.put("approvers", approvers); - KogitoProcessInstance processInstance = kruntime.startProcess("MultiInstanceSubprocessWithBoundarySignal", params); + KogitoProcessInstance processInstance = kruntime.startProcess("MultiInstanceSubprocessWithBoundarySignal", + params); assertProcessInstanceActive(processInstance); List workItems = handler.getWorkItems(); @@ -1729,7 +1627,8 @@ public void testSignalBoundaryEventNoInteruptOnMultiInstanceSubprocess() throws params.put("approvers", approvers); - KogitoProcessInstance processInstance = kruntime.startProcess("MultiInstanceSubprocessWithBoundarySignalNoInterupting", params); + KogitoProcessInstance processInstance = kruntime + .startProcess("MultiInstanceSubprocessWithBoundarySignalNoInterupting", params); assertProcessInstanceActive(processInstance); List workItems = handler.getWorkItems(); @@ -1761,20 +1660,15 @@ public void testErrorBoundaryEventOnMultiInstanceSubprocess() throws Exception { params.put("approvers", approvers); - KogitoProcessInstance processInstance = kruntime.startProcess("MultiInstanceSubprocessWithBoundaryError", params); + KogitoProcessInstance processInstance = kruntime.startProcess("MultiInstanceSubprocessWithBoundaryError", + params); assertProcessInstanceActive(processInstance); Set> eventDescriptions = processInstance.getEventDescriptions(); - assertThat(eventDescriptions) - .hasSize(3) - .extracting("event").contains("workItemCompleted", "Inside", "Error-_D83CFC28-3322-4ABC-A12D-83476B08C7E8-MyError"); - assertThat(eventDescriptions) - .extracting("eventType").contains("workItem", "signal"); - assertThat(eventDescriptions) - .extracting("processInstanceId").contains(processInstance.getStringId()); - assertThat(eventDescriptions) - .filteredOn("eventType", "signal") - .hasSize(2) - .extracting("properties", Map.class) + assertThat(eventDescriptions).hasSize(3).extracting("event").contains("workItemCompleted", "Inside", + "Error-_D83CFC28-3322-4ABC-A12D-83476B08C7E8-MyError"); + assertThat(eventDescriptions).extracting("eventType").contains("workItem", "signal"); + assertThat(eventDescriptions).extracting("processInstanceId").contains(processInstance.getStringId()); + assertThat(eventDescriptions).filteredOn("eventType", "signal").hasSize(2).extracting("properties", Map.class) .anyMatch(m -> m.containsKey("AttachedToID") && m.containsKey("AttachedToName")); List workItems = handler.getWorkItems(); @@ -1810,13 +1704,11 @@ public void testIntermediateCatchEventSignalAndBoundarySignalEvent() throws Exce @Test @Disabled("Transfomer has been disabled") public void testSignalIntermediateThrowEventWithTransformation() throws Exception { - kruntime = createKogitoProcessRuntime( - "BPMN2-BoundarySignalEventOnTaskbpmn2.bpmn", + kruntime = createKogitoProcessRuntime("BPMN2-BoundarySignalEventOnTaskbpmn2.bpmn", "BPMN2-IntermediateThrowEventSignalWithTransformation.bpmn2"); TestWorkItemHandler handler = new TestWorkItemHandler(); - kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Human Task", - handler); + kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Human Task", handler); Map params = new HashMap<>(); params.put("x", "john"); @@ -1834,14 +1726,18 @@ public void testSignalIntermediateThrowEventWithTransformation() throws Exceptio @Test public void testSignalBoundaryEventWithTransformation() throws Exception { Application application = ProcessTestHelper.newApplication(); - org.kie.kogito.process.Process processBoundary = BoundarySignalEventOnTaskWithTransformationProcess.newProcess(application); - org.kie.kogito.process.Process processIntermediate = IntermediateThrowEventSignalProcess.newProcess(application); + org.kie.kogito.process.Process processBoundary = BoundarySignalEventOnTaskWithTransformationProcess + .newProcess(application); + org.kie.kogito.process.Process processIntermediate = IntermediateThrowEventSignalProcess + .newProcess(application); - ProcessInstance instanceBoundary = processBoundary.createInstance(processBoundary.createModel()); + ProcessInstance instanceBoundary = processBoundary + .createInstance(processBoundary.createModel()); instanceBoundary.start(); IntermediateThrowEventSignalModel modelIntermediate = processIntermediate.createModel(); modelIntermediate.setX("john"); - ProcessInstance instanceIntermediate = processIntermediate.createInstance(modelIntermediate); + ProcessInstance instanceIntermediate = processIntermediate + .createInstance(modelIntermediate); instanceIntermediate.start(); assertThat(instanceIntermediate).extracting(ProcessInstance::status).isEqualTo(ProcessInstance.STATE_COMPLETED); assertThat(instanceBoundary).extracting(ProcessInstance::status).isEqualTo(ProcessInstance.STATE_COMPLETED); @@ -1853,8 +1749,8 @@ public void testSignalBoundaryEventWithTransformation() throws Exception { public void testMessageIntermediateThrowWithTransformation() throws Exception { StringBuilder messageContent = new StringBuilder(); Application application = ProcessTestHelper.newApplication(); - IntermediateThrowEventMessageWithTransformationProcess definition = - (IntermediateThrowEventMessageWithTransformationProcess) IntermediateThrowEventMessageWithTransformationProcess.newProcess(application); + IntermediateThrowEventMessageWithTransformationProcess definition = (IntermediateThrowEventMessageWithTransformationProcess) IntermediateThrowEventMessageWithTransformationProcess + .newProcess(application); definition.setProducer__2(new MessageProducer() { @Override public void produce(KogitoProcessInstance pi, String eventData) { @@ -1863,7 +1759,8 @@ public void produce(KogitoProcessInstance pi, String eventData) { }); IntermediateThrowEventMessageWithTransformationModel model = definition.createModel(); model.setX("MyValue"); - ProcessInstance instance = definition.createInstance(model); + ProcessInstance instance = definition + .createInstance(model); instance.start(); assertThat(instance.status()).isEqualTo(ProcessInstance.STATE_COMPLETED); @@ -1877,19 +1774,19 @@ public void testIntermediateCatchEventSignalWithTransformation() throws Exceptio EventTrackerProcessListener listener = new EventTrackerProcessListener(); ProcessTestHelper.registerProcessEventListener(app, listener); ProcessTestHelper.registerHandler(app, "Human Task", new SystemOutWorkItemHandler()); - org.kie.kogito.process.Process definition = IntermediateCatchEventSignalWithTransformationProcess.newProcess(app); + org.kie.kogito.process.Process definition = IntermediateCatchEventSignalWithTransformationProcess + .newProcess(app); - org.kie.kogito.process.ProcessInstance instance = definition.createInstance(definition.createModel()); + org.kie.kogito.process.ProcessInstance instance = definition + .createInstance(definition.createModel()); instance.start(); assertThat(instance.status()).isEqualTo(org.kie.kogito.process.ProcessInstance.STATE_ACTIVE); instance.send(Sig.of("MyMessage", "SomeValue")); assertThat(instance.status()).isEqualTo(org.kie.kogito.process.ProcessInstance.STATE_COMPLETED); assertThat(instance.variables().getX()).isNotNull().isEqualTo("SOMEVALUE"); - assertThat(listener.tracked()) - .anyMatch(ProcessTestHelper.triggered("StartProcess")) - .anyMatch(ProcessTestHelper.triggered("UserTask")) - .anyMatch(ProcessTestHelper.triggered("EndProcess")) + assertThat(listener.tracked()).anyMatch(ProcessTestHelper.triggered("StartProcess")) + .anyMatch(ProcessTestHelper.triggered("UserTask")).anyMatch(ProcessTestHelper.triggered("EndProcess")) .anyMatch(ProcessTestHelper.triggered("event")); } @@ -1905,8 +1802,10 @@ public void afterProcessCompleted(ProcessCompletedEvent event) { latch.countDown(); } }); - org.kie.kogito.process.Process definition = IntermediateCatchEventTimerCycle3Process.newProcess(app); - org.kie.kogito.process.ProcessInstance instance = definition.createInstance(definition.createModel()); + org.kie.kogito.process.Process definition = IntermediateCatchEventTimerCycle3Process + .newProcess(app); + org.kie.kogito.process.ProcessInstance instance = definition + .createInstance(definition.createModel()); instance.start(); latch.await(5, TimeUnit.SECONDS); assertThat(instance.status()).isEqualTo(org.kie.kogito.process.ProcessInstance.STATE_ACTIVE); @@ -1925,8 +1824,10 @@ public void afterProcessCompleted(ProcessCompletedEvent event) { latch.countDown(); } }); - org.kie.kogito.process.Process definition = IntermediateCatchEventTimerCycleCronProcess.newProcess(app); - org.kie.kogito.process.ProcessInstance instance = definition.createInstance(definition.createModel()); + org.kie.kogito.process.Process definition = IntermediateCatchEventTimerCycleCronProcess + .newProcess(app); + org.kie.kogito.process.ProcessInstance instance = definition + .createInstance(definition.createModel()); instance.start(); latch.await(5, TimeUnit.SECONDS); assertThat(instance.status()).isEqualTo(org.kie.kogito.process.ProcessInstance.STATE_COMPLETED); @@ -1936,8 +1837,10 @@ public void afterProcessCompleted(ProcessCompletedEvent event) { public void testIntermediateCatchSignalBetweenUserTasksModel() throws Exception { Application app = ProcessTestHelper.newApplication(); ProcessTestHelper.registerHandler(app, "Human Task", new SystemOutWorkItemHandler()); - org.kie.kogito.process.Process definition = IntermediateCatchSignalBetweenUserTasksProcess.newProcess(app); - org.kie.kogito.process.ProcessInstance instance = definition.createInstance(definition.createModel()); + org.kie.kogito.process.Process definition = IntermediateCatchSignalBetweenUserTasksProcess + .newProcess(app); + org.kie.kogito.process.ProcessInstance instance = definition + .createInstance(definition.createModel()); instance.start(); assertThat(instance.status()).isEqualTo(org.kie.kogito.process.ProcessInstance.STATE_ACTIVE); instance.send(Sig.of("MySignal", null)); @@ -1947,8 +1850,10 @@ public void testIntermediateCatchSignalBetweenUserTasksModel() throws Exception @Test public void testIntermediateCatchEventTimerDurationWithError() throws Exception { Application app = ProcessTestHelper.newApplication(); - org.kie.kogito.process.Process definition = IntermediateCatchEventTimerDurationWithErrorProcess.newProcess(app); - IntermediateCatchEventTimerDurationWithErrorProcessInstance instance = (IntermediateCatchEventTimerDurationWithErrorProcessInstance) definition.createInstance(definition.createModel()); + org.kie.kogito.process.Process definition = IntermediateCatchEventTimerDurationWithErrorProcess + .newProcess(app); + IntermediateCatchEventTimerDurationWithErrorProcessInstance instance = (IntermediateCatchEventTimerDurationWithErrorProcessInstance) definition + .createInstance(definition.createModel()); instance.start(); CompletionKogitoEventListener listener = ProcessTestHelper.registerCompletionEventListener(instance); listener.await(); @@ -1961,9 +1866,11 @@ public void testIntermediateCatchEventTimerDurationWithError() throws Exception public void testIntermediateCatchEventMessageWithTransformation() throws Exception { Application app = ProcessTestHelper.newApplication(); ProcessTestHelper.registerHandler(app, "Human Task", new SystemOutWorkItemHandler()); - org.kie.kogito.process.Process definition = IntermediateCatchEventMessageWithTransformationProcess.newProcess(app); + org.kie.kogito.process.Process definition = IntermediateCatchEventMessageWithTransformationProcess + .newProcess(app); - org.kie.kogito.process.ProcessInstance instance = definition.createInstance(definition.createModel()); + org.kie.kogito.process.ProcessInstance instance = definition + .createInstance(definition.createModel()); instance.start(); instance.send(Sig.of("Message-HelloMessage", "SomeValue")); @@ -1973,28 +1880,38 @@ public void testIntermediateCatchEventMessageWithTransformation() throws Excepti } @Test - @Disabled("Transfomer has been disabled") + public void testEventSubprocessSignalWithTransformation() throws Exception { - kruntime = createKogitoProcessRuntime("BPMN2-EventSubprocessSignalWithTransformation.bpmn2"); + Application app = ProcessTestHelper.newApplication(); TestWorkItemHandler workItemHandler = new TestWorkItemHandler(); - kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Human Task", - workItemHandler); - KogitoProcessInstance processInstance = kruntime.startProcess("BPMN2-EventSubprocessSignal"); - assertProcessInstanceActive(processInstance); + ProcessTestHelper.registerHandler(app, "Human Task", workItemHandler); - kruntime.signalEvent("MySignal", "john", processInstance.getStringId()); + EventTrackerProcessListener trackerListener = new EventTrackerProcessListener(); + ProcessTestHelper.registerProcessEventListener(app, trackerListener); + org.kie.kogito.process.Process definition = EventSubprocessSignalWithTransformationProcess + .newProcess(app); + org.kie.kogito.process.ProcessInstance instance = definition + .createInstance(definition.createModel()); - assertProcessInstanceFinished(processInstance, kruntime); - assertNodeTriggered(processInstance.getStringId(), "start", "User Task 1", - "Sub Process 1", "start-sub", "end-sub"); + instance.start(); - String var = getProcessVarValue(processInstance, "x"); - assertThat(var).isNotNull().isEqualTo("JOHN"); + assertThat(instance.status()).isEqualTo(org.kie.kogito.process.ProcessInstance.STATE_ACTIVE); + + instance.send(Sig.of("MySignal", "john")); + + assertThat(trackerListener.tracked()).anyMatch(ProcessTestHelper.triggered("start")) + .anyMatch(ProcessTestHelper.triggered("User Task 1")) + .anyMatch(ProcessTestHelper.left("Sub Process 1")) + .anyMatch(ProcessTestHelper.left("start-sub")) + .anyMatch(ProcessTestHelper.triggered("end-sub")); + + assertThat(instance.variables().getX()).isNotNull().isEqualTo("JOHN"); } @Test public void testMultipleMessageSignalSubprocess() throws Exception { - kruntime = createKogitoProcessRuntime("org/jbpm/bpmn2/intermediate/BPMN2-MultipleMessageSignalSubprocess.bpmn2"); + kruntime = createKogitoProcessRuntime( + "org/jbpm/bpmn2/intermediate/BPMN2-MultipleMessageSignalSubprocess.bpmn2"); KogitoProcessInstance processInstance = kruntime.startProcess("MultipleMessageSignalSubprocess"); logger.debug("Parent Process ID: " + processInstance.getStringId()); @@ -2007,7 +1924,8 @@ public void testMultipleMessageSignalSubprocess() throws Exception { @Test public void testIntermediateCatchEventSignalWithRef() throws Exception { - kruntime = createKogitoProcessRuntime("org/jbpm/bpmn2/intermediate/BPMN2-IntermediateCatchEventSignalWithRef.bpmn2"); + kruntime = createKogitoProcessRuntime( + "org/jbpm/bpmn2/intermediate/BPMN2-IntermediateCatchEventSignalWithRef.bpmn2"); kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Human Task", new SystemOutWorkItemHandler()); KogitoProcessInstance processInstance = kruntime.startProcess("IntermediateCatchEventSignalWithRef"); assertProcessInstanceActive(processInstance); @@ -2020,33 +1938,165 @@ public void testIntermediateCatchEventSignalWithRef() throws Exception { } @Test - public void testTimerMultipleInstances() throws Exception { + public void testMultiInstanceLoopBoundaryTimer() throws Exception { + Application app = ProcessTestHelper.newApplication(); NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("timer", 3); - kruntime = createKogitoProcessRuntime("BPMN2-MultiInstanceLoopBoundaryTimer.bpmn2"); - kruntime.getProcessEventManager().addEventListener(countDownListener); + ProcessTestHelper.registerProcessEventListener(app, countDownListener); TestWorkItemHandler handler = new TestWorkItemHandler(); + ProcessTestHelper.registerHandler(app, "Human Task", handler); - kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Human Task", handler); - KogitoProcessInstance processInstance = kruntime.startProcess("MultiInstanceLoopBoundaryTimer"); - assertProcessInstanceActive(processInstance); + org.kie.kogito.process.Process definition = MultiInstanceLoopBoundaryTimerProcess.newProcess(app); + org.kie.kogito.process.ProcessInstance instance = definition.createInstance(definition.createModel()); + instance.start(); + + assertThat(instance.status()).isEqualTo(org.kie.kogito.process.ProcessInstance.STATE_ACTIVE); countDownListener.waitTillCompleted(); List workItems = handler.getWorkItems(); assertThat(workItems).isNotNull().hasSize(3); - for (KogitoWorkItem wi : workItems) { - kruntime.getKogitoWorkItemManager().completeWorkItem(wi.getStringId(), null); - } + ProcessTestHelper.completeWorkItem(instance, "john", Collections.emptyMap()); + ProcessTestHelper.completeWorkItem(instance, "mary", Collections.emptyMap()); + ProcessTestHelper.completeWorkItem(instance, "krisv", Collections.emptyMap()); - assertProcessInstanceFinished(processInstance, kruntime); + assertThat(instance.status()).isEqualTo(org.kie.kogito.process.ProcessInstance.STATE_COMPLETED); + } + + @Test + public void testMultiInstanceLoopCharacteristicsProcessSequential() throws Exception { + Application app = ProcessTestHelper.newApplication(); + TestWorkItemHandler handler = new TestWorkItemHandler(); + ProcessTestHelper.registerHandler(app, "Human Task", handler); + + org.kie.kogito.process.Process definition = MultiInstanceLoopCharacteristicsProcessSequentialProcess.newProcess(app); + MultiInstanceLoopCharacteristicsProcessSequentialModel model = definition.createModel(); + model.setList(List.of(1, 2, 3)); + org.kie.kogito.process.ProcessInstance instance = definition.createInstance(model); + instance.start(); + + assertThat(instance.status()).isEqualTo(org.kie.kogito.process.ProcessInstance.STATE_ACTIVE); + + assertThat(handler.getWorkItems()).isNotNull().hasSize(1); + ProcessTestHelper.completeWorkItem(instance, "john", Collections.emptyMap()); + + assertThat(handler.getWorkItems()).isNotNull().hasSize(1); + ProcessTestHelper.completeWorkItem(instance, "john", Collections.emptyMap()); + + assertThat(handler.getWorkItems()).isNotNull().hasSize(1); + ProcessTestHelper.completeWorkItem(instance, "john", Collections.emptyMap()); + assertThat(instance.status()).isEqualTo(org.kie.kogito.process.ProcessInstance.STATE_COMPLETED); + } + + @Test + public void testMultiInstanceLoopCharacteristicsProcessWithOutputAndScripts() throws Exception { + Application app = ProcessTestHelper.newApplication(); + TestWorkItemHandler handler = new TestWorkItemHandler(); + ProcessTestHelper.registerHandler(app, "Human Task", handler); + + org.kie.kogito.process.Process definition = + MultiInstanceLoopCharacteristicsProcessWithOutputAndScriptsProcess.newProcess(app); + MultiInstanceLoopCharacteristicsProcessWithOutputAndScriptsModel model = definition.createModel(); + model.setList(new ArrayList<>(List.of("1", "2", "3"))); + model.setScriptList(new ArrayList()); + org.kie.kogito.process.ProcessInstance instance = definition.createInstance(model); + instance.start(); + + assertThat(instance.variables().getListOut()).containsExactly("1 changed", "2 changed", "3 changed"); + + assertThat(instance.status()).isEqualTo(org.kie.kogito.process.ProcessInstance.STATE_COMPLETED); + } + + @Test + public void testMultiInstanceLoopCharacteristicsTask() throws Exception { + Application app = ProcessTestHelper.newApplication(); + TestWorkItemHandler handler = new TestWorkItemHandler(); + ProcessTestHelper.registerHandler(app, "Human Task", handler); + + org.kie.kogito.process.Process definition = MultiInstanceLoopCharacteristicsTaskProcess.newProcess(app); + MultiInstanceLoopCharacteristicsTaskModel model = definition.createModel(); + model.setList(new ArrayList<>(List.of("1", "2", "3"))); + + org.kie.kogito.process.ProcessInstance instance = definition.createInstance(model); + instance.start(); + + List workItems = handler.getWorkItems(); + assertThat(workItems).isNotNull().hasSize(3); + assertThat(workItems.get(0).getParameter("Item")).isEqualTo("1"); + assertThat(workItems.get(1).getParameter("Item")).isEqualTo("2"); + assertThat(workItems.get(2).getParameter("Item")).isEqualTo("3"); + ProcessTestHelper.completeWorkItem(instance, "john", Collections.emptyMap()); + ProcessTestHelper.completeWorkItem(instance, "john", Collections.emptyMap()); + ProcessTestHelper.completeWorkItem(instance, "john", Collections.emptyMap()); + + assertThat(instance.status()).isEqualTo(org.kie.kogito.process.ProcessInstance.STATE_COMPLETED); + } + + @Test + public void testMultiInstanceLoopCharacteristicsTaskSequential() throws Exception { + Application app = ProcessTestHelper.newApplication(); + TestWorkItemHandler handler = new TestWorkItemHandler(); + ProcessTestHelper.registerHandler(app, "Human Task", handler); + + org.kie.kogito.process.Process definition = MultiInstanceLoopCharacteristicsTaskSequentialProcess.newProcess(app); + MultiInstanceLoopCharacteristicsTaskSequentialModel model = definition.createModel(); + model.setList(new ArrayList<>(List.of("1", "2", "3"))); + + org.kie.kogito.process.ProcessInstance instance = definition.createInstance(model); + instance.start(); + + List workItems = null; + workItems = handler.getWorkItems(); + assertThat(workItems).isNotNull().hasSize(1); + assertThat(workItems.get(0).getParameter("Item")).isEqualTo("1"); + ProcessTestHelper.completeWorkItem(instance, "john", Collections.emptyMap()); + + workItems = handler.getWorkItems(); + assertThat(workItems).isNotNull().hasSize(1); + assertThat(workItems.get(0).getParameter("Item")).isEqualTo("2"); + ProcessTestHelper.completeWorkItem(instance, "john", Collections.emptyMap()); + + workItems = handler.getWorkItems(); + assertThat(workItems).isNotNull().hasSize(1); + assertThat(workItems.get(0).getParameter("Item")).isEqualTo("3"); + ProcessTestHelper.completeWorkItem(instance, "john", Collections.emptyMap()); + + assertThat(instance.status()).isEqualTo(org.kie.kogito.process.ProcessInstance.STATE_COMPLETED); + } + + @Test + public void testMultiInstanceLoopCharacteristicsTaskWithOutputCmpCondSequential() throws Exception { + Application app = ProcessTestHelper.newApplication(); + TestWorkItemHandler handler = new TestWorkItemHandler(); + ProcessTestHelper.registerHandler(app, "Human Task", handler); + + org.kie.kogito.process.Process definition = + MultiInstanceLoopCharacteristicsTaskWithOutputCmpCondSequentialProcess.newProcess(app); + MultiInstanceLoopCharacteristicsTaskWithOutputCmpCondSequentialModel model = definition.createModel(); + model.setList(new ArrayList<>(List.of("1", "2", "3"))); + model.setListOut(new ArrayList()); + + org.kie.kogito.process.ProcessInstance instance = definition.createInstance(model); + instance.start(); + + List workItems = null; + workItems = handler.getWorkItems(); + assertThat(workItems).isNotNull().hasSize(1); + assertThat(workItems.get(0).getParameter("Item")).isEqualTo("1"); + ProcessTestHelper.completeWorkItem(instance, "john", Collections.emptyMap()); + + assertThat(instance.status()).isEqualTo(org.kie.kogito.process.ProcessInstance.STATE_COMPLETED); + assertThat(instance.variables().getListOut()).hasSize(1); } @Test public void testIntermediateTimerParallelGateway() throws Exception { - NodeLeftCountDownProcessEventListener countDownListener1 = new NodeLeftCountDownProcessEventListener("Timer1", 1); - NodeLeftCountDownProcessEventListener countDownListener2 = new NodeLeftCountDownProcessEventListener("Timer2", 1); - NodeLeftCountDownProcessEventListener countDownListener3 = new NodeLeftCountDownProcessEventListener("Timer3", 1); + NodeLeftCountDownProcessEventListener countDownListener1 = new NodeLeftCountDownProcessEventListener("Timer1", + 1); + NodeLeftCountDownProcessEventListener countDownListener2 = new NodeLeftCountDownProcessEventListener("Timer2", + 1); + NodeLeftCountDownProcessEventListener countDownListener3 = new NodeLeftCountDownProcessEventListener("Timer3", + 1); ProcessCompletedCountDownProcessEventListener countDownProcessEventListener = new ProcessCompletedCountDownProcessEventListener(); kruntime = createKogitoProcessRuntime("org/jbpm/bpmn2/timer/BPMN2-IntermediateTimerParallelGateway.bpmn2"); kruntime.getProcessEventManager().addEventListener(countDownListener1); @@ -2069,7 +2119,8 @@ public void testIntermediateTimerParallelGateway() throws Exception { @Test public void testIntermediateTimerEventMI() throws Exception { - NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("After timer", 3); + NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener( + "After timer", 3); kruntime = createKogitoProcessRuntime("org/jbpm/bpmn2/timer/BPMN2-IntermediateTimerEventMI.bpmn2"); kruntime.getProcessEventManager().addEventListener(countDownListener); TestWorkItemHandler handler = new TestWorkItemHandler(); @@ -2160,7 +2211,8 @@ public void testThrowEndSignalWithScope() throws Exception { @Test public void testThrowIntermediateSignalWithExternalScope() throws Exception { - kruntime = createKogitoProcessRuntime("org/jbpm/bpmn2/intermediate/BPMN2-IntermediateThrowEventExternalScope.bpmn2"); + kruntime = createKogitoProcessRuntime( + "org/jbpm/bpmn2/intermediate/BPMN2-IntermediateThrowEventExternalScope.bpmn2"); TestWorkItemHandler handler = new TestWorkItemHandler(); KogitoWorkItemHandler externalHandler = new KogitoWorkItemHandler() { @@ -2203,13 +2255,15 @@ public void abortWorkItem(KogitoWorkItem workItem, KogitoWorkItemManager manager @Test public void testIntermediateCatchEventSignalWithVariable() throws Exception { - kruntime = createKogitoProcessRuntime("org/jbpm/bpmn2/intermediate/BPMN2-IntermediateCatchEventSignalWithVariable.bpmn2"); + kruntime = createKogitoProcessRuntime( + "org/jbpm/bpmn2/intermediate/BPMN2-IntermediateCatchEventSignalWithVariable.bpmn2"); kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Human Task", new SystemOutWorkItemHandler()); String signalVar = "myVarSignal"; Map parameters = new HashMap<>(); parameters.put("signalName", signalVar); - KogitoProcessInstance processInstance = kruntime.startProcess("IntermediateCatchEventSignalWithVariable", parameters); + KogitoProcessInstance processInstance = kruntime.startProcess("IntermediateCatchEventSignalWithVariable", + parameters); assertProcessInstanceActive(processInstance); // now signal process instance @@ -2229,13 +2283,15 @@ public void testSignalIntermediateThrowWithVariable() throws Exception { String signalVar = "myVarSignal"; Map parameters = new HashMap<>(); parameters.put("signalName", signalVar); - KogitoProcessInstance processInstance = kruntime.startProcess("IntermediateCatchEventSignalWithVariable", parameters); + KogitoProcessInstance processInstance = kruntime.startProcess("IntermediateCatchEventSignalWithVariable", + parameters); assertProcessInstanceActive(processInstance); Map params = new HashMap<>(); params.put("x", "MyValue"); params.put("signalName", signalVar); - KogitoProcessInstance processInstanceThrow = kruntime.startProcess("IntermediateThrowEventSignalWithVariable", params); + KogitoProcessInstance processInstanceThrow = kruntime.startProcess("IntermediateThrowEventSignalWithVariable", + params); assertThat(processInstanceThrow.getState()).isEqualTo(KogitoProcessInstance.STATE_COMPLETED); // catch process instance should now be completed @@ -2275,9 +2331,11 @@ public void testInvalidCycleTimerBoundary() throws Exception { @Test public void testIntermediateCatchEventConditionSetVariableAfter() throws Exception { - kruntime = createKogitoProcessRuntime("org/jbpm/bpmn2/intermediate/BPMN2-IntermediateCatchEventConditionSetVariableAfter.bpmn2"); + kruntime = createKogitoProcessRuntime( + "org/jbpm/bpmn2/intermediate/BPMN2-IntermediateCatchEventConditionSetVariableAfter.bpmn2"); kruntime.getProcessEventManager().addEventListener(new RuleAwareProcessEventListener()); - KogitoProcessInstance processInstance = kruntime.startProcess("IntermediateCatchEventConditionSetVariableAfter"); + KogitoProcessInstance processInstance = kruntime + .startProcess("IntermediateCatchEventConditionSetVariableAfter"); assertProcessInstanceActive(processInstance); kruntime.getProcessEventManager().addEventListener(new RuleAwareProcessEventListener()); @@ -2307,7 +2365,8 @@ public void testIntermediateCatchEventConditionSetVariableAfter() throws Excepti @Test public void testIntermediateCatchEventConditionRemovePIAfter() throws Exception { - kruntime = createKogitoProcessRuntime("org/jbpm/bpmn2/intermediate/BPMN2-IntermediateCatchEventCondition.bpmn2"); + kruntime = createKogitoProcessRuntime( + "org/jbpm/bpmn2/intermediate/BPMN2-IntermediateCatchEventCondition.bpmn2"); kruntime.getProcessEventManager().addEventListener(new RuleAwareProcessEventListener()); KogitoProcessInstance processInstance = kruntime.startProcess("IntermediateCatchEventCondition"); assertProcessInstanceActive(processInstance); @@ -2341,10 +2400,14 @@ public void testIntermediateCatchEventConditionRemovePIAfter() throws Exception public void testEventBasedSplitWithCronTimerAndSignal() throws Exception { System.setProperty("jbpm.enable.multi.con", "true"); try { - NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("Request photos of order in use", 1); - NodeLeftCountDownProcessEventListener countDownListener2 = new NodeLeftCountDownProcessEventListener("Request an online review", 1); - NodeLeftCountDownProcessEventListener countDownListener3 = new NodeLeftCountDownProcessEventListener("Send a thank you card", 1); - NodeLeftCountDownProcessEventListener countDownListener4 = new NodeLeftCountDownProcessEventListener("Request an online review", 1); + NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener( + "Request photos of order in use", 1); + NodeLeftCountDownProcessEventListener countDownListener2 = new NodeLeftCountDownProcessEventListener( + "Request an online review", 1); + NodeLeftCountDownProcessEventListener countDownListener3 = new NodeLeftCountDownProcessEventListener( + "Send a thank you card", 1); + NodeLeftCountDownProcessEventListener countDownListener4 = new NodeLeftCountDownProcessEventListener( + "Request an online review", 1); kruntime = createKogitoProcessRuntime("timer/BPMN2-CronTimerWithEventBasedGateway.bpmn2"); TestWorkItemHandler handler = new TestWorkItemHandler(); @@ -2381,8 +2444,10 @@ public void testEventBasedSplitWithCronTimerAndSignal() throws Exception { public void testEventSubprocessWithEmbeddedSignals() throws Exception { Application app = ProcessTestHelper.newApplication(); - org.kie.kogito.process.Process definition = EventSubprocessErrorSignalEmbeddedProcess.newProcess(app); - org.kie.kogito.process.ProcessInstance instance = definition.createInstance(definition.createModel()); + org.kie.kogito.process.Process definition = EventSubprocessErrorSignalEmbeddedProcess + .newProcess(app); + org.kie.kogito.process.ProcessInstance instance = definition + .createInstance(definition.createModel()); instance.start(); instance.send(Sig.of("signal1", null)); assertThat(instance.status()).isEqualTo(org.kie.kogito.process.ProcessInstance.STATE_ACTIVE); @@ -2394,7 +2459,8 @@ public void testEventSubprocessWithEmbeddedSignals() throws Exception { @Test public void testEventSubprocessWithExpression() throws Exception { - kruntime = createKogitoProcessRuntime("org/jbpm/bpmn2/intermediate/BPMN2-EventSubprocessSignalExpression.bpmn2"); + kruntime = createKogitoProcessRuntime( + "org/jbpm/bpmn2/intermediate/BPMN2-EventSubprocessSignalExpression.bpmn2"); TestWorkItemHandler handler = new TestWorkItemHandler(); kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Human Task", handler); Map params = new HashMap<>(); @@ -2410,7 +2476,9 @@ public void testEventSubprocessWithExpression() throws Exception { @Test public void testConditionalProcessFactInsertedBefore() throws Exception { - kruntime = createKogitoProcessRuntime("org/jbpm/bpmn2/intermediate/BPMN2-IntermediateCatchEventConditionPI.bpmn2", "org/jbpm/bpmn2/intermediate/BPMN2-IntermediateCatchEventSignal.bpmn2"); + kruntime = createKogitoProcessRuntime( + "org/jbpm/bpmn2/intermediate/BPMN2-IntermediateCatchEventConditionPI.bpmn2", + "org/jbpm/bpmn2/intermediate/BPMN2-IntermediateCatchEventSignal.bpmn2"); TestWorkItemHandler handler = new TestWorkItemHandler(); kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Human Task", handler); Person person0 = new Person("john"); @@ -2441,13 +2509,15 @@ public void testConditionalProcessFactInsertedBefore() throws Exception { @Test public void testBoundarySignalEventOnSubprocessWithVariableResolution() throws Exception { - kruntime = createKogitoProcessRuntime("org/jbpm/bpmn2/intermediate/BPMN2-SubprocessWithSignalEndEventAndSignalBoundaryEvent.bpmn2"); + kruntime = createKogitoProcessRuntime( + "org/jbpm/bpmn2/intermediate/BPMN2-SubprocessWithSignalEndEventAndSignalBoundaryEvent.bpmn2"); kruntime.getProcessEventManager().addEventListener(LOGGING_EVENT_LISTENER); Map params = new HashMap<>(); params.put("document-ref", "signalling"); params.put("message", "hello"); - KogitoProcessInstance processInstance = kruntime.startProcess("SubprocessWithSignalEndEventAndSignalBoundaryEvent", params); + KogitoProcessInstance processInstance = kruntime + .startProcess("SubprocessWithSignalEndEventAndSignalBoundaryEvent", params); assertNodeTriggered(processInstance.getStringId(), "sysout from boundary", "end2"); assertNotNodeTriggered(processInstance.getStringId(), "end1"); @@ -2457,10 +2527,10 @@ public void testBoundarySignalEventOnSubprocessWithVariableResolution() throws E @Test public void testSignalEndWithData() throws Exception { - kruntime = createKogitoProcessRuntime("org/jbpm/bpmn2/intermediate/BPMN2-IntermediateThrowEventSignalWithData.bpmn2"); + kruntime = createKogitoProcessRuntime( + "org/jbpm/bpmn2/intermediate/BPMN2-IntermediateThrowEventSignalWithData.bpmn2"); - kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Human Task", - new SystemOutWorkItemHandler()); + kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Human Task", new SystemOutWorkItemHandler()); Map params = new HashMap<>(); KogitoProcessInstance processInstance = kruntime.startProcess("IntermediateThrowEventSignalWithData", params); @@ -2475,7 +2545,8 @@ 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"); + 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<>(); @@ -2516,7 +2587,8 @@ public void beforeProcessStarted(ProcessStartedEvent event) { @Test @Disabled("On Exit not supported, see https://issues.redhat.com/browse/KOGITO-2067") public void testDynamicCatchEventSignalWithVariableUpdated() throws Exception { - kruntime = createKogitoProcessRuntime("subprocess/dynamic-signal-parent.bpmn2", "subprocess/dynamic-signal-child.bpmn2"); + 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<>(); @@ -2542,11 +2614,13 @@ public void beforeProcessStarted(ProcessStartedEvent event) { assertProcessInstanceActive(child); } - // change one child process instance variable (fatherId) to something else then original fatherId + // change one child process instance variable (fatherId) to something else then + // original fatherId String changeProcessInstanceId = instances.remove(0); Map updatedVariables = new HashMap<>(); updatedVariables.put("fatherId", "999"); - kruntime.getKieSession().execute(new KogitoSetProcessInstanceVariablesCommand(changeProcessInstanceId, updatedVariables)); + kruntime.getKieSession() + .execute(new KogitoSetProcessInstanceVariablesCommand(changeProcessInstanceId, updatedVariables)); // now complete user task to signal all child instances to stop KogitoWorkItem workItem = handler.getWorkItem(); @@ -2570,7 +2644,8 @@ public void beforeProcessStarted(ProcessStartedEvent event) { @Test @Disabled("On Exit not supported, see https://issues.redhat.com/browse/KOGITO-2067") public void testDynamicCatchEventSignalWithVariableUpdatedBroadcastSignal() throws Exception { - kruntime = createKogitoProcessRuntime("subprocess/dynamic-signal-parent.bpmn2", "subprocess/dynamic-signal-child.bpmn2"); + 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<>(); @@ -2596,11 +2671,13 @@ public void beforeProcessStarted(ProcessStartedEvent event) { assertProcessInstanceActive(child); } - // change one child process instance variable (fatherId) to something else then original fatherId + // change one child process instance variable (fatherId) to something else then + // original fatherId String changeProcessInstanceId = instances.remove(0); Map updatedVariables = new HashMap<>(); updatedVariables.put("fatherId", "999"); - kruntime.getKieSession().execute(new KogitoSetProcessInstanceVariablesCommand(changeProcessInstanceId, updatedVariables)); + kruntime.getKieSession() + .execute(new KogitoSetProcessInstanceVariablesCommand(changeProcessInstanceId, updatedVariables)); // now complete user task to signal all child instances to stop KogitoWorkItem workItem = handler.getWorkItem(); diff --git a/jbpm/jbpm-tests/src/test/java/org/jbpm/bpmn2/StandaloneBPMNProcessTest.java b/jbpm/jbpm-tests/src/test/java/org/jbpm/bpmn2/StandaloneBPMNProcessTest.java index 640515b1e1d..2e0093de5e6 100755 --- a/jbpm/jbpm-tests/src/test/java/org/jbpm/bpmn2/StandaloneBPMNProcessTest.java +++ b/jbpm/jbpm-tests/src/test/java/org/jbpm/bpmn2/StandaloneBPMNProcessTest.java @@ -204,18 +204,6 @@ public void testExclusiveSplit() throws Exception { assertThat(processInstance.getState()).isEqualTo(KogitoProcessInstance.STATE_COMPLETED); } - @Test - public void testExclusiveSplitDefault() throws Exception { - kruntime = createKogitoProcessRuntime("BPMN2-ExclusiveSplitDefault.bpmn2"); - - kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Email", new SystemOutWorkItemHandler()); - Map params = new HashMap<>(); - params.put("x", "NotFirst"); - params.put("y", "Second"); - KogitoProcessInstance processInstance = kruntime.startProcess("ExclusiveSplitDefault", params); - assertThat(processInstance.getState()).isEqualTo(KogitoProcessInstance.STATE_COMPLETED); - } - @Test public void testInclusiveSplit() throws Exception { kruntime = createKogitoProcessRuntime("org/jbpm/bpmn2/flow/BPMN2-InclusiveSplit.bpmn2"); @@ -226,16 +214,6 @@ public void testInclusiveSplit() throws Exception { assertThat(processInstance.getState()).isEqualTo(KogitoProcessInstance.STATE_COMPLETED); } - @Test - public void testInclusiveSplitDefault() throws Exception { - kruntime = createKogitoProcessRuntime("BPMN2-InclusiveSplitDefault.bpmn2"); - - Map params = new HashMap<>(); - params.put("x", -5); - KogitoProcessInstance processInstance = kruntime.startProcess("InclusiveSplitDefault", params); - assertThat(processInstance.getState()).isEqualTo(KogitoProcessInstance.STATE_COMPLETED); - } - @Test @Disabled public void testExclusiveSplitXPath() throws Exception { @@ -528,7 +506,7 @@ public void testAdHocSubProcessAutoComplete() throws Exception { // adhoc we need to trigger the human task instance.triggerNode("_2-1"); - ProcessTestHelper.completeWorkItem(instance, "john", Collections.emptyMap()); + ProcessTestHelper.completeWorkItem(instance, Collections.emptyMap(), "john"); assertThat(instance.status()).isEqualTo(KogitoProcessInstance.STATE_COMPLETED); } @@ -547,7 +525,7 @@ public void testAdHocSubProcessAutoCompleteExpression() throws Exception { // adhoc we need to trigger the human task instance.triggerNode("_2-1"); - ProcessTestHelper.completeWorkItem(instance, "john", Collections.singletonMap("testHT", 0)); + ProcessTestHelper.completeWorkItem(instance, Collections.singletonMap("testHT", 0), "john"); assertThat(instance.status()).isEqualTo(KogitoProcessInstance.STATE_COMPLETED); } @@ -566,7 +544,7 @@ public void testAdHocTerminateEndEvent() throws Exception { // adhoc we need to trigger the human task instance.triggerNode("_560E157E-3173-4CFD-9CC6-26676D8B0A02"); - ProcessTestHelper.completeWorkItem(instance, "john", Collections.emptyMap()); + ProcessTestHelper.completeWorkItem(instance, Collections.emptyMap(), "john"); assertThat(instance.status()).isEqualTo(KogitoProcessInstance.STATE_COMPLETED); } diff --git a/jbpm/jbpm-tests/src/test/java/org/jbpm/bpmn2/StartEventTest.java b/jbpm/jbpm-tests/src/test/java/org/jbpm/bpmn2/StartEventTest.java index b85d0b41ef5..a5bd46317dd 100755 --- a/jbpm/jbpm-tests/src/test/java/org/jbpm/bpmn2/StartEventTest.java +++ b/jbpm/jbpm-tests/src/test/java/org/jbpm/bpmn2/StartEventTest.java @@ -29,13 +29,18 @@ import java.util.List; import java.util.Map; +import org.jbpm.bpmn2.event.ConditionalStartModel; +import org.jbpm.bpmn2.event.ConditionalStartProcess; import org.jbpm.bpmn2.objects.NotAvailableGoodsReport; import org.jbpm.bpmn2.objects.Person; import org.jbpm.bpmn2.objects.TestWorkItemHandler; import org.jbpm.bpmn2.start.SignalStartWithTransformationModel; import org.jbpm.bpmn2.start.SignalStartWithTransformationProcess; +import org.jbpm.process.instance.impl.demo.SystemOutWorkItemHandler; import org.jbpm.test.util.NodeLeftCountDownProcessEventListener; +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.KieServices; import org.kie.api.builder.KieRepository; @@ -57,10 +62,13 @@ public class StartEventTest extends JbpmBpmn2TestCase { @Test + @Disabled public void testConditionalStart() throws Exception { - kruntime = createKogitoProcessRuntime("BPMN2-ConditionalStart.bpmn2"); - final List startedInstances = new ArrayList<>(); - kruntime.getProcessEventManager().addEventListener(new DefaultKogitoProcessEventListener() { + Application app = ProcessTestHelper.newApplication(); + List startedInstances = new ArrayList<>(); + EventTrackerProcessListener listener = new EventTrackerProcessListener(); + ProcessTestHelper.registerProcessEventListener(app, listener); + ProcessTestHelper.registerProcessEventListener(app, new DefaultKogitoProcessEventListener() { @Override public void afterProcessStarted(ProcessStartedEvent event) { @@ -68,17 +76,20 @@ public void afterProcessStarted(ProcessStartedEvent event) { } }); + ProcessTestHelper.registerHandler(app, "Email", new SystemOutWorkItemHandler()); + org.kie.kogito.process.Process definition = ConditionalStartProcess.newProcess(app); + Person person = new Person(); person.setName("jack"); - kruntime.getKieSession().insert(person); - assertThat(startedInstances).isEmpty(); - person = new Person(); - person.setName("john"); - kruntime.getKieSession().insert(person); + definition.send(Sig.of("Conditional", person)); + assertThat(startedInstances).hasSize(1); - assertNodeTriggered(startedInstances.get(0), "StartProcess", "Hello", "EndProcess"); + assertThat(listener.tracked()) + .anyMatch(ProcessTestHelper.triggered("StartProcess")) + .anyMatch(ProcessTestHelper.triggered("Hello")) + .anyMatch(ProcessTestHelper.triggered("EndProcess")); } @Test diff --git a/jbpm/jbpm-tests/src/test/java/org/jbpm/bpmn2/structureref/StructureRefTest.java b/jbpm/jbpm-tests/src/test/java/org/jbpm/bpmn2/structureref/StructureRefTest.java index 8042b5f97a3..479720a0cbe 100755 --- a/jbpm/jbpm-tests/src/test/java/org/jbpm/bpmn2/structureref/StructureRefTest.java +++ b/jbpm/jbpm-tests/src/test/java/org/jbpm/bpmn2/structureref/StructureRefTest.java @@ -42,6 +42,7 @@ import org.kie.kogito.Application; import org.kie.kogito.internal.process.runtime.KogitoProcessInstance; import org.kie.kogito.process.bpmn2.BpmnVariables; +import org.kie.kogito.process.workitem.Policies; import jakarta.xml.bind.JAXBContext; import jakarta.xml.bind.JAXBException; @@ -64,8 +65,10 @@ public void testStringStructureRef() throws Exception { Map res = new HashMap<>(); res.put("testHT", "test value"); + kruntime.getKogitoWorkItemManager().completeWorkItem( - workItemHandler.getWorkItem().getStringId(), res); + workItemHandler.getWorkItem().getStringId(), res, + Policies.of("john")); assertProcessInstanceCompleted(processInstance.getStringId(), kruntime); } @@ -82,7 +85,7 @@ public void testBooleanStructureRef() throws Exception { instance.start(); assertThat(instance.status()).isEqualTo(org.kie.kogito.process.ProcessInstance.STATE_ACTIVE); - ProcessTestHelper.completeWorkItem(instance, "john", Collections.singletonMap("testHT", "true")); + ProcessTestHelper.completeWorkItem(instance, Collections.singletonMap("testHT", "true"), "john"); assertThat(instance.status()).isEqualTo(org.kie.kogito.process.ProcessInstance.STATE_COMPLETED); } @@ -101,7 +104,7 @@ public void testIntegerStructureRef() throws Exception { instance.start(); assertThat(instance.status()).isEqualTo(org.kie.kogito.process.ProcessInstance.STATE_ACTIVE); - ProcessTestHelper.completeWorkItem(instance, "john", Collections.singletonMap("testHT", value)); + ProcessTestHelper.completeWorkItem(instance, Collections.singletonMap("testHT", value), "john"); assertThat(instance.status()).isEqualTo(org.kie.kogito.process.ProcessInstance.STATE_COMPLETED); assertThat(instance.variables().getTest()).isEqualTo(Integer.valueOf(value)); @@ -122,7 +125,7 @@ public void testFloatStructureRef() throws Exception { instance.start(); assertThat(instance.status()).isEqualTo(org.kie.kogito.process.ProcessInstance.STATE_ACTIVE); - ProcessTestHelper.completeWorkItem(instance, "john", Collections.singletonMap("testHT", value)); + ProcessTestHelper.completeWorkItem(instance, Collections.singletonMap("testHT", value), "john"); assertThat(instance.status()).isEqualTo(org.kie.kogito.process.ProcessInstance.STATE_COMPLETED); assertThat(instance.variables().getTest()).isEqualTo(Float.valueOf(value)); @@ -153,7 +156,7 @@ public void testObjectStructureRef() throws Exception { instance.start(); assertThat(instance.status()).isEqualTo(org.kie.kogito.process.ProcessInstance.STATE_ACTIVE); - ProcessTestHelper.completeWorkItem(instance, "john", Collections.singletonMap("testHT", value)); + ProcessTestHelper.completeWorkItem(instance, Collections.singletonMap("testHT", value), "john"); assertThat(instance.status()).isEqualTo(org.kie.kogito.process.ProcessInstance.STATE_COMPLETED); assertThat(instance.variables().getTest()).isEqualTo(new Person(1, "john")); @@ -174,7 +177,7 @@ public void testDefaultObjectStructureRef() throws Exception { instance.start(); assertThat(instance.status()).isEqualTo(org.kie.kogito.process.ProcessInstance.STATE_ACTIVE); - ProcessTestHelper.completeWorkItem(instance, "john", Collections.singletonMap("testHT", value)); + ProcessTestHelper.completeWorkItem(instance, Collections.singletonMap("testHT", value), "john"); assertThat(instance.status()).isEqualTo(org.kie.kogito.process.ProcessInstance.STATE_COMPLETED); assertThat(instance.variables().getTest()).isEqualTo(value); @@ -222,7 +225,7 @@ public void testInvalidBooleanStructureRefOnWIComplete() throws Exception { assertThat(instance.status()).isEqualTo(org.kie.kogito.process.ProcessInstance.STATE_ACTIVE); try { - ProcessTestHelper.completeWorkItem(instance, "john", Collections.singletonMap("testHT", true)); + ProcessTestHelper.completeWorkItem(instance, Collections.singletonMap("testHT", true), "john"); fail(""); } catch (IllegalArgumentException iae) { logger.info("Expected IllegalArgumentException caught: " + iae); @@ -265,7 +268,7 @@ public void testNotExistingBooleanStructureRefOnWIComplete() throws Exception { assertThat(instance.status()).isEqualTo(org.kie.kogito.process.ProcessInstance.STATE_ACTIVE); try { - ProcessTestHelper.completeWorkItem(instance, "john", Collections.singletonMap(wrongDataOutput, true)); + ProcessTestHelper.completeWorkItem(instance, Collections.singletonMap(wrongDataOutput, true), "john"); fail("it should not work!"); } catch (IllegalArgumentException e) { assertThat(e.getMessage()).isEqualTo("Data output '" + wrongDataOutput + "' is not defined in process 'IntegerStructureRef' for task 'User Task'"); diff --git a/jbpm/jbpm-tests/src/test/java/org/jbpm/test/utils/ProcessTestHelper.java b/jbpm/jbpm-tests/src/test/java/org/jbpm/test/utils/ProcessTestHelper.java index 3db866f82bd..1b6cfbdeca1 100644 --- a/jbpm/jbpm-tests/src/test/java/org/jbpm/test/utils/ProcessTestHelper.java +++ b/jbpm/jbpm-tests/src/test/java/org/jbpm/test/utils/ProcessTestHelper.java @@ -18,6 +18,7 @@ */ package org.jbpm.test.utils; +import java.util.Arrays; import java.util.List; import java.util.Map; import java.util.concurrent.CountDownLatch; @@ -69,16 +70,38 @@ public static void registerHandler(Application app, String handlerName, KogitoWo ((DefaultWorkItemHandlerConfig) app.config().get(ProcessConfig.class).workItemHandlers()).register(handlerName, handler); } + /** + * Will be removed in favor of the {@link #completeWorkItem(ProcessInstance, Map, String, String...)} + */ + @Deprecated public static void completeWorkItem(ProcessInstance processInstance, String userName, Map outputVars) { - completeWorkItem(processInstance, userName, outputVars, item -> { - }); + completeWorkItem(processInstance, outputVars, item -> { + }, userName); } + /** + * Will be removed in favor of the {@link #completeWorkItem(ProcessInstance, Map, Consumer, String, String...)} + */ + @Deprecated public static void completeWorkItem(ProcessInstance processInstance, String userName, Map outputVars, Consumer workItem) { - List workItems = processInstance.workItems(SecurityPolicy.of(userName, emptyList())); + completeWorkItem(processInstance, outputVars, workItem, userName); + } + + public static void completeWorkItem(ProcessInstance processInstance, Map outputVars) { + completeWorkItem(processInstance, outputVars, item -> { + }, null); + } + + public static void completeWorkItem(ProcessInstance processInstance, Map outputVars, String userName, String... groups) { + completeWorkItem(processInstance, outputVars, item -> { + }, userName, groups); + } + + public static void completeWorkItem(ProcessInstance processInstance, Map outputVars, Consumer workItem, String userName, String... groups) { + List workItems = processInstance.workItems(SecurityPolicy.of(userName, Arrays.asList(groups))); workItems.stream().findFirst().ifPresent(e -> { workItem.accept(e); - processInstance.completeWorkItem(e.getId(), outputVars, SecurityPolicy.of(userName, emptyList())); + processInstance.completeWorkItem(e.getId(), outputVars, SecurityPolicy.of(userName, Arrays.asList(groups))); }); } diff --git a/jbpm/jbpm-tests/src/test/resources/BPMN2-StringStructureRef.bpmn2 b/jbpm/jbpm-tests/src/test/resources/BPMN2-StringStructureRef.bpmn2 index 184ccc9f0f6..60b94bb8129 100755 --- a/jbpm/jbpm-tests/src/test/resources/BPMN2-StringStructureRef.bpmn2 +++ b/jbpm/jbpm-tests/src/test/resources/BPMN2-StringStructureRef.bpmn2 @@ -1,99 +1,183 @@ - - - - - - - - - - - - - - - - - - - - - _2_testHTOutput - - - - _2_testHTOutput - test - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + _1-_2 + + + + + + + + _1-_2 + _2-_3 + + + + + + _2_TaskNameInputX + _2_SkippableInputX + + + _2_testHTOutputX + + + + _2_TaskNameInputX + + + + + + + _2_SkippableInputX + + + + + + + _2_testHTOutputX + test + + + + john + + + + + + + + + + _2-_3 + _3-_4 + System.out.println("Result "+test); + + + + + + + + _3-_4 + + + - - - + + + - - + + - - + + - - + + - - - + + + - - - + + + - - - + + + - - \ No newline at end of file + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + _YAgnYCW3ED28RYvCqRMntQ + _YAgnYCW3ED28RYvCqRMntQ + + \ No newline at end of file diff --git a/jbpm/jbpm-tools/jbpm-tools-maven-plugin/src/test/resources/unit/project/src/main/bpmn/BPMN2-BoundaryErrorEventDefaultHandlerWithoutErrorCodeWithStructureRef.bpmn2 b/jbpm/jbpm-tools/jbpm-tools-maven-plugin/src/test/resources/unit/project/src/main/bpmn/BPMN2-BoundaryErrorEventDefaultHandlerWithoutErrorCodeWithStructureRef.bpmn2 deleted file mode 100755 index 877c96ebe26..00000000000 --- a/jbpm/jbpm-tools/jbpm-tools-maven-plugin/src/test/resources/unit/project/src/main/bpmn/BPMN2-BoundaryErrorEventDefaultHandlerWithoutErrorCodeWithStructureRef.bpmn2 +++ /dev/null @@ -1,234 +0,0 @@ - - - - - - - - - - - - - - - - - - SequenceFlow_3 - - - SequenceFlow_3 - SequenceFlow_4 - - SequenceFlow_5 - SequenceFlow_6 - - - - - - - - - - - _DataInput_9 - _DataInput_10 - _DataInput_11 - _DataInput_12 - _DataInput_13 - _DataInput_14 - _DataInput_15 - - - - - - _DataInput_9 - - - _DataInput_10 - - - _DataInput_11 - - - _DataInput_12 - - - _DataInput_13 - - - _DataInput_14 - - - _DataInput_15 - - - - SequenceFlow_5 - - - - SequenceFlow_6 - - - - - - - SequenceFlow_7 - - - DataOutput_1 - var1 - - - DataOutput_1 - - - - - SequenceFlow_7 - SequenceFlow_8 - System.out.println("Error is handled : var1 = " + var1); - - - - SequenceFlow_8 - - - - SequenceFlow_4 - SequenceFlow_9 - System.out.println("Process is finishing"); - - - SequenceFlow_9 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/jbpm/jbpm-tools/jbpm-tools-maven-plugin/src/test/resources/unit/project/src/main/bpmn/BPMN2-BoundaryErrorEventDefaultHandlerWithoutErrorCodeWithoutStructureRef.bpmn2 b/jbpm/jbpm-tools/jbpm-tools-maven-plugin/src/test/resources/unit/project/src/main/bpmn/BPMN2-BoundaryErrorEventDefaultHandlerWithoutErrorCodeWithoutStructureRef.bpmn2 deleted file mode 100755 index 470d99feab0..00000000000 --- a/jbpm/jbpm-tools/jbpm-tools-maven-plugin/src/test/resources/unit/project/src/main/bpmn/BPMN2-BoundaryErrorEventDefaultHandlerWithoutErrorCodeWithoutStructureRef.bpmn2 +++ /dev/null @@ -1,234 +0,0 @@ - - - - - - - - - - - - - - - - - - SequenceFlow_3 - - - SequenceFlow_3 - SequenceFlow_4 - - SequenceFlow_5 - SequenceFlow_6 - - - - - - - - - - - _DataInput_9 - _DataInput_10 - _DataInput_11 - _DataInput_12 - _DataInput_13 - _DataInput_14 - _DataInput_15 - - - - - - _DataInput_9 - - - _DataInput_10 - - - _DataInput_11 - - - _DataInput_12 - - - _DataInput_13 - - - _DataInput_14 - - - _DataInput_15 - - - - SequenceFlow_5 - - - - SequenceFlow_6 - - - - - - - SequenceFlow_7 - - - DataOutput_1 - var1 - - - DataOutput_1 - - - - - SequenceFlow_7 - SequenceFlow_8 - System.out.println("Error is handled : var1 = " + var1); - - - - SequenceFlow_8 - - - - SequenceFlow_4 - SequenceFlow_9 - System.out.println("Process is finishing"); - - - SequenceFlow_9 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/jbpm/jbpm-tools/jbpm-tools-maven-plugin/src/test/resources/unit/project/src/main/bpmn/BPMN2-BoundaryErrorEventSubProcessExceptionMapping.bpmn2 b/jbpm/jbpm-tools/jbpm-tools-maven-plugin/src/test/resources/unit/project/src/main/bpmn/BPMN2-BoundaryErrorEventSubProcessExceptionMapping.bpmn2 deleted file mode 100755 index 5c77c5460dd..00000000000 --- a/jbpm/jbpm-tools/jbpm-tools-maven-plugin/src/test/resources/unit/project/src/main/bpmn/BPMN2-BoundaryErrorEventSubProcessExceptionMapping.bpmn2 +++ /dev/null @@ -1,234 +0,0 @@ - - - - - - - - - - - - - - - - - - SequenceFlow_3 - - - SequenceFlow_3 - SequenceFlow_4 - - SequenceFlow_5 - SequenceFlow_6 - - - - - - - - - - - _DataInput_9 - _DataInput_10 - _DataInput_11 - _DataInput_12 - _DataInput_13 - _DataInput_14 - _DataInput_15 - - - - - - _DataInput_9 - - - _DataInput_10 - - - _DataInput_11 - - - _DataInput_12 - - - _DataInput_13 - - - _DataInput_14 - - - _DataInput_15 - - - - SequenceFlow_5 - - - - SequenceFlow_6 - - - - - - - SequenceFlow_7 - - - DataOutput_1 - var1 - - - DataOutput_1 - - - - - SequenceFlow_7 - SequenceFlow_8 - System.out.println("Error is handled : var1 = " + var1); - - - - SequenceFlow_8 - - - - SequenceFlow_4 - SequenceFlow_9 - System.out.println("Process is finishing"); - - - SequenceFlow_9 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/jbpm/jbpm-tools/jbpm-tools-maven-plugin/src/test/resources/unit/project/src/main/bpmn/BPMN2-ConditionalFlowWithoutGateway.bpmn2 b/jbpm/jbpm-tools/jbpm-tools-maven-plugin/src/test/resources/unit/project/src/main/bpmn/BPMN2-ConditionalFlowWithoutGateway.bpmn2 new file mode 100755 index 00000000000..63a64e43fa0 --- /dev/null +++ b/jbpm/jbpm-tools/jbpm-tools-maven-plugin/src/test/resources/unit/project/src/main/bpmn/BPMN2-ConditionalFlowWithoutGateway.bpmn2 @@ -0,0 +1,102 @@ + + + + + + + + + + + + + + _1897CC4D-9026-42F4-A3E9-663EBD1B00F3 + + + _1897CC4D-9026-42F4-A3E9-663EBD1B00F3 + _99179D07-2AD3-4F1D-9851-11A6F92179C5 + _53A779A0-66A0-4A12-BD82-6CCDDE3D5CE9 + _0DD13F4B-C5E8-4AA3-84EE-B98461099FC4 + + + + _99179D07-2AD3-4F1D-9851-11A6F92179C5 + + + _53A779A0-66A0-4A12-BD82-6CCDDE3D5CE9 + + + _0DD13F4B-C5E8-4AA3-84EE-B98461099FC4 + + + + 1;]]> + + + 10;]]> + + + 100;]]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/jbpm/jbpm-tools/jbpm-tools-maven-plugin/src/test/resources/unit/project/src/main/bpmn/BPMN2-ErrorBoundaryEventOnServiceTask.bpmn2 b/jbpm/jbpm-tools/jbpm-tools-maven-plugin/src/test/resources/unit/project/src/main/bpmn/BPMN2-ErrorBoundaryEventOnServiceTask.bpmn2 deleted file mode 100755 index 68d9d161fe5..00000000000 --- a/jbpm/jbpm-tools/jbpm-tools-maven-plugin/src/test/resources/unit/project/src/main/bpmn/BPMN2-ErrorBoundaryEventOnServiceTask.bpmn2 +++ /dev/null @@ -1,195 +0,0 @@ - - - - - - - - - - - _2_InMessage - - - - - - SequenceFlow_4 - - - SequenceFlow_2 - SequenceFlow_6 - - - - - - - - - _DataInput_26 - _DataInput_27 - _DataInput_28 - _DataInput_29 - _DataInput_30 - _DataInput_31 - - - - - _DataInput_26 - - - _DataInput_27 - - - _DataInput_28 - - - _DataInput_29 - - - _DataInput_30 - - - _DataInput_31 - - - - john - - - - - SequenceFlow_3 - SequenceFlow_5 - - - - - _2_param - - - _2_result - - - - s - _2_param - - - _2_result - s - - - - SequenceFlow_4 - SequenceFlow_2 - SequenceFlow_3 - - - - - - SequenceFlow_5 - - - - - SequenceFlow_6 - - - SequenceFlow_7 - - - - SequenceFlow_7 - SequenceFlow_8 - - - - - - SequenceFlow_8 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/jbpm/jbpm-tools/jbpm-tools-maven-plugin/src/test/resources/unit/project/src/main/bpmn/BPMN2-EventSubprocessErrorSignalEmbedded.bpmn2 b/jbpm/jbpm-tools/jbpm-tools-maven-plugin/src/test/resources/unit/project/src/main/bpmn/BPMN2-EventSubprocessErrorSignalEmbedded.bpmn2 deleted file mode 100755 index ebafacec5b2..00000000000 --- a/jbpm/jbpm-tools/jbpm-tools-maven-plugin/src/test/resources/unit/project/src/main/bpmn/BPMN2-EventSubprocessErrorSignalEmbedded.bpmn2 +++ /dev/null @@ -1,342 +0,0 @@ - - - - - - - - - - - _39010054-5D46-4E8C-A9FA-64E46B4E293A - - - _39010054-5D46-4E8C-A9FA-64E46B4E293A - _FCC2871C-1D99-46E5-BE85-294F2F5EC58A - - - - - _FCC2871C-1D99-46E5-BE85-294F2F5EC58A - _05EE3913-3EAD-424B-92DC-6465CFA11A50 - - - - - _05EE3913-3EAD-424B-92DC-6465CFA11A50 - - - - - - _87AD2D24-CFFC-4352-BC76-DA18AE611768 - - - - _87AD2D24-CFFC-4352-BC76-DA18AE611768 - _4099F2E8-745B-4C8A-81F5-177D8B3D09A3 - - - - _4099F2E8-745B-4C8A-81F5-177D8B3D09A3 - _C970DF27-4230-4477-9D81-0C34636CE8BB - - - - _C970DF27-4230-4477-9D81-0C34636CE8BB - _52E875AC-A9EA-41CF-A168-3C02CEB2AA06 - - - - _52E875AC-A9EA-41CF-A168-3C02CEB2AA06 - _AA209FC7-33F3-483C-ABAB-541246AD4445 - - - - _AA209FC7-33F3-483C-ABAB-541246AD4445 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - _pgP6sHTaEeaoApuNXeI-uQ - _pgP6sHTaEeaoApuNXeI-uQ - - \ No newline at end of file diff --git a/jbpm/jbpm-tests/src/test/resources/BPMN2-EventSubprocessSignalWithTransformation.bpmn2 b/jbpm/jbpm-tools/jbpm-tools-maven-plugin/src/test/resources/unit/project/src/main/bpmn/BPMN2-EventSubprocessSignalWithTransformation.bpmn2 similarity index 97% rename from jbpm/jbpm-tests/src/test/resources/BPMN2-EventSubprocessSignalWithTransformation.bpmn2 rename to jbpm/jbpm-tools/jbpm-tools-maven-plugin/src/test/resources/unit/project/src/main/bpmn/BPMN2-EventSubprocessSignalWithTransformation.bpmn2 index 99972a8d8ac..70f97f5d1f4 100755 --- a/jbpm/jbpm-tests/src/test/resources/BPMN2-EventSubprocessSignalWithTransformation.bpmn2 +++ b/jbpm/jbpm-tools/jbpm-tools-maven-plugin/src/test/resources/unit/project/src/main/bpmn/BPMN2-EventSubprocessSignalWithTransformation.bpmn2 @@ -20,7 +20,7 @@ - + SequenceFlow_2 diff --git a/jbpm/jbpm-tools/jbpm-tools-maven-plugin/src/test/resources/unit/project/src/main/bpmn/BPMN2-MessageEndEvent.bpmn2 b/jbpm/jbpm-tools/jbpm-tools-maven-plugin/src/test/resources/unit/project/src/main/bpmn/BPMN2-MessageEndEvent.bpmn2 deleted file mode 100755 index 9d8f225ba59..00000000000 --- a/jbpm/jbpm-tools/jbpm-tools-maven-plugin/src/test/resources/unit/project/src/main/bpmn/BPMN2-MessageEndEvent.bpmn2 +++ /dev/null @@ -1,77 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - x - _2_Input - - - _2_Input - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/jbpm/jbpm-tests/src/test/resources/BPMN2-MultiInstanceLoopCharacteristicsTaskWithOutputCmpCondSequential.bpmn2 b/jbpm/jbpm-tools/jbpm-tools-maven-plugin/src/test/resources/unit/project/src/main/bpmn/BPMN2-MultiInstanceLoopCharacteristicsTaskWithOutputCmpCondSequential.bpmn2 similarity index 91% rename from jbpm/jbpm-tests/src/test/resources/BPMN2-MultiInstanceLoopCharacteristicsTaskWithOutputCmpCondSequential.bpmn2 rename to jbpm/jbpm-tools/jbpm-tools-maven-plugin/src/test/resources/unit/project/src/main/bpmn/BPMN2-MultiInstanceLoopCharacteristicsTaskWithOutputCmpCondSequential.bpmn2 index 15a95166b01..bce624ffd86 100644 --- a/jbpm/jbpm-tests/src/test/resources/BPMN2-MultiInstanceLoopCharacteristicsTaskWithOutputCmpCondSequential.bpmn2 +++ b/jbpm/jbpm-tools/jbpm-tools-maven-plugin/src/test/resources/unit/project/src/main/bpmn/BPMN2-MultiInstanceLoopCharacteristicsTaskWithOutputCmpCondSequential.bpmn2 @@ -35,7 +35,7 @@ - + @@ -68,6 +68,14 @@ list _2_input + + _2_listOutOutput + listOut + + + _2_itemOut + itemOut + john diff --git a/jbpm/pom.xml b/jbpm/pom.xml index 7aa8ccfca39..6129c935bc1 100755 --- a/jbpm/pom.xml +++ b/jbpm/pom.xml @@ -46,8 +46,9 @@ jbpm-flow-migration process-serialization-protobuf process-workitems - jbpm-tools - jbpm-tests + jbpm-tools + jbpm-tests + jbpm-deps-groups diff --git a/kogito-bom/pom.xml b/kogito-bom/pom.xml index 6e6671e62e3..b0bd0020724 100755 --- a/kogito-bom/pom.xml +++ b/kogito-bom/pom.xml @@ -1777,6 +1777,24 @@ + + org.kie.kogito + jbpm-deps-group-bpmn2-compiler + ${project.version} + pom + + + org.kie.kogito + jbpm-deps-group-compiler + ${project.version} + pom + + + org.kie.kogito + jbpm-deps-group-engine + ${project.version} + pom + org.kie.kogito process-workitems diff --git a/kogito-build/kogito-dependencies-bom/pom.xml b/kogito-build/kogito-dependencies-bom/pom.xml index 9e0e21dea0d..e936a83d036 100644 --- a/kogito-build/kogito-dependencies-bom/pom.xml +++ b/kogito-build/kogito-dependencies-bom/pom.xml @@ -366,7 +366,11 @@ jackson-jq ${version.net.thisptr.jackson-jq} - + + org.postgresql + postgresql + ${version.org.postgresql} + io.smallrye smallrye-open-api-core diff --git a/kogito-codegen-modules/kogito-codegen-api/src/main/java/org/kie/kogito/codegen/api/context/KogitoApplicationPropertyProvider.java b/kogito-codegen-modules/kogito-codegen-api/src/main/java/org/kie/kogito/codegen/api/context/KogitoApplicationPropertyProvider.java index 6aceefe760e..aefc03e19f1 100644 --- a/kogito-codegen-modules/kogito-codegen-api/src/main/java/org/kie/kogito/codegen/api/context/KogitoApplicationPropertyProvider.java +++ b/kogito-codegen-modules/kogito-codegen-api/src/main/java/org/kie/kogito/codegen/api/context/KogitoApplicationPropertyProvider.java @@ -47,6 +47,11 @@ public void setApplicationProperty(String key, String value) { public Optional getApplicationProperty(String property, Class clazz) { return Optional.ofNullable(convert(properties.getProperty(property), clazz)); } + + @Override + public void removeApplicationProperty(String key) { + properties.remove(key); + } }; } @@ -57,4 +62,6 @@ public Optional getApplicationProperty(String property, Class clazz) { Collection getApplicationProperties(); void setApplicationProperty(String key, String value); + + void removeApplicationProperty(String key); } diff --git a/kogito-codegen-modules/kogito-codegen-api/src/main/java/org/kie/kogito/codegen/api/context/impl/AbstractKogitoBuildContext.java b/kogito-codegen-modules/kogito-codegen-api/src/main/java/org/kie/kogito/codegen/api/context/impl/AbstractKogitoBuildContext.java index d46cfdb118a..f8cb06a9a0e 100644 --- a/kogito-codegen-modules/kogito-codegen-api/src/main/java/org/kie/kogito/codegen/api/context/impl/AbstractKogitoBuildContext.java +++ b/kogito-codegen-modules/kogito-codegen-api/src/main/java/org/kie/kogito/codegen/api/context/impl/AbstractKogitoBuildContext.java @@ -155,6 +155,11 @@ public void setApplicationProperty(String key, String value) { applicationProperties.setApplicationProperty(key, value); } + @Override + public void removeApplicationProperty(String key) { + applicationProperties.removeApplicationProperty(key); + } + @Override public String getPackageName() { return packageName; diff --git a/kogito-codegen-modules/kogito-codegen-core/src/main/java/org/kie/kogito/codegen/core/ApplicationGenerator.java b/kogito-codegen-modules/kogito-codegen-core/src/main/java/org/kie/kogito/codegen/core/ApplicationGenerator.java index 5b8facb99d8..f239870d5a6 100644 --- a/kogito-codegen-modules/kogito-codegen-core/src/main/java/org/kie/kogito/codegen/core/ApplicationGenerator.java +++ b/kogito-codegen-modules/kogito-codegen-core/src/main/java/org/kie/kogito/codegen/core/ApplicationGenerator.java @@ -49,7 +49,8 @@ public class ApplicationGenerator { private static final Logger LOGGER = LoggerFactory.getLogger(ApplicationGenerator.class); public static final String APPLICATION_CLASS_NAME = "Application"; - private static final GeneratedFileType APPLICATION_SECTION_TYPE = GeneratedFileType.of("APPLICATION_SECTION", GeneratedFileType.Category.SOURCE); + private static final GeneratedFileType APPLICATION_SECTION_TYPE = GeneratedFileType.of("APPLICATION_SECTION", + GeneratedFileType.Category.SOURCE); private final ApplicationContainerGenerator applicationMainGenerator; private ApplicationConfigGenerator applicationConfigGenerator; @@ -95,8 +96,11 @@ public Collection generate() { public List generateComponents() { return generators.stream() - .flatMap(gen -> gen.generate().stream()) - .filter(this::filterGeneratedFile) + .flatMap(gen -> { + boolean keepRestFile = keepRestFile(gen); + return gen.generate().stream() + .filter(generatedFile -> filterGeneratedFile(generatedFile, keepRestFile)); + }) .collect(Collectors.toList()); } @@ -112,8 +116,12 @@ public GeneratedFile generateApplicationDescriptor() { return applicationMainGenerator.generate(); } - private boolean filterGeneratedFile(GeneratedFile generatedFile) { - boolean keepFile = context.hasRESTGloballyAvailable() || !REST_TYPE.equals(generatedFile.type()); + boolean keepRestFile(Generator generator) { + return context.hasRESTForGenerator(generator); + } + + private boolean filterGeneratedFile(GeneratedFile generatedFile, boolean keepRestFile) { + boolean keepFile = keepRestFile || !REST_TYPE.equals(generatedFile.type()); if (!keepFile) { LOGGER.warn("Skipping file because REST is disabled: " + generatedFile.relativePath()); } @@ -134,7 +142,7 @@ private Collection generateApplicationSections() { /** * Method to wire Generator with ApplicationGenerator if enabled - * + * * @param generator * @param * @return diff --git a/kogito-codegen-modules/kogito-codegen-core/src/test/java/org/kie/kogito/codegen/core/ApplicationGeneratorTest.java b/kogito-codegen-modules/kogito-codegen-core/src/test/java/org/kie/kogito/codegen/core/ApplicationGeneratorTest.java index ee642d44ab7..46b3019230e 100644 --- a/kogito-codegen-modules/kogito-codegen-core/src/test/java/org/kie/kogito/codegen/core/ApplicationGeneratorTest.java +++ b/kogito-codegen-modules/kogito-codegen-core/src/test/java/org/kie/kogito/codegen/core/ApplicationGeneratorTest.java @@ -37,6 +37,7 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.kie.kogito.codegen.api.Generator.REST_TYPE; +import static org.kie.kogito.codegen.api.context.KogitoBuildContext.generateRESTConfigurationKeyForResource; public class ApplicationGeneratorTest { @@ -168,6 +169,66 @@ public void disableGlobalRestGeneration(KogitoBuildContext.Builder contextBuilde } } + @ParameterizedTest + @MethodSource("org.kie.kogito.codegen.api.utils.KogitoContextTestUtils#contextBuilders") + public void keepRestFile(KogitoBuildContext.Builder contextBuilder) { + final KogitoBuildContext context = contextBuilder.build(); + final ApplicationGenerator appGenerator = new ApplicationGenerator(context); + final MockGenerator restGenerator = new MockGenerator(context, true); + final String generateRESTConfigurationKeyForResource = generateRESTConfigurationKeyForResource(restGenerator.name()); + + assertThat(appGenerator.registerGeneratorIfEnabled(restGenerator)) + .isNotEmpty(); + assertThat(appGenerator.getGenerators()).hasSize(1); + + if (context.hasRESTForGenerator(restGenerator)) { + // globally and engine-specific disable REST + context.setApplicationProperty(KogitoBuildContext.KOGITO_GENERATE_REST, "false"); + context.setApplicationProperty(generateRESTConfigurationKeyForResource, "false"); + assertThat(appGenerator.keepRestFile(restGenerator)).isFalse(); + + // globally disable REST, engine-specific enable REST + context.setApplicationProperty(KogitoBuildContext.KOGITO_GENERATE_REST, "false"); + context.setApplicationProperty(generateRESTConfigurationKeyForResource, "true"); + assertThat(appGenerator.keepRestFile(restGenerator)).isFalse(); + + // globally enable REST, engine-specific disable REST + context.setApplicationProperty(KogitoBuildContext.KOGITO_GENERATE_REST, "true"); + context.setApplicationProperty(generateRESTConfigurationKeyForResource, "false"); + assertThat(appGenerator.keepRestFile(restGenerator)).isFalse(); + + // globally and engine-specific enable REST + context.setApplicationProperty(KogitoBuildContext.KOGITO_GENERATE_REST, "true"); + context.setApplicationProperty(generateRESTConfigurationKeyForResource, "true"); + assertThat(appGenerator.keepRestFile(restGenerator)).isTrue(); + + // engine-specific enable REST + context.removeApplicationProperty(KogitoBuildContext.KOGITO_GENERATE_REST); + context.setApplicationProperty(generateRESTConfigurationKeyForResource, "true"); + assertThat(appGenerator.keepRestFile(restGenerator)).isTrue(); + + // engine-specific disable REST + context.removeApplicationProperty(KogitoBuildContext.KOGITO_GENERATE_REST); + context.setApplicationProperty(generateRESTConfigurationKeyForResource, "false"); + assertThat(appGenerator.keepRestFile(restGenerator)).isFalse(); + + // globally enable REST + context.setApplicationProperty(KogitoBuildContext.KOGITO_GENERATE_REST, "true"); + context.removeApplicationProperty(generateRESTConfigurationKeyForResource); + assertThat(appGenerator.keepRestFile(restGenerator)).isTrue(); + + // globally disable REST + context.setApplicationProperty(KogitoBuildContext.KOGITO_GENERATE_REST, "false"); + context.removeApplicationProperty(generateRESTConfigurationKeyForResource); + assertThat(appGenerator.keepRestFile(restGenerator)).isFalse(); + + // defaults + context.removeApplicationProperty(KogitoBuildContext.KOGITO_GENERATE_REST); + context.removeApplicationProperty(generateRESTConfigurationKeyForResource); + assertThat(appGenerator.keepRestFile(restGenerator)).isTrue(); + } + } + private void assertCompilationUnit(final CompilationUnit compilationUnit, final boolean checkCDI) { assertThat(compilationUnit).isNotNull(); diff --git a/kogito-codegen-modules/kogito-codegen-processes/pom.xml b/kogito-codegen-modules/kogito-codegen-processes/pom.xml index bf6b70968f0..f020e88a914 100644 --- a/kogito-codegen-modules/kogito-codegen-processes/pom.xml +++ b/kogito-codegen-modules/kogito-codegen-processes/pom.xml @@ -50,15 +50,8 @@ org.kie.kogito - jbpm-flow - - - org.kie.kogito - jbpm-flow-builder - - - org.kie.kogito - jbpm-bpmn2 + jbpm-deps-group-bpmn2-compiler + pom org.kie.kogito diff --git a/kogito-codegen-modules/kogito-codegen-processes/src/main/resources/class-templates/RestResourceUserTaskQuarkusTemplate.java b/kogito-codegen-modules/kogito-codegen-processes/src/main/resources/class-templates/RestResourceUserTaskQuarkusTemplate.java index 34c0d6a96dd..fa858163fe7 100644 --- a/kogito-codegen-modules/kogito-codegen-processes/src/main/resources/class-templates/RestResourceUserTaskQuarkusTemplate.java +++ b/kogito-codegen-modules/kogito-codegen-processes/src/main/resources/class-templates/RestResourceUserTaskQuarkusTemplate.java @@ -40,8 +40,11 @@ public class $Type$Resource { @Path("/{id}/$taskName$") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) - public Response signal(@PathParam("id") final String id, @Context UriInfo uriInfo) { - return processService.signalTask(process, id, "$taskName$") + public Response signal(@PathParam("id") final String id, + @QueryParam("user") final String user, + @QueryParam("group") final List groups, + @Context UriInfo uriInfo) { + return processService.signalTask(process, id, "$taskName$", SecurityPolicy.of(user, groups)) .map(task -> Response .created(uriInfo.getAbsolutePathBuilder().path(task.getId()).build()) .entity(task.getResults()) diff --git a/kogito-codegen-modules/kogito-codegen-processes/src/main/resources/class-templates/RestResourceUserTaskSpringTemplate.java b/kogito-codegen-modules/kogito-codegen-processes/src/main/resources/class-templates/RestResourceUserTaskSpringTemplate.java index 0ae5bebd054..9779d13e7f6 100644 --- a/kogito-codegen-modules/kogito-codegen-processes/src/main/resources/class-templates/RestResourceUserTaskSpringTemplate.java +++ b/kogito-codegen-modules/kogito-codegen-processes/src/main/resources/class-templates/RestResourceUserTaskSpringTemplate.java @@ -48,9 +48,11 @@ public class $Type$Resource { @PostMapping(value = "/{id}/$taskName$", produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity signal(@PathVariable("id") final String id, - final UriComponentsBuilder uriComponentsBuilder) { + @RequestParam("user") final String user, + @RequestParam("group") final List groups, + final UriComponentsBuilder uriComponentsBuilder) { - return processService.signalTask(process, id, "$taskName$") + return processService.signalTask(process, id, "$taskName$", SecurityPolicy.of(user, groups)) .map(task -> ResponseEntity .created(uriComponentsBuilder .path("/$name$/{id}/$taskName$/{taskId}") diff --git a/kogito-serverless-workflow/kogito-jq-expression/pom.xml b/kogito-serverless-workflow/kogito-jq-expression/pom.xml index d197e785b76..7bebf4dc7c1 100644 --- a/kogito-serverless-workflow/kogito-jq-expression/pom.xml +++ b/kogito-serverless-workflow/kogito-jq-expression/pom.xml @@ -41,7 +41,8 @@ org.kie.kogito - jbpm-flow + jbpm-deps-group-engine + pom net.thisptr diff --git a/kogito-serverless-workflow/kogito-jq-expression/src/main/java/org/kie/kogito/expr/jq/JqExpression.java b/kogito-serverless-workflow/kogito-jq-expression/src/main/java/org/kie/kogito/expr/jq/JqExpression.java index 9438aca8227..9d8c1676658 100644 --- a/kogito-serverless-workflow/kogito-jq-expression/src/main/java/org/kie/kogito/expr/jq/JqExpression.java +++ b/kogito-serverless-workflow/kogito-jq-expression/src/main/java/org/kie/kogito/expr/jq/JqExpression.java @@ -134,7 +134,9 @@ public void emit(JsonNode out) throws JsonQueryException { if (sb.length() > 0) { sb.append(' '); } - sb.append(out.asText()); + if (!out.isNull() && out.asText() != null) { + sb.append(out.asText()); + } } @Override diff --git a/kogito-serverless-workflow/kogito-jq-expression/src/test/java/org/kie/kogito/expr/jq/JqExpressionHandlerTest.java b/kogito-serverless-workflow/kogito-jq-expression/src/test/java/org/kie/kogito/expr/jq/JqExpressionHandlerTest.java index b4806b5403b..ad1f70ac6ec 100644 --- a/kogito-serverless-workflow/kogito-jq-expression/src/test/java/org/kie/kogito/expr/jq/JqExpressionHandlerTest.java +++ b/kogito-serverless-workflow/kogito-jq-expression/src/test/java/org/kie/kogito/expr/jq/JqExpressionHandlerTest.java @@ -287,7 +287,7 @@ private static Stream provideMagicWordExpressionsToTest() { Arguments.of("\"WORKFLOW.instanceId\"", "WORKFLOW.instanceId", getContext()), Arguments.of("\"$WORKFLOW.instanceId\"", "$WORKFLOW.instanceId", getContext()), Arguments.of("\"$WORKFLOW.instanceId: \" + $WORKFLOW.instanceId", "$WORKFLOW.instanceId: 1111-2222-3333", getContext()), - Arguments.of("$SECRET.none", "null", getContext()), + Arguments.of("$SECRET.none", "", getContext()), Arguments.of("\"$SECRET.none\"", "$SECRET.none", getContext()), Arguments.of("$SECRET.lettersonly", "secretlettersonly", getContext()), Arguments.of("$SECRET.dot.secret", "secretdotsecret", getContext()), @@ -295,7 +295,7 @@ private static Stream provideMagicWordExpressionsToTest() { Arguments.of("$SECRET.\"dash-secret\"", "secretdashsecret", getContext()), Arguments.of("$CONST.someconstant", "value", getContext()), Arguments.of("$CONST.\"someconstant\"", "value", getContext()), - Arguments.of("$CONST.some.constant", "null", getContext()), + Arguments.of("$CONST.some.constant", "", getContext()), Arguments.of("$CONST.\"some.constant\"", "value", getContext()), Arguments.of("$CONST.\"some-constant\"", "value", getContext()), Arguments.of("$CONST.injectedexpression", "$WORKFLOW.instanceId", getContext()), diff --git a/kogito-serverless-workflow/kogito-jsonpath-expression/pom.xml b/kogito-serverless-workflow/kogito-jsonpath-expression/pom.xml index d029661f15b..38a5d97a75f 100644 --- a/kogito-serverless-workflow/kogito-jsonpath-expression/pom.xml +++ b/kogito-serverless-workflow/kogito-jsonpath-expression/pom.xml @@ -41,7 +41,8 @@ org.kie.kogito - jbpm-flow + jbpm-deps-group-engine + pom com.jayway.jsonpath diff --git a/kogito-serverless-workflow/kogito-serverless-workflow-builder/pom.xml b/kogito-serverless-workflow/kogito-serverless-workflow-builder/pom.xml index 0d7ae54d492..14a47e2b7e9 100644 --- a/kogito-serverless-workflow/kogito-serverless-workflow-builder/pom.xml +++ b/kogito-serverless-workflow/kogito-serverless-workflow-builder/pom.xml @@ -40,7 +40,8 @@ org.kie.kogito - jbpm-flow-builder + jbpm-deps-group-compiler + pom org.kie.kogito diff --git a/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/io/CachedContentLoader.java b/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/io/CachedContentLoader.java index ad2c78948c4..d8ff0935d24 100644 --- a/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/io/CachedContentLoader.java +++ b/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/io/CachedContentLoader.java @@ -20,7 +20,6 @@ import java.io.ByteArrayInputStream; import java.io.InputStream; -import java.net.URI; import java.nio.file.Path; import java.util.Optional; @@ -48,10 +47,10 @@ public synchronized byte[] readAllBytes() { } } - private final URI uri; + protected final String uri; private URIContentLoader[] fallbackContentLoaders; - protected CachedContentLoader(URI uri, URIContentLoader... fallbackContentLoaders) { + protected CachedContentLoader(String uri, URIContentLoader... fallbackContentLoaders) { this.uri = uri; this.fallbackContentLoaders = fallbackContentLoaders; } @@ -91,10 +90,13 @@ public InputStream getInputStream() { } } - protected abstract byte[] loadURI(URI uri); - - @Override - public URI uri() { - return uri; + protected static String trimScheme(String uri, String scheme) { + String str = uri; + if (str.toLowerCase().startsWith(scheme)) { + str = str.substring(scheme.length()); + } + return str; } + + protected abstract byte[] loadURI(); } diff --git a/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/io/ClassPathContentLoader.java b/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/io/ClassPathContentLoader.java index 413c199a674..dc940f398ad 100644 --- a/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/io/ClassPathContentLoader.java +++ b/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/io/ClassPathContentLoader.java @@ -21,11 +21,8 @@ import java.io.IOException; import java.io.InputStream; import java.io.UncheckedIOException; -import java.net.URI; import java.net.URISyntaxException; import java.net.URL; -import java.net.URLDecoder; -import java.nio.charset.Charset; import java.nio.file.Path; import java.util.Optional; @@ -34,24 +31,12 @@ public class ClassPathContentLoader extends CachedContentLoader { private final Optional resource; private final String classpath; - ClassPathContentLoader(URI uri, Optional cl, URIContentLoader... fallbackContentLoaders) { + ClassPathContentLoader(String uri, Optional cl, URIContentLoader... fallbackContentLoaders) { super(uri, fallbackContentLoaders); - this.classpath = getPath(uri); + this.classpath = uriToPath(uri); this.resource = Optional.ofNullable(cl.orElse(Thread.currentThread().getContextClassLoader()).getResource(classpath)); } - static String getPath(URI uri) { - final String classPathPrefix = "classpath:"; - String str = URLDecoder.decode(uri.toString(), Charset.defaultCharset()); - if (str.toLowerCase().startsWith(classPathPrefix)) { - str = str.substring(classPathPrefix.length()); - while (str.startsWith("/")) { - str = str.substring(1); - } - } - return str; - } - public Optional getResource() { return resource; } @@ -74,7 +59,7 @@ private static Path fromURL(URL url) { } @Override - protected byte[] loadURI(URI uri) { + protected byte[] loadURI() { return resource.map(this::loadBytes).orElseThrow(() -> new IllegalArgumentException("cannot find classpath resource " + classpath)); } @@ -86,6 +71,17 @@ private byte[] loadBytes(URL r) { } } + static String uriToPath(String uri) { + return removeSlash(trimScheme(uri, URIContentLoaderType.CLASSPATH.scheme())); + } + + private static String removeSlash(String str) { + while (str.startsWith("/")) { + str = str.substring(1); + } + return str; + } + @Override public URIContentLoaderType type() { return URIContentLoaderType.CLASSPATH; diff --git a/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/io/FileContentLoader.java b/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/io/FileContentLoader.java index 336efe012f0..aabd9b1258b 100644 --- a/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/io/FileContentLoader.java +++ b/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/io/FileContentLoader.java @@ -25,13 +25,18 @@ import java.nio.file.Path; import java.util.Optional; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + public class FileContentLoader extends CachedContentLoader { private final Path path; - FileContentLoader(URI uri, URIContentLoader... fallbackContentLoaders) { + private static final Logger logger = LoggerFactory.getLogger(FileContentLoader.class); + + FileContentLoader(String uri, URIContentLoader... fallbackContentLoaders) { super(uri, fallbackContentLoaders); - this.path = Path.of(getPath(uri)); + this.path = obtainPath(uri); } @Override @@ -39,13 +44,24 @@ public URIContentLoaderType type() { return URIContentLoaderType.FILE; } + private static Path obtainPath(String uri) { + if (uri.startsWith(URIContentLoaderType.FILE.scheme())) { + try { + return Path.of(URI.create(uri)); + } catch (Exception ex) { + logger.info("URI {} is not valid one according to Java, trying alternative approach", uri, ex); + } + } + return Path.of(uriToPath(uri)); + } + @Override protected Optional internalGetPath() { return Files.exists(path) ? Optional.of(path) : Optional.empty(); } @Override - protected byte[] loadURI(URI uri) { + protected byte[] loadURI() { try { return Files.readAllBytes(path); } catch (IOException io) { @@ -53,7 +69,7 @@ protected byte[] loadURI(URI uri) { } } - static String getPath(URI uri) { - return uri.getPath(); + static String uriToPath(String uri) { + return trimScheme(uri, URIContentLoaderType.FILE.scheme()); } } diff --git a/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/io/HttpContentLoader.java b/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/io/HttpContentLoader.java index 195fcdabd41..21b9c178a16 100644 --- a/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/io/HttpContentLoader.java +++ b/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/io/HttpContentLoader.java @@ -22,6 +22,7 @@ import java.io.InputStream; import java.net.HttpURLConnection; import java.net.URI; +import java.net.URL; import java.util.Base64; import java.util.Collection; import java.util.HashMap; @@ -50,17 +51,19 @@ class HttpContentLoader extends CachedContentLoader { private Optional workflow; private String authRef; + private final URIContentLoaderType type; - HttpContentLoader(URI uri, Optional workflow, String authRef) { + HttpContentLoader(String uri, Optional workflow, String authRef, URIContentLoaderType type) { super(uri); this.workflow = workflow; this.authRef = authRef; + this.type = type; } @Override - protected byte[] loadURI(URI u) { + protected byte[] loadURI() { try { - HttpURLConnection conn = (HttpURLConnection) u.toURL().openConnection(); + HttpURLConnection conn = (HttpURLConnection) new URL(uri).openConnection(); // some http servers required specific accept header (*/* is specified for those we do not care about accept) conn.setRequestProperty("Accept", "application/json,application/yaml,application/yml,application/text,text/*,*/*"); workflow.map(Workflow::getAuth).map(Auth::getAuthDefs).stream().flatMap(Collection::stream) @@ -74,7 +77,7 @@ protected byte[] loadURI(URI u) { } else { try (InputStream is = conn.getErrorStream()) { throw new IllegalArgumentException(String.format( - "Failed to fetch remote file: %s. Status code is %d and response: %n %s", u, code, is == null ? "" : new String(is.readAllBytes()))); + "Failed to fetch remote file: %s. Status code is %d and response: %n %s", uri, code, is == null ? "" : new String(is.readAllBytes()))); } } } catch (IOException io) { @@ -147,6 +150,11 @@ private String encode(String str) { @Override public URIContentLoaderType type() { - return URIContentLoaderType.HTTP; + return type; } + + static String uriToPath(String uri) { + return URI.create(uri).getPath(); + } + } diff --git a/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/io/ResourceCache.java b/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/io/ResourceCache.java index 85f3581ba80..dee2d22f1d1 100644 --- a/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/io/ResourceCache.java +++ b/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/io/ResourceCache.java @@ -18,9 +18,8 @@ */ package org.kie.kogito.serverless.workflow.io; -import java.net.URI; -import java.util.function.Function; +import java.util.function.Supplier; public interface ResourceCache { - byte[] get(URI uri, Function retrieveCall); + byte[] get(String uri, Supplier retrieveCall); } diff --git a/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/io/ResourceCacheFactory.java b/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/io/ResourceCacheFactory.java index 9352508a6cd..2e49f4fa398 100644 --- a/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/io/ResourceCacheFactory.java +++ b/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/io/ResourceCacheFactory.java @@ -18,12 +18,11 @@ */ package org.kie.kogito.serverless.workflow.io; -import java.net.URI; import java.util.Collections; import java.util.Map; import java.util.WeakHashMap; import java.util.concurrent.atomic.AtomicReference; -import java.util.function.Function; +import java.util.function.Supplier; public class ResourceCacheFactory { private static final AtomicReference cache = new AtomicReference<>(new LocalResourceCache()); @@ -33,11 +32,11 @@ public static ResourceCache getCache() { } private static class LocalResourceCache implements ResourceCache { - private final Map map = Collections.synchronizedMap(new WeakHashMap<>()); + private final Map map = Collections.synchronizedMap(new WeakHashMap<>()); @Override - public byte[] get(URI uri, Function retrieveCall) { - return map.computeIfAbsent(uri, retrieveCall); + public byte[] get(String uri, Supplier retrieveCall) { + return map.computeIfAbsent(uri, u -> retrieveCall.get()); } } diff --git a/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/io/URIContentLoader.java b/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/io/URIContentLoader.java index 41b17ab3d0c..121d82450e9 100644 --- a/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/io/URIContentLoader.java +++ b/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/io/URIContentLoader.java @@ -19,14 +19,11 @@ package org.kie.kogito.serverless.workflow.io; import java.io.InputStream; -import java.net.URI; import java.nio.file.Path; import java.util.Optional; public interface URIContentLoader { - URI uri(); - InputStream getInputStream(); URIContentLoaderType type(); diff --git a/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/io/URIContentLoaderFactory.java b/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/io/URIContentLoaderFactory.java index 6e5b806594a..5c3f82c725f 100644 --- a/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/io/URIContentLoaderFactory.java +++ b/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/io/URIContentLoaderFactory.java @@ -22,9 +22,6 @@ import java.io.InputStream; import java.io.UncheckedIOException; import java.net.URI; -import java.net.URISyntaxException; -import java.net.URLEncoder; -import java.nio.charset.Charset; import java.util.Optional; import org.kie.kogito.serverless.workflow.parser.ParserContext; @@ -51,29 +48,11 @@ public static String readString(URIContentLoader loader) { return new String(readAllBytes(loader)); } - public static String getFileName(URI uri) { - URIContentLoaderType type = URIContentLoaderType.from(uri); - String path = uriToPath(type, uri); - return type.lastPart(path); - } - - private static String uriToPath(URIContentLoaderType type, URI uri) { - switch (type) { - case CLASSPATH: - return ClassPathContentLoader.getPath(uri); - case FILE: - return FileContentLoader.getPath(uri); - case HTTP: - default: - return uri.getPath(); - } - } - public static String readString(Builder builder) { return readString(builder.build()); } - public static URIContentLoader buildLoader(URI uri, Workflow workflow, Optional context, String authRef) { + public static URIContentLoader buildLoader(String uri, Workflow workflow, Optional context, String authRef) { Builder builder = new Builder(uri).withWorkflow(workflow).withAuthRef(authRef); context.map(c -> c.getContext().getClassLoader()).ifPresent(builder::withClassloader); getBaseURI(workflow).ifPresent(builder::withBaseURI); @@ -85,25 +64,29 @@ public static byte[] readBytes(String uriStr, Workflow workflow, ParserContext p } public static byte[] readBytes(String uriStr, Workflow workflow, Optional parserContext) { - return readAllBytes(buildLoader(URI.create(uriStr), workflow, parserContext, null)); + return readAllBytes(buildLoader(uriStr, workflow, parserContext, null)); } public static Builder builder(URI uri) { - return new Builder(uri); + return new Builder(uri.toString()); } public static Builder builder(String uri) { - return new Builder(URI.create(URLEncoder.encode(uri, Charset.defaultCharset()))); + return new Builder(uri); } public static class Builder { - private URI uri; + private String uri; private ClassLoader cl; private Workflow workflow; private String authRef; - private URI baseURI; + private String baseURI; private Builder(URI uri) { + this.uri = uri.toString(); + } + + private Builder(String uri) { this.uri = uri; } @@ -122,19 +105,21 @@ public Builder withAuthRef(String authRef) { return this; } - public Builder withBaseURI(URI baseURI) { + public Builder withBaseURI(String baseURI) { this.baseURI = baseURI; return this; } public URIContentLoader build() { - final URI finalURI = baseURI != null ? compoundURI(baseURI, uri) : uri; + final String finalURI = baseURI != null ? compoundURI(baseURI, uri) : uri; switch (URIContentLoaderType.from(finalURI)) { default: case FILE: return new FileContentLoader(finalURI, new ClassPathContentLoader(uri, Optional.ofNullable(cl))); case HTTP: - return new HttpContentLoader(finalURI, Optional.ofNullable(workflow), authRef); + return new HttpContentLoader(finalURI, Optional.ofNullable(workflow), authRef, URIContentLoaderType.HTTP); + case HTTPS: + return new HttpContentLoader(finalURI, Optional.ofNullable(workflow), authRef, URIContentLoaderType.HTTPS); case CLASSPATH: Optional optionalCl = Optional.ofNullable(cl); return finalURI == uri ? new ClassPathContentLoader(finalURI, optionalCl) : new ClassPathContentLoader(finalURI, optionalCl, new ClassPathContentLoader(uri, optionalCl)); @@ -142,24 +127,8 @@ public URIContentLoader build() { } } - public static URI compoundURI(URI baseURI, URI uri) { - if (uri.getScheme() != null) { - return uri; - } - URIContentLoaderType type = URIContentLoaderType.from(baseURI); - String basePath = type.trimLast(uriToPath(type, baseURI)); - String additionalPath = uriToPath(type, uri); - String path; - if (type.isAbsolutePath(additionalPath)) { - path = additionalPath; - } else { - path = type.concat(basePath, additionalPath); - } - try { - return new URI(type.toString().toLowerCase(), baseURI.getAuthority(), path, uri.getQuery(), uri.getFragment()); - } catch (URISyntaxException e) { - throw new IllegalArgumentException(e.getMessage(), e); - } + public static String compoundURI(String baseURI, String uri) { + return URIContentLoaderType.scheme(uri).isPresent() ? uri : URIContentLoaderType.from(baseURI).concat(baseURI, uri); } private URIContentLoaderFactory() { diff --git a/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/io/URIContentLoaderType.java b/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/io/URIContentLoaderType.java index 5b9ed8dbc37..515195bdf95 100644 --- a/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/io/URIContentLoaderType.java +++ b/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/io/URIContentLoaderType.java @@ -19,35 +19,44 @@ package org.kie.kogito.serverless.workflow.io; import java.io.File; -import java.net.URI; +import java.util.Optional; +import java.util.function.Function; public enum URIContentLoaderType { - CLASSPATH(), - FILE(File.separatorChar), - HTTP(); + CLASSPATH(ClassPathContentLoader::uriToPath), + FILE(FileContentLoader::uriToPath, File.separatorChar), + HTTP(HttpContentLoader::uriToPath), + HTTPS(HttpContentLoader::uriToPath); private final char[] additionalSeparators; + private final Function getPathFunction; - private URIContentLoaderType(char... additionalSeparators) { + private final String scheme = name().toLowerCase() + ':'; + + private URIContentLoaderType(Function getPathFunction, char... additionalSeparators) { + this.getPathFunction = getPathFunction; this.additionalSeparators = additionalSeparators; } - public static URIContentLoaderType from(URI uri) { - String scheme = uri.getScheme(); - if (scheme == null) { - return FILE; - } - switch (uri.getScheme().toLowerCase()) { - case "file": - return FILE; - case "classpath": - return CLASSPATH; - case "http": - case "https": - return HTTP; - default: - throw new IllegalArgumentException("Unrecognized uri protocol " + uri); - } + public static Optional scheme(String uri) { + int indexOf = uri.indexOf(":"); + return indexOf == -1 ? Optional.empty() : Optional.of(uri.substring(0, indexOf).toLowerCase()); + } + + public static URIContentLoaderType from(String uri) { + return scheme(uri).map(scheme -> { + switch (scheme) { + default: + case "file": + return FILE; + case "classpath": + return CLASSPATH; + case "http": + return HTTP; + case "https": + return HTTPS; + } + }).orElse(FILE); } public boolean isAbsolutePath(String path) { @@ -63,16 +72,19 @@ public boolean isAbsolutePath(String path) { } public String concat(String basePath, String additionalPath) { - char separator = separator(); - if (!basePath.isBlank() && !isAbsolutePath(basePath)) { - basePath = separator + basePath; + if (isAbsolutePath(additionalPath)) { + return keepSchemaIfPresent(basePath, additionalPath); + } + int indexOf = lastIndexOf(basePath); + if (indexOf != -1) { + return keepSchemaIfPresent(basePath, basePath.substring(0, indexOf + 1) + additionalPath); + } else { + return keepSchemaIfPresent(basePath, additionalPath); } - return basePath + separator + additionalPath; } - public String trimLast(String path) { - int indexOf = lastIndexOf(path); - return indexOf != -1 ? path.substring(0, indexOf) : ""; + private String keepSchemaIfPresent(String basePath, String resultPath) { + return basePath.startsWith(scheme) && !resultPath.startsWith(scheme) ? scheme + resultPath : resultPath; } public String lastPart(String path) { @@ -80,6 +92,14 @@ public String lastPart(String path) { return indexOf != -1 ? path.substring(indexOf + 1) : path; } + public String scheme() { + return scheme; + } + + public String uriToPath(String uri) { + return getPathFunction.apply(uri); + } + private int lastIndexOf(String path) { int indexOf = path.lastIndexOf('/'); int i = 0; @@ -89,7 +109,4 @@ private int lastIndexOf(String path) { return indexOf; } - private char separator() { - return additionalSeparators.length > 0 ? additionalSeparators[0] : '/'; - } } diff --git a/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/operationid/AbstractWorkflowOperationIdFactory.java b/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/operationid/AbstractWorkflowOperationIdFactory.java index 7fefb0f2a8d..5f4278c92d6 100644 --- a/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/operationid/AbstractWorkflowOperationIdFactory.java +++ b/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/operationid/AbstractWorkflowOperationIdFactory.java @@ -20,7 +20,6 @@ import java.io.IOException; import java.io.UncheckedIOException; -import java.net.URI; import java.util.Optional; import org.kie.kogito.jackson.utils.ObjectMapperFactory; @@ -47,13 +46,13 @@ public abstract class AbstractWorkflowOperationIdFactory implements WorkflowOper public WorkflowOperationId from(Workflow workflow, FunctionDefinition function, Optional context) { ActionResource actionResource = ActionResourceFactory.getActionResource(function); Optional convertedUri = convertURI(workflow, context, actionResource.getUri()); - final URI uri; final String fileName; + final String uri; if (convertedUri.isPresent()) { - uri = URI.create(convertedUri.get()); + uri = convertedUri.get(); fileName = actionResource.getUri(); } else { - uri = URI.create(actionResource.getUri()); + uri = actionResource.getUri(); fileName = getFileName(workflow, function, context, uri, actionResource.getOperation(), actionResource.getService()); } if (fileName == null || fileName.isBlank()) { @@ -88,5 +87,5 @@ private JsonNode getUriDefinitions(Workflow workflow, Optional co return definitions; } - protected abstract String getFileName(Workflow workflow, FunctionDefinition function, Optional context, URI uri, String operation, String service); + protected abstract String getFileName(Workflow workflow, FunctionDefinition function, Optional context, String uri, String operation, String service); } diff --git a/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/operationid/FileNameWorkflowOperationIdFactory.java b/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/operationid/FileNameWorkflowOperationIdFactory.java index 0348f9df43e..3cbb9bd79de 100644 --- a/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/operationid/FileNameWorkflowOperationIdFactory.java +++ b/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/operationid/FileNameWorkflowOperationIdFactory.java @@ -18,11 +18,10 @@ */ package org.kie.kogito.serverless.workflow.operationid; -import java.net.URI; import java.util.Optional; import java.util.Set; -import org.kie.kogito.serverless.workflow.io.URIContentLoaderFactory; +import org.kie.kogito.serverless.workflow.io.URIContentLoaderType; import org.kie.kogito.serverless.workflow.parser.ParserContext; import io.serverlessworkflow.api.Workflow; @@ -33,8 +32,9 @@ public class FileNameWorkflowOperationIdFactory extends AbstractWorkflowOperatio public static final String FILE_PROP_VALUE = "FILE_NAME"; @Override - public String getFileName(Workflow workflow, FunctionDefinition function, Optional context, URI uri, String operation, String service) { - return URIContentLoaderFactory.getFileName(uri); + public String getFileName(Workflow workflow, FunctionDefinition function, Optional context, String uri, String operation, String service) { + URIContentLoaderType type = URIContentLoaderType.from(uri); + return type.lastPart(type.uriToPath(uri)); } @Override diff --git a/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/operationid/FunctionWorkflowOperationIdFactory.java b/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/operationid/FunctionWorkflowOperationIdFactory.java index 90ce8f093c9..b81c3127350 100644 --- a/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/operationid/FunctionWorkflowOperationIdFactory.java +++ b/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/operationid/FunctionWorkflowOperationIdFactory.java @@ -18,7 +18,6 @@ */ package org.kie.kogito.serverless.workflow.operationid; -import java.net.URI; import java.util.Optional; import java.util.Set; @@ -31,7 +30,7 @@ public class FunctionWorkflowOperationIdFactory extends AbstractWorkflowOperatio public static final String FUNCTION_PROP_VALUE = "FUNCTION_NAME"; @Override - public String getFileName(Workflow workflow, FunctionDefinition function, Optional context, URI uri, String operation, String service) { + public String getFileName(Workflow workflow, FunctionDefinition function, Optional context, String uri, String operation, String service) { return workflow.getId() + '_' + function.getName(); } diff --git a/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/operationid/URIWorkflowOperationIdFactory.java b/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/operationid/URIWorkflowOperationIdFactory.java index d15a557b63b..e75cdd1a9ef 100644 --- a/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/operationid/URIWorkflowOperationIdFactory.java +++ b/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/operationid/URIWorkflowOperationIdFactory.java @@ -18,11 +18,10 @@ */ package org.kie.kogito.serverless.workflow.operationid; -import java.net.URI; -import java.nio.file.Path; import java.util.Optional; import java.util.Set; +import org.kie.kogito.serverless.workflow.io.URIContentLoaderType; import org.kie.kogito.serverless.workflow.parser.ParserContext; import io.serverlessworkflow.api.Workflow; @@ -33,8 +32,8 @@ public class URIWorkflowOperationIdFactory extends AbstractWorkflowOperationIdFa public static final String URI_PROP_VALUE = "FULL_URI"; @Override - public String getFileName(Workflow workflow, FunctionDefinition function, Optional context, URI uri, String operation, String service) { - return Path.of(uri.getPath()).toString(); + public String getFileName(Workflow workflow, FunctionDefinition function, Optional context, String uri, String operation, String service) { + return URIContentLoaderType.from(uri).uriToPath(uri); } @Override diff --git a/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/operationid/WorkflowOperationId.java b/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/operationid/WorkflowOperationId.java index c32be6e22c6..258f60a2bb8 100644 --- a/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/operationid/WorkflowOperationId.java +++ b/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/operationid/WorkflowOperationId.java @@ -18,16 +18,14 @@ */ package org.kie.kogito.serverless.workflow.operationid; -import java.net.URI; - public class WorkflowOperationId { - private final URI uri; + private final String uri; private final String operation; private final String fileName; private final String packageName; private final String service; - WorkflowOperationId(URI uri, String operation, String service, String fileName, String packageName) { + WorkflowOperationId(String uri, String operation, String service, String fileName, String packageName) { this.uri = uri; this.operation = operation; this.service = service; @@ -35,7 +33,7 @@ public class WorkflowOperationId { this.packageName = packageName; } - public URI getUri() { + public String getUri() { return uri; } diff --git a/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/parser/JsonSchemaReader.java b/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/parser/JsonSchemaReader.java index 5fe1027a851..81e47771caf 100644 --- a/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/parser/JsonSchemaReader.java +++ b/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/parser/JsonSchemaReader.java @@ -20,7 +20,6 @@ import java.io.IOException; import java.io.UncheckedIOException; -import java.net.URI; import java.util.HashMap; import java.util.Map; import java.util.Objects; @@ -62,12 +61,12 @@ private static String getId(JsonNode schemaContent, Counter counter) { } } - static JsonNode read(URI baseURI, byte[] content) { + static JsonNode read(String baseURI, byte[] content) { try { ObjectNode node = ObjectMapperFactory.get().readValue(content, ObjectNode.class); JsonNode id = node.get("$id"); if (id != null) { - baseURI = URI.create(id.asText()); + baseURI = id.asText(); } Objects.requireNonNull(baseURI, "BaseURI must not be null"); Map schemas = new HashMap<>(); @@ -88,7 +87,7 @@ private static JsonNode fillDefs(Map schemas) { return node; } - private static void replaceRefsWithDefs(JsonNode node, URI baseURI, Map schemas, Counter counter) { + private static void replaceRefsWithDefs(JsonNode node, String baseURI, Map schemas, Counter counter) { if (node.isArray()) { node.elements().forEachRemaining(n -> replaceRefsWithDefs(n, baseURI, schemas, counter)); } else if (node.isObject()) { @@ -103,7 +102,7 @@ private static void replaceRefsWithDefs(JsonNode node, URI baseURI, Map parseProcess() { private Optional modelValidator(ParserContext parserContext, Optional schema) { return schema.map(s -> new JsonSchemaValidatorSupplier(JsonSchemaReader.read( - getBaseURI(workflow).map(u -> compoundURI(u, URI.create(s.getSchema()))).orElseGet(() -> URI.create(s.getSchema())), + getBaseURI(workflow).map(u -> compoundURI(u, s.getSchema())).orElseGet(() -> s.getSchema()), readBytes(s.getSchema(), workflow, parserContext)), s.isFailOnValidationErrors())); } diff --git a/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/parser/handlers/CompositeContextNodeHandler.java b/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/parser/handlers/CompositeContextNodeHandler.java index c4341e399ae..d5b473bef8c 100644 --- a/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/parser/handlers/CompositeContextNodeHandler.java +++ b/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/parser/handlers/CompositeContextNodeHandler.java @@ -19,6 +19,7 @@ package org.kie.kogito.serverless.workflow.parser.handlers; import java.util.List; +import java.util.Map; import java.util.Optional; import java.util.stream.Stream; @@ -209,9 +210,15 @@ private Stream getFunctionDefStream() { private NodeFactory fromFunctionDefinition(RuleFlowNodeContainerFactory embeddedSubProcess, FunctionDefinition functionDef, FunctionRef functionRef, VariableInfo varInfo) { - return FunctionTypeHandlerFactory.instance().getTypeHandler(functionDef) + NodeFactory result = FunctionTypeHandlerFactory.instance().getTypeHandler(functionDef) .map(type -> type.getActionNode(workflow, parserContext, embeddedSubProcess, functionDef, functionRef, varInfo)) - .orElseGet(() -> (NodeFactory) embeddedSubProcess.actionNode(parserContext.newId()).name(functionRef.getRefName()).action(JavaDialect.ID, "")); + .orElseGet(() -> (NodeFactory) embeddedSubProcess.actionNode(parserContext.newId()).name(functionRef.getRefName()).action(JavaDialect.ID, "") + .metaData(XORSPLITDEFAULT, varInfo)); + Map metadata = functionDef.getMetadata(); + if (metadata != null) { + metadata.forEach((k, v) -> result.metaData(k, v)); + } + return result; } private Optional fromPredefinedFunction(RuleFlowNodeContainerFactory embeddedSubProcess, diff --git a/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/utils/ServerlessWorkflowUtils.java b/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/utils/ServerlessWorkflowUtils.java index 9a85a798e86..e21330ef2e1 100644 --- a/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/utils/ServerlessWorkflowUtils.java +++ b/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/utils/ServerlessWorkflowUtils.java @@ -22,7 +22,6 @@ import java.io.InputStreamReader; import java.io.Reader; import java.io.Writer; -import java.net.URI; import java.net.URL; import java.nio.file.Files; import java.nio.file.Path; @@ -141,8 +140,8 @@ public static void writeWorkflow(Workflow workflow, Writer writer, WorkflowForma objectMapper.writeValue(writer, workflow); } - public static Optional getBaseURI(Workflow workflow) { - return Optional.ofNullable(getMetadata(workflow).get(BASE_URI)).map(URI::create); + public static Optional getBaseURI(Workflow workflow) { + return Optional.ofNullable(getMetadata(workflow).get(BASE_URI)); } public static Workflow withBaseURI(Workflow workflow, String baseURI) { diff --git a/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/test/java/org/kie/kogito/serverless/workflow/io/ClassPathContentLoaderTest.java b/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/test/java/org/kie/kogito/serverless/workflow/io/ClassPathContentLoaderTest.java index 4c317433b50..5f732566b16 100644 --- a/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/test/java/org/kie/kogito/serverless/workflow/io/ClassPathContentLoaderTest.java +++ b/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/test/java/org/kie/kogito/serverless/workflow/io/ClassPathContentLoaderTest.java @@ -18,7 +18,6 @@ */ package org.kie.kogito.serverless.workflow.io; -import java.net.URI; import java.util.Optional; import org.junit.jupiter.api.Test; @@ -45,7 +44,7 @@ void testPrefixSlashPath() { } void testPath(String prefix) { - ClassPathContentLoader contentLoader = new ClassPathContentLoader(URI.create(prefix + PATH), Optional.empty()); + ClassPathContentLoader contentLoader = new ClassPathContentLoader(prefix + PATH, Optional.empty()); assertThat(contentLoader.classpath()).isEqualTo(PATH); } diff --git a/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/test/java/org/kie/kogito/serverless/workflow/io/ResourceCacheFactoryTest.java b/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/test/java/org/kie/kogito/serverless/workflow/io/ResourceCacheFactoryTest.java index 76d419bed84..a995d3d4cb4 100644 --- a/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/test/java/org/kie/kogito/serverless/workflow/io/ResourceCacheFactoryTest.java +++ b/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/test/java/org/kie/kogito/serverless/workflow/io/ResourceCacheFactoryTest.java @@ -18,11 +18,10 @@ */ package org.kie.kogito.serverless.workflow.io; -import java.net.URI; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.atomic.AtomicInteger; -import java.util.function.Function; +import java.util.function.Supplier; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -31,13 +30,13 @@ public class ResourceCacheFactoryTest { - private URI uri; + private String uri; private AtomicInteger counter; @BeforeEach void setup() { - uri = URI.create("http:://www.google.com"); + uri = "http:://www.google.com"; counter = new AtomicInteger(); } @@ -62,11 +61,11 @@ void testCustomResourceCache() { } private static class TestResourceCache implements ResourceCache { - private Map map = new ConcurrentHashMap<>(); + private Map map = new ConcurrentHashMap<>(); @Override - public byte[] get(URI uri, Function retrieveCall) { - return map.computeIfAbsent(uri, retrieveCall); + public byte[] get(String uri, Supplier retrieveCall) { + return map.computeIfAbsent(uri, u -> retrieveCall.get()); } } @@ -77,7 +76,7 @@ private void callIt(int numOfTimes) { } } - private byte[] called(URI uri) { + private byte[] called() { return new byte[] { (byte) counter.incrementAndGet() }; } } diff --git a/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/test/java/org/kie/kogito/serverless/workflow/io/URIContentLoaderTest.java b/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/test/java/org/kie/kogito/serverless/workflow/io/URIContentLoaderTest.java index e3c2ec36962..551b9c22fbc 100644 --- a/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/test/java/org/kie/kogito/serverless/workflow/io/URIContentLoaderTest.java +++ b/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/test/java/org/kie/kogito/serverless/workflow/io/URIContentLoaderTest.java @@ -19,7 +19,6 @@ package org.kie.kogito.serverless.workflow.io; import java.io.UncheckedIOException; -import java.net.URI; import java.net.URISyntaxException; import org.junit.jupiter.api.Test; @@ -35,12 +34,12 @@ class URIContentLoaderTest { @Test void testExistingFile() throws URISyntaxException { - assertThat(readString(builder(Thread.currentThread().getContextClassLoader().getResource("pepe.txt").toURI()))).isEqualTo("my name is javierito"); + assertThat(readString(builder(Thread.currentThread().getContextClassLoader().getResource("pepe a pepa.txt").toURI()))).isEqualTo("my name is javierito"); } @Test void testExistingClasspath() { - assertThat(readString(builder("classpath:pepe.txt"))).isEqualTo("my name is javierito"); + assertThat(readString(builder("classpath:pepe a pepa.txt"))).isEqualTo("my name is javierito"); } @Test @@ -52,18 +51,19 @@ void testNotExistingFile() { @Test void testNotExistingClasspath() { Builder builder = builder("classpath:/noPepe.txt"); - assertThatExceptionOfType(UncheckedIOException.class).isThrownBy(() -> readString(builder)); + assertThatExceptionOfType(IllegalArgumentException.class).isThrownBy(() -> readString(builder)); } @Test void testCompoundURI() { - assertThat(compoundURI(URI.create("classpath:pepe.json"), URI.create("pepa.json"))).isEqualTo(URI.create("classpath:/pepa.json")); - assertThat(compoundURI(URI.create("classpath:pepe.json"), URI.create("file:///pepa.json"))).isEqualTo(URI.create("file:///pepa.json")); - assertThat(compoundURI(URI.create("classpath:schema/pepe.json"), URI.create("/pepa.json"))).isEqualTo(URI.create("classpath:/pepa.json")); - assertThat(compoundURI(URI.create("classpath:schema/pepe.json"), URI.create("pepa.json"))).isEqualTo(URI.create("classpath:/schema/pepa.json")); - assertThat(compoundURI(URI.create("pepe.json"), URI.create("pepa.json"))).isEqualTo(URI.create("file:///pepa.json")); - assertThat(compoundURI(URI.create("schema/pepe.json"), URI.create("pepa.json"))).isEqualTo(URI.create("file:///schema/pepa.json")); - assertThat(compoundURI(URI.create("schema/pepe.json"), URI.create("/pepa.json"))).isEqualTo(URI.create("file:///pepa.json")); - assertThat(compoundURI(URI.create("pepe.json"), URI.create("classpath:pepa.json"))).isEqualTo(URI.create("classpath:pepa.json")); + assertThat(compoundURI("classpath:pepe.json", "pepa.json")).isEqualTo("classpath:pepa.json"); + assertThat(compoundURI("classpath:pepe.json", "file:/pepa.json")).isEqualTo("file:/pepa.json"); + assertThat(compoundURI("classpath:schema/pepe.json", "/pepa.json")).isEqualTo("classpath:/pepa.json"); + assertThat(compoundURI("classpath:schema/pepe.json", "pepa.json")).isEqualTo("classpath:schema/pepa.json"); + assertThat(compoundURI("pepe.json", "pepa.json")).isEqualTo("pepa.json"); + assertThat(compoundURI("schema/pepe.json", "pepa.json")).isEqualTo("schema/pepa.json"); + assertThat(compoundURI("schema/pepe.json", "/pepa.json")).isEqualTo("/pepa.json"); + assertThat(compoundURI("pepe.json", "classpath:pepa.json")).isEqualTo("classpath:pepa.json"); } + } diff --git a/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/test/java/org/kie/kogito/serverless/workflow/operationid/FileNameWorkflowOperationIdTest.java b/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/test/java/org/kie/kogito/serverless/workflow/operationid/FileNameWorkflowOperationIdTest.java index e9606a5093f..336cb8ae143 100644 --- a/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/test/java/org/kie/kogito/serverless/workflow/operationid/FileNameWorkflowOperationIdTest.java +++ b/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/test/java/org/kie/kogito/serverless/workflow/operationid/FileNameWorkflowOperationIdTest.java @@ -28,7 +28,6 @@ import io.serverlessworkflow.api.functions.FunctionDefinition.Type; import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.mockito.Mockito.mock; class FileNameWorkflowOperationIdTest { @@ -67,12 +66,4 @@ void testOperationIdWithService() { assertThat(id.getUri()).hasToString("http://myserver.com/spec/PePE1.yaml"); assertThat(id.getService()).isEqualTo("service"); } - - @Test - void testEmptyFileName() { - definition.setType(Type.REST); - definition.setOperation("file://wrongUri.yaml#doSomething"); - assertThatThrownBy(() -> factory.from(workflow, definition, Optional.empty())).isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining("Empty file name"); - } } diff --git a/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/test/resources/pepe.txt b/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/test/resources/pepe a pepa.txt similarity index 100% rename from kogito-serverless-workflow/kogito-serverless-workflow-builder/src/test/resources/pepe.txt rename to kogito-serverless-workflow/kogito-serverless-workflow-builder/src/test/resources/pepe a pepa.txt diff --git a/kogito-serverless-workflow/kogito-serverless-workflow-openapi-common/src/main/java/org/kie/kogito/serverless/workflow/operationid/SpecWorkflowOperationIdFactory.java b/kogito-serverless-workflow/kogito-serverless-workflow-openapi-common/src/main/java/org/kie/kogito/serverless/workflow/operationid/SpecWorkflowOperationIdFactory.java index 0561f95b7d7..9c606ecd981 100644 --- a/kogito-serverless-workflow/kogito-serverless-workflow-openapi-common/src/main/java/org/kie/kogito/serverless/workflow/operationid/SpecWorkflowOperationIdFactory.java +++ b/kogito-serverless-workflow/kogito-serverless-workflow-openapi-common/src/main/java/org/kie/kogito/serverless/workflow/operationid/SpecWorkflowOperationIdFactory.java @@ -18,12 +18,13 @@ */ package org.kie.kogito.serverless.workflow.operationid; -import java.net.URI; import java.util.Optional; import java.util.Set; import org.kie.kogito.serverless.workflow.parser.ParserContext; import org.kie.kogito.serverless.workflow.utils.OpenAPIFactory; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import io.serverlessworkflow.api.Workflow; import io.serverlessworkflow.api.functions.FunctionDefinition; @@ -31,8 +32,10 @@ public class SpecWorkflowOperationIdFactory extends AbstractWorkflowOperationIdFactory { public static final String SPEC_PROP_VALUE = "SPEC_TITLE"; + private static final Logger logger = LoggerFactory.getLogger(SpecWorkflowOperationIdFactory.class); + @Override - public String getFileName(Workflow workflow, FunctionDefinition function, Optional context, URI uri, String operation, String service) { + public String getFileName(Workflow workflow, FunctionDefinition function, Optional context, String uri, String operation, String service) { return OpenAPIFactory.getOpenAPI(uri, workflow, function, context).getInfo() .getTitle(); } diff --git a/kogito-serverless-workflow/kogito-serverless-workflow-openapi-common/src/main/java/org/kie/kogito/serverless/workflow/utils/OpenAPIFactory.java b/kogito-serverless-workflow/kogito-serverless-workflow-openapi-common/src/main/java/org/kie/kogito/serverless/workflow/utils/OpenAPIFactory.java index 5d49f07e71f..6f6835d5f4a 100644 --- a/kogito-serverless-workflow/kogito-serverless-workflow-openapi-common/src/main/java/org/kie/kogito/serverless/workflow/utils/OpenAPIFactory.java +++ b/kogito-serverless-workflow/kogito-serverless-workflow-openapi-common/src/main/java/org/kie/kogito/serverless/workflow/utils/OpenAPIFactory.java @@ -18,7 +18,6 @@ */ package org.kie.kogito.serverless.workflow.utils; -import java.net.URI; import java.util.Optional; import org.kie.kogito.serverless.workflow.parser.ParserContext; @@ -41,7 +40,7 @@ public class OpenAPIFactory { private OpenAPIFactory() { } - public static OpenAPI getOpenAPI(URI uri, Workflow workflow, FunctionDefinition function, Optional context) { + public static OpenAPI getOpenAPI(String uri, Workflow workflow, FunctionDefinition function, Optional context) { SwaggerParseResult result = new OpenAPIParser().readContents(readString(buildLoader(uri, workflow, context, function.getAuthRef())), null, null); OpenAPI openAPI = result.getOpenAPI(); diff --git a/kogito-serverless-workflow/kogito-serverless-workflow-openapi-parser/src/main/java/org/kie/kogito/serverless/workflow/parser/rest/DescriptorRestOperationHandler.java b/kogito-serverless-workflow/kogito-serverless-workflow-openapi-parser/src/main/java/org/kie/kogito/serverless/workflow/parser/rest/DescriptorRestOperationHandler.java index dd46b0b4279..82a63c7cb20 100644 --- a/kogito-serverless-workflow/kogito-serverless-workflow-openapi-parser/src/main/java/org/kie/kogito/serverless/workflow/parser/rest/DescriptorRestOperationHandler.java +++ b/kogito-serverless-workflow/kogito-serverless-workflow-openapi-parser/src/main/java/org/kie/kogito/serverless/workflow/parser/rest/DescriptorRestOperationHandler.java @@ -18,7 +18,6 @@ */ package org.kie.kogito.serverless.workflow.parser.rest; -import java.net.URI; import java.util.ArrayList; import java.util.Collection; import java.util.Optional; @@ -86,7 +85,7 @@ public class DescriptorRestOperationHandler extends OpenAPITypeHandler { private > WorkItemNodeFactory addOpenApiParameters(WorkItemNodeFactory node, Workflow workflow, FunctionDefinition function, ParserContext parserContext, WorkflowOperationId operationId) { - URI uri = operationId.getUri(); + String uri = operationId.getUri(); String serviceName = replaceNonAlphanumeric(operationId.getFileName()); // although OpenAPIParser has built in support to load uri, it messes up when using contextclassloader, so using our retrieval apis to get the content OpenAPI openAPI = OpenAPIFactory.getOpenAPI(uri, workflow, function, Optional.of(parserContext)); diff --git a/kogito-serverless-workflow/kogito-serverless-workflow-runtime/pom.xml b/kogito-serverless-workflow/kogito-serverless-workflow-runtime/pom.xml index abb39d11ef3..fbe32164ce3 100644 --- a/kogito-serverless-workflow/kogito-serverless-workflow-runtime/pom.xml +++ b/kogito-serverless-workflow/kogito-serverless-workflow-runtime/pom.xml @@ -38,9 +38,10 @@ - + org.kie.kogito - jbpm-flow + jbpm-deps-group-engine + pom org.kie.kogito diff --git a/kogito-serverless-workflow/kogito-serverless-workflow-runtime/src/main/java/org/kie/kogito/serverless/workflow/models/JsonNodeModel.java b/kogito-serverless-workflow/kogito-serverless-workflow-runtime/src/main/java/org/kie/kogito/serverless/workflow/models/JsonNodeModel.java index fd7596ec6e7..cd8bdb78ebf 100644 --- a/kogito-serverless-workflow/kogito-serverless-workflow-runtime/src/main/java/org/kie/kogito/serverless/workflow/models/JsonNodeModel.java +++ b/kogito-serverless-workflow/kogito-serverless-workflow-runtime/src/main/java/org/kie/kogito/serverless/workflow/models/JsonNodeModel.java @@ -39,6 +39,7 @@ public class JsonNodeModel implements Model, MapInput, MapInputId, MapOutput, MappableToModel { private JsonNode workflowdata; + private JsonNode input; private String id; private Map additionalProperties = Collections.emptyMap(); @@ -57,6 +58,7 @@ public JsonNodeModel(String id, Object workflowdata) { ObjectMapper mapper = ObjectMapperFactory.listenerAware(); this.workflowdata = workflowdata == null ? mapper.createObjectNode() : mapper.convertValue(workflowdata, JsonNode.class); } + this.input = this.workflowdata.deepCopy(); } public String getId() { @@ -122,6 +124,9 @@ public MapInput fromMap(Map params) { public Map toMap() { Map map = new HashMap<>(); map.put(SWFConstants.DEFAULT_WORKFLOW_VAR, workflowdata); + if (input != null) { + map.put(SWFConstants.INPUT_WORKFLOW_VAR, input); + } map.putAll(additionalProperties); return map; } diff --git a/kogito-serverless-workflow/kogito-serverless-workflow-utils/pom.xml b/kogito-serverless-workflow/kogito-serverless-workflow-utils/pom.xml index 055f36c0645..254c0e825da 100644 --- a/kogito-serverless-workflow/kogito-serverless-workflow-utils/pom.xml +++ b/kogito-serverless-workflow/kogito-serverless-workflow-utils/pom.xml @@ -39,9 +39,10 @@ - + org.kie.kogito - jbpm-flow + jbpm-deps-group-engine + pom org.kie.kogito diff --git a/kogito-serverless-workflow/kogito-serverless-workflow-runtime/src/main/java/org/kie/kogito/serverless/workflow/SWFConstants.java b/kogito-serverless-workflow/kogito-serverless-workflow-utils/src/main/java/org/kie/kogito/serverless/workflow/SWFConstants.java similarity index 96% rename from kogito-serverless-workflow/kogito-serverless-workflow-runtime/src/main/java/org/kie/kogito/serverless/workflow/SWFConstants.java rename to kogito-serverless-workflow/kogito-serverless-workflow-utils/src/main/java/org/kie/kogito/serverless/workflow/SWFConstants.java index 3d822ab0be3..5f7dcd17640 100644 --- a/kogito-serverless-workflow/kogito-serverless-workflow-runtime/src/main/java/org/kie/kogito/serverless/workflow/SWFConstants.java +++ b/kogito-serverless-workflow/kogito-serverless-workflow-utils/src/main/java/org/kie/kogito/serverless/workflow/SWFConstants.java @@ -21,6 +21,7 @@ public class SWFConstants { public static final String DEFAULT_WORKFLOW_VAR = "workflowdata"; + public static final String INPUT_WORKFLOW_VAR = "workflowdatainput"; public static final String RESULT = "Result"; public static final String MODEL_WORKFLOW_VAR = "Parameter"; public static final String CONTENT_DATA = "ContentData"; diff --git a/kogito-serverless-workflow/kogito-serverless-workflow-utils/src/main/java/org/kie/kogito/serverless/workflow/utils/InputKogitoProcessContextResolver.java b/kogito-serverless-workflow/kogito-serverless-workflow-utils/src/main/java/org/kie/kogito/serverless/workflow/utils/InputKogitoProcessContextResolver.java new file mode 100644 index 00000000000..f4cd58fb23a --- /dev/null +++ b/kogito-serverless-workflow/kogito-serverless-workflow-utils/src/main/java/org/kie/kogito/serverless/workflow/utils/InputKogitoProcessContextResolver.java @@ -0,0 +1,37 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.kogito.serverless.workflow.utils; + +import java.util.Map; +import java.util.function.Function; + +import org.kie.kogito.internal.process.runtime.KogitoProcessContext; +import org.kie.kogito.serverless.workflow.SWFConstants; + +public class InputKogitoProcessContextResolver implements KogitoProcessContextResolverExtension { + + @Override + public Map> getKogitoProcessContextResolver() { + return Map.of("input", this::getInputVariables); + } + + private Object getInputVariables(KogitoProcessContext context) { + return context.getVariable(SWFConstants.INPUT_WORKFLOW_VAR); + } +} diff --git a/kogito-serverless-workflow/kogito-serverless-workflow-utils/src/main/resources/META-INF/services/org.kie.kogito.serverless.workflow.utils.KogitoProcessContextResolverExtension b/kogito-serverless-workflow/kogito-serverless-workflow-utils/src/main/resources/META-INF/services/org.kie.kogito.serverless.workflow.utils.KogitoProcessContextResolverExtension new file mode 100644 index 00000000000..ccea45bb0cc --- /dev/null +++ b/kogito-serverless-workflow/kogito-serverless-workflow-utils/src/main/resources/META-INF/services/org.kie.kogito.serverless.workflow.utils.KogitoProcessContextResolverExtension @@ -0,0 +1,20 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# + +org.kie.kogito.serverless.workflow.utils.InputKogitoProcessContextResolver \ No newline at end of file diff --git a/kogito-serverless-workflow/kogito-serverless-workflow-utils/src/test/java/org/kie/kogito/serverless/workflow/test/MockBuilder.java b/kogito-serverless-workflow/kogito-serverless-workflow-utils/src/test/java/org/kie/kogito/serverless/workflow/test/MockBuilder.java index 60489858b92..46e2dd6da16 100644 --- a/kogito-serverless-workflow/kogito-serverless-workflow-utils/src/test/java/org/kie/kogito/serverless/workflow/test/MockBuilder.java +++ b/kogito-serverless-workflow/kogito-serverless-workflow-utils/src/test/java/org/kie/kogito/serverless/workflow/test/MockBuilder.java @@ -31,6 +31,9 @@ import org.kie.kogito.internal.process.runtime.KogitoProcessContext; import org.kie.kogito.internal.process.runtime.KogitoProcessInstance; import org.kie.kogito.jackson.utils.ObjectMapperFactory; +import org.kie.kogito.serverless.workflow.SWFConstants; + +import com.fasterxml.jackson.databind.JsonNode; import io.serverlessworkflow.api.Workflow; import io.serverlessworkflow.api.functions.FunctionDefinition; @@ -89,6 +92,7 @@ public Workflow build() { public static class KogitoProcessContextMockBuilder { private Consumer processInstanceMockManipulation; private Map constants = new HashMap<>(); + private JsonNode input; public KogitoProcessContextMockBuilder withProcessInstanceMock(Consumer processInstanceMockManipulation) { this.processInstanceMockManipulation = processInstanceMockManipulation; @@ -100,6 +104,11 @@ public KogitoProcessContextMockBuilder withConstants(Map constan return this; } + public KogitoProcessContextMockBuilder withInput(JsonNode input) { + this.input = input; + return this; + } + public KogitoProcessContext build() { KogitoProcessContext context = mock(KogitoProcessContext.class); KogitoProcessInstance kogitoProcessInstanceMock = mock(KogitoProcessInstance.class); @@ -112,6 +121,7 @@ public KogitoProcessContext build() { if (constants != null && !constants.isEmpty()) { when(processMock.getMetaData()).thenReturn(Collections.singletonMap(Metadata.CONSTANTS, ObjectMapperFactory.get().valueToTree(constants))); } + when(context.getVariable(SWFConstants.INPUT_WORKFLOW_VAR)).thenReturn(input); return context; } } diff --git a/kogito-serverless-workflow/kogito-serverless-workflow-utils/src/test/java/org/kie/kogito/serverless/workflow/utils/KogitoProcessContextResolverTest.java b/kogito-serverless-workflow/kogito-serverless-workflow-utils/src/test/java/org/kie/kogito/serverless/workflow/utils/KogitoProcessContextResolverTest.java index 62d13a7d54c..83ad2df3be4 100644 --- a/kogito-serverless-workflow/kogito-serverless-workflow-utils/src/test/java/org/kie/kogito/serverless/workflow/utils/KogitoProcessContextResolverTest.java +++ b/kogito-serverless-workflow/kogito-serverless-workflow-utils/src/test/java/org/kie/kogito/serverless/workflow/utils/KogitoProcessContextResolverTest.java @@ -20,8 +20,11 @@ import org.junit.jupiter.api.Test; import org.kie.kogito.internal.process.runtime.KogitoProcessContext; +import org.kie.kogito.jackson.utils.ObjectMapperFactory; import org.kie.kogito.serverless.workflow.test.MockBuilder; +import com.fasterxml.jackson.databind.JsonNode; + import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; import static org.mockito.Mockito.when; @@ -29,6 +32,7 @@ public class KogitoProcessContextResolverTest { KogitoProcessContext context = MockBuilder.kogitoProcessContext() + .withInput(ObjectMapperFactory.get().createObjectNode().put("pepe", "pepe")) .withProcessInstanceMock(it -> { when(it.getId()).thenReturn("value-id"); when(it.getProcessId()).thenReturn("value-process-id"); @@ -50,6 +54,11 @@ void testGetName() { assertThat(KogitoProcessContextResolver.get().readKey(context, "name")).isEqualTo("value-name"); } + @Test + void testGetInput() { + assertThat(KogitoProcessContextResolver.get().readKey(context, "input")).isInstanceOf(JsonNode.class); + } + @Test void testGetNonExistentKey() { assertThatIllegalArgumentException().isThrownBy(() -> KogitoProcessContextResolver.get().readKey(context, "nonexistent")); diff --git a/kogito-workitems/kogito-rest-workitem/pom.xml b/kogito-workitems/kogito-rest-workitem/pom.xml index b9f14cb19ad..75ebc13e8a7 100644 --- a/kogito-workitems/kogito-rest-workitem/pom.xml +++ b/kogito-workitems/kogito-rest-workitem/pom.xml @@ -41,7 +41,8 @@ org.kie.kogito - jbpm-flow + jbpm-deps-group-engine + pom org.kie.kogito diff --git a/kogito-workitems/kogito-rest-workitem/src/main/java/org/kogito/workitem/rest/RestWorkItemHandler.java b/kogito-workitems/kogito-rest-workitem/src/main/java/org/kogito/workitem/rest/RestWorkItemHandler.java index dbe814e4ba8..279daa331d2 100644 --- a/kogito-workitems/kogito-rest-workitem/src/main/java/org/kogito/workitem/rest/RestWorkItemHandler.java +++ b/kogito-workitems/kogito-rest-workitem/src/main/java/org/kogito/workitem/rest/RestWorkItemHandler.java @@ -152,27 +152,27 @@ public void executeWorkItem(KogitoWorkItem workItem, KogitoWorkItemManager manag path += "?" + query; } } catch (MalformedURLException ex) { - logger.info("Parameter endpoint {} is not valid uri {}", endPoint, ex.getMessage()); + logger.debug("Parameter endpoint {} is not valid uri {}", endPoint, ex.getMessage()); } if (isEmpty(protocol)) { protocol = getParam(parameters, PROTOCOL, String.class, "http"); - logger.info("Protocol not specified, using {}", protocol); + logger.debug("Protocol not specified, using {}", protocol); } boolean isSsl = protocol.equalsIgnoreCase("https"); if (isEmpty(host)) { host = getParam(parameters, HOST, String.class, "localhost"); - logger.info("Host not specified, using {}", host); + logger.debug("Host not specified, using {}", host); } if (port == -1) { port = getParam(parameters, PORT, Integer.class, isSsl ? DEFAULT_SSL_PORT : DEFAULT_PORT); - logger.info("Port not specified, using {}", port); + logger.debug("Port not specified, using {}", port); } if (isEmpty(path)) { path = endPoint; - logger.info("Path is empty, using whole endpoint {}", endPoint); + logger.debug("Path is empty, using whole endpoint {}", endPoint); } logger.debug("Invoking request with protocol {} host {} port {} and endpoint {}", protocol, host, port, path); WebClient client = isSsl ? httpsClient : httpClient; diff --git a/quarkus/addons/jobs/management/runtime/pom.xml b/quarkus/addons/jobs/management/runtime/pom.xml index d63813e0ae0..15da773cd0b 100644 --- a/quarkus/addons/jobs/management/runtime/pom.xml +++ b/quarkus/addons/jobs/management/runtime/pom.xml @@ -43,7 +43,8 @@ org.kie.kogito - jbpm-flow + jbpm-deps-group-engine + pom org.kie diff --git a/quarkus/addons/process-management/runtime/pom.xml b/quarkus/addons/process-management/runtime/pom.xml index f61b4292fe8..48161a444b1 100644 --- a/quarkus/addons/process-management/runtime/pom.xml +++ b/quarkus/addons/process-management/runtime/pom.xml @@ -54,7 +54,8 @@ org.kie.kogito - jbpm-flow + jbpm-deps-group-engine + pom jakarta.ws.rs diff --git a/quarkus/extensions/kogito-quarkus-extension-common/kogito-quarkus-common-deployment/src/main/java/org/kie/kogito/quarkus/common/deployment/KogitoQuarkusApplicationPropertiesProvider.java b/quarkus/extensions/kogito-quarkus-extension-common/kogito-quarkus-common-deployment/src/main/java/org/kie/kogito/quarkus/common/deployment/KogitoQuarkusApplicationPropertiesProvider.java index c0ac45589dc..a64c114c242 100644 --- a/quarkus/extensions/kogito-quarkus-extension-common/kogito-quarkus-common-deployment/src/main/java/org/kie/kogito/quarkus/common/deployment/KogitoQuarkusApplicationPropertiesProvider.java +++ b/quarkus/extensions/kogito-quarkus-extension-common/kogito-quarkus-common-deployment/src/main/java/org/kie/kogito/quarkus/common/deployment/KogitoQuarkusApplicationPropertiesProvider.java @@ -48,4 +48,9 @@ public Optional getApplicationProperty(String property, Class clazz) { public void setApplicationProperty(String key, String value) { System.setProperty(key, value); } + + @Override + public void removeApplicationProperty(String key) { + System.clearProperty(key); + } } diff --git a/quarkus/extensions/kogito-quarkus-processes-extension/kogito-quarkus-processes-integration-test/src/main/resources/com/example/flexible.bpmn b/quarkus/extensions/kogito-quarkus-processes-extension/kogito-quarkus-processes-integration-test/src/main/resources/com/example/flexible.bpmn index 529cde4ec97..a0d6fa7e761 100644 --- a/quarkus/extensions/kogito-quarkus-processes-extension/kogito-quarkus-processes-integration-test/src/main/resources/com/example/flexible.bpmn +++ b/quarkus/extensions/kogito-quarkus-processes-extension/kogito-quarkus-processes-integration-test/src/main/resources/com/example/flexible.bpmn @@ -1,23 +1,5 @@ - - - + + @@ -31,6 +13,9 @@ + + + @@ -77,6 +62,11 @@ + + + manager + + @@ -148,7 +138,7 @@ - _KmYCMDvREDqHa4Mxr_tnBQ - _KmYCMDvREDqHa4Mxr_tnBQ + _wmQzoCcAED2Zf_0CU-GloA + _wmQzoCcAED2Zf_0CU-GloA \ No newline at end of file diff --git a/quarkus/extensions/kogito-quarkus-processes-extension/kogito-quarkus-processes-integration-test/src/test/java/org/acme/StatefulProcessResourceTest.java b/quarkus/extensions/kogito-quarkus-processes-extension/kogito-quarkus-processes-integration-test/src/test/java/org/acme/StatefulProcessResourceTest.java index 87625b9c092..0ec92c1cca7 100644 --- a/quarkus/extensions/kogito-quarkus-processes-extension/kogito-quarkus-processes-integration-test/src/test/java/org/acme/StatefulProcessResourceTest.java +++ b/quarkus/extensions/kogito-quarkus-processes-extension/kogito-quarkus-processes-integration-test/src/test/java/org/acme/StatefulProcessResourceTest.java @@ -18,6 +18,7 @@ */ package org.acme; +import java.util.Collections; import java.util.List; import java.util.Map; @@ -263,13 +264,15 @@ public void signalTaskProcess() { created.data().as(MapDataContext.class) .get("test", Payload.class).getValue()); + TaskMetaDataContext tmdc = TaskMetaDataContext.of(Policy.of("manager", Collections.emptyList())); + // send signal to complete (empty data context for this signal) - ExtendedDataContext taskCreated = taskSvc.create(pid.tasks().get("InitialTask")); + ExtendedDataContext taskCreated = taskSvc.create(pid.tasks().get("InitialTask"), ExtendedDataContext.of(tmdc, EmptyDataContext.Instance)); String tid = taskCreated.data().as(MapDataContext.class).get("id", String.class); TaskInstanceId taskInstanceId = pid.tasks().get("InitialTask").instances().get(tid); - ExtendedDataContext result = taskSvc.complete(taskInstanceId, EmptyDataContext.Instance); + ExtendedDataContext result = taskSvc.complete(taskInstanceId, ExtendedDataContext.of(tmdc, EmptyDataContext.Instance)); assertEquals("ad-hoc", result.data().as(MapDataContext.class).get("test", Payload.class).getValue()); diff --git a/quarkus/extensions/kogito-quarkus-processes-extension/kogito-quarkus-processes/src/main/java/org/kie/kogito/core/process/incubation/quarkus/support/HumanTaskServiceImpl.java b/quarkus/extensions/kogito-quarkus-processes-extension/kogito-quarkus-processes/src/main/java/org/kie/kogito/core/process/incubation/quarkus/support/HumanTaskServiceImpl.java index d9ddd44889b..d1f89d6d86d 100644 --- a/quarkus/extensions/kogito-quarkus-processes-extension/kogito-quarkus-processes/src/main/java/org/kie/kogito/core/process/incubation/quarkus/support/HumanTaskServiceImpl.java +++ b/quarkus/extensions/kogito-quarkus-processes-extension/kogito-quarkus-processes/src/main/java/org/kie/kogito/core/process/incubation/quarkus/support/HumanTaskServiceImpl.java @@ -98,16 +98,19 @@ public ExtendedDataContext get(LocalId id, MetaDataContext meta) { } @Override - public ExtendedDataContext create(LocalId id) { + public ExtendedDataContext create(LocalId id, DataContext dataContext) { TaskId taskId = ProcessIdParser.select(id, TaskId.class); ProcessInstanceId instanceId = taskId.processInstanceId(); Process> process = parseProcess(instanceId.processId()); - WorkItem workItem = svc.signalTask(process, instanceId.processInstanceId(), taskId.taskId()) + ExtendedDataContext edc = dataContext.as(ExtendedDataContext.class); + TaskMetaDataContext mdc = edc.meta().as(TaskMetaDataContext.class); + SecurityPolicy securityPolicy = convertPolicyObject(mdc.policy()); + + WorkItem workItem = svc.signalTask(process, instanceId.processInstanceId(), taskId.taskId(), securityPolicy) .orElseThrow(); - MapDataContext dataContext = MapDataContext.from(workItem); - return ExtendedDataContext.of(ProcessMetaDataContext.of(taskId), dataContext); + return ExtendedDataContext.of(ProcessMetaDataContext.of(taskId), MapDataContext.from(workItem)); } @Override diff --git a/quarkus/extensions/kogito-quarkus-processes-extension/kogito-quarkus-processes/src/main/java/org/kie/kogito/core/process/incubation/quarkus/support/QuarkusHumanTaskService.java b/quarkus/extensions/kogito-quarkus-processes-extension/kogito-quarkus-processes/src/main/java/org/kie/kogito/core/process/incubation/quarkus/support/QuarkusHumanTaskService.java index d1e07cbe397..dbefc3d8f9a 100644 --- a/quarkus/extensions/kogito-quarkus-processes-extension/kogito-quarkus-processes/src/main/java/org/kie/kogito/core/process/incubation/quarkus/support/QuarkusHumanTaskService.java +++ b/quarkus/extensions/kogito-quarkus-processes-extension/kogito-quarkus-processes/src/main/java/org/kie/kogito/core/process/incubation/quarkus/support/QuarkusHumanTaskService.java @@ -51,8 +51,8 @@ public ExtendedDataContext get(LocalId id, MetaDataContext meta) { } @Override - public ExtendedDataContext create(LocalId taskId) { - return delegate.create(taskId); + public ExtendedDataContext create(LocalId taskId, DataContext dataContext) { + return delegate.create(taskId, dataContext); } @Override diff --git a/quarkus/extensions/kogito-quarkus-serverless-workflow-extension/kogito-quarkus-serverless-workflow-deployment/src/main/java/org/kie/kogito/quarkus/serverless/workflow/rpc/WorkflowRPCCodeGenProvider.java b/quarkus/extensions/kogito-quarkus-serverless-workflow-extension/kogito-quarkus-serverless-workflow-deployment/src/main/java/org/kie/kogito/quarkus/serverless/workflow/rpc/WorkflowRPCCodeGenProvider.java index 8c35dcc7bf7..59afcdc0f1d 100644 --- a/quarkus/extensions/kogito-quarkus-serverless-workflow-extension/kogito-quarkus-serverless-workflow-deployment/src/main/java/org/kie/kogito/quarkus/serverless/workflow/rpc/WorkflowRPCCodeGenProvider.java +++ b/quarkus/extensions/kogito-quarkus-serverless-workflow-extension/kogito-quarkus-serverless-workflow-deployment/src/main/java/org/kie/kogito/quarkus/serverless/workflow/rpc/WorkflowRPCCodeGenProvider.java @@ -72,7 +72,8 @@ public boolean trigger(CodeGenContext context) throws CodeGenException { } ProtocUtils.generateDescriptor(protoFiles, context); return true; - } catch (IOException io) { + } catch (Exception io) { + logger.error("Exception generating RPC code", io); throw new CodeGenException(io); } } diff --git a/quarkus/extensions/kogito-quarkus-serverless-workflow-extension/kogito-quarkus-serverless-workflow-deployment/src/main/java/org/kie/kogito/serverless/workflow/io/QuarkusResourceCache.java b/quarkus/extensions/kogito-quarkus-serverless-workflow-extension/kogito-quarkus-serverless-workflow-deployment/src/main/java/org/kie/kogito/serverless/workflow/io/QuarkusResourceCache.java index 310dedb1d6b..17beb1d815b 100644 --- a/quarkus/extensions/kogito-quarkus-serverless-workflow-extension/kogito-quarkus-serverless-workflow-deployment/src/main/java/org/kie/kogito/serverless/workflow/io/QuarkusResourceCache.java +++ b/quarkus/extensions/kogito-quarkus-serverless-workflow-extension/kogito-quarkus-serverless-workflow-deployment/src/main/java/org/kie/kogito/serverless/workflow/io/QuarkusResourceCache.java @@ -18,8 +18,7 @@ */ package org.kie.kogito.serverless.workflow.io; -import java.net.URI; -import java.util.function.Function; +import java.util.function.Supplier; import io.quarkus.cache.Cache; import io.quarkus.cache.CacheName; @@ -40,7 +39,7 @@ void init() { ResourceCacheFactory.setResourceCache(this::get); } - private byte[] get(URI uri, Function retrieveCall) { - return cache.get(uri, retrieveCall).await().indefinitely(); + private byte[] get(String uri, Supplier retrieveCall) { + return cache.get(uri, u -> retrieveCall.get()).await().indefinitely(); } } diff --git a/quarkus/extensions/kogito-quarkus-serverless-workflow-extension/kogito-quarkus-serverless-workflow-integration-test/src/main/resources/application.properties b/quarkus/extensions/kogito-quarkus-serverless-workflow-extension/kogito-quarkus-serverless-workflow-integration-test/src/main/resources/application.properties index cb8cbdd9adf..977b9583315 100644 --- a/quarkus/extensions/kogito-quarkus-serverless-workflow-extension/kogito-quarkus-serverless-workflow-integration-test/src/main/resources/application.properties +++ b/quarkus/extensions/kogito-quarkus-serverless-workflow-extension/kogito-quarkus-serverless-workflow-integration-test/src/main/resources/application.properties @@ -38,7 +38,7 @@ quarkus.kafka.devservices.enabled=false quarkus.kubernetes-client.devservices.enabled=false # OpenApi client properties, see OperationsMockService, which is mocking these two services -quarkus.rest-client.multiplication.url=${multiplication-service-mock.url} +quarkus.rest-client.multiplication.cluster1.url=${multiplication-service-mock.url} quarkus.rest-client.subtraction.url=${subtraction-service-mock.url} quarkus.rest-client.array_yaml.url=${array-service-mock.url} diff --git a/quarkus/extensions/kogito-quarkus-serverless-workflow-extension/kogito-quarkus-serverless-workflow-integration-test/src/main/resources/compensation.sw.json b/quarkus/extensions/kogito-quarkus-serverless-workflow-extension/kogito-quarkus-serverless-workflow-integration-test/src/main/resources/compensation.sw.json new file mode 100644 index 00000000000..884b5fc16da --- /dev/null +++ b/quarkus/extensions/kogito-quarkus-serverless-workflow-extension/kogito-quarkus-serverless-workflow-integration-test/src/main/resources/compensation.sw.json @@ -0,0 +1,93 @@ +{ + "id": "compensation", + "version": "1.0", + "name": "Workflow Error example", + "description": "An example of how compensation works", + "start": "printStatus", + "errors": [ + { + "name": "OddException", + "code": "java.lang.RuntimeException" + } + ], + "functions": [ + { + "name": "isEven", + "type": "custom", + "operation": "service:java:org.kie.kogito.workflows.services.EvenService::isEven" + }], + "states": [ + { + "name": "printStatus", + "type": "inject", + "data": { + "compensated": false + }, + "compensatedBy" : "compensating", + "transition": "branch" + }, + { + "name": "branch", + "type": "switch", + "dataConditions": [ + { + "condition": ".shouldCompensate==true", + "transition": { + "nextState" : "finish_compensate", + "compensate" : true + } + }, + { + "condition": ".shouldCompensate==false", + "transition": { + "nextState" : "finish_not_compensate", + "compensate" : false + } + } + ] + }, + { + "name": "compensating", + "usedForCompensation" : true, + "type": "inject", + "data": { + "compensated": true + }, + "transition" : "compensating_more" + }, + { + "name": "compensating_more", + "usedForCompensation" : true, + "type": "operation", + "actions": [{ "functionRef": { + "refName": "isEven", + "arguments": { + "number": ".number" + } + }}], + "onErrors": [ + { + "errorRef": "OddException", + "transition": "OddHandler" + } + ] + }, + { "name": "OddHandler", + "type":"inject", + "data": { "isEven": false}, + "end": true + }, + { + "name": "finish_compensate", + "type": "operation", + "actions": [], + "end": true + }, + { + "name": "finish_not_compensate", + "type": "operation", + "actions": [], + "end": true + } + ] +} diff --git a/quarkus/extensions/kogito-quarkus-serverless-workflow-extension/kogito-quarkus-serverless-workflow-integration-test/src/main/resources/expression.sw.json b/quarkus/extensions/kogito-quarkus-serverless-workflow-extension/kogito-quarkus-serverless-workflow-integration-test/src/main/resources/expression.sw.json index 9a0b96344ea..84868c3706c 100644 --- a/quarkus/extensions/kogito-quarkus-serverless-workflow-extension/kogito-quarkus-serverless-workflow-integration-test/src/main/resources/expression.sw.json +++ b/quarkus/extensions/kogito-quarkus-serverless-workflow-extension/kogito-quarkus-serverless-workflow-integration-test/src/main/resources/expression.sw.json @@ -85,7 +85,7 @@ "name": "finish", "type": "operation", "stateDataFilter": { - "input": "{result: .number, message: .message}" + "input": "{result: .number, message: .message, originalFirstX: $WORKFLOW.input.numbers[0].x}" }, "actions": [ { diff --git a/quarkus/extensions/kogito-quarkus-serverless-workflow-extension/kogito-quarkus-serverless-workflow-integration-test/src/main/resources/fahrenheit-to-celsius.sw.json b/quarkus/extensions/kogito-quarkus-serverless-workflow-extension/kogito-quarkus-serverless-workflow-integration-test/src/main/resources/fahrenheit-to-celsius.sw.json index 0c33245fad5..1b89b7dd347 100644 --- a/quarkus/extensions/kogito-quarkus-serverless-workflow-extension/kogito-quarkus-serverless-workflow-integration-test/src/main/resources/fahrenheit-to-celsius.sw.json +++ b/quarkus/extensions/kogito-quarkus-serverless-workflow-extension/kogito-quarkus-serverless-workflow-integration-test/src/main/resources/fahrenheit-to-celsius.sw.json @@ -14,7 +14,10 @@ "functions": [ { "name": "multiplication", - "operation": "multiplication#Do Operation" + "operation": "multiplication#Do Operation", + "metadata": { + "configKey" : ".clusterName" + } }, { "name": "subtraction", diff --git a/quarkus/extensions/kogito-quarkus-serverless-workflow-extension/kogito-quarkus-serverless-workflow-integration-test/src/test/java/org/kie/kogito/quarkus/workflows/CompensationRestIT.java b/quarkus/extensions/kogito-quarkus-serverless-workflow-extension/kogito-quarkus-serverless-workflow-integration-test/src/test/java/org/kie/kogito/quarkus/workflows/CompensationRestIT.java new file mode 100644 index 00000000000..11cab0d9f01 --- /dev/null +++ b/quarkus/extensions/kogito-quarkus-serverless-workflow-extension/kogito-quarkus-serverless-workflow-integration-test/src/test/java/org/kie/kogito/quarkus/workflows/CompensationRestIT.java @@ -0,0 +1,60 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.kogito.quarkus.workflows; + +import org.junit.jupiter.api.Test; + +import io.quarkus.test.junit.QuarkusIntegrationTest; +import io.restassured.http.ContentType; + +import static io.restassured.RestAssured.given; +import static org.hamcrest.CoreMatchers.is; + +@QuarkusIntegrationTest +public class CompensationRestIT { + + @Test + public void testErrorRest() { + given() + .contentType(ContentType.JSON) + .accept(ContentType.JSON) + .body("{\"shouldCompensate\" : true, \"number\":2}").when() + .post("/compensation") + .then() + .statusCode(201) + .body("workflowdata.compensated", is(true)); + given() + .contentType(ContentType.JSON) + .accept(ContentType.JSON) + .body("{\"shouldCompensate\" : true, \"number\":3}").when() + .post("/compensation") + .then() + .statusCode(201) + .body("workflowdata.compensated", is(true)) + .body("workflowdata.isEven", is(false)); + given() + .contentType(ContentType.JSON) + .accept(ContentType.JSON) + .body("{\"shouldCompensate\" : false}").when() + .post("/compensation") + .then() + .statusCode(201) + .body("workflowdata.compensated", is(false)); + } +} diff --git a/quarkus/extensions/kogito-quarkus-serverless-workflow-extension/kogito-quarkus-serverless-workflow-integration-test/src/test/java/org/kie/kogito/quarkus/workflows/ConversationFlowIT.java b/quarkus/extensions/kogito-quarkus-serverless-workflow-extension/kogito-quarkus-serverless-workflow-integration-test/src/test/java/org/kie/kogito/quarkus/workflows/ConversationFlowIT.java index ced575a07ef..9d18e18b133 100644 --- a/quarkus/extensions/kogito-quarkus-serverless-workflow-extension/kogito-quarkus-serverless-workflow-integration-test/src/test/java/org/kie/kogito/quarkus/workflows/ConversationFlowIT.java +++ b/quarkus/extensions/kogito-quarkus-serverless-workflow-extension/kogito-quarkus-serverless-workflow-integration-test/src/test/java/org/kie/kogito/quarkus/workflows/ConversationFlowIT.java @@ -18,7 +18,7 @@ */ package org.kie.kogito.quarkus.workflows; -import java.util.Collections; +import java.util.Map; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; @@ -46,11 +46,7 @@ void sanityVerification() { given() .contentType(ContentType.JSON) .when() - .body( - Collections - .singletonMap( - "workflowdata", - Collections.singletonMap("fahrenheit", "100"))) + .body(Map.of("fahrenheit", "100", "clusterName", "cluster1")) .post("/fahrenheit_to_celsius") .then() .statusCode(201) @@ -58,4 +54,26 @@ void sanityVerification() { .body("workflowdata.fahrenheit", is("100")) .body("workflowdata.celsius", is(37.808f)); //values from mock server } + + @Test + void wrongCluster() { + given() + .contentType(ContentType.JSON) + .when() + .body(Map.of("fahrenheit", "100", "clusterName", "cluster2")) + .post("/fahrenheit_to_celsius") + .then() + .statusCode(400); + } + + @Test + void wrongData() { + given() + .contentType(ContentType.JSON) + .when() + .body(Map.of("fahrenheit", "100")) + .post("/fahrenheit_to_celsius") + .then() + .statusCode(400); + } } diff --git a/quarkus/extensions/kogito-quarkus-serverless-workflow-extension/kogito-quarkus-serverless-workflow-integration-test/src/test/java/org/kie/kogito/quarkus/workflows/ExpressionRestIT.java b/quarkus/extensions/kogito-quarkus-serverless-workflow-extension/kogito-quarkus-serverless-workflow-integration-test/src/test/java/org/kie/kogito/quarkus/workflows/ExpressionRestIT.java index e27b4d1ba66..d6d4122929d 100644 --- a/quarkus/extensions/kogito-quarkus-serverless-workflow-extension/kogito-quarkus-serverless-workflow-integration-test/src/test/java/org/kie/kogito/quarkus/workflows/ExpressionRestIT.java +++ b/quarkus/extensions/kogito-quarkus-serverless-workflow-extension/kogito-quarkus-serverless-workflow-integration-test/src/test/java/org/kie/kogito/quarkus/workflows/ExpressionRestIT.java @@ -43,6 +43,7 @@ void testExpressionRest() { .then() .statusCode(201) .body("workflowdata.result", is(4)) + .body("workflowdata.originalFirstX", is(2)) .body("workflowdata.number", nullValue()) .body("workflowdata.message", is("my name is javierito and in my native language dog is translated to perro and the header pepe is pepa")) .body("workflowdata.user", is("anonymous")) diff --git a/quarkus/extensions/kogito-quarkus-serverless-workflow-extension/kogito-quarkus-serverless-workflow/src/main/java/io/quarkus/restclient/runtime/RestClientBuilderFactory.java b/quarkus/extensions/kogito-quarkus-serverless-workflow-extension/kogito-quarkus-serverless-workflow/src/main/java/io/quarkus/restclient/runtime/RestClientBuilderFactory.java index 16098bec511..2eb0ca6a71f 100644 --- a/quarkus/extensions/kogito-quarkus-serverless-workflow-extension/kogito-quarkus-serverless-workflow/src/main/java/io/quarkus/restclient/runtime/RestClientBuilderFactory.java +++ b/quarkus/extensions/kogito-quarkus-serverless-workflow-extension/kogito-quarkus-serverless-workflow/src/main/java/io/quarkus/restclient/runtime/RestClientBuilderFactory.java @@ -18,6 +18,8 @@ */ package io.quarkus.restclient.runtime; +import java.util.Optional; + import org.eclipse.microprofile.context.ManagedExecutor; import org.eclipse.microprofile.rest.client.RestClientBuilder; import org.eclipse.microprofile.rest.client.inject.RegisterRestClient; @@ -32,8 +34,13 @@ public RestClientBuilderFactory(Class proxyType, String baseUriFromAnnotation } public static RestClientBuilder build(Class restClass) { + return build(restClass, Optional.empty()); + } + + public static RestClientBuilder build(Class restClass, Optional calculatedConfigKey) { RegisterRestClient annotation = restClass.getAnnotation(RegisterRestClient.class); - RestClientBuilderFactory instance = new RestClientBuilderFactory(restClass, annotation.baseUri(), annotation.configKey()); + RestClientBuilderFactory instance = + new RestClientBuilderFactory(restClass, annotation.baseUri(), calculatedConfigKey.map(c -> annotation.configKey() + "." + c).orElse(annotation.configKey())); RestClientBuilder builder = RestClientBuilder.newBuilder(); instance.configureBaseUrl(builder); instance.configureTimeouts(builder); diff --git a/quarkus/extensions/kogito-quarkus-serverless-workflow-extension/kogito-quarkus-serverless-workflow/src/main/java/org/kie/kogito/serverless/workflow/openapi/OpenApiWorkItemHandler.java b/quarkus/extensions/kogito-quarkus-serverless-workflow-extension/kogito-quarkus-serverless-workflow/src/main/java/org/kie/kogito/serverless/workflow/openapi/OpenApiWorkItemHandler.java index e8c97f413da..db3799b1a88 100644 --- a/quarkus/extensions/kogito-quarkus-serverless-workflow-extension/kogito-quarkus-serverless-workflow/src/main/java/org/kie/kogito/serverless/workflow/openapi/OpenApiWorkItemHandler.java +++ b/quarkus/extensions/kogito-quarkus-serverless-workflow-extension/kogito-quarkus-serverless-workflow/src/main/java/org/kie/kogito/serverless/workflow/openapi/OpenApiWorkItemHandler.java @@ -22,10 +22,16 @@ import java.lang.reflect.ParameterizedType; import java.util.Collections; import java.util.Map; +import java.util.Optional; +import org.jbpm.process.instance.KogitoProcessContextImpl; +import org.jbpm.util.ContextFactory; +import org.jbpm.workflow.core.WorkflowProcess; import org.kie.kogito.event.cloudevents.extension.ProcessMeta; import org.kie.kogito.internal.process.runtime.KogitoWorkItem; +import org.kie.kogito.process.expr.ExpressionHandlerFactory; import org.kie.kogito.process.workitem.WorkItemExecutionException; +import org.kie.kogito.serverless.workflow.SWFConstants; import org.kie.kogito.serverless.workflow.WorkflowWorkItemHandler; import io.quarkus.restclient.runtime.RestClientBuilderFactory; @@ -39,7 +45,7 @@ public abstract class OpenApiWorkItemHandler extends WorkflowWorkItemHandler @Override protected Object internalExecute(KogitoWorkItem workItem, Map parameters) { Class clazz = getRestClass(); - T ref = RestClientBuilderFactory.build(clazz).register(new ClientRequestFilter() { + T ref = RestClientBuilderFactory.build(clazz, calculatedConfigKey(workItem, parameters)).register(new ClientRequestFilter() { @Override public void filter(ClientRequestContext requestContext) throws IOException { ProcessMeta.fromKogitoWorkItem(workItem).asMap().forEach((k, v) -> requestContext.getHeaders().put(k, Collections.singletonList(v))); @@ -52,6 +58,20 @@ public void filter(ClientRequestContext requestContext) throws IOException { } } + private Optional calculatedConfigKey(KogitoWorkItem workItem, Map parameters) { + String configKeyExpr = (String) workItem.getNodeInstance().getNode().getMetaData().get("configKey"); + if (configKeyExpr == null) { + return Optional.empty(); + } + KogitoProcessContextImpl context = ContextFactory.fromItem(workItem); + String result = ExpressionHandlerFactory.get(((WorkflowProcess) workItem.getProcessInstance().getProcess()).getExpressionLanguage(), configKeyExpr) + .eval(context.getVariable(SWFConstants.DEFAULT_WORKFLOW_VAR), String.class, context); + if (result == null || result.isBlank()) { + throw new IllegalArgumentException("Expression " + configKeyExpr + " returns null or empty value"); + } + return Optional.of(result); + } + protected abstract Object internalExecute(T openAPIRef, Map parameters); protected Class getRestClass() { diff --git a/quarkus/extensions/kogito-quarkus-workflow-extension-common/kogito-quarkus-workflow-common/pom.xml b/quarkus/extensions/kogito-quarkus-workflow-extension-common/kogito-quarkus-workflow-common/pom.xml index 61a6e76d9e1..69118742393 100644 --- a/quarkus/extensions/kogito-quarkus-workflow-extension-common/kogito-quarkus-workflow-common/pom.xml +++ b/quarkus/extensions/kogito-quarkus-workflow-extension-common/kogito-quarkus-workflow-common/pom.xml @@ -47,15 +47,8 @@ org.kie.kogito - jbpm-flow - - - org.kie.kogito - process-serialization-protobuf - - - org.kie.kogito - jbpm-flow-migration + jbpm-deps-group-engine + pom diff --git a/quarkus/integration-tests/integration-tests-quarkus-processes-persistence/integration-tests-processes-persistence-common/src/main/resources/EmbeddedProcess.bpmn b/quarkus/integration-tests/integration-tests-quarkus-processes-persistence/integration-tests-processes-persistence-common/src/main/resources/EmbeddedProcess.bpmn index cecc79f8d2f..9dfe55cf448 100644 --- a/quarkus/integration-tests/integration-tests-quarkus-processes-persistence/integration-tests-processes-persistence-common/src/main/resources/EmbeddedProcess.bpmn +++ b/quarkus/integration-tests/integration-tests-quarkus-processes-persistence/integration-tests-processes-persistence-common/src/main/resources/EmbeddedProcess.bpmn @@ -1,23 +1,5 @@ - - - + + @@ -30,6 +12,9 @@ + + + @@ -107,6 +92,11 @@ + + + admin + + _F42E47AE-D4F9-4D37-8EB2-AC801442B1D3 @@ -169,7 +159,7 @@ - _pN8NAFD8EDqUgOO8muwFaA - _pN8NAFD8EDqUgOO8muwFaA + _rAo8ICf2ED21aIqHWO2T7A + _rAo8ICf2ED21aIqHWO2T7A \ No newline at end of file diff --git a/quarkus/integration-tests/integration-tests-quarkus-processes-persistence/integration-tests-processes-persistence-common/src/test/java/org/kie/kogito/it/PersistenceTest.java b/quarkus/integration-tests/integration-tests-quarkus-processes-persistence/integration-tests-processes-persistence-common/src/test/java/org/kie/kogito/it/PersistenceTest.java index 287a3bf5604..72a8a4a6fc5 100644 --- a/quarkus/integration-tests/integration-tests-quarkus-processes-persistence/integration-tests-processes-persistence-common/src/test/java/org/kie/kogito/it/PersistenceTest.java +++ b/quarkus/integration-tests/integration-tests-quarkus-processes-persistence/integration-tests-processes-persistence-common/src/test/java/org/kie/kogito/it/PersistenceTest.java @@ -187,8 +187,8 @@ void testEmbeddedProcess() { .pathParam("pId", pId) .pathParam("taskId", taskId) .pathParam("processId", PROCESS_EMBEDDED_ID) - .queryParam("user", "test") - .queryParam("group", "test") + .queryParam("user", "admin") + .queryParam("group", "managers") .body("{}") .when() .post("/{processId}/{pId}/Task/{taskId}/phases/complete") @@ -300,6 +300,8 @@ void testAdHocProcess() { String location = given().contentType(ContentType.JSON) .pathParam("pId", pId) + .queryParam("user", "user") + .queryParam("group", "agroup") .when() .post("/AdHocProcess/{pId}/CloseTask") .then() diff --git a/quarkus/integration-tests/integration-tests-quarkus-processes/src/main/resources/AdHocFragments.bpmn b/quarkus/integration-tests/integration-tests-quarkus-processes/src/main/resources/AdHocFragments.bpmn index 207ad199ce1..b1f2dcd8979 100644 --- a/quarkus/integration-tests/integration-tests-quarkus-processes/src/main/resources/AdHocFragments.bpmn +++ b/quarkus/integration-tests/integration-tests-quarkus-processes/src/main/resources/AdHocFragments.bpmn @@ -1,25 +1,8 @@ - - - + + + @@ -46,12 +29,22 @@ + + + + - + + _FACFF454-18FA-420D-A9AB-F4323E38499C_InMessage + _FACFF454-18FA-420D-A9AB-F4323E38499C_OutMessage + + + + @@ -164,6 +157,11 @@ _1853795C-BF23-478D-BD43-7DAE695479DF_newVar1OutputX var1 + + + john + + _830D53F8-A344-45AE-A1A1-2173DD983A43 @@ -207,6 +205,11 @@ _17762652-67B8-46FF-ADFE-D7AF3EA2ADAB_newVar1OutputX var1 + + + john + + @@ -228,26 +231,25 @@ _A6C76B12-32F2-4B07-AD3B-F502D8C3B745 - + - + _731518E6-88A2-4CCC-A2C0-97C45189A7F3_ConditionInputX _731518E6-88A2-4CCC-A2C0-97C45189A7F3_TaskNameInputX - - + _731518E6-88A2-4CCC-A2C0-97C45189A7F3_TaskNameInputX - - - _731518E6-88A2-4CCC-A2C0-97C45189A7F3_TaskNameInputX + + + - + @@ -421,7 +423,7 @@ - _oPtyIJ7WEDidGqXCSGV4Ig - _oPtyIJ7WEDidGqXCSGV4Ig + _N6FuoCf0ED2UEYYcqSwxzw + _N6FuoCf0ED2UEYYcqSwxzw \ No newline at end of file diff --git a/quarkus/integration-tests/integration-tests-quarkus-processes/src/main/resources/cinema.bpmn b/quarkus/integration-tests/integration-tests-quarkus-processes/src/main/resources/cinema.bpmn index aa42fb1a664..31001420145 100644 --- a/quarkus/integration-tests/integration-tests-quarkus-processes/src/main/resources/cinema.bpmn +++ b/quarkus/integration-tests/integration-tests-quarkus-processes/src/main/resources/cinema.bpmn @@ -1,23 +1,5 @@ - - - + + @@ -34,6 +16,9 @@ + + + @@ -72,11 +57,13 @@ + _D61BED76-3864-4739-8C22-63FF18984247_TaskNameInputX _D61BED76-3864-4739-8C22-63FF18984247_movieInputX _D61BED76-3864-4739-8C22-63FF18984247_SkippableInputX + _D61BED76-3864-4739-8C22-63FF18984247_GroupIdInputX _D61BED76-3864-4739-8C22-63FF18984247_reviewedRatingOutputX @@ -100,6 +87,13 @@ + + _D61BED76-3864-4739-8C22-63FF18984247_GroupIdInputX + + + + + _D61BED76-3864-4739-8C22-63FF18984247_reviewedRatingOutputX rating @@ -165,7 +159,7 @@ - _dH388O39EDmWWfa6AU2qgA - _dH388O39EDmWWfa6AU2qgA + _lku_ACf0ED2_05Uj0LuheQ + _lku_ACf0ED2_05Uj0LuheQ \ No newline at end of file diff --git a/quarkus/integration-tests/integration-tests-quarkus-processes/src/main/resources/monitoring.bpmn b/quarkus/integration-tests/integration-tests-quarkus-processes/src/main/resources/monitoring.bpmn index 0ef685eede4..417df6efeb6 100644 --- a/quarkus/integration-tests/integration-tests-quarkus-processes/src/main/resources/monitoring.bpmn +++ b/quarkus/integration-tests/integration-tests-quarkus-processes/src/main/resources/monitoring.bpmn @@ -1,23 +1,5 @@ - - - + + @@ -30,6 +12,9 @@ + + + @@ -81,6 +66,11 @@ + + + admin + + _3627EB59-E9EB-4E98-B00B-F6371CB95F6F @@ -142,7 +132,7 @@ - _MpAUYNfQEDm0G9lwHSzyAw - _MpAUYNfQEDm0G9lwHSzyAw + _a7f6ACf1ED2B6pw-5oYiMQ + _a7f6ACf1ED2B6pw-5oYiMQ \ No newline at end of file diff --git a/quarkus/integration-tests/integration-tests-quarkus-processes/src/main/resources/multi-instance-task.bpmn b/quarkus/integration-tests/integration-tests-quarkus-processes/src/main/resources/multi-instance-task.bpmn index e1c6b95f86a..61bfd8853fa 100644 --- a/quarkus/integration-tests/integration-tests-quarkus-processes/src/main/resources/multi-instance-task.bpmn +++ b/quarkus/integration-tests/integration-tests-quarkus-processes/src/main/resources/multi-instance-task.bpmn @@ -1,24 +1,5 @@ - - - + @@ -35,6 +16,9 @@ + + + @@ -99,6 +83,11 @@ _91B1A61F-5218-4DC8-861D-4C3D2B6C7B49_outputOutputX output + + + admin + + _91B1A61F-5218-4DC8-861D-4C3D2B6C7B49_IN_COLLECTIONInputX _91B1A61F-5218-4DC8-861D-4C3D2B6C7B49_OUT_COLLECTIONOutputX @@ -166,7 +155,7 @@ - _COuUAGniEDqn6_hfs-lZcw - _COuUAGniEDqn6_hfs-lZcw + _3wtAMCf0ED2oFcXdqRefeA + _3wtAMCf0ED2oFcXdqRefeA \ No newline at end of file diff --git a/quarkus/integration-tests/integration-tests-quarkus-processes/src/test/java/org/kie/kogito/integrationtests/quarkus/AdHocFragmentsIT.java b/quarkus/integration-tests/integration-tests-quarkus-processes/src/test/java/org/kie/kogito/integrationtests/quarkus/AdHocFragmentsIT.java index ad9f44d1280..083b39bec01 100644 --- a/quarkus/integration-tests/integration-tests-quarkus-processes/src/test/java/org/kie/kogito/integrationtests/quarkus/AdHocFragmentsIT.java +++ b/quarkus/integration-tests/integration-tests-quarkus-processes/src/test/java/org/kie/kogito/integrationtests/quarkus/AdHocFragmentsIT.java @@ -61,6 +61,8 @@ void testUserTaskProcess() { String taskId = extractID(given() .contentType(ContentType.JSON) + .queryParam("user", "john") + .queryParam("group", "manager") .when() .post("/AdHocFragments/{pid}/AdHocTask1", id) .then() @@ -73,6 +75,7 @@ void testUserTaskProcess() { params.put("newVar1", "Gonzo"); given() .contentType(ContentType.JSON) + .queryParam("user", "john") .when() .body(params) .post("/AdHocFragments/{id}/AdHocTask1/{taskId}", id, taskId) @@ -122,6 +125,7 @@ void testNonAdHocUserTaskProcess() { given() .contentType(ContentType.JSON) + .queryParam("user", "john") .when() .post("/AdHocFragments/{pid}/Task", pid) .then() diff --git a/quarkus/integration-tests/integration-tests-quarkus-processes/src/test/java/org/kie/kogito/integrationtests/quarkus/BasicRestIT.java b/quarkus/integration-tests/integration-tests-quarkus-processes/src/test/java/org/kie/kogito/integrationtests/quarkus/BasicRestIT.java index 60d4467930b..60377d50b2d 100644 --- a/quarkus/integration-tests/integration-tests-quarkus-processes/src/test/java/org/kie/kogito/integrationtests/quarkus/BasicRestIT.java +++ b/quarkus/integration-tests/integration-tests-quarkus-processes/src/test/java/org/kie/kogito/integrationtests/quarkus/BasicRestIT.java @@ -302,6 +302,8 @@ void testGetTasks() { .path("id"); given() + .queryParam("user", "john") + .queryParam("group", "manager") .when() .get("/AdHocFragments/{id}/tasks", id) .then() diff --git a/quarkus/integration-tests/integration-tests-quarkus-processes/src/test/java/org/kie/kogito/integrationtests/quarkus/EnumsIT.java b/quarkus/integration-tests/integration-tests-quarkus-processes/src/test/java/org/kie/kogito/integrationtests/quarkus/EnumsIT.java index da8b93efee1..eb3c5bee60b 100644 --- a/quarkus/integration-tests/integration-tests-quarkus-processes/src/test/java/org/kie/kogito/integrationtests/quarkus/EnumsIT.java +++ b/quarkus/integration-tests/integration-tests-quarkus-processes/src/test/java/org/kie/kogito/integrationtests/quarkus/EnumsIT.java @@ -67,6 +67,7 @@ void testSubmitMovie() { .path("id"); String taskId = given() + .queryParam("group", "customer") .when() .get("/cinema/{pid}/tasks", pid) .then() @@ -80,6 +81,7 @@ void testSubmitMovie() { reviewedRating.put("reviewedRating", Rating.PG_13); given() .contentType(ContentType.JSON) + .queryParam("group", "customer") .when() .body(reviewedRating) .post("/cinema/{pid}/ReviewRatingTask/{taskId}", pid, taskId) diff --git a/quarkus/integration-tests/integration-tests-quarkus-processes/src/test/java/org/kie/kogito/integrationtests/quarkus/MultiInstanceTaskIT.java b/quarkus/integration-tests/integration-tests-quarkus-processes/src/test/java/org/kie/kogito/integrationtests/quarkus/MultiInstanceTaskIT.java index 3c090b4c598..071cf2dcc29 100644 --- a/quarkus/integration-tests/integration-tests-quarkus-processes/src/test/java/org/kie/kogito/integrationtests/quarkus/MultiInstanceTaskIT.java +++ b/quarkus/integration-tests/integration-tests-quarkus-processes/src/test/java/org/kie/kogito/integrationtests/quarkus/MultiInstanceTaskIT.java @@ -69,6 +69,8 @@ void testStartProcess() { given() .contentType(ContentType.JSON) + .queryParam("user", "admin") + .queryParam("group", "managers") .when() .body(Collections.singletonMap("output", "user3")) .post("/multiinstancetaskprocess/{id}/MultiInstanceTask/{tId}", processId, tasks.get(0)) @@ -77,6 +79,8 @@ void testStartProcess() { given() .contentType(ContentType.JSON) + .queryParam("user", "admin") + .queryParam("group", "managers") .when() .body(Collections.singletonMap("output", "user4")) .post("/multiinstancetaskprocess/{id}/MultiInstanceTask/{tId}", processId, tasks.get(1)) diff --git a/springboot/addons/jobs/pom.xml b/springboot/addons/jobs/pom.xml index 1254f0d45cd..2f309f3e9c8 100644 --- a/springboot/addons/jobs/pom.xml +++ b/springboot/addons/jobs/pom.xml @@ -42,7 +42,8 @@ org.kie.kogito - jbpm-flow + jbpm-deps-group-engine + pom org.kie diff --git a/springboot/integration-tests/pom.xml b/springboot/integration-tests/pom.xml index 8079ddab7b8..f9e7e609891 100644 --- a/springboot/integration-tests/pom.xml +++ b/springboot/integration-tests/pom.xml @@ -74,6 +74,10 @@ ${project.version} pom + + org.kie.kogito + kogito-serverless-workflow-openapi-common + org.kie.kogito kogito-maven-plugin diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-processes-it/src/main/resources/AdHocFragments.bpmn b/springboot/integration-tests/src/it/integration-tests-springboot-processes-it/src/main/resources/AdHocFragments.bpmn index 9204dbddc86..5910d68133c 100644 --- a/springboot/integration-tests/src/it/integration-tests-springboot-processes-it/src/main/resources/AdHocFragments.bpmn +++ b/springboot/integration-tests/src/it/integration-tests-springboot-processes-it/src/main/resources/AdHocFragments.bpmn @@ -1,24 +1,7 @@ - - - + + + @@ -45,12 +28,22 @@ + + + + - + + _FACFF454-18FA-420D-A9AB-F4323E38499C_InMessage + _FACFF454-18FA-420D-A9AB-F4323E38499C_OutMessage + + + + @@ -162,6 +155,11 @@ _1853795C-BF23-478D-BD43-7DAE695479DF_newVar1OutputX var1 + + + john + + _830D53F8-A344-45AE-A1A1-2173DD983A43 @@ -205,6 +203,11 @@ _17762652-67B8-46FF-ADFE-D7AF3EA2ADAB_newVar1OutputX var1 + + + john + + @@ -226,20 +229,19 @@ _A6C76B12-32F2-4B07-AD3B-F502D8C3B745 - + - + _731518E6-88A2-4CCC-A2C0-97C45189A7F3_ConditionInputX _731518E6-88A2-4CCC-A2C0-97C45189A7F3_TaskNameInputX - - + _731518E6-88A2-4CCC-A2C0-97C45189A7F3_TaskNameInputX - - - _731518E6-88A2-4CCC-A2C0-97C45189A7F3_TaskNameInputX + + + @@ -419,7 +421,7 @@ - _oPtyIJ7WEDidGqXCSGV4Ig - _oPtyIJ7WEDidGqXCSGV4Ig + _WL3jkCdwED2KYMa5towL6A + _WL3jkCdwED2KYMa5towL6A \ No newline at end of file diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-processes-it/src/main/resources/cinema.bpmn b/springboot/integration-tests/src/it/integration-tests-springboot-processes-it/src/main/resources/cinema.bpmn index 948744b0332..07fad205630 100644 --- a/springboot/integration-tests/src/it/integration-tests-springboot-processes-it/src/main/resources/cinema.bpmn +++ b/springboot/integration-tests/src/it/integration-tests-springboot-processes-it/src/main/resources/cinema.bpmn @@ -1,23 +1,5 @@ - - - + + @@ -33,6 +15,9 @@ + + + @@ -70,11 +55,13 @@ + _D61BED76-3864-4739-8C22-63FF18984247_TaskNameInputX _D61BED76-3864-4739-8C22-63FF18984247_movieInputX _D61BED76-3864-4739-8C22-63FF18984247_SkippableInputX + _D61BED76-3864-4739-8C22-63FF18984247_GroupIdInputX _D61BED76-3864-4739-8C22-63FF18984247_reviewedRatingOutputX @@ -98,6 +85,13 @@ + + _D61BED76-3864-4739-8C22-63FF18984247_GroupIdInputX + + + + + _D61BED76-3864-4739-8C22-63FF18984247_reviewedRatingOutputX @@ -166,7 +160,7 @@ - _Fn2AALIuEDixAIoM09vFmg - _Fn2AALIuEDixAIoM09vFmg + _qASusCfQED2czsDli3US7g + _qASusCfQED2czsDli3US7g \ No newline at end of file diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-processes-it/src/main/resources/monitoring.bpmn b/springboot/integration-tests/src/it/integration-tests-springboot-processes-it/src/main/resources/monitoring.bpmn index a5569e74bc2..29c2c5ca76b 100644 --- a/springboot/integration-tests/src/it/integration-tests-springboot-processes-it/src/main/resources/monitoring.bpmn +++ b/springboot/integration-tests/src/it/integration-tests-springboot-processes-it/src/main/resources/monitoring.bpmn @@ -1,23 +1,5 @@ - - - + + @@ -30,6 +12,9 @@ + + + @@ -81,6 +66,11 @@ + + + admin + + _3627EB59-E9EB-4E98-B00B-F6371CB95F6F @@ -142,7 +132,7 @@ - _VeFwoNfOEDmUhMFz-g9hJw - _VeFwoNfOEDmUhMFz-g9hJw + _HotWUCfXED2W2uK4sFZlyg + _HotWUCfXED2W2uK4sFZlyg \ No newline at end of file diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-processes-it/src/main/resources/multi-instance-task.bpmn b/springboot/integration-tests/src/it/integration-tests-springboot-processes-it/src/main/resources/multi-instance-task.bpmn index e1c6b95f86a..1d6cd33cf0a 100644 --- a/springboot/integration-tests/src/it/integration-tests-springboot-processes-it/src/main/resources/multi-instance-task.bpmn +++ b/springboot/integration-tests/src/it/integration-tests-springboot-processes-it/src/main/resources/multi-instance-task.bpmn @@ -1,24 +1,5 @@ - - - + @@ -35,6 +16,9 @@ + + + @@ -99,6 +83,11 @@ _91B1A61F-5218-4DC8-861D-4C3D2B6C7B49_outputOutputX output + + + admin + + _91B1A61F-5218-4DC8-861D-4C3D2B6C7B49_IN_COLLECTIONInputX _91B1A61F-5218-4DC8-861D-4C3D2B6C7B49_OUT_COLLECTIONOutputX @@ -166,7 +155,7 @@ - _COuUAGniEDqn6_hfs-lZcw - _COuUAGniEDqn6_hfs-lZcw + _xNj0YCfVED2fyK_p0KZlvQ + _xNj0YCfVED2fyK_p0KZlvQ \ No newline at end of file diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-processes-it/src/test/java/org/kie/kogito/integrationtests/springboot/AdHocFragmentsTest.java b/springboot/integration-tests/src/it/integration-tests-springboot-processes-it/src/test/java/org/kie/kogito/integrationtests/springboot/AdHocFragmentsTest.java index da3217be541..85ec3edcf7d 100644 --- a/springboot/integration-tests/src/it/integration-tests-springboot-processes-it/src/test/java/org/kie/kogito/integrationtests/springboot/AdHocFragmentsTest.java +++ b/springboot/integration-tests/src/it/integration-tests-springboot-processes-it/src/test/java/org/kie/kogito/integrationtests/springboot/AdHocFragmentsTest.java @@ -56,7 +56,9 @@ void testUserTaskProcess() { String taskId = extractID(given() .contentType(ContentType.JSON) - .when() + .queryParam("user", "john") + .queryParam("group", "manager") + .when() .post("/AdHocFragments/{pid}/AdHocTask1", id) .then() .statusCode(201) @@ -70,6 +72,7 @@ void testUserTaskProcess() { .contentType(ContentType.JSON) .when() .body(params) + .queryParam("user", "john") .post("/AdHocFragments/{id}/AdHocTask1/{taskId}", id, taskId) .then() .statusCode(200) @@ -117,6 +120,7 @@ void testNonAdHocUserTaskProcess() { given() .contentType(ContentType.JSON) + .queryParam("user", "john") .when() .post("/AdHocFragments/{pid}/Task", pid) .then() diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-processes-it/src/test/java/org/kie/kogito/integrationtests/springboot/BasicRestTest.java b/springboot/integration-tests/src/it/integration-tests-springboot-processes-it/src/test/java/org/kie/kogito/integrationtests/springboot/BasicRestTest.java index cd1350d8090..945a4b321df 100644 --- a/springboot/integration-tests/src/it/integration-tests-springboot-processes-it/src/test/java/org/kie/kogito/integrationtests/springboot/BasicRestTest.java +++ b/springboot/integration-tests/src/it/integration-tests-springboot-processes-it/src/test/java/org/kie/kogito/integrationtests/springboot/BasicRestTest.java @@ -259,9 +259,11 @@ void testGetTasks() { .path("id"); given() - .when() + .queryParam("user", "john") + .queryParam("group", "manager") + .when() .get("/AdHocFragments/{id}/tasks", id) - .then() + .then() .statusCode(200) .body("$.size()", is(1)) .body("[0].name", is("Task")); diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-processes-it/src/test/java/org/kie/kogito/integrationtests/springboot/EnumsTest.java b/springboot/integration-tests/src/it/integration-tests-springboot-processes-it/src/test/java/org/kie/kogito/integrationtests/springboot/EnumsTest.java index fd30482fcb7..dea61421451 100644 --- a/springboot/integration-tests/src/it/integration-tests-springboot-processes-it/src/test/java/org/kie/kogito/integrationtests/springboot/EnumsTest.java +++ b/springboot/integration-tests/src/it/integration-tests-springboot-processes-it/src/test/java/org/kie/kogito/integrationtests/springboot/EnumsTest.java @@ -19,11 +19,9 @@ package org.kie.kogito.integrationtests.springboot; import java.util.Collections; - import java.util.HashMap; import java.util.Map; -import io.restassured.http.ContentType; import org.acme.examples.model.Movie; import org.acme.examples.model.MovieGenre; import org.acme.examples.model.Rating; @@ -33,6 +31,8 @@ import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.junit.jupiter.SpringExtension; +import io.restassured.http.ContentType; + import static io.restassured.RestAssured.given; import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.CoreMatchers.is; @@ -67,6 +67,7 @@ void testSubmitMovie() { .path("id"); TaskModel task = given() + .queryParam("group", "customer") .when() .get("/cinema/{pid}/tasks", pid) .then() @@ -79,6 +80,7 @@ void testSubmitMovie() { given() .contentType(ContentType.JSON) + .queryParam("group", "customer") .when() .body(Collections.singletonMap("reviewedRating", Rating.PG_13)) .post("/cinema/{pid}/ReviewRatingTask/{taskId}", pid, task.getId()) diff --git a/springboot/integration-tests/src/it/integration-tests-springboot-processes-it/src/test/java/org/kie/kogito/integrationtests/springboot/MultiInstanceTaskTest.java b/springboot/integration-tests/src/it/integration-tests-springboot-processes-it/src/test/java/org/kie/kogito/integrationtests/springboot/MultiInstanceTaskTest.java index 6c3981b3499..a9657758fc4 100644 --- a/springboot/integration-tests/src/it/integration-tests-springboot-processes-it/src/test/java/org/kie/kogito/integrationtests/springboot/MultiInstanceTaskTest.java +++ b/springboot/integration-tests/src/it/integration-tests-springboot-processes-it/src/test/java/org/kie/kogito/integrationtests/springboot/MultiInstanceTaskTest.java @@ -69,6 +69,8 @@ void testStartProcess() { given() .contentType(ContentType.JSON) + .queryParam("user", "admin") + .queryParam("group", "managers") .when() .body(Collections.singletonMap("output", "user3")) .post("/multiinstancetaskprocess/{id}/MultiInstanceTask/{tId}", processId, tasks.get(0)) @@ -77,6 +79,8 @@ void testStartProcess() { given() .contentType(ContentType.JSON) + .queryParam("user", "admin") + .queryParam("group", "managers") .when() .body(Collections.singletonMap("output", "user4")) .post("/multiinstancetaskprocess/{id}/MultiInstanceTask/{tId}", processId, tasks.get(1)) diff --git a/springboot/starters/kogito-processes-spring-boot-starter/pom.xml b/springboot/starters/kogito-processes-spring-boot-starter/pom.xml index 675de5803db..c29c25ebe10 100644 --- a/springboot/starters/kogito-processes-spring-boot-starter/pom.xml +++ b/springboot/starters/kogito-processes-spring-boot-starter/pom.xml @@ -39,13 +39,10 @@ - - org.kie.kogito - jbpm-bpmn2 - - + org.kie.kogito - jbpm-flow-migration + jbpm-deps-group-bpmn2-compiler + pom org.kie.kogito