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: support zeebe:TaskListener #67

Merged
merged 1 commit into from
Nov 7, 2024
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
46 changes: 46 additions & 0 deletions resources/zeebe.json
Original file line number Diff line number Diff line change
Expand Up @@ -548,6 +548,52 @@
}
]
},
{
"name": "TaskListeners",
"superClass": [
"Element"
],
"meta": {
"allowedIn": [
"bpmn:UserTask"
]
},
"properties": [
{
"name": "listeners",
"type": "TaskListener",
"isMany": true
}
]
},
{
"name": "TaskListener",
"superClass": [
"Element"
],
"meta": {
"allowedIn": [
"zeebe:TaskListeners"
]
},
"properties": [
{
"name": "eventType",
"type": "String",
"isAttr": true
},
{
"name": "retries",
"type": "String",
"isAttr": true
},
{
"name": "type",
"type": "String",
"isAttr": true
}
]
},
{
"name": "VersionTag",
"superClass": [
Expand Down
11 changes: 11 additions & 0 deletions test/fixtures/xml/userTask-zeebe-taskListener.part.bpmn
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<bpmn:userTask
id="UserTask"
xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL"
xmlns:zeebe="http://camunda.org/schema/zeebe/1.0"
>
<bpmn:extensionElements>
<zeebe:taskListeners>
<zeebe:taskListener eventType="complete" retries="3" type="complete_listener"/>
</zeebe:taskListeners>
</bpmn:extensionElements>
</bpmn:userTask>
34 changes: 34 additions & 0 deletions test/fixtures/xml/zeebe-taskListeners.bpmn
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?>
<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:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:zeebe="http://camunda.org/schema/zeebe/1.0" xmlns:modeler="http://camunda.org/schema/modeler/1.0" id="Definitions_0qh9wc7" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="5.23.0" modeler:userTaskPlatform="Camunda Cloud" modeler:userTaskPlatformVersion="8.0.0">
<bpmn:process id="ZeebePropertiesTest" name="Zeebe Properties Test" isExecutable="true">
<bpmn:userTask id="UserTask">
<bpmn:extensionElements>
<zeebe:taskListeners>
<zeebe:taskListener eventType="assign" retries="2" type="assign_listener" />
</zeebe:taskListeners>
</bpmn:extensionElements>
</bpmn:userTask>
<bpmn:subProcess id="SubProcess">
<bpmn:userTask id="UserTaskSubprocess">
<bpmn:extensionElements>
<zeebe:taskListeners>
<zeebe:taskListener eventType="assign" retries="4" type="assign_listener" />
</zeebe:taskListeners>
</bpmn:extensionElements>
</bpmn:userTask>
</bpmn:subProcess>
</bpmn:process>
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="ZeebePropertiesTest">
<bpmndi:BPMNShape id="UserTask_di" bpmnElement="UserTask">
<dc:Bounds x="160" y="400" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="SubProcess_di" bpmnElement="SubProcess" isExpanded="true">
<dc:Bounds x="160" y="510" width="350" height="200" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="UserTaskSubprocess_di" bpmnElement="UserTaskSubprocess">
<dc:Bounds x="200" y="592" width="100" height="80" />
</bpmndi:BPMNShape>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</bpmn:definitions>
38 changes: 38 additions & 0 deletions test/spec/xml/read.js
Original file line number Diff line number Diff line change
Expand Up @@ -1231,6 +1231,44 @@ describe('read', function() {

});


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

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

// given
var xml = readFile('test/fixtures/xml/userTask-zeebe-taskListener.part.bpmn');

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

// then
expect(task).to.jsonEqual({
$type: 'bpmn:UserTask',
id: 'UserTask',
extensionElements: {
$type: 'bpmn:ExtensionElements',
values: [
{
$type: 'zeebe:TaskListeners',
listeners: [
{
$type: 'zeebe:TaskListener',
eventType: 'complete',
retries: '3',
type: 'complete_listener'
}
]
}
]
}
});
});

});

});

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

});


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

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

});

});
26 changes: 26 additions & 0 deletions test/spec/xml/write.js
Original file line number Diff line number Diff line change
Expand Up @@ -686,6 +686,32 @@ describe('write', function() {

});


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

// given
const moddleElement = moddle.create('zeebe:TaskListeners', {
listeners: [
moddle.create('zeebe:TaskListener', {
eventType: 'complete',
retries: '1',
type: 'complete_listener'
})
]
});

const expectedXML = '<zeebe:taskListeners ' +
'xmlns:zeebe="http://camunda.org/schema/zeebe/1.0">' +
'<zeebe:taskListener eventType="complete" retries="1" type="complete_listener" />' +
'</zeebe:taskListeners>';

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

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

});

});
Loading