Skip to content

Commit 0472e70

Browse files
committed
test: verify used variables in pro-code setup
1 parent c3e9db3 commit 0472e70

File tree

2 files changed

+261
-0
lines changed

2 files changed

+261
-0
lines changed
Lines changed: 178 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,178 @@
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:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:bioc="http://bpmn.io/schema/bpmn/biocolor/1.0" xmlns:color="http://www.omg.org/spec/BPMN/non-normative/color/1.0" xmlns:modeler="http://camunda.org/schema/modeler/1.0" id="Definitions_19hmm0v" 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:sequenceFlow id="SequenceFlow_2" sourceRef="StartEvent_1" targetRef="TriggerCheckTask" />
5+
<bpmn:startEvent id="StartEvent_1" name="New subscription request">
6+
<bpmn:outgoing>SequenceFlow_2</bpmn:outgoing>
7+
<bpmn:messageEventDefinition id="MessageEventDefinition_06kuoon" messageRef="SUBSCRIPTION_REQUEST_MESSAGE" />
8+
</bpmn:startEvent>
9+
<bpmn:serviceTask id="TriggerCheckTask" name="Trigger check">
10+
<bpmn:incoming>SequenceFlow_2</bpmn:incoming>
11+
<bpmn:outgoing>SequenceFlow_3</bpmn:outgoing>
12+
</bpmn:serviceTask>
13+
<bpmn:exclusiveGateway id="Gateway_1" name="Is age verified" default="SequenceFlow_4">
14+
<bpmn:incoming>SequenceFlow_3</bpmn:incoming>
15+
<bpmn:outgoing>SequenceFlow_1</bpmn:outgoing>
16+
<bpmn:outgoing>SequenceFlow_4</bpmn:outgoing>
17+
</bpmn:exclusiveGateway>
18+
<bpmn:sequenceFlow id="SequenceFlow_3" sourceRef="TriggerCheckTask" targetRef="Gateway_1" />
19+
<bpmn:sequenceFlow id="SequenceFlow_1" name="Yes" sourceRef="Gateway_1" targetRef="Gateway_2">
20+
<bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">=isAgeVerified</bpmn:conditionExpression>
21+
</bpmn:sequenceFlow>
22+
<bpmn:sequenceFlow id="SequenceFlow_4" sourceRef="Gateway_1" targetRef="VerifyAgeTask" />
23+
<bpmn:receiveTask id="VerifyAgeTask" name="Verify Age" messageRef="AGE_VERIFIED_MESSAGE">
24+
<bpmn:incoming>SequenceFlow_4</bpmn:incoming>
25+
<bpmn:outgoing>SequenceFlow_5</bpmn:outgoing>
26+
</bpmn:receiveTask>
27+
<bpmn:exclusiveGateway id="Gateway_2">
28+
<bpmn:incoming>SequenceFlow_1</bpmn:incoming>
29+
<bpmn:incoming>SequenceFlow_5</bpmn:incoming>
30+
<bpmn:outgoing>SequenceFlow_6</bpmn:outgoing>
31+
</bpmn:exclusiveGateway>
32+
<bpmn:sequenceFlow id="SequenceFlow_6" sourceRef="Gateway_2" targetRef="Gateway_3" />
33+
<bpmn:sequenceFlow id="SequenceFlow_5" sourceRef="VerifyAgeTask" targetRef="Gateway_2" />
34+
<bpmn:exclusiveGateway id="Gateway_3" name="Can create subscription?" default="SequenceFlow_7">
35+
<bpmn:incoming>SequenceFlow_6</bpmn:incoming>
36+
<bpmn:outgoing>SequenceFlow_10</bpmn:outgoing>
37+
<bpmn:outgoing>SequenceFlow_7</bpmn:outgoing>
38+
</bpmn:exclusiveGateway>
39+
<bpmn:sequenceFlow id="SequenceFlow_10" name="Yes" sourceRef="Gateway_1" targetRef="CreateSubscriptionTask">
40+
<bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">=isAgeVerified and is empty(checkResults)</bpmn:conditionExpression>
41+
</bpmn:sequenceFlow>
42+
<bpmn:sequenceFlow id="SequenceFlow_7" sourceRef="Gateway_1" targetRef="Send_Rejection" />
43+
<bpmn:serviceTask id="CreateSubscriptionTask" name="Create Subscription">
44+
<bpmn:incoming>SequenceFlow_10</bpmn:incoming>
45+
<bpmn:outgoing>SequenceFlow_9</bpmn:outgoing>
46+
</bpmn:serviceTask>
47+
<bpmn:endEvent id="EndEvent_2" name="Subscription created">
48+
<bpmn:incoming>SequenceFlow_9</bpmn:incoming>
49+
</bpmn:endEvent>
50+
<bpmn:sequenceFlow id="SequenceFlow_9" sourceRef="CreateSubscriptionTask" targetRef="EndEvent_2" />
51+
<bpmn:serviceTask id="Send_Rejection" name="Send Rejection">
52+
<bpmn:incoming>SequenceFlow_7</bpmn:incoming>
53+
<bpmn:outgoing>SequenceFlow_8</bpmn:outgoing>
54+
</bpmn:serviceTask>
55+
<bpmn:endEvent id="EndEvent_1" name="Rejected">
56+
<bpmn:incoming>SequenceFlow_8</bpmn:incoming>
57+
</bpmn:endEvent>
58+
<bpmn:sequenceFlow id="SequenceFlow_8" sourceRef="Send_Rejection" targetRef="EndEvent_1" />
59+
<bpmn:textAnnotation id="TextAnnotation_1id10go">
60+
<bpmn:text>This process models a typical pro-code scenario where the data model is implicit ("in code")
61+
62+
* variables are only used, never written in the model
63+
* intelligence should indicate variables used</bpmn:text>
64+
</bpmn:textAnnotation>
65+
</bpmn:process>
66+
<bpmn:message id="SUBSCRIPTION_REQUEST_MESSAGE" name="SUBSCRIPTION_REQUEST_MESSAGE" />
67+
<bpmn:message id="AGE_VERIFIED_MESSAGE" name="AGE_VERIFIED">
68+
<bpmn:extensionElements>
69+
<zeebe:subscription correlationKey="=subscriptionRequestID" />
70+
</bpmn:extensionElements>
71+
</bpmn:message>
72+
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
73+
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Process_1">
74+
<bpmndi:BPMNShape id="Event_0g6g003_di" bpmnElement="StartEvent_1">
75+
<dc:Bounds x="182" y="302" width="36" height="36" />
76+
<bpmndi:BPMNLabel>
77+
<dc:Bounds x="158" y="345" width="84" height="27" />
78+
</bpmndi:BPMNLabel>
79+
</bpmndi:BPMNShape>
80+
<bpmndi:BPMNShape id="TriggerCheckTask_di" bpmnElement="TriggerCheckTask">
81+
<dc:Bounds x="270" y="280" width="100" height="80" />
82+
<bpmndi:BPMNLabel />
83+
</bpmndi:BPMNShape>
84+
<bpmndi:BPMNShape id="Gateway_1_di" bpmnElement="Gateway_1" isMarkerVisible="true">
85+
<dc:Bounds x="425" y="295" width="50" height="50" />
86+
<bpmndi:BPMNLabel>
87+
<dc:Bounds x="416" y="265" width="69" height="14" />
88+
</bpmndi:BPMNLabel>
89+
</bpmndi:BPMNShape>
90+
<bpmndi:BPMNShape id="VerifyAgeTask_di" bpmnElement="VerifyAgeTask">
91+
<dc:Bounds x="500" y="390" width="100" height="80" />
92+
<bpmndi:BPMNLabel />
93+
</bpmndi:BPMNShape>
94+
<bpmndi:BPMNShape id="Gateway_2_di" bpmnElement="Gateway_2" isMarkerVisible="true">
95+
<dc:Bounds x="655" y="295" width="50" height="50" />
96+
</bpmndi:BPMNShape>
97+
<bpmndi:BPMNShape id="Gateway_3_di" bpmnElement="Gateway_3" isMarkerVisible="true">
98+
<dc:Bounds x="755" y="295" width="50" height="50" />
99+
<bpmndi:BPMNLabel>
100+
<dc:Bounds x="747" y="258" width="65" height="27" />
101+
</bpmndi:BPMNLabel>
102+
</bpmndi:BPMNShape>
103+
<bpmndi:BPMNShape id="CreateSubscriptionTask_di" bpmnElement="CreateSubscriptionTask">
104+
<dc:Bounds x="870" y="280" width="100" height="80" />
105+
<bpmndi:BPMNLabel />
106+
</bpmndi:BPMNShape>
107+
<bpmndi:BPMNShape id="Send_Rejection_di" bpmnElement="Send_Rejection">
108+
<dc:Bounds x="870" y="390" width="100" height="80" />
109+
<bpmndi:BPMNLabel />
110+
</bpmndi:BPMNShape>
111+
<bpmndi:BPMNShape id="EndEvent_2_di" bpmnElement="EndEvent_2">
112+
<dc:Bounds x="1032" y="302" width="36" height="36" />
113+
<bpmndi:BPMNLabel>
114+
<dc:Bounds x="1020" y="345" width="61" height="27" />
115+
</bpmndi:BPMNLabel>
116+
</bpmndi:BPMNShape>
117+
<bpmndi:BPMNShape id="EndEvent_1_di" bpmnElement="EndEvent_1">
118+
<dc:Bounds x="1032" y="412" width="36" height="36" />
119+
<bpmndi:BPMNLabel>
120+
<dc:Bounds x="1028" y="455" width="44" height="14" />
121+
</bpmndi:BPMNLabel>
122+
</bpmndi:BPMNShape>
123+
<bpmndi:BPMNEdge id="SequenceFlow_2_di" bpmnElement="SequenceFlow_2">
124+
<di:waypoint x="218" y="320" />
125+
<di:waypoint x="270" y="320" />
126+
</bpmndi:BPMNEdge>
127+
<bpmndi:BPMNEdge id="SequenceFlow_3_di" bpmnElement="SequenceFlow_3">
128+
<di:waypoint x="370" y="320" />
129+
<di:waypoint x="425" y="320" />
130+
</bpmndi:BPMNEdge>
131+
<bpmndi:BPMNEdge id="SequenceFlow_1_di" bpmnElement="SequenceFlow_1">
132+
<di:waypoint x="475" y="320" />
133+
<di:waypoint x="655" y="320" />
134+
<bpmndi:BPMNLabel>
135+
<dc:Bounds x="493" y="293" width="18" height="14" />
136+
</bpmndi:BPMNLabel>
137+
</bpmndi:BPMNEdge>
138+
<bpmndi:BPMNEdge id="SequenceFlow_4_di" bpmnElement="SequenceFlow_4">
139+
<di:waypoint x="450" y="345" />
140+
<di:waypoint x="450" y="430" />
141+
<di:waypoint x="500" y="430" />
142+
</bpmndi:BPMNEdge>
143+
<bpmndi:BPMNEdge id="SequenceFlow_6_di" bpmnElement="SequenceFlow_6">
144+
<di:waypoint x="705" y="320" />
145+
<di:waypoint x="755" y="320" />
146+
</bpmndi:BPMNEdge>
147+
<bpmndi:BPMNEdge id="SequenceFlow_5_di" bpmnElement="SequenceFlow_5">
148+
<di:waypoint x="600" y="430" />
149+
<di:waypoint x="680" y="430" />
150+
<di:waypoint x="680" y="345" />
151+
</bpmndi:BPMNEdge>
152+
<bpmndi:BPMNEdge id="SequenceFlow_10_di" bpmnElement="SequenceFlow_10">
153+
<di:waypoint x="805" y="320" />
154+
<di:waypoint x="870" y="320" />
155+
<bpmndi:BPMNLabel>
156+
<dc:Bounds x="829" y="302" width="18" height="14" />
157+
</bpmndi:BPMNLabel>
158+
</bpmndi:BPMNEdge>
159+
<bpmndi:BPMNEdge id="SequenceFlow_7_di" bpmnElement="SequenceFlow_7">
160+
<di:waypoint x="780" y="345" />
161+
<di:waypoint x="780" y="430" />
162+
<di:waypoint x="870" y="430" />
163+
</bpmndi:BPMNEdge>
164+
<bpmndi:BPMNEdge id="SequenceFlow_9_di" bpmnElement="SequenceFlow_9">
165+
<di:waypoint x="970" y="320" />
166+
<di:waypoint x="1032" y="320" />
167+
</bpmndi:BPMNEdge>
168+
<bpmndi:BPMNEdge id="SequenceFlow_8_di" bpmnElement="SequenceFlow_8">
169+
<di:waypoint x="970" y="430" />
170+
<di:waypoint x="1032" y="430" />
171+
</bpmndi:BPMNEdge>
172+
<bpmndi:BPMNShape id="TextAnnotation_1id10go_di" bpmnElement="TextAnnotation_1id10go" bioc:stroke="#0d4372" bioc:fill="#bbdefb" color:background-color="#bbdefb" color:border-color="#0d4372">
173+
<dc:Bounds x="350" y="80" width="375" height="84" />
174+
<bpmndi:BPMNLabel />
175+
</bpmndi:BPMNShape>
176+
</bpmndi:BPMNPlane>
177+
</bpmndi:BPMNDiagram>
178+
</bpmn:definitions>

test/spec/zeebe/ZeebeVariableResolver.spec.js

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ 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 usedVariablesXML from 'test/fixtures/zeebe/used-variables.bpmn';
3435
import usedVariablesScopesXML from 'test/fixtures/zeebe/used-variables.scopes.bpmn';
3536
import readWriteXML from 'test/fixtures/zeebe/read-write.bpmn';
3637
import readWriteHierarchicalXML from 'test/fixtures/zeebe/read-write.hierarchical.bpmn';
@@ -2652,6 +2653,88 @@ describe('ZeebeVariableResolver', function() {
26522653
});
26532654

26542655

2656+
describe('used variables - pro code', function() {
2657+
2658+
beforeEach(bootstrapModeler(usedVariablesXML, {
2659+
additionalModules: [
2660+
ZeebeVariableResolverModule
2661+
],
2662+
moddleExtensions: {
2663+
zeebe: ZeebeModdle
2664+
}
2665+
}));
2666+
2667+
2668+
it('should expose used variables globally', inject(async function(elementRegistry, variableResolver) {
2669+
2670+
// when
2671+
const allVariables = await variableResolver.getVariables();
2672+
2673+
// then
2674+
expect(allVariables).to.have.property('Process_1');
2675+
2676+
expect(allVariables['Process_1']).to.variableEqual([
2677+
{ name: 'isAgeVerified', usedBy: [ 'SequenceFlow_1', 'SequenceFlow_10' ], scope: undefined, origin: undefined },
2678+
{ name: 'subscriptionRequestID', usedBy: [ 'VerifyAgeTask' ], scope: undefined, origin: undefined },
2679+
{ name: 'checkResults', usedBy: [ 'SequenceFlow_10' ], scope: undefined, origin: undefined }
2680+
]);
2681+
2682+
// and when
2683+
const rootElement = elementRegistry.get('Process_1');
2684+
2685+
const processVariables = await variableResolver.getProcessVariables(rootElement);
2686+
2687+
expect(processVariables).to.eql(allVariables['Process_1']);
2688+
}));
2689+
2690+
2691+
describe('should expose used variables per element', function() {
2692+
2693+
it('sequence flow', inject(async function(elementRegistry, variableResolver) {
2694+
2695+
// when
2696+
const flow = elementRegistry.get('SequenceFlow_1');
2697+
2698+
const variables = await variableResolver.getVariablesForElement(flow);
2699+
2700+
// then
2701+
expect(variables).to.variableEqual([
2702+
{ name: 'isAgeVerified', usedBy: [ 'SequenceFlow_1', 'SequenceFlow_10' ], scope: undefined, origin: undefined }
2703+
]);
2704+
}));
2705+
2706+
2707+
it('receive task', inject(async function(elementRegistry, variableResolver) {
2708+
2709+
// when
2710+
const task = elementRegistry.get('VerifyAgeTask');
2711+
2712+
const variables = await variableResolver.getVariablesForElement(task);
2713+
2714+
// then
2715+
expect(variables).to.variableEqual([
2716+
{ name: 'subscriptionRequestID', usedBy: [ 'VerifyAgeTask' ], scope: undefined, origin: undefined }
2717+
]);
2718+
}));
2719+
2720+
2721+
it('process', inject(async function(elementRegistry, variableResolver) {
2722+
2723+
// when
2724+
const rootElement = elementRegistry.get('Process_1');
2725+
2726+
const variables = await variableResolver.getVariablesForElement(rootElement);
2727+
2728+
// then
2729+
// TODO(nikku): should that include variables not used by process?
2730+
expect(variables['Process_1']).to.variableEqual([]);
2731+
}));
2732+
2733+
});
2734+
2735+
});
2736+
2737+
26552738
describe('used variables - read and written', function() {
26562739

26572740
beforeEach(bootstrapModeler(readWriteXML, {

0 commit comments

Comments
 (0)