Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 73 additions & 0 deletions test/fixtures/zeebe/used-variables.scopes.bpmn
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
<?xml version="1.0" encoding="UTF-8"?>
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:zeebe="http://camunda.org/schema/zeebe/1.0" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:modeler="http://camunda.org/schema/modeler/1.0" id="Definitions_1kvhh4n" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="5.44.0" modeler:executionPlatform="Camunda Cloud" modeler:executionPlatformVersion="8.7.0">
<bpmn:process id="Process_1" name="Process_1" isExecutable="true">
<bpmn:subProcess id="SubProcess_1" name="SubProcess_1">
<bpmn:extensionElements>
<zeebe:ioMapping>
<zeebe:input target="approved" />
</zeebe:ioMapping>
</bpmn:extensionElements>
<bpmn:outgoing>Flow_03u12aa</bpmn:outgoing>
<bpmn:scriptTask id="Task_2" name="Task_2">
<bpmn:extensionElements>
<zeebe:script expression="=if approved then 1 else 0" resultVariable="taskResult" />
</bpmn:extensionElements>
</bpmn:scriptTask>
</bpmn:subProcess>
<bpmn:sequenceFlow id="Flow_03u12aa" sourceRef="SubProcess_1" targetRef="Task_1" />
<bpmn:scriptTask id="Task_1" name="Task_1">
<bpmn:extensionElements>
<zeebe:script expression="=if approved then &#34;APPROVED&#34; else &#34;NOT APPROVED&#34;" resultVariable="taskResult" />
</bpmn:extensionElements>
<bpmn:incoming>Flow_03u12aa</bpmn:incoming>
</bpmn:scriptTask>
<bpmn:textAnnotation id="TextAnnotation_06v37so">
<bpmn:text>Defines &lt;approved&gt; as local variable</bpmn:text>
</bpmn:textAnnotation>
<bpmn:association id="Association_1vyzo9d" associationDirection="None" sourceRef="SubProcess_1" targetRef="TextAnnotation_06v37so" />
<bpmn:textAnnotation id="TextAnnotation_1gqpt1k">
<bpmn:text>Uses &lt;approved&gt; variable</bpmn:text>
</bpmn:textAnnotation>
<bpmn:association id="Association_1613yyk" associationDirection="None" sourceRef="TextAnnotation_1gqpt1k" targetRef="Task_1" />
<bpmn:association id="Association_15s62zn" associationDirection="None" sourceRef="TextAnnotation_1gqpt1k" targetRef="Task_2" />
</bpmn:process>
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Process_1">
<bpmndi:BPMNShape id="Activity_0rpc80a_di" bpmnElement="Task_1">
<dc:Bounds x="570" y="270" width="100" height="80" />
<bpmndi:BPMNLabel />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_13kwa1s_di" bpmnElement="SubProcess_1" isExpanded="true">
<dc:Bounds x="160" y="210" width="350" height="200" />
<bpmndi:BPMNLabel />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_0azqo33_di" bpmnElement="Task_2">
<dc:Bounds x="220" y="270" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="Association_1613yyk_di" bpmnElement="Association_1613yyk">
<di:waypoint x="480" y="530" />
<di:waypoint x="613" y="350" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Association_1vyzo9d_di" bpmnElement="Association_1vyzo9d">
<di:waypoint x="347" y="210" />
<di:waypoint x="355" y="135" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Association_15s62zn_di" bpmnElement="Association_15s62zn">
<di:waypoint x="436" y="530" />
<di:waypoint x="279" y="350" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNShape id="TextAnnotation_06v37so_di" bpmnElement="TextAnnotation_06v37so">
<dc:Bounds x="310" y="80" width="100" height="54.999996185302734" />
<bpmndi:BPMNLabel />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="BPMNShape_0u3y3b2" bpmnElement="TextAnnotation_1gqpt1k">
<dc:Bounds x="410" y="530" width="110" height="50" />
<bpmndi:BPMNLabel />
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="Flow_03u12aa_di" bpmnElement="Flow_03u12aa">
<di:waypoint x="510" y="310" />
<di:waypoint x="570" y="310" />
</bpmndi:BPMNEdge>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</bpmn:definitions>
47 changes: 47 additions & 0 deletions test/spec/zeebe/ZeebeVariableResolver.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import subprocessNoOutputMappingXML from 'test/fixtures/zeebe/sub-process.no-out
import longBrokenExpressionXML from 'test/fixtures/zeebe/long-broken-expression.bpmn';
import immediatelyBrokenExpressionXML from 'test/fixtures/zeebe/immediately-broken-expression.bpmn';
import typeResolutionXML from 'test/fixtures/zeebe/type-resolution.bpmn';
import usedVariablesScopesXML from 'test/fixtures/zeebe/used-variables.scopes.bpmn';

import VariableProvider from 'lib/VariableProvider';
import { getInputOutput } from '../../../lib/base/util/ExtensionElementsUtil';
Expand Down Expand Up @@ -2602,6 +2603,52 @@ describe('ZeebeVariableResolver', function() {

});


describe('used variables - scopes', function() {

beforeEach(bootstrapModeler(usedVariablesScopesXML, {
additionalModules: [
ZeebeVariableResolverModule
],
moddleExtensions: {
zeebe: ZeebeModdle
}
}));


it('should attach <usedBy> to local scope', inject(async function(elementRegistry, variableResolver) {

// given
const subProcess = elementRegistry.get('SubProcess_1');

// when
const variables = await variableResolver.getVariablesForElement(subProcess);

// then
expect(variables).to.variableEqual([
{ name: 'taskResult' },
{ name: 'approved', usedBy: [ 'Task_2' ] }
]);
}));


it('should attach <usedBy> to global scope', inject(async function(elementRegistry, variableResolver) {

// given
const rootElement = elementRegistry.get('Process_1');

// when
const variables = await variableResolver.getVariablesForElement(rootElement);

// then
expect(variables).to.variableEqual([
{ name: 'taskResult' },
{ name: 'approved', usedBy: [ 'Task_1' ] }
]);
}));

});

});

// helpers //////////////////////
Expand Down
Loading