Skip to content

Commit

Permalink
feat(camunda): allow <camunda:In> in signal throw events
Browse files Browse the repository at this point in the history
  • Loading branch information
barmac authored and merge-me[bot] committed Feb 11, 2020
1 parent 51005be commit 5d62e55
Show file tree
Hide file tree
Showing 3 changed files with 169 additions and 1 deletion.
25 changes: 25 additions & 0 deletions lib/extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ CamundaModdleExtension.prototype.canCopyProperty = function(property, parent) {
return false;
}

if (is(property, 'camunda:In') && !this.canHostIn(parent)) {
return false;
}
};

CamundaModdleExtension.prototype.canHostInputOutput = function(parent) {
Expand Down Expand Up @@ -87,6 +90,28 @@ CamundaModdleExtension.prototype.canHostConnector = function(parent) {
return true;
};

CamundaModdleExtension.prototype.canHostIn = function(parent) {

var callActivity = getParent(parent, 'bpmn:CallActivity');

if (callActivity) {
return true;
}

var signalEventDefinition = getParent(parent, 'bpmn:SignalEventDefinition');

if (signalEventDefinition) {

// only allow on throw and end events
return (
getParent(parent, 'bpmn:IntermediateThrowEvent') ||
getParent(parent, 'bpmn:EndEvent')
);
}

return true;
};

module.exports = CamundaModdleExtension;

// helpers //////////
Expand Down
3 changes: 2 additions & 1 deletion resources/camunda.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@
],
"meta": {
"allowedIn": [
"bpmn:CallActivity"
"bpmn:CallActivity",
"bpmn:SignalEventDefinition"
]
}
},
Expand Down
142 changes: 142 additions & 0 deletions test/spec/extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,148 @@ describe('extension', function() {
});


describe('camunda:In', function() {

it('should allow <camunda:In> on CallActivity', function() {

// given
var inOutBinding = moddle.create('camunda:In'),
extensionElements = moddle.create('bpmn:ExtensionElements'),
callActivity = moddle.create('bpmn:CallActivity');

extensionElements.$parent = callActivity;

callActivity.extensionElements = extensionElements;

// when
var canCopyProperty = camundaModdleExtension.canCopyProperty(inOutBinding, extensionElements);

// then
expect(canCopyProperty).not.to.be.false;
});


it('should allow <camunda:In> on SignalIntermediateThrowEvent', function() {

// given
var inOutBinding = moddle.create('camunda:In'),
extensionElements = moddle.create('bpmn:ExtensionElements'),
signalEventDefinition = moddle.create('bpmn:SignalEventDefinition'),
intermediateThrowEvent = moddle.create('bpmn:IntermediateThrowEvent');

extensionElements.$parent = signalEventDefinition;

signalEventDefinition.extensionElements = extensionElements;

signalEventDefinition.$parent = intermediateThrowEvent;

intermediateThrowEvent.eventDefinitions = [ signalEventDefinition ];

// when
var canCopyProperty = camundaModdleExtension.canCopyProperty(inOutBinding, extensionElements);

// then
expect(canCopyProperty).not.to.be.false;
});


it('should allow <camunda:In> on SignalEndEvent', function() {

// given
var inOutBinding = moddle.create('camunda:In'),
extensionElements = moddle.create('bpmn:ExtensionElements'),
signalEventDefinition = moddle.create('bpmn:SignalEventDefinition'),
endEvent = moddle.create('bpmn:EndEvent');

extensionElements.$parent = signalEventDefinition;

signalEventDefinition.extensionElements = extensionElements;

signalEventDefinition.$parent = endEvent;

endEvent.eventDefinitions = [ signalEventDefinition ];

// when
var canCopyProperty = camundaModdleExtension.canCopyProperty(inOutBinding, extensionElements);

// then
expect(canCopyProperty).not.to.be.false;
});


it('should NOT allow <camunda:In> on SignalStartEvent', function() {

// given
var inOutBinding = moddle.create('camunda:In'),
extensionElements = moddle.create('bpmn:ExtensionElements'),
signalEventDefinition = moddle.create('bpmn:SignalEventDefinition'),
startEvent = moddle.create('bpmn:StartEvent');

extensionElements.$parent = signalEventDefinition;

signalEventDefinition.extensionElements = extensionElements;

signalEventDefinition.$parent = startEvent;

startEvent.eventDefinitions = [ signalEventDefinition ];

// when
var canCopyProperty = camundaModdleExtension.canCopyProperty(inOutBinding, extensionElements);

// then
expect(canCopyProperty).to.be.false;
});


it('should NOT allow <camunda:In> on SignalIntermediateCatchEvent', function() {

// given
var inOutBinding = moddle.create('camunda:In'),
extensionElements = moddle.create('bpmn:ExtensionElements'),
signalEventDefinition = moddle.create('bpmn:SignalEventDefinition'),
intermediateCatchEvent = moddle.create('bpmn:IntermediateCatchEvent');

extensionElements.$parent = signalEventDefinition;

signalEventDefinition.extensionElements = extensionElements;

signalEventDefinition.$parent = intermediateCatchEvent;

intermediateCatchEvent.eventDefinitions = [ signalEventDefinition ];

// when
var canCopyProperty = camundaModdleExtension.canCopyProperty(inOutBinding, extensionElements);

// then
expect(canCopyProperty).to.be.false;
});


it('should NOT allow <camunda:In> on MessageIntermediateThrowEvent', function() {

// given
var inOutBinding = moddle.create('camunda:In'),
extensionElements = moddle.create('bpmn:ExtensionElements'),
messageEventDefinition = moddle.create('bpmn:MessageEventDefinition'),
intermediateCatchEvent = moddle.create('bpmn:IntermediateCatchEvent');

extensionElements.$parent = messageEventDefinition;

messageEventDefinition.extensionElements = extensionElements;

messageEventDefinition.$parent = intermediateCatchEvent;

intermediateCatchEvent.eventDefinitions = [ messageEventDefinition ];

// when
var canCopyProperty = camundaModdleExtension.canCopyProperty(inOutBinding, extensionElements);

// then
expect(canCopyProperty).to.be.false;
});
});


describe('camunda:InputOutput', function() {

it('should NOT allow on Gateway', function() {
Expand Down

0 comments on commit 5d62e55

Please sign in to comment.