Skip to content

Commit d66f0a7

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

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
@@ -31,6 +31,8 @@ import subprocessNoOutputMappingXML from 'test/fixtures/zeebe/sub-process.no-out
3131
import longBrokenExpressionXML from 'test/fixtures/zeebe/long-broken-expression.bpmn';
3232
import immediatelyBrokenExpressionXML from 'test/fixtures/zeebe/immediately-broken-expression.bpmn';
3333
import typeResolutionXML from 'test/fixtures/zeebe/type-resolution.bpmn';
34+
import readWriteXML from 'test/fixtures/zeebe/read-write.bpmn';
35+
import readWriteHierarchicalXML from 'test/fixtures/zeebe/read-write.hierarchical.bpmn';
3436

3537
import VariableProvider from 'lib/VariableProvider';
3638
import { getInputOutput } from '../../../lib/base/util/ExtensionElementsUtil';
@@ -2602,6 +2604,64 @@ describe('ZeebeVariableResolver', function() {
26022604

26032605
});
26042606

2607+
2608+
describe('used variables - read and written', function() {
2609+
2610+
beforeEach(bootstrapModeler(readWriteXML, {
2611+
additionalModules: [
2612+
ZeebeVariableResolverModule
2613+
],
2614+
moddleExtensions: {
2615+
zeebe: ZeebeModdle
2616+
}
2617+
}));
2618+
2619+
2620+
it('should indicate dual use', inject(async function(elementRegistry, variableResolver) {
2621+
2622+
// given
2623+
const task = elementRegistry.get('ValidateApprovedTask');
2624+
2625+
// when
2626+
const variables = await variableResolver.getVariablesForElement(task);
2627+
2628+
// then
2629+
expect(variables).to.variableEqual([
2630+
{ name: 'approved', scope: 'Process_1', origin: [ 'ValidateApprovedTask' ], usedBy: [ 'ValidateApprovedTask' ] }
2631+
]);
2632+
}));
2633+
2634+
});
2635+
2636+
2637+
describe('used variables - read and written / hierarchical', function() {
2638+
2639+
beforeEach(bootstrapModeler(readWriteHierarchicalXML, {
2640+
additionalModules: [
2641+
ZeebeVariableResolverModule
2642+
],
2643+
moddleExtensions: {
2644+
zeebe: ZeebeModdle
2645+
}
2646+
}));
2647+
2648+
2649+
it('should indicate dual use', inject(async function(elementRegistry, variableResolver) {
2650+
2651+
// given
2652+
const task = elementRegistry.get('ValidateApprovedTask');
2653+
2654+
// when
2655+
const variables = await variableResolver.getVariablesForElement(task);
2656+
2657+
// then
2658+
expect(variables).to.variableEqual([
2659+
{ name: 'application', scope: 'Process_1', origin: [ 'ValidateApprovedTask' ], usedBy: [ 'ValidateApprovedTask' ] }
2660+
]);
2661+
}));
2662+
2663+
});
2664+
26052665
});
26062666

26072667
// helpers //////////////////////

0 commit comments

Comments
 (0)