Skip to content

Commit

Permalink
test(zeebe): validate linkedResource templates
Browse files Browse the repository at this point in the history
  • Loading branch information
marstamm committed Jan 16, 2025
1 parent cc705c9 commit c09781c
Show file tree
Hide file tree
Showing 4 changed files with 151 additions and 1 deletion.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ All notable changes to [element-templates-validator](https://github.com/bpmn-io/

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

## 2.3.0

* `FEAT`: support `linkedElements` property for zeebe templates ([#153](https://github.com/camunda/element-templates-json-schema/pull/153))
* `DEPS`: update to `@camunda/[email protected]`

## 2.2.0

* `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))
Expand Down
45 changes: 45 additions & 0 deletions test/fixtures/linked-resource-broken.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
[
{
"$schema": "https://unpkg.com/@camunda/zeebe-element-templates-json-schema/resources/schema.json",
"name": "linkedResource missing linkName",
"id": "linkedResource-missing-linkName",
"version": 1,
"appliesTo": [
"bpmn:Task"
],
"elementType": {
"value": "bpmn:ServiceTask"
},
"properties": [
{
"type": "String",
"binding": {
"type": "zeebe:linkedResource",
"property": "resourceType"
}
}
]
},
{
"$schema": "https://unpkg.com/@camunda/zeebe-element-templates-json-schema/resources/schema.json",
"name": "linkedResource missing linkName",
"id": "linkedResource-invalid-binding",
"version": 1,
"appliesTo": [
"bpmn:Task"
],
"elementType": {
"value": "bpmn:ServiceTask"
},
"properties": [
{
"type": "String",
"binding": {
"type": "zeebe:linkedResource",
"linkName": "persistedLink",
"property": "invalidProperty"
}
}
]
}
]
61 changes: 61 additions & 0 deletions test/fixtures/linked-resource.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
[
{
"$schema": "https://unpkg.com/@camunda/zeebe-element-templates-json-schema/resources/schema.json",
"name": "linkedResource",
"id": "linkedResource",
"version": 1,
"appliesTo": [
"bpmn:Task"
],
"elementType": {
"value": "bpmn:ServiceTask"
},
"properties": [
{
"type": "String",
"value": "RPA",
"binding": {
"type": "zeebe:linkedResource",
"linkName": "persistedLink",
"property": "resourceType"
}
},
{
"type": "String",
"feel": "optional",
"binding": {
"type": "zeebe:linkedResource",
"linkName": "persistedLink",
"property": "resourceId"
}
},
{
"type": "String",
"value": "versionTag",
"binding": {
"type": "zeebe:linkedResource",
"linkName": "persistedLink",
"property": "bindingType"
}
},
{
"type": "String",
"value": "v123",
"binding": {
"type": "zeebe:linkedResource",
"linkName": "persistedLink",
"property": "versionTag"
}
},
{
"type": "String",
"value": "RPA",
"binding": {
"type": "zeebe:linkedResource",
"linkName": "removedLink",
"property": "resourceType"
}
}
]
}
]
41 changes: 40 additions & 1 deletion test/spec/validationSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ describe('Validator', function() {
message: 'must provide choices=[] with "Dropdown" type'
},
{
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 }'
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 }'
},
{
message: 'property.binding "zeebe:taskHeader" requires key'
Expand Down Expand Up @@ -435,6 +435,45 @@ describe('Validator', function() {
expect(results.map(r => r.object)).to.eql(samples);
});


it('should validate linked resource templates', function() {

// given
const samples = require('../fixtures/linked-resource.json');

// when
const {
valid,
results
} = validateAllZeebe(samples);

// then
expect(valid).to.be.true;
expect(results.length).to.eql(samples.length);

expect(results.every(r => r.valid)).to.be.true;

expect(results.map(r => r.object)).to.eql(samples);
});


it('should validate linked resource templates with errors', function() {

// given
const samples = require('../fixtures/linked-resource-broken.json');

// when
const {
valid,
results
} = validateAllZeebe(samples);

// then
expect(valid).to.be.false;
expect(results.every(r => !r.valid)).to.be.true;
expect(results.map(r => r.object)).to.eql(samples);
});

});

});
Expand Down

0 comments on commit c09781c

Please sign in to comment.