forked from flowable/flowable-engine
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for input variables for script tasks
- Loading branch information
Showing
33 changed files
with
719 additions
and
113 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
...pmn-converter/src/test/java/org/flowable/editor/language/xml/ScriptTaskConverterTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* Licensed 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.flowable.editor.language.xml; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
import static org.assertj.core.api.Assertions.tuple; | ||
|
||
import org.flowable.bpmn.model.BpmnModel; | ||
import org.flowable.bpmn.model.FlowElement; | ||
import org.flowable.bpmn.model.IOParameter; | ||
import org.flowable.bpmn.model.ScriptTask; | ||
import org.flowable.editor.language.xml.util.BpmnXmlConverterTest; | ||
|
||
/** | ||
* @author Filip Hrisafov | ||
*/ | ||
class ScriptTaskConverterTest { | ||
|
||
@BpmnXmlConverterTest("scriptTask/script-task-input-parameters.xml") | ||
void scriptTaskWithInputParameters(BpmnModel model) { | ||
FlowElement element = model.getMainProcess().getFlowElement("script1"); | ||
assertThat(element) | ||
.isInstanceOfSatisfying(ScriptTask.class, scriptTask -> { | ||
assertThat(scriptTask.isDoNotIncludeVariables()).isFalse(); | ||
assertThat(scriptTask.getInParameters()) | ||
.extracting(IOParameter::getSource, IOParameter::getSourceExpression, IOParameter::getTarget) | ||
.containsExactlyInAnyOrder( | ||
tuple("aVar", null, "targetAVar"), | ||
tuple(null, "${'test'}", "targetVar") | ||
); | ||
}); | ||
|
||
} | ||
|
||
@BpmnXmlConverterTest("scriptTask/script-task-do-not-include-variables.xml") | ||
void scriptTaskWithDoNotIncludeVariables(BpmnModel model) { | ||
FlowElement element = model.getMainProcess().getFlowElement("script1"); | ||
assertThat(element) | ||
.isInstanceOfSatisfying(ScriptTask.class, scriptTask -> { | ||
assertThat(scriptTask.isDoNotIncludeVariables()).isTrue(); | ||
}); | ||
} | ||
|
||
} |
40 changes: 40 additions & 0 deletions
40
...ble-bpmn-converter/src/test/resources/scriptTask/script-task-do-not-include-variables.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
~ Licensed 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. | ||
--> | ||
|
||
<definitions id="definitions" | ||
xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" | ||
xmlns:flowable="http://flowable.org/bpmn" | ||
targetNamespace="Examples"> | ||
|
||
<process id="testInputVariables"> | ||
|
||
<startEvent id="theStart"/> | ||
<sequenceFlow id="flow1" sourceRef="theStart" targetRef="script1"/> | ||
|
||
<scriptTask id="script1" scriptFormat="JavaScript" flowable:doNotIncludeVariables="true"> | ||
<script><![CDATA[ | ||
var sum = a + b; | ||
execution.setVariable("sum", sum); | ||
]]></script> | ||
</scriptTask> | ||
<sequenceFlow id="flow2" sourceRef="script1" targetRef="theEnd"/> | ||
|
||
<endEvent id="theEnd"/> | ||
|
||
</process> | ||
|
||
</definitions> |
43 changes: 43 additions & 0 deletions
43
...es/flowable-bpmn-converter/src/test/resources/scriptTask/script-task-input-parameters.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
~ Licensed 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. | ||
--> | ||
|
||
<definitions id="definitions" | ||
xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" | ||
xmlns:flowable="http://flowable.org/bpmn" | ||
targetNamespace="Examples"> | ||
|
||
<process id="testInputVariables"> | ||
|
||
<startEvent id="theStart"/> | ||
<sequenceFlow id="flow1" sourceRef="theStart" targetRef="script1"/> | ||
|
||
<scriptTask id="script1" scriptFormat="JavaScript"> | ||
<extensionElements> | ||
<flowable:in source="aVar" target="targetAVar"/> | ||
<flowable:in sourceExpression="${'test'}" target="targetVar"/> | ||
</extensionElements> | ||
<script><![CDATA[ | ||
var sum = a + b; | ||
execution.setVariable("sum", sum); | ||
]]></script> | ||
</scriptTask> | ||
<sequenceFlow id="flow2" sourceRef="script1" targetRef="theEnd"/> | ||
<endEvent id="theEnd"/> | ||
|
||
</process> | ||
|
||
</definitions> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.