From cbb2238e855f2bafe655f17e63bdbe6991789a69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Konopski?= Date: Wed, 6 Nov 2024 09:56:29 +0100 Subject: [PATCH] feat: support zeebe:TaskListener related to https://github.com/camunda/camunda-modeler/issues/4590 --- resources/zeebe.json | 46 +++++++++++++++++++ .../xml/userTask-zeebe-taskListener.part.bpmn | 11 +++++ test/fixtures/xml/zeebe-taskListeners.bpmn | 34 ++++++++++++++ test/spec/xml/read.js | 38 +++++++++++++++ test/spec/xml/roundtrip.js | 7 +++ test/spec/xml/write.js | 26 +++++++++++ 6 files changed, 162 insertions(+) create mode 100644 test/fixtures/xml/userTask-zeebe-taskListener.part.bpmn create mode 100644 test/fixtures/xml/zeebe-taskListeners.bpmn diff --git a/resources/zeebe.json b/resources/zeebe.json index a99a53e..9974bf3 100644 --- a/resources/zeebe.json +++ b/resources/zeebe.json @@ -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": [ diff --git a/test/fixtures/xml/userTask-zeebe-taskListener.part.bpmn b/test/fixtures/xml/userTask-zeebe-taskListener.part.bpmn new file mode 100644 index 0000000..d09183c --- /dev/null +++ b/test/fixtures/xml/userTask-zeebe-taskListener.part.bpmn @@ -0,0 +1,11 @@ + + + + + + + diff --git a/test/fixtures/xml/zeebe-taskListeners.bpmn b/test/fixtures/xml/zeebe-taskListeners.bpmn new file mode 100644 index 0000000..c770818 --- /dev/null +++ b/test/fixtures/xml/zeebe-taskListeners.bpmn @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/test/spec/xml/read.js b/test/spec/xml/read.js index 5438d67..bb9faec 100644 --- a/test/spec/xml/read.js +++ b/test/spec/xml/read.js @@ -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' + } + ] + } + ] + } + }); + }); + + }); + }); }); diff --git a/test/spec/xml/roundtrip.js b/test/spec/xml/roundtrip.js index f4a79b4..8fc8a70 100644 --- a/test/spec/xml/roundtrip.js +++ b/test/spec/xml/roundtrip.js @@ -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')); + + }); + }); diff --git a/test/spec/xml/write.js b/test/spec/xml/write.js index 2181576..d550cee 100644 --- a/test/spec/xml/write.js +++ b/test/spec/xml/write.js @@ -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 = '' + + '' + + ''; + + // when + const xml = await write(moddleElement); + + // then + expect(xml).to.eql(expectedXML); + }); + }); });