From ac0c3b6b7cecd7153c0fce452fe3e1b11fc5e42b 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 | 52 +++++++++ .../event-zeebe-executionListener.part.bpmn | 11 ++ .../gateway-zeebe-executionListener.part.bpmn | 11 ++ .../task-zeebe-executionListener.part.bpmn | 11 ++ .../xml/zeebe-execution-listeners.bpmn | 84 ++++++++++++++ test/spec/xml/read.js | 105 ++++++++++++++++++ test/spec/xml/roundtrip.js | 6 + test/spec/xml/write.js | 26 +++++ 8 files changed, 306 insertions(+) create mode 100644 test/fixtures/xml/event-zeebe-executionListener.part.bpmn create mode 100644 test/fixtures/xml/gateway-zeebe-executionListener.part.bpmn create mode 100644 test/fixtures/xml/task-zeebe-executionListener.part.bpmn create mode 100644 test/fixtures/xml/zeebe-execution-listeners.bpmn diff --git a/resources/zeebe.json b/resources/zeebe.json index f368c3d..ff217da 100644 --- a/resources/zeebe.json +++ b/resources/zeebe.json @@ -479,6 +479,58 @@ "isAttr": true } ] + }, + { + "name": "ExecutionListeners", + "superClass": [ + "Element" + ], + "meta": { + "allowedIn": [ + "bpmn:Event", + "bpmn:Activity", + "bpmn:Process", + "bpmn:ExclusiveGateway", + "bpmn:InclusiveGateway", + "bpmn:ParallelGateway", + "bpmn:EventBasedGateway" + ] + }, + "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/event-zeebe-executionListener.part.bpmn b/test/fixtures/xml/event-zeebe-executionListener.part.bpmn new file mode 100644 index 0000000..6346b1d --- /dev/null +++ b/test/fixtures/xml/event-zeebe-executionListener.part.bpmn @@ -0,0 +1,11 @@ + + + + + + + diff --git a/test/fixtures/xml/gateway-zeebe-executionListener.part.bpmn b/test/fixtures/xml/gateway-zeebe-executionListener.part.bpmn new file mode 100644 index 0000000..1b73bff --- /dev/null +++ b/test/fixtures/xml/gateway-zeebe-executionListener.part.bpmn @@ -0,0 +1,11 @@ + + + + + + + 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/fixtures/xml/zeebe-execution-listeners.bpmn b/test/fixtures/xml/zeebe-execution-listeners.bpmn new file mode 100644 index 0000000..09f85a0 --- /dev/null +++ b/test/fixtures/xml/zeebe-execution-listeners.bpmn @@ -0,0 +1,84 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/test/spec/xml/read.js b/test/spec/xml/read.js index c50bcba..fc141ac 100644 --- a/test/spec/xml/read.js +++ b/test/spec/xml/read.js @@ -886,6 +886,111 @@ 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' + } + ] + } + ] + } + }); + }); + + + it('on Event', async function() { + + // given + var xml = readFile('test/fixtures/xml/event-zeebe-executionListener.part.bpmn'); + + // when + const { + rootElement: event + } = await moddle.fromXML(xml, 'bpmn:EndEvent'); + + // then + expect(event).to.jsonEqual({ + $type: 'bpmn:EndEvent', + id: 'endEvent-1', + extensionElements: { + $type: 'bpmn:ExtensionElements', + values: [ + { + $type: 'zeebe:ExecutionListeners', + listeners: [ + { + $type: 'zeebe:ExecutionListener', + eventType: 'start', + retries: '3', + type: 'sysout' + } + ] + } + ] + } + }); + }); + + + it('on Gateway', async function() { + + // given + var xml = readFile('test/fixtures/xml/gateway-zeebe-executionListener.part.bpmn'); + + // when + const { + rootElement: gateway + } = await moddle.fromXML(xml, 'bpmn:ExclusiveGateway'); + + // then + expect(gateway).to.jsonEqual({ + $type: 'bpmn:ExclusiveGateway', + id: 'exclusiveGateway-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/roundtrip.js b/test/spec/xml/roundtrip.js index 04583b8..1917f52 100644 --- a/test/spec/xml/roundtrip.js +++ b/test/spec/xml/roundtrip.js @@ -60,4 +60,10 @@ describe('import -> export roundtrip', function() { it('should keep zeebe:formDefinition properties', validateExport('test/fixtures/xml/userTask-zeebe-formDefinition.bpmn')); }); + + + describe('executionListeners', function() { + + it('should keep zeebe:executionListeners', validateExport('test/fixtures/xml/zeebe-execution-listeners.bpmn')); + }); }); 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); + }); + }); });