From 320209064c959b4d4c51bb344f32c83107b9c161 Mon Sep 17 00:00:00 2001 From: Philipp Fromme Date: Fri, 19 Jul 2024 12:05:47 +0200 Subject: [PATCH] feat: support `zeebe:bindingType` Related to https://github.com/camunda/camunda-modeler/issues/4385 --- resources/zeebe.json | 21 ++++- .../xml/calledDecision-bindingType.part.bpmn | 8 ++ .../xml/calledElement-bindingType.part.bpmn | 8 ++ .../xml/formDefinition-bindingType.part.bpmn | 8 ++ test/fixtures/xml/zeebe-bindingType.bpmn | 33 +++++++ test/spec/xml/read.js | 89 +++++++++++++++++++ test/spec/xml/roundtrip.js | 7 ++ test/spec/xml/write.js | 61 +++++++++++++ 8 files changed, 232 insertions(+), 3 deletions(-) create mode 100644 test/fixtures/xml/calledDecision-bindingType.part.bpmn create mode 100644 test/fixtures/xml/calledElement-bindingType.part.bpmn create mode 100644 test/fixtures/xml/formDefinition-bindingType.part.bpmn create mode 100644 test/fixtures/xml/zeebe-bindingType.bpmn diff --git a/resources/zeebe.json b/resources/zeebe.json index ba9ee55..cb61be7 100644 --- a/resources/zeebe.json +++ b/resources/zeebe.json @@ -218,7 +218,7 @@ { "name": "CalledElement", "superClass": [ - "Element" + "BindingTypeSupported" ], "meta": { "allowedIn": [ @@ -275,7 +275,7 @@ { "name": "FormDefinition", "superClass": [ - "Element" + "BindingTypeSupported" ], "meta": { "allowedIn": [ @@ -315,7 +315,7 @@ { "name": "CalledDecision", "superClass": [ - "Element" + "BindingTypeSupported" ], "meta": { "allowedIn": [ @@ -549,6 +549,21 @@ "isAttr": true } ] + }, + { + "name": "BindingTypeSupported", + "isAbstract": true, + "superClass": [ + "Element" + ], + "properties": [ + { + "name": "bindingType", + "isAttr": true, + "type": "String", + "default": "latest" + } + ] } ] } diff --git a/test/fixtures/xml/calledDecision-bindingType.part.bpmn b/test/fixtures/xml/calledDecision-bindingType.part.bpmn new file mode 100644 index 0000000..85162d1 --- /dev/null +++ b/test/fixtures/xml/calledDecision-bindingType.part.bpmn @@ -0,0 +1,8 @@ + + + + + \ No newline at end of file diff --git a/test/fixtures/xml/calledElement-bindingType.part.bpmn b/test/fixtures/xml/calledElement-bindingType.part.bpmn new file mode 100644 index 0000000..09c3ad1 --- /dev/null +++ b/test/fixtures/xml/calledElement-bindingType.part.bpmn @@ -0,0 +1,8 @@ + + + + + \ No newline at end of file diff --git a/test/fixtures/xml/formDefinition-bindingType.part.bpmn b/test/fixtures/xml/formDefinition-bindingType.part.bpmn new file mode 100644 index 0000000..f1a5a97 --- /dev/null +++ b/test/fixtures/xml/formDefinition-bindingType.part.bpmn @@ -0,0 +1,8 @@ + + + + + \ No newline at end of file diff --git a/test/fixtures/xml/zeebe-bindingType.bpmn b/test/fixtures/xml/zeebe-bindingType.bpmn new file mode 100644 index 0000000..146b117 --- /dev/null +++ b/test/fixtures/xml/zeebe-bindingType.bpmn @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/spec/xml/read.js b/test/spec/xml/read.js index 7b534fe..c6ddf82 100644 --- a/test/spec/xml/read.js +++ b/test/spec/xml/read.js @@ -1023,6 +1023,95 @@ describe('read', function() { }); + + describe('zeebe:BindingTypeSupported', function() { + + describe('zeebe:bindingType', function() { + + it('on zeebe:CalledDecision', async function() { + + // given + var xml = readFile('test/fixtures/xml/calledDecision-bindingType.part.bpmn'); + + // when + const { + rootElement: businessRuleTask + } = await moddle.fromXML(xml, 'bpmn:BusinessRuleTask'); + + // then + expect(businessRuleTask).to.jsonEqual({ + $type: 'bpmn:BusinessRuleTask', + id: 'BusinessRuleTask_1', + extensionElements: { + $type: 'bpmn:ExtensionElements', + values: [ + { + $type: 'zeebe:CalledDecision', + bindingType: 'deployment' + } + ] + } + }); + }); + + + it('on zeebe:CalledElement', async function() { + + // given + var xml = readFile('test/fixtures/xml/calledElement-bindingType.part.bpmn'); + + // when + const { + rootElement: callActivity + } = await moddle.fromXML(xml, 'bpmn:CallActivity'); + + // then + expect(callActivity).to.jsonEqual({ + $type: 'bpmn:CallActivity', + id: 'CallActivity_1', + extensionElements: { + $type: 'bpmn:ExtensionElements', + values: [ + { + $type: 'zeebe:CalledElement', + bindingType: 'deployment' + } + ] + } + }); + }); + + + it('on zeebe:FormDefinition', async function() { + + // given + var xml = readFile('test/fixtures/xml/formDefinition-bindingType.part.bpmn'); + + // when + const { + rootElement: userTask + } = await moddle.fromXML(xml, 'bpmn:UserTask'); + + // then + expect(userTask).to.jsonEqual({ + $type: 'bpmn:UserTask', + id: 'UserTask_1', + extensionElements: { + $type: 'bpmn:ExtensionElements', + values: [ + { + $type: 'zeebe:FormDefinition', + bindingType: 'deployment' + } + ] + } + }); + }); + + }); + + }); + }); }); diff --git a/test/spec/xml/roundtrip.js b/test/spec/xml/roundtrip.js index a921e7b..f4a79b4 100644 --- a/test/spec/xml/roundtrip.js +++ b/test/spec/xml/roundtrip.js @@ -75,4 +75,11 @@ describe('import -> export roundtrip', function() { }); + + describe('zeebe:BindingTypeSupported', function() { + + it('should keep zeebe:bindingType', validateExport('test/fixtures/xml/zeebe-bindingType.bpmn')); + + }); + }); diff --git a/test/spec/xml/write.js b/test/spec/xml/write.js index 265cbc5..ebaa09a 100644 --- a/test/spec/xml/write.js +++ b/test/spec/xml/write.js @@ -534,6 +534,67 @@ describe('write', function() { expect(xml).to.eql(expectedXML); }); + + describe('zeebe:BindingTypeSupported', function() { + + it('on zeebe:CalledDecision', async function() { + + // given + const moddleElement = moddle.create('zeebe:CalledDecision', { + bindingType: 'deployment' + }); + + const expectedXML = ''; + + // when + const xml = await write(moddleElement); + + // then + expect(xml).to.eql(expectedXML); + }); + + + it('on zeebe:CalledElement', async function() { + + // given + const moddleElement = moddle.create('zeebe:CalledElement', { + bindingType: 'deployment' + }); + + const expectedXML = ''; + + // when + const xml = await write(moddleElement); + + // then + expect(xml).to.eql(expectedXML); + }); + + + it('on zeebe:FormDefinition', async function() { + + // given + const moddleElement = moddle.create('zeebe:FormDefinition', { + bindingType: 'deployment' + }); + + const expectedXML = ''; + + // when + const xml = await write(moddleElement); + + // then + expect(xml).to.eql(expectedXML); + }); + + }); + }); });