Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add support for zeebe:LinkedResource #68

Merged
merged 3 commits into from
Jan 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ All notable changes to [zeebe-bpmn-moddle](https://github.com/camunda/zeebe-bpmn

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

* `FEAT`: support `zeebe:LinkedResource` for `bpmn:ServiceTask`

## 1.7.0

* `FEAT`: support `zeebe:TaskListener` for `bpmn:UserTask` ([#67](https://github.com/camunda/zeebe-bpmn-moddle/pull/67))
Expand Down
49 changes: 48 additions & 1 deletion resources/zeebe.json
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,52 @@
}
]
},
{
"name": "LinkedResource",
"superClass": [
"Element"
],
"meta": {
"allowedIn": [
"bpmn:ServiceTask"
]
},
"properties": [
{
"name": "resourceId",
"type": "String",
"isAttr": true
},
{
"name": "resourceType",
"type": "String",
"isAttr": true
},
{
"name": "linkName",
"type": "String",
"isAttr": true
}
]
},
{
"name": "LinkedResources",
"superClass": [
"Element"
],
"meta": {
"allowedIn": [
"bpmn:ServiceTask"
]
},
"properties": [
{
"name": "values",
"type": "LinkedResource",
"isMany": true
}
]
},
{
"name": "UserTask",
"superClass": [
Expand Down Expand Up @@ -618,7 +664,8 @@
"extends": [
"zeebe:CalledDecision",
"zeebe:CalledElement",
"zeebe:FormDefinition"
"zeebe:FormDefinition",
"zeebe:LinkedResource"
],
"properties": [
{
Expand Down
27 changes: 27 additions & 0 deletions test/fixtures/xml/zeebe-linkedResources.bpmn
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:zeebe="http://camunda.org/schema/zeebe/1.0" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn">
<bpmn:process id="Process_1" isExecutable="true">
<bpmn:serviceTask id="collect-money" name="Collect Money">
<bpmn:extensionElements>
<zeebe:linkedResources>
<zeebe:linkedResource
resourceId="=myScript"
resourceType="RPA"
/>
<zeebe:linkedResource
resourceId="=myScript"
resourceType="RPA"
bindingType="versionTag"
versionTag="v1"
/>
<zeebe:linkedResource
resourceId="=myScript"
resourceType="RPA"
linkName="myScript"
bindingType="deployment"
/>
</zeebe:linkedResources>
</bpmn:extensionElements>
</bpmn:serviceTask>
</bpmn:process>
</bpmn:definitions>
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<bpmn:serviceTask
id="collect-money" name="Collect Money"
xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL"
xmlns:zeebe="http://camunda.org/schema/zeebe/1.0"
>
<bpmn:extensionElements>
<zeebe:linkedResources>
<zeebe:linkedResource
resourceId="=myScript"
resourceType="RPA"
bindingType="latest"
></zeebe:linkedResource>
<zeebe:linkedResource
resourceId="=myScript"
resourceType="RPA"
bindingType="versionTag"
versionTag="v1"
></zeebe:linkedResource>
<zeebe:linkedResource
resourceId="=myScript"
resourceType="RPA"
bindingType="deployment"
linkName="myScript"
></zeebe:linkedResource>
</zeebe:linkedResources>
</bpmn:extensionElements>
</bpmn:serviceTask>
53 changes: 53 additions & 0 deletions test/spec/xml/read.js
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,59 @@ describe('read', function() {
});


describe('zeebe:linkedResource', function() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No tests for write or roundtrip?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🙈

Added in 7056529


it('on ServiceTask', async function() {

// given
var xml = readFile('test/fixtures/xml/zeebe-service-task/serviceTask-zeebe-linkedResource.part.bpmn');

// when
const {
rootElement: proc
} = await moddle.fromXML(xml, 'bpmn:ServiceTask');

// then
expect(proc).to.jsonEqual({
$type: 'bpmn:ServiceTask',
id: 'collect-money',
name: 'Collect Money',
extensionElements: {
$type: 'bpmn:ExtensionElements',
values: [
{
$type: 'zeebe:LinkedResources',
values: [
{
$type: 'zeebe:LinkedResource',
resourceId:'=myScript',
resourceType:'RPA',
bindingType:'latest'
},
{
$type: 'zeebe:LinkedResource',
resourceId: '=myScript',
resourceType: 'RPA',
bindingType: 'versionTag',
versionTag: 'v1'
},
{
$type: 'zeebe:LinkedResource',
resourceId: '=myScript',
resourceType: 'RPA',
bindingType: 'deployment',
linkName: 'myScript'
}
]
}
]
}
});

});

});

describe('zeebe:ioMapping / zeebe:Input / zeebe:Output', function() {

it('on ServiceTask', async function() {
Expand Down
7 changes: 7 additions & 0 deletions test/spec/xml/roundtrip.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,4 +89,11 @@ describe('import -> export roundtrip', function() {

});


describe('zeebe:LinkedResource', function() {

it('should keep zeebe:linkedResource', validateExport('test/fixtures/xml/zeebe-linkedResources.bpmn'));

});

});
57 changes: 57 additions & 0 deletions test/spec/xml/write.js
Original file line number Diff line number Diff line change
Expand Up @@ -682,6 +682,27 @@ describe('write', function() {
expect(xml).to.eql(expectedXML);
});


it('on zeebe:LinkedResource', async function() {

// given
const moddleElement = moddle.create('zeebe:LinkedResource', {
bindingType: 'versionTag',
versionTag: 'v1.0.0'
});

const expectedXML = '<zeebe:linkedResource ' +
'xmlns:zeebe="http://camunda.org/schema/zeebe/1.0" ' +
'bindingType="versionTag" ' +
'versionTag="v1.0.0" />';

// when
const xml = await write(moddleElement);

// then
expect(xml).to.eql(expectedXML);
});

});

});
Expand Down Expand Up @@ -712,6 +733,42 @@ describe('write', function() {
expect(xml).to.eql(expectedXML);
});


it('zeebe:LinkedResource', async function() {

// given
const moddleElement = moddle.create('zeebe:LinkedResource', {
resourceId:'=myScript',
resourceType:'RPA',
linkName:'myScript' });

const expectedXML = '<zeebe:linkedResource ' +
'xmlns:zeebe="http://camunda.org/schema/zeebe/1.0" ' +
'resourceId="=myScript" ' +
'resourceType="RPA" ' +
'linkName="myScript" />';

// when
const xml = await write(moddleElement);

// then
expect(xml).to.eql(expectedXML);
});


it('zeebe:LinkedResources', async function() {

// given
const moddleElement = moddle.create('zeebe:LinkedResources');

const expectedXML = '<zeebe:linkedResources xmlns:zeebe="http://camunda.org/schema/zeebe/1.0" />';

// when
const xml = await write(moddleElement);

// then
expect(xml).to.eql(expectedXML);
});
});

});
Loading