Skip to content

Commit c3e9db3

Browse files
committed
test: validate dual use of read and written variable
1 parent 9517567 commit c3e9db3

File tree

3 files changed

+150
-0
lines changed

3 files changed

+150
-0
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<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">
3+
<bpmn:process id="Process_1" name="Write: approved" isExecutable="true">
4+
<bpmn:serviceTask id="ValidateApprovedTask" name="Validate Approved">
5+
<bpmn:extensionElements>
6+
<zeebe:ioMapping>
7+
<zeebe:input source="=approved" target="localApproved" />
8+
<zeebe:output source="=localApproved" target="approved" />
9+
</zeebe:ioMapping>
10+
</bpmn:extensionElements>
11+
</bpmn:serviceTask>
12+
<bpmn:textAnnotation id="TextAnnotation_12joy1t">
13+
<bpmn:text>Write: approved</bpmn:text>
14+
</bpmn:textAnnotation>
15+
<bpmn:association id="Association_1x9i5o6" associationDirection="None" sourceRef="ValidateApprovedTask" targetRef="TextAnnotation_12joy1t" />
16+
<bpmn:textAnnotation id="TextAnnotation_0cyrq9q">
17+
<bpmn:text>Read: approved</bpmn:text>
18+
</bpmn:textAnnotation>
19+
<bpmn:association id="Association_1qg1o3f" associationDirection="None" sourceRef="TextAnnotation_0cyrq9q" targetRef="ValidateApprovedTask" />
20+
</bpmn:process>
21+
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
22+
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Process_1">
23+
<bpmndi:BPMNShape id="Activity_13wsimk_di" bpmnElement="ValidateApprovedTask">
24+
<dc:Bounds x="240" y="170" width="100" height="80" />
25+
<bpmndi:BPMNLabel />
26+
</bpmndi:BPMNShape>
27+
<bpmndi:BPMNEdge id="Association_1x9i5o6_di" bpmnElement="Association_1x9i5o6">
28+
<di:waypoint x="328" y="170" />
29+
<di:waypoint x="386" y="110" />
30+
</bpmndi:BPMNEdge>
31+
<bpmndi:BPMNEdge id="Association_1qg1o3f_di" bpmnElement="Association_1qg1o3f">
32+
<di:waypoint x="201" y="110" />
33+
<di:waypoint x="244" y="172" />
34+
</bpmndi:BPMNEdge>
35+
<bpmndi:BPMNShape id="TextAnnotation_12joy1t_di" bpmnElement="TextAnnotation_12joy1t">
36+
<dc:Bounds x="350" y="80" width="120" height="30" />
37+
<bpmndi:BPMNLabel />
38+
</bpmndi:BPMNShape>
39+
<bpmndi:BPMNShape id="BPMNShape_1n8m9kv" bpmnElement="TextAnnotation_0cyrq9q">
40+
<dc:Bounds x="160" y="80" width="130" height="30" />
41+
<bpmndi:BPMNLabel />
42+
</bpmndi:BPMNShape>
43+
</bpmndi:BPMNPlane>
44+
</bpmndi:BPMNDiagram>
45+
</bpmn:definitions>
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<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">
3+
<bpmn:process id="Process_1" isExecutable="true">
4+
<bpmn:serviceTask id="ValidateApprovedTask" name="Validate Approved">
5+
<bpmn:extensionElements>
6+
<zeebe:ioMapping>
7+
<zeebe:input source="=application.approved" target="localApproved" />
8+
<zeebe:output source="=localApproved" target="application.approved" />
9+
</zeebe:ioMapping>
10+
</bpmn:extensionElements>
11+
</bpmn:serviceTask>
12+
<bpmn:textAnnotation id="TextAnnotation_12joy1t">
13+
<bpmn:text>Write: application.approved</bpmn:text>
14+
</bpmn:textAnnotation>
15+
<bpmn:association id="Association_1x9i5o6" associationDirection="None" sourceRef="ValidateApprovedTask" targetRef="TextAnnotation_12joy1t" />
16+
<bpmn:textAnnotation id="TextAnnotation_0cyrq9q">
17+
<bpmn:text>Read: application.approved</bpmn:text>
18+
</bpmn:textAnnotation>
19+
<bpmn:association id="Association_1qg1o3f" associationDirection="None" sourceRef="TextAnnotation_0cyrq9q" targetRef="ValidateApprovedTask" />
20+
</bpmn:process>
21+
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
22+
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Process_1">
23+
<bpmndi:BPMNShape id="Activity_13wsimk_di" bpmnElement="ValidateApprovedTask">
24+
<dc:Bounds x="290" y="170" width="100" height="80" />
25+
<bpmndi:BPMNLabel />
26+
</bpmndi:BPMNShape>
27+
<bpmndi:BPMNEdge id="Association_1qg1o3f_di" bpmnElement="Association_1qg1o3f">
28+
<di:waypoint x="249" y="106" />
29+
<di:waypoint x="294" y="172" />
30+
</bpmndi:BPMNEdge>
31+
<bpmndi:BPMNEdge id="Association_1x9i5o6_di" bpmnElement="Association_1x9i5o6">
32+
<di:waypoint x="378" y="170" />
33+
<di:waypoint x="436" y="110" />
34+
</bpmndi:BPMNEdge>
35+
<bpmndi:BPMNShape id="TextAnnotation_12joy1t_di" bpmnElement="TextAnnotation_12joy1t">
36+
<dc:Bounds x="400" y="80" width="170" height="30" />
37+
<bpmndi:BPMNLabel />
38+
</bpmndi:BPMNShape>
39+
<bpmndi:BPMNShape id="BPMNShape_1n8m9kv" bpmnElement="TextAnnotation_0cyrq9q">
40+
<dc:Bounds x="160" y="80" width="170" height="25.999998092651367" />
41+
<bpmndi:BPMNLabel />
42+
</bpmndi:BPMNShape>
43+
</bpmndi:BPMNPlane>
44+
</bpmndi:BPMNDiagram>
45+
</bpmn:definitions>

test/spec/zeebe/ZeebeVariableResolver.spec.js

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ import longBrokenExpressionXML from 'test/fixtures/zeebe/long-broken-expression.
3232
import immediatelyBrokenExpressionXML from 'test/fixtures/zeebe/immediately-broken-expression.bpmn';
3333
import typeResolutionXML from 'test/fixtures/zeebe/type-resolution.bpmn';
3434
import usedVariablesScopesXML from 'test/fixtures/zeebe/used-variables.scopes.bpmn';
35+
import readWriteXML from 'test/fixtures/zeebe/read-write.bpmn';
36+
import readWriteHierarchicalXML from 'test/fixtures/zeebe/read-write.hierarchical.bpmn';
3537

3638
import VariableProvider from 'lib/VariableProvider';
3739
import { getInputOutput } from '../../../lib/base/util/ExtensionElementsUtil';
@@ -2649,6 +2651,64 @@ describe('ZeebeVariableResolver', function() {
26492651

26502652
});
26512653

2654+
2655+
describe('used variables - read and written', function() {
2656+
2657+
beforeEach(bootstrapModeler(readWriteXML, {
2658+
additionalModules: [
2659+
ZeebeVariableResolverModule
2660+
],
2661+
moddleExtensions: {
2662+
zeebe: ZeebeModdle
2663+
}
2664+
}));
2665+
2666+
2667+
it('should indicate dual use', inject(async function(elementRegistry, variableResolver) {
2668+
2669+
// given
2670+
const task = elementRegistry.get('ValidateApprovedTask');
2671+
2672+
// when
2673+
const variables = await variableResolver.getVariablesForElement(task);
2674+
2675+
// then
2676+
expect(variables).to.variableEqual([
2677+
{ name: 'approved', scope: 'Process_1', origin: [ 'ValidateApprovedTask' ], usedBy: [ 'ValidateApprovedTask' ] }
2678+
]);
2679+
}));
2680+
2681+
});
2682+
2683+
2684+
describe('used variables - read and written / hierarchical', function() {
2685+
2686+
beforeEach(bootstrapModeler(readWriteHierarchicalXML, {
2687+
additionalModules: [
2688+
ZeebeVariableResolverModule
2689+
],
2690+
moddleExtensions: {
2691+
zeebe: ZeebeModdle
2692+
}
2693+
}));
2694+
2695+
2696+
it('should indicate dual use', inject(async function(elementRegistry, variableResolver) {
2697+
2698+
// given
2699+
const task = elementRegistry.get('ValidateApprovedTask');
2700+
2701+
// when
2702+
const variables = await variableResolver.getVariablesForElement(task);
2703+
2704+
// then
2705+
expect(variables).to.variableEqual([
2706+
{ name: 'application', scope: 'Process_1', origin: [ 'ValidateApprovedTask' ], usedBy: [ 'ValidateApprovedTask' ] }
2707+
]);
2708+
}));
2709+
2710+
});
2711+
26522712
});
26532713

26542714
// helpers //////////////////////

0 commit comments

Comments
 (0)