fix(modeling): create ConditionalEventDefinition with condition

This ensures we always create valid BPMN 2.0 XML when
creating conditional start and intermediate events.

Closes #747
This commit is contained in:
Nico Rehwaldt 2018-01-03 14:19:01 +01:00
parent f15407d95b
commit 1f5c69a58b
2 changed files with 35 additions and 10 deletions

View File

@ -103,6 +103,10 @@ ElementFactory.prototype.createBpmnElement = function(elementType, attrs) {
eventDefinitions = businessObject.get('eventDefinitions') || [];
newEventDefinition = this._moddle.create(attrs.eventDefinitionType);
if (attrs.eventDefinitionType === 'bpmn:ConditionalEventDefinition') {
newEventDefinition.condition = this._moddle.create('bpmn:FormalExpression');
}
eventDefinitions.push(newEventDefinition);
newEventDefinition.$parent = businessObject;

View File

@ -1226,7 +1226,8 @@ describe('features/replace - bpmn replace', function() {
}));
it('should properly set parent of event definitions', inject(function(elementRegistry, modeling, bpmnReplace) {
it('should properly set parent of event definitions', inject(
function(elementRegistry, modeling, bpmnReplace) {
var startEvent = elementRegistry.get('StartEvent_1');
@ -1239,7 +1240,27 @@ describe('features/replace - bpmn replace', function() {
expect(parent).to.exist;
expect(parent).to.equal(messageEvent.businessObject);
}));
})
);
it('should add condition with ConditionalEventDefinition', inject(
function(elementRegistry, modeling, bpmnReplace) {
var startEvent = elementRegistry.get('StartEvent_1');
// when
var messageEvent = bpmnReplace.replaceElement(startEvent, {
type: 'bpmn:StartEvent',
eventDefinitionType: 'bpmn:ConditionalEventDefinition'
});
var definition = messageEvent.businessObject.eventDefinitions[0];
// then
expect(definition.condition).to.exist;
})
);
});