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:
parent
f15407d95b
commit
1f5c69a58b
|
@ -103,6 +103,10 @@ ElementFactory.prototype.createBpmnElement = function(elementType, attrs) {
|
||||||
eventDefinitions = businessObject.get('eventDefinitions') || [];
|
eventDefinitions = businessObject.get('eventDefinitions') || [];
|
||||||
newEventDefinition = this._moddle.create(attrs.eventDefinitionType);
|
newEventDefinition = this._moddle.create(attrs.eventDefinitionType);
|
||||||
|
|
||||||
|
if (attrs.eventDefinitionType === 'bpmn:ConditionalEventDefinition') {
|
||||||
|
newEventDefinition.condition = this._moddle.create('bpmn:FormalExpression');
|
||||||
|
}
|
||||||
|
|
||||||
eventDefinitions.push(newEventDefinition);
|
eventDefinitions.push(newEventDefinition);
|
||||||
|
|
||||||
newEventDefinition.$parent = businessObject;
|
newEventDefinition.$parent = businessObject;
|
||||||
|
|
|
@ -1226,20 +1226,41 @@ 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');
|
var startEvent = elementRegistry.get('StartEvent_1');
|
||||||
|
|
||||||
var messageEvent = bpmnReplace.replaceElement(startEvent, {
|
var messageEvent = bpmnReplace.replaceElement(startEvent, {
|
||||||
type: 'bpmn:StartEvent',
|
type: 'bpmn:StartEvent',
|
||||||
eventDefinitionType: 'bpmn:MessageEventDefinition'
|
eventDefinitionType: 'bpmn:MessageEventDefinition'
|
||||||
});
|
});
|
||||||
|
|
||||||
var parent = messageEvent.businessObject.eventDefinitions[0].$parent;
|
var parent = messageEvent.businessObject.eventDefinitions[0].$parent;
|
||||||
|
|
||||||
expect(parent).to.exist;
|
expect(parent).to.exist;
|
||||||
expect(parent).to.equal(messageEvent.businessObject);
|
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;
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue