Skip to content

Commit 8febb16

Browse files
marstammbarmac
authored andcommitted
test(zeebe): validate linkedResource templates
1 parent c759def commit 8febb16

File tree

4 files changed

+151
-1
lines changed

4 files changed

+151
-1
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ All notable changes to [element-templates-validator](https://github.com/bpmn-io/
66

77
___Note:__ Yet to be released changes appear here._
88

9+
## 2.3.0
10+
11+
* `FEAT`: support `linkedElements` property for zeebe templates ([#153](https://github.com/camunda/element-templates-json-schema/pull/153))
12+
* `DEPS`: update to `@camunda/[email protected]`
13+
914
## 2.2.0
1015

1116
* `FEAT`: support `engines` property for zeebe templates ([#146](https://github.com/camunda/element-templates-json-schema/issues/146), [#152](https://github.com/camunda/element-templates-json-schema/pull/152))
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
[
2+
{
3+
"$schema": "https://unpkg.com/@camunda/zeebe-element-templates-json-schema/resources/schema.json",
4+
"name": "linkedResource missing linkName",
5+
"id": "linkedResource-missing-linkName",
6+
"version": 1,
7+
"appliesTo": [
8+
"bpmn:Task"
9+
],
10+
"elementType": {
11+
"value": "bpmn:ServiceTask"
12+
},
13+
"properties": [
14+
{
15+
"type": "String",
16+
"binding": {
17+
"type": "zeebe:linkedResource",
18+
"property": "resourceType"
19+
}
20+
}
21+
]
22+
},
23+
{
24+
"$schema": "https://unpkg.com/@camunda/zeebe-element-templates-json-schema/resources/schema.json",
25+
"name": "linkedResource missing linkName",
26+
"id": "linkedResource-invalid-binding",
27+
"version": 1,
28+
"appliesTo": [
29+
"bpmn:Task"
30+
],
31+
"elementType": {
32+
"value": "bpmn:ServiceTask"
33+
},
34+
"properties": [
35+
{
36+
"type": "String",
37+
"binding": {
38+
"type": "zeebe:linkedResource",
39+
"linkName": "persistedLink",
40+
"property": "invalidProperty"
41+
}
42+
}
43+
]
44+
}
45+
]

test/fixtures/linked-resource.json

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
[
2+
{
3+
"$schema": "https://unpkg.com/@camunda/zeebe-element-templates-json-schema/resources/schema.json",
4+
"name": "linkedResource",
5+
"id": "linkedResource",
6+
"version": 1,
7+
"appliesTo": [
8+
"bpmn:Task"
9+
],
10+
"elementType": {
11+
"value": "bpmn:ServiceTask"
12+
},
13+
"properties": [
14+
{
15+
"type": "String",
16+
"value": "RPA",
17+
"binding": {
18+
"type": "zeebe:linkedResource",
19+
"linkName": "persistedLink",
20+
"property": "resourceType"
21+
}
22+
},
23+
{
24+
"type": "String",
25+
"feel": "optional",
26+
"binding": {
27+
"type": "zeebe:linkedResource",
28+
"linkName": "persistedLink",
29+
"property": "resourceId"
30+
}
31+
},
32+
{
33+
"type": "String",
34+
"value": "versionTag",
35+
"binding": {
36+
"type": "zeebe:linkedResource",
37+
"linkName": "persistedLink",
38+
"property": "bindingType"
39+
}
40+
},
41+
{
42+
"type": "String",
43+
"value": "v123",
44+
"binding": {
45+
"type": "zeebe:linkedResource",
46+
"linkName": "persistedLink",
47+
"property": "versionTag"
48+
}
49+
},
50+
{
51+
"type": "String",
52+
"value": "RPA",
53+
"binding": {
54+
"type": "zeebe:linkedResource",
55+
"linkName": "removedLink",
56+
"property": "resourceType"
57+
}
58+
}
59+
]
60+
}
61+
]

test/spec/validationSpec.js

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ describe('Validator', function() {
252252
message: 'must provide choices=[] with "Dropdown" type'
253253
},
254254
{
255-
message: 'invalid property.binding type "zeebe:taskDefinition:foo"; must be any of { property, zeebe:taskDefinition:type, zeebe:input, zeebe:output, zeebe:property, zeebe:taskHeader, bpmn:Message#property, bpmn:Message#zeebe:subscription#property }'
255+
message: 'invalid property.binding type "zeebe:taskDefinition:foo"; must be any of { property, zeebe:taskDefinition:type, zeebe:input, zeebe:output, zeebe:property, zeebe:taskHeader, bpmn:Message#property, bpmn:Message#zeebe:subscription#property, zeebe:taskDefinition, zeebe:calledElement, zeebe:linkedResource }'
256256
},
257257
{
258258
message: 'property.binding "zeebe:taskHeader" requires key'
@@ -435,6 +435,45 @@ describe('Validator', function() {
435435
expect(results.map(r => r.object)).to.eql(samples);
436436
});
437437

438+
439+
it('should validate linked resource templates', function() {
440+
441+
// given
442+
const samples = require('../fixtures/linked-resource.json');
443+
444+
// when
445+
const {
446+
valid,
447+
results
448+
} = validateAllZeebe(samples);
449+
450+
// then
451+
expect(valid).to.be.true;
452+
expect(results.length).to.eql(samples.length);
453+
454+
expect(results.every(r => r.valid)).to.be.true;
455+
456+
expect(results.map(r => r.object)).to.eql(samples);
457+
});
458+
459+
460+
it('should validate linked resource templates with errors', function() {
461+
462+
// given
463+
const samples = require('../fixtures/linked-resource-broken.json');
464+
465+
// when
466+
const {
467+
valid,
468+
results
469+
} = validateAllZeebe(samples);
470+
471+
// then
472+
expect(valid).to.be.false;
473+
expect(results.every(r => !r.valid)).to.be.true;
474+
expect(results.map(r => r.object)).to.eql(samples);
475+
});
476+
438477
});
439478

440479
});

0 commit comments

Comments
 (0)