2015-01-02 15:15:18 +00:00
|
|
|
'use strict';
|
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
require('../../../TestHelper');
|
2015-01-02 15:15:18 +00:00
|
|
|
|
|
|
|
/* global bootstrapModeler, inject */
|
|
|
|
|
|
|
|
|
|
|
|
var modelingModule = require('../../../../lib/features/modeling'),
|
|
|
|
coreModule = require('../../../../lib/core');
|
|
|
|
|
|
|
|
|
|
|
|
describe('features/modeling - update properties', function() {
|
|
|
|
|
2015-03-31 12:17:15 +00:00
|
|
|
var diagramXML = require('../../../fixtures/bpmn/conditions.bpmn');
|
2015-01-02 15:15:18 +00:00
|
|
|
|
|
|
|
var testModules = [ coreModule, modelingModule ];
|
|
|
|
|
|
|
|
beforeEach(bootstrapModeler(diagramXML, { modules: testModules }));
|
|
|
|
|
|
|
|
|
|
|
|
var updatedElements;
|
|
|
|
|
|
|
|
beforeEach(inject(function(eventBus) {
|
|
|
|
|
|
|
|
eventBus.on([ 'commandStack.execute', 'commandStack.revert' ], function() {
|
|
|
|
updatedElements = [];
|
|
|
|
});
|
|
|
|
|
|
|
|
eventBus.on('element.changed', function(event) {
|
|
|
|
updatedElements.push(event.element);
|
|
|
|
});
|
|
|
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
|
|
describe('should execute', function() {
|
|
|
|
|
|
|
|
it('setting loop characteristics', inject(function(elementRegistry, modeling, moddle) {
|
|
|
|
|
|
|
|
// given
|
|
|
|
var loopCharacteristics = moddle.create('bpmn:MultiInstanceLoopCharacteristics');
|
|
|
|
|
|
|
|
var taskShape = elementRegistry.get('ServiceTask_1');
|
|
|
|
|
|
|
|
// when
|
|
|
|
modeling.updateProperties(taskShape, { loopCharacteristics: loopCharacteristics });
|
|
|
|
|
|
|
|
// then
|
2015-07-15 15:22:19 +00:00
|
|
|
expect(taskShape.businessObject.loopCharacteristics).to.eql(loopCharacteristics);
|
2015-01-02 15:15:18 +00:00
|
|
|
|
|
|
|
|
|
|
|
// task shape got updated
|
2015-07-15 15:22:19 +00:00
|
|
|
expect(updatedElements).to.include(taskShape);
|
2015-01-02 15:15:18 +00:00
|
|
|
}));
|
|
|
|
|
|
|
|
|
2015-12-08 12:29:03 +00:00
|
|
|
it('unsetting default flow', inject(function(elementRegistry, modeling) {
|
2015-01-02 15:15:18 +00:00
|
|
|
|
|
|
|
// given
|
|
|
|
var gatewayShape = elementRegistry.get('ExclusiveGateway_1');
|
|
|
|
|
|
|
|
// when
|
|
|
|
modeling.updateProperties(gatewayShape, { 'default': undefined });
|
|
|
|
|
|
|
|
// then
|
2015-12-01 07:27:45 +00:00
|
|
|
expect(gatewayShape.businessObject['default']).not.to.exist;
|
2015-01-02 15:15:18 +00:00
|
|
|
|
|
|
|
// flow got updated, too
|
2015-07-15 15:22:19 +00:00
|
|
|
expect(updatedElements).to.include(elementRegistry.get('SequenceFlow_1'));
|
2015-01-02 15:15:18 +00:00
|
|
|
}));
|
|
|
|
|
|
|
|
|
2015-12-08 12:29:03 +00:00
|
|
|
it('updating default flow', inject(function(elementRegistry, modeling) {
|
|
|
|
|
|
|
|
// given
|
|
|
|
var gatewayShape = elementRegistry.get('ExclusiveGateway_1'),
|
|
|
|
newDefaultFlowConnection = elementRegistry.get('SequenceFlow_2'),
|
|
|
|
newDefaultFlow = newDefaultFlowConnection.businessObject;
|
|
|
|
|
|
|
|
// when
|
|
|
|
modeling.updateProperties(gatewayShape, { 'default': newDefaultFlow });
|
|
|
|
|
|
|
|
// then
|
|
|
|
expect(gatewayShape.businessObject['default']).to.eql(newDefaultFlow);
|
|
|
|
|
|
|
|
// flow got updated, too
|
|
|
|
expect(updatedElements).to.include(newDefaultFlowConnection);
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
2016-06-20 14:27:36 +00:00
|
|
|
it('updating conditional flow on source replace', inject(function(bpmnReplace, elementRegistry) {
|
|
|
|
|
|
|
|
//given
|
|
|
|
var conditionalFlow = elementRegistry.get('SequenceFlow_3'),
|
|
|
|
serviceTask = elementRegistry.get('ServiceTask_1');
|
|
|
|
|
|
|
|
var conditionExpression = conditionalFlow.businessObject.conditionExpression;
|
|
|
|
|
|
|
|
var userTaskData = {
|
|
|
|
type: 'bpmn:UserTask'
|
|
|
|
};
|
|
|
|
|
|
|
|
// when
|
|
|
|
bpmnReplace.replaceElement(serviceTask, userTaskData);
|
|
|
|
|
|
|
|
// then
|
|
|
|
expect(conditionalFlow.businessObject.conditionExpression).to.eql(conditionExpression);
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
|
|
it('updating conditional flow on target replace', inject(function(bpmnReplace, elementRegistry) {
|
|
|
|
|
|
|
|
//given
|
|
|
|
var conditionalFlow = elementRegistry.get('SequenceFlow_3'),
|
|
|
|
endEvent = elementRegistry.get('EndEvent_1');
|
|
|
|
|
|
|
|
var conditionExpression = conditionalFlow.businessObject.conditionExpression;
|
|
|
|
|
|
|
|
var messageEndEventData = {
|
|
|
|
type: 'bpmn:EndEvent',
|
|
|
|
eventDefinitionType: 'bpmn:MessageEventDefinition'
|
|
|
|
};
|
|
|
|
|
|
|
|
// when
|
|
|
|
bpmnReplace.replaceElement(endEvent, messageEndEventData);
|
|
|
|
|
|
|
|
// then
|
|
|
|
expect(conditionalFlow.businessObject.conditionExpression).to.eql(conditionExpression);
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
2015-09-14 14:03:46 +00:00
|
|
|
it('setting name', inject(function(elementRegistry, modeling) {
|
|
|
|
|
|
|
|
// given
|
|
|
|
var flowConnection = elementRegistry.get('SequenceFlow_4');
|
|
|
|
|
|
|
|
// when
|
|
|
|
modeling.updateProperties(flowConnection, { name: 'FOO BAR' });
|
|
|
|
|
|
|
|
// then
|
|
|
|
expect(flowConnection.businessObject.name).to.equal('FOO BAR');
|
|
|
|
|
|
|
|
// flow label is now shown
|
|
|
|
expect(flowConnection.label.hidden).to.be.false;
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
2015-06-18 14:57:58 +00:00
|
|
|
it('updating name', inject(function(elementRegistry, modeling) {
|
2015-01-02 15:15:18 +00:00
|
|
|
|
|
|
|
// given
|
|
|
|
var flowConnection = elementRegistry.get('SequenceFlow_1');
|
|
|
|
|
|
|
|
// when
|
|
|
|
modeling.updateProperties(flowConnection, { name: 'FOO BAR' });
|
|
|
|
|
|
|
|
// then
|
2015-07-15 15:22:19 +00:00
|
|
|
expect(flowConnection.businessObject.name).to.equal('FOO BAR');
|
2015-01-02 15:15:18 +00:00
|
|
|
|
|
|
|
// flow label got updated, too
|
2015-07-15 15:22:19 +00:00
|
|
|
expect(updatedElements).to.include(elementRegistry.get('SequenceFlow_1_label'));
|
2015-01-02 15:15:18 +00:00
|
|
|
}));
|
|
|
|
|
2015-04-13 08:55:17 +00:00
|
|
|
|
2015-06-18 14:57:58 +00:00
|
|
|
it('unsetting name', inject(function(elementRegistry, modeling) {
|
|
|
|
|
|
|
|
// given
|
|
|
|
var flowConnection = elementRegistry.get('SequenceFlow_3');
|
|
|
|
|
|
|
|
// when
|
|
|
|
modeling.updateProperties(flowConnection, { name: undefined });
|
|
|
|
|
|
|
|
// then
|
2015-12-01 07:27:45 +00:00
|
|
|
expect(flowConnection.businessObject.name).not.to.exist;
|
2015-09-14 14:03:46 +00:00
|
|
|
|
|
|
|
// flow label is now hidden
|
|
|
|
expect(flowConnection.label.hidden).to.be.true;
|
2015-06-18 14:57:58 +00:00
|
|
|
}));
|
|
|
|
|
|
|
|
|
2015-04-13 08:55:17 +00:00
|
|
|
it('updating id', inject(function(elementRegistry, modeling) {
|
|
|
|
|
|
|
|
// given
|
|
|
|
var flowConnection = elementRegistry.get('SequenceFlow_1');
|
2015-10-05 11:35:10 +00:00
|
|
|
var ids = flowConnection.businessObject.$model.ids;
|
2015-04-13 08:55:17 +00:00
|
|
|
|
|
|
|
// when
|
|
|
|
modeling.updateProperties(flowConnection, { id: 'FOO_BAR' });
|
|
|
|
|
|
|
|
// then
|
2016-04-18 14:15:00 +00:00
|
|
|
expect(ids.assigned('FOO_BAR')).to.eql(flowConnection.businessObject);
|
2015-10-05 11:35:10 +00:00
|
|
|
expect(ids.assigned('SequenceFlow_1')).to.be.false;
|
|
|
|
|
2015-07-15 15:22:19 +00:00
|
|
|
expect(flowConnection.businessObject.id).to.equal('FOO_BAR');
|
|
|
|
expect(flowConnection.id).to.equal('FOO_BAR');
|
2015-04-13 08:55:17 +00:00
|
|
|
}));
|
|
|
|
|
2015-06-18 14:57:58 +00:00
|
|
|
|
|
|
|
it('updating extension elements', inject(function(elementRegistry, modeling) {
|
|
|
|
|
|
|
|
// given
|
|
|
|
var flowConnection = elementRegistry.get('SequenceFlow_1');
|
|
|
|
|
|
|
|
// when
|
|
|
|
modeling.updateProperties(flowConnection, {
|
|
|
|
'xmlns:foo': 'http://foo',
|
|
|
|
'foo:customAttr': 'FOO'
|
|
|
|
});
|
|
|
|
|
|
|
|
// then
|
2015-07-15 15:22:19 +00:00
|
|
|
expect(flowConnection.businessObject.get('xmlns:foo')).to.equal('http://foo');
|
|
|
|
expect(flowConnection.businessObject.get('foo:customAttr')).to.equal('FOO');
|
2015-06-18 14:57:58 +00:00
|
|
|
}));
|
|
|
|
|
2015-01-02 15:15:18 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
describe('should undo', function() {
|
|
|
|
|
|
|
|
it('setting loop characteristics', inject(function(elementRegistry, modeling, commandStack, moddle) {
|
|
|
|
|
|
|
|
// given
|
|
|
|
var loopCharactersistics = moddle.create('bpmn:MultiInstanceLoopCharacteristics');
|
|
|
|
|
|
|
|
var taskShape = elementRegistry.get('ServiceTask_1');
|
|
|
|
|
|
|
|
// when
|
|
|
|
modeling.updateProperties(taskShape, { loopCharacteristics: loopCharactersistics });
|
|
|
|
commandStack.undo();
|
|
|
|
|
|
|
|
// then
|
2015-12-01 07:27:45 +00:00
|
|
|
expect(taskShape.businessObject.loopCharactersistics).not.to.exist;
|
2015-01-02 15:15:18 +00:00
|
|
|
}));
|
|
|
|
|
|
|
|
|
2015-12-08 12:29:03 +00:00
|
|
|
it('unsetting default flow', inject(function(elementRegistry, commandStack, modeling) {
|
2015-01-02 15:15:18 +00:00
|
|
|
|
|
|
|
// given
|
2015-12-08 12:29:03 +00:00
|
|
|
var gatewayShape = elementRegistry.get('ExclusiveGateway_1'),
|
|
|
|
oldDefaultFlow = gatewayShape.businessObject['default'];
|
2015-01-02 15:15:18 +00:00
|
|
|
|
|
|
|
// when
|
|
|
|
modeling.updateProperties(gatewayShape, { 'default': undefined });
|
|
|
|
commandStack.undo();
|
|
|
|
|
|
|
|
// then
|
2015-12-08 12:29:03 +00:00
|
|
|
expect(gatewayShape.businessObject['default']).to.eql(oldDefaultFlow);
|
2015-01-02 15:15:18 +00:00
|
|
|
|
|
|
|
// flow got updated, too
|
2015-12-08 12:29:03 +00:00
|
|
|
expect(updatedElements).to.include(elementRegistry.get(oldDefaultFlow.id));
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
|
|
it('updating default flow', inject(function(elementRegistry, commandStack, modeling) {
|
|
|
|
|
|
|
|
// given
|
|
|
|
var gatewayShape = elementRegistry.get('ExclusiveGateway_1'),
|
|
|
|
newDefaultFlowConnection = elementRegistry.get('SequenceFlow_2'),
|
|
|
|
newDefaultFlow = newDefaultFlowConnection.businessObject,
|
|
|
|
oldDefaultFlowConnection = elementRegistry.get('SequenceFlow_1'),
|
|
|
|
oldDefaultFlow = oldDefaultFlowConnection.businessObject;
|
|
|
|
|
|
|
|
// when
|
|
|
|
modeling.updateProperties(gatewayShape, { 'default': newDefaultFlow });
|
|
|
|
commandStack.undo();
|
|
|
|
|
|
|
|
// then
|
|
|
|
expect(gatewayShape.businessObject['default']).to.eql(oldDefaultFlow);
|
|
|
|
|
|
|
|
// flow got updated, too
|
|
|
|
expect(updatedElements).to.include(newDefaultFlowConnection);
|
|
|
|
expect(updatedElements).to.include(oldDefaultFlowConnection);
|
2015-01-02 15:15:18 +00:00
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
|
|
it('updating name', inject(function(elementRegistry, commandStack, modeling) {
|
|
|
|
|
|
|
|
// given
|
|
|
|
var flowConnection = elementRegistry.get('SequenceFlow_1');
|
|
|
|
|
|
|
|
// when
|
|
|
|
modeling.updateProperties(flowConnection, { name: 'FOO BAR' });
|
|
|
|
commandStack.undo();
|
|
|
|
|
|
|
|
// then
|
2015-07-15 15:22:19 +00:00
|
|
|
expect(flowConnection.businessObject.name).to.equal('default');
|
2015-01-02 15:15:18 +00:00
|
|
|
|
|
|
|
// flow got updated, too
|
2015-07-15 15:22:19 +00:00
|
|
|
expect(updatedElements).to.include(elementRegistry.get('SequenceFlow_1_label'));
|
2015-01-02 15:15:18 +00:00
|
|
|
}));
|
|
|
|
|
2015-04-13 08:55:17 +00:00
|
|
|
|
2015-06-18 14:57:58 +00:00
|
|
|
it('unsetting name', inject(function(elementRegistry, commandStack, modeling) {
|
|
|
|
|
|
|
|
// given
|
|
|
|
var flowConnection = elementRegistry.get('SequenceFlow_3');
|
|
|
|
|
|
|
|
modeling.updateProperties(flowConnection, { name: undefined });
|
|
|
|
|
|
|
|
// when
|
|
|
|
commandStack.undo();
|
|
|
|
|
|
|
|
// then
|
2015-07-15 15:22:19 +00:00
|
|
|
expect(flowConnection.businessObject.name).to.equal('conditional');
|
2015-06-18 14:57:58 +00:00
|
|
|
}));
|
|
|
|
|
|
|
|
|
2015-04-13 08:55:17 +00:00
|
|
|
it('updating id', inject(function(elementRegistry, commandStack, modeling) {
|
|
|
|
|
|
|
|
// given
|
|
|
|
var flowConnection = elementRegistry.get('SequenceFlow_1');
|
2015-10-05 11:35:10 +00:00
|
|
|
var ids = flowConnection.businessObject.$model.ids;
|
2015-04-13 08:55:17 +00:00
|
|
|
|
|
|
|
// when
|
|
|
|
modeling.updateProperties(flowConnection, { id: 'FOO_BAR' });
|
|
|
|
commandStack.undo();
|
|
|
|
|
|
|
|
// then
|
2015-10-05 11:35:10 +00:00
|
|
|
expect(ids.assigned('FOO_BAR')).to.be.false;
|
2016-04-18 14:15:00 +00:00
|
|
|
expect(ids.assigned('SequenceFlow_1')).to.eql(flowConnection.businessObject);
|
2015-10-05 11:35:10 +00:00
|
|
|
|
2015-07-15 15:22:19 +00:00
|
|
|
expect(flowConnection.businessObject.id).to.equal('SequenceFlow_1');
|
|
|
|
expect(flowConnection.id).to.equal('SequenceFlow_1');
|
2015-04-13 08:55:17 +00:00
|
|
|
}));
|
|
|
|
|
2015-06-18 14:57:58 +00:00
|
|
|
|
|
|
|
it('updating extension elements', inject(function(elementRegistry, commandStack, modeling) {
|
|
|
|
|
|
|
|
// given
|
|
|
|
var flowConnection = elementRegistry.get('SequenceFlow_1');
|
|
|
|
|
|
|
|
modeling.updateProperties(flowConnection, {
|
|
|
|
'xmlns:foo': 'http://foo',
|
|
|
|
'foo:customAttr': 'FOO'
|
|
|
|
});
|
|
|
|
|
|
|
|
// when
|
|
|
|
commandStack.undo();
|
|
|
|
|
|
|
|
// then
|
2015-12-01 07:27:45 +00:00
|
|
|
expect(flowConnection.businessObject.get('xmlns:foo')).not.to.exist;
|
|
|
|
expect(flowConnection.businessObject.get('foo:customAttr')).not.to.exist;
|
2015-06-18 14:57:58 +00:00
|
|
|
}));
|
|
|
|
|
2015-01-02 15:15:18 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
describe('should redo', function() {
|
|
|
|
|
|
|
|
it('setting loop characteristics', inject(function(elementRegistry, modeling, commandStack, moddle) {
|
|
|
|
|
|
|
|
// given
|
|
|
|
var loopCharacteristics = moddle.create('bpmn:MultiInstanceLoopCharacteristics');
|
|
|
|
|
|
|
|
var taskShape = elementRegistry.get('ServiceTask_1');
|
|
|
|
|
|
|
|
// when
|
|
|
|
modeling.updateProperties(taskShape, { loopCharacteristics: loopCharacteristics });
|
|
|
|
commandStack.undo();
|
|
|
|
commandStack.redo();
|
|
|
|
|
|
|
|
// then
|
2015-07-15 15:22:19 +00:00
|
|
|
expect(taskShape.businessObject.loopCharacteristics).to.eql(loopCharacteristics);
|
2015-01-02 15:15:18 +00:00
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
|
|
it('updating default flow', inject(function(elementRegistry, commandStack, modeling) {
|
|
|
|
|
|
|
|
// given
|
|
|
|
var gatewayShape = elementRegistry.get('ExclusiveGateway_1');
|
|
|
|
|
|
|
|
// when
|
|
|
|
modeling.updateProperties(gatewayShape, { 'default': undefined });
|
|
|
|
commandStack.undo();
|
|
|
|
commandStack.redo();
|
|
|
|
|
|
|
|
// then
|
2015-12-01 07:27:45 +00:00
|
|
|
expect(gatewayShape.businessObject['default']).not.to.exist;
|
2015-01-02 15:15:18 +00:00
|
|
|
|
|
|
|
// flow got updated, too
|
2015-07-15 15:22:19 +00:00
|
|
|
expect(updatedElements).to.include(elementRegistry.get('SequenceFlow_1'));
|
2015-01-02 15:15:18 +00:00
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
|
|
it('updating name', inject(function(elementRegistry, commandStack, modeling) {
|
|
|
|
|
|
|
|
// given
|
|
|
|
var flowConnection = elementRegistry.get('SequenceFlow_1');
|
|
|
|
|
|
|
|
// when
|
|
|
|
modeling.updateProperties(flowConnection, { name: 'FOO BAR' });
|
|
|
|
commandStack.undo();
|
|
|
|
commandStack.redo();
|
|
|
|
|
|
|
|
// then
|
2015-07-15 15:22:19 +00:00
|
|
|
expect(flowConnection.businessObject.name).to.equal('FOO BAR');
|
2015-01-02 15:15:18 +00:00
|
|
|
|
|
|
|
// flow got updated, too
|
2015-07-15 15:22:19 +00:00
|
|
|
expect(updatedElements).to.include(elementRegistry.get('SequenceFlow_1_label'));
|
2015-01-02 15:15:18 +00:00
|
|
|
}));
|
|
|
|
|
2015-06-18 14:57:58 +00:00
|
|
|
|
|
|
|
it('unsetting name', inject(function(elementRegistry, commandStack, modeling) {
|
|
|
|
|
|
|
|
// given
|
|
|
|
var flowConnection = elementRegistry.get('SequenceFlow_3');
|
|
|
|
|
|
|
|
modeling.updateProperties(flowConnection, { name: undefined });
|
|
|
|
|
|
|
|
// when
|
|
|
|
commandStack.undo();
|
|
|
|
commandStack.redo();
|
|
|
|
|
|
|
|
// then
|
2015-12-01 07:27:45 +00:00
|
|
|
expect(flowConnection.businessObject.name).not.to.exist;
|
2015-06-18 14:57:58 +00:00
|
|
|
}));
|
|
|
|
|
2015-01-02 15:15:18 +00:00
|
|
|
});
|
|
|
|
|
2015-11-25 20:53:02 +00:00
|
|
|
|
2015-12-08 12:29:03 +00:00
|
|
|
describe('unwrap diagram elements', function() {
|
|
|
|
|
|
|
|
it('updating default flow with connection', inject(function(elementRegistry, modeling) {
|
|
|
|
|
|
|
|
// given
|
|
|
|
var gatewayShape = elementRegistry.get('ExclusiveGateway_1'),
|
|
|
|
newDefaultFlowConnection = elementRegistry.get('SequenceFlow_2');
|
|
|
|
|
|
|
|
// when
|
|
|
|
modeling.updateProperties(gatewayShape, { 'default': newDefaultFlowConnection });
|
|
|
|
|
|
|
|
// then
|
|
|
|
expect(gatewayShape.businessObject['default']).to.eql(newDefaultFlowConnection.businessObject);
|
|
|
|
|
|
|
|
// flow got updated, too
|
|
|
|
expect(updatedElements).to.include(newDefaultFlowConnection);
|
|
|
|
}));
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
2015-11-25 20:53:02 +00:00
|
|
|
describe('error handling', function() {
|
|
|
|
|
|
|
|
it('should ignore unchanged id', inject(function(elementRegistry, modeling) {
|
|
|
|
|
|
|
|
// given
|
|
|
|
var flowConnection = elementRegistry.get('SequenceFlow_1');
|
|
|
|
var ids = flowConnection.businessObject.$model.ids;
|
|
|
|
|
|
|
|
// when
|
|
|
|
modeling.updateProperties(flowConnection, { id: 'SequenceFlow_1' });
|
|
|
|
|
|
|
|
// then
|
2016-04-18 14:15:00 +00:00
|
|
|
expect(ids.assigned('SequenceFlow_1')).to.eql(flowConnection.businessObject);
|
2015-11-25 20:53:02 +00:00
|
|
|
|
|
|
|
expect(flowConnection.businessObject.id).to.equal('SequenceFlow_1');
|
|
|
|
}));
|
|
|
|
|
|
|
|
});
|
|
|
|
|
2015-01-02 15:15:18 +00:00
|
|
|
});
|