From ab63d4dd3db55f05169ac77b711ee18085bf4423 Mon Sep 17 00:00:00 2001 From: Maciej Barelkowski Date: Wed, 8 May 2024 11:58:17 +0200 Subject: [PATCH] feat: support zeebe:ExecutionListener Related to https://github.com/camunda/camunda-modeler/issues/3951 --- resources/zeebe.json | 47 +++++++++++++++++++ .../task-zeebe-executionListener.part.bpmn | 11 +++++ test/spec/xml/read.js | 37 +++++++++++++++ test/spec/xml/write.js | 26 ++++++++++ 4 files changed, 121 insertions(+) create mode 100644 test/fixtures/xml/task-zeebe-executionListener.part.bpmn diff --git a/resources/zeebe.json b/resources/zeebe.json index f368c3d..a148334 100644 --- a/resources/zeebe.json +++ b/resources/zeebe.json @@ -479,6 +479,53 @@ "isAttr": true } ] + }, + { + "name": "ExecutionListeners", + "superClass": [ + "Element" + ], + "meta": { + "allowedIn": [ + "bpmn:FlowNode", + "bpmn:Process" + ] + }, + "properties": [ + { + "name": "listeners", + "type": "ExecutionListener", + "isMany": true + } + ] + }, + { + "name": "ExecutionListener", + "superClass": [ + "Element" + ], + "meta": { + "allowedIn": [ + "zeebe:ExecutionListeners" + ] + }, + "properties": [ + { + "name": "eventType", + "type": "String", + "isAttr": true + }, + { + "name": "retries", + "type": "String", + "isAttr": true + }, + { + "name": "type", + "type": "String", + "isAttr": true + } + ] } ] } diff --git a/test/fixtures/xml/task-zeebe-executionListener.part.bpmn b/test/fixtures/xml/task-zeebe-executionListener.part.bpmn new file mode 100644 index 0000000..7dc5e31 --- /dev/null +++ b/test/fixtures/xml/task-zeebe-executionListener.part.bpmn @@ -0,0 +1,11 @@ + + + + + + + diff --git a/test/spec/xml/read.js b/test/spec/xml/read.js index c50bcba..cc59283 100644 --- a/test/spec/xml/read.js +++ b/test/spec/xml/read.js @@ -886,6 +886,43 @@ describe('read', function() { }); + + describe('zeebe:ExecutionListener', function() { + + + it('on Task', async function() { + + // given + var xml = readFile('test/fixtures/xml/task-zeebe-executionListener.part.bpmn'); + + // when + const { + rootElement: task + } = await moddle.fromXML(xml, 'bpmn:Task'); + + // then + expect(task).to.jsonEqual({ + $type: 'bpmn:Task', + id: 'task-1', + extensionElements: { + $type: 'bpmn:ExtensionElements', + values: [ + { + $type: 'zeebe:ExecutionListeners', + listeners: [ + { + $type: 'zeebe:ExecutionListener', + eventType: 'start', + retries: '3', + type: 'sysout' + } + ] + } + ] + } + }); + }); + }); }); }); diff --git a/test/spec/xml/write.js b/test/spec/xml/write.js index c0c6d89..d695c24 100644 --- a/test/spec/xml/write.js +++ b/test/spec/xml/write.js @@ -489,6 +489,32 @@ describe('write', function() { expect(xml).to.eql(expectedXML); }); + + it('zeebe:ExecutionListeners', async function() { + + // given + const moddleElement = moddle.create('zeebe:ExecutionListeners', { + listeners: [ + moddle.create('zeebe:ExecutionListener', { + eventType: 'start', + retries: '3', + type: 'sysout' + }) + ] + }); + + const expectedXML = '' + + '' + + ''; + + // when + const xml = await write(moddleElement); + + // then + expect(xml).to.eql(expectedXML); + }); + }); });