2018-04-02 19:01:53 +00:00
|
|
|
import {
|
|
|
|
bootstrapModeler,
|
|
|
|
inject
|
|
|
|
} from 'test/TestHelper';
|
|
|
|
|
2019-04-29 09:09:31 +00:00
|
|
|
import {
|
|
|
|
assign,
|
|
|
|
pick
|
|
|
|
} from 'min-dash';
|
|
|
|
|
2018-04-02 19:01:53 +00:00
|
|
|
import modelingModule from 'lib/features/modeling';
|
|
|
|
import replaceModule from 'lib/features/replace';
|
|
|
|
import moveModule from 'diagram-js/lib/features/move';
|
|
|
|
import coreModule from 'lib/core';
|
|
|
|
|
2019-08-07 13:17:28 +00:00
|
|
|
import camundaModdleModule from 'camunda-bpmn-moddle/lib';
|
|
|
|
import camundaPackage from 'camunda-bpmn-moddle/resources/camunda.json';
|
|
|
|
|
2018-04-02 19:01:53 +00:00
|
|
|
import {
|
|
|
|
is
|
|
|
|
} from 'lib/util/ModelUtil';
|
|
|
|
|
|
|
|
import {
|
|
|
|
isExpanded,
|
|
|
|
isInterrupting,
|
|
|
|
isEventSubProcess,
|
|
|
|
hasErrorEventDefinition
|
|
|
|
} from 'lib/util/DiUtil';
|
2015-01-19 11:13:39 +00:00
|
|
|
|
|
|
|
|
2016-01-20 10:31:01 +00:00
|
|
|
describe('features/replace - bpmn replace', function() {
|
2015-01-19 11:13:39 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
var testModules = [
|
2019-08-07 13:17:28 +00:00
|
|
|
camundaModdleModule,
|
2016-06-07 06:46:45 +00:00
|
|
|
coreModule,
|
|
|
|
modelingModule,
|
2019-08-07 13:17:28 +00:00
|
|
|
moveModule,
|
|
|
|
replaceModule
|
2016-06-07 06:46:45 +00:00
|
|
|
];
|
|
|
|
|
2015-01-19 11:13:39 +00:00
|
|
|
|
2015-08-11 09:58:30 +00:00
|
|
|
describe('should replace', function() {
|
2015-01-19 11:13:39 +00:00
|
|
|
|
2015-08-11 09:58:30 +00:00
|
|
|
var diagramXML = require('../../../fixtures/bpmn/features/replace/01_replace.bpmn');
|
|
|
|
|
2019-08-07 13:17:28 +00:00
|
|
|
beforeEach(bootstrapModeler(diagramXML, {
|
|
|
|
modules: testModules,
|
|
|
|
moddleExtensions: {
|
|
|
|
camunda: camundaPackage
|
|
|
|
}
|
|
|
|
}));
|
2015-01-19 11:13:39 +00:00
|
|
|
|
|
|
|
|
2015-07-03 08:48:32 +00:00
|
|
|
it('task', inject(function(elementRegistry, bpmnReplace) {
|
2015-01-19 11:13:39 +00:00
|
|
|
|
|
|
|
// given
|
|
|
|
var task = elementRegistry.get('Task_1');
|
2018-02-27 09:08:31 +00:00
|
|
|
var newElementData = {
|
2015-01-19 11:13:39 +00:00
|
|
|
type: 'bpmn:UserTask'
|
|
|
|
};
|
|
|
|
|
|
|
|
// when
|
2015-03-11 15:17:19 +00:00
|
|
|
var newElement = bpmnReplace.replaceElement(task, newElementData);
|
2015-01-19 11:13:39 +00:00
|
|
|
|
|
|
|
// then
|
|
|
|
var businessObject = newElement.businessObject;
|
|
|
|
|
2015-12-01 07:27:45 +00:00
|
|
|
expect(newElement).to.exist;
|
2015-07-15 15:22:19 +00:00
|
|
|
expect(is(businessObject, 'bpmn:UserTask')).to.be.true;
|
2015-01-19 11:13:39 +00:00
|
|
|
}));
|
|
|
|
|
|
|
|
|
2015-07-03 08:48:32 +00:00
|
|
|
it('gateway', inject(function(elementRegistry, bpmnReplace) {
|
2015-01-19 11:13:39 +00:00
|
|
|
|
|
|
|
// given
|
|
|
|
var gateway = elementRegistry.get('ExclusiveGateway_1');
|
2018-02-27 09:08:31 +00:00
|
|
|
var newElementData = {
|
2015-01-19 11:13:39 +00:00
|
|
|
type: 'bpmn:InclusiveGateway'
|
|
|
|
};
|
|
|
|
|
|
|
|
// when
|
2015-03-11 15:17:19 +00:00
|
|
|
var newElement = bpmnReplace.replaceElement(gateway, newElementData);
|
2015-01-19 11:13:39 +00:00
|
|
|
|
|
|
|
|
|
|
|
// then
|
|
|
|
var businessObject = newElement.businessObject;
|
|
|
|
|
2015-12-01 07:27:45 +00:00
|
|
|
expect(newElement).to.exist;
|
2015-07-15 15:22:19 +00:00
|
|
|
expect(is(businessObject, 'bpmn:InclusiveGateway')).to.be.true;
|
2015-06-24 09:43:07 +00:00
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
|
|
it('expanded sub process', inject(function(elementRegistry, modeling, bpmnReplace, canvas) {
|
2015-07-13 13:18:18 +00:00
|
|
|
|
2015-06-24 09:43:07 +00:00
|
|
|
// given
|
|
|
|
var subProcess = elementRegistry.get('SubProcess_1'),
|
|
|
|
newElementData = {
|
|
|
|
type: 'bpmn:Transaction',
|
|
|
|
isExpanded: true
|
|
|
|
};
|
|
|
|
|
|
|
|
// when
|
|
|
|
var newElement = bpmnReplace.replaceElement(subProcess, newElementData);
|
|
|
|
|
|
|
|
// then
|
2015-12-01 07:27:45 +00:00
|
|
|
expect(newElement).to.exist;
|
2015-07-15 15:22:19 +00:00
|
|
|
expect(is(newElement.businessObject, 'bpmn:Transaction')).to.be.true;
|
2015-06-24 09:43:07 +00:00
|
|
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
|
|
it('transaction', inject(function(elementRegistry, modeling, bpmnReplace, canvas) {
|
2015-07-13 13:18:18 +00:00
|
|
|
|
2015-07-23 11:59:47 +00:00
|
|
|
// given
|
2015-06-24 09:43:07 +00:00
|
|
|
var transaction = elementRegistry.get('Transaction_1'),
|
|
|
|
newElementData = {
|
|
|
|
type: 'bpmn:SubProcess',
|
|
|
|
isExpanded: true
|
|
|
|
};
|
|
|
|
|
2015-07-23 11:59:47 +00:00
|
|
|
// when
|
2015-06-24 09:43:07 +00:00
|
|
|
var newElement = bpmnReplace.replaceElement(transaction, newElementData);
|
|
|
|
|
2015-07-23 11:59:47 +00:00
|
|
|
// then
|
2015-12-01 07:27:45 +00:00
|
|
|
expect(newElement).to.exist;
|
2015-07-15 15:22:19 +00:00
|
|
|
expect(is(newElement.businessObject, 'bpmn:SubProcess')).to.be.true;
|
2015-06-24 09:43:07 +00:00
|
|
|
|
2015-01-19 11:13:39 +00:00
|
|
|
}));
|
|
|
|
|
2015-07-23 11:59:47 +00:00
|
|
|
|
2015-08-04 15:52:43 +00:00
|
|
|
it('event sub process', inject(function(elementRegistry, bpmnReplace) {
|
|
|
|
|
|
|
|
// given
|
|
|
|
var transaction = elementRegistry.get('SubProcess_1'),
|
|
|
|
newElementData = {
|
|
|
|
type: 'bpmn:SubProcess',
|
|
|
|
triggeredByEvent: true
|
|
|
|
};
|
|
|
|
|
|
|
|
// when
|
|
|
|
var newElement = bpmnReplace.replaceElement(transaction, newElementData);
|
|
|
|
|
|
|
|
// then
|
2015-12-01 07:27:45 +00:00
|
|
|
expect(newElement).to.exist;
|
2015-08-04 15:52:43 +00:00
|
|
|
expect(isEventSubProcess(newElement)).to.be.true;
|
|
|
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
2018-06-27 13:11:34 +00:00
|
|
|
describe('boundary event', function() {
|
2015-07-23 11:59:47 +00:00
|
|
|
|
2018-06-27 13:11:34 +00:00
|
|
|
it('<non-interrupting> with <interrupting>',
|
|
|
|
inject(function(elementRegistry, modeling, bpmnReplace, canvas) {
|
2015-07-23 11:59:47 +00:00
|
|
|
|
2018-06-27 13:11:34 +00:00
|
|
|
// given
|
|
|
|
var boundaryEvent = elementRegistry.get('BoundaryEvent_1'),
|
|
|
|
boundaryBo = boundaryEvent.businessObject,
|
|
|
|
newElementData = {
|
|
|
|
type: 'bpmn:BoundaryEvent',
|
|
|
|
eventDefinitionType: 'bpmn:TimerEventDefinition'
|
|
|
|
};
|
2015-07-23 11:59:47 +00:00
|
|
|
|
2018-06-27 13:11:34 +00:00
|
|
|
var eventDefinitions = boundaryBo.eventDefinitions.slice();
|
2015-07-23 11:59:47 +00:00
|
|
|
|
2018-06-27 13:11:34 +00:00
|
|
|
// when
|
|
|
|
var newElement = bpmnReplace.replaceElement(boundaryEvent, newElementData);
|
|
|
|
var newBo = newElement.businessObject;
|
2015-07-23 11:59:47 +00:00
|
|
|
|
2018-06-27 13:11:34 +00:00
|
|
|
// then
|
|
|
|
expect(newElement).to.exist;
|
2015-07-23 11:59:47 +00:00
|
|
|
|
2018-06-27 13:11:34 +00:00
|
|
|
expect(is(newBo, 'bpmn:BoundaryEvent')).to.be.true;
|
2015-07-23 11:59:47 +00:00
|
|
|
|
2018-06-27 13:11:34 +00:00
|
|
|
expect(newBo.eventDefinitions).to.jsonEqual(eventDefinitions, skipId);
|
2015-07-23 11:59:47 +00:00
|
|
|
|
2018-06-27 13:11:34 +00:00
|
|
|
expect(newBo.cancelActivity).to.be.true;
|
|
|
|
})
|
|
|
|
);
|
2015-07-23 11:59:47 +00:00
|
|
|
|
|
|
|
|
2018-06-27 13:11:34 +00:00
|
|
|
it('<interrupting> with <non-interrupting>',
|
|
|
|
inject(function(elementRegistry, modeling, bpmnReplace, canvas) {
|
2015-07-23 11:59:47 +00:00
|
|
|
|
2018-06-27 13:11:34 +00:00
|
|
|
// given
|
|
|
|
var boundaryEvent = elementRegistry.get('BoundaryEvent_2'),
|
|
|
|
boundaryBo = boundaryEvent.businessObject,
|
|
|
|
newElementData = {
|
|
|
|
type: 'bpmn:BoundaryEvent',
|
|
|
|
eventDefinitionType: 'bpmn:ConditionalEventDefinition',
|
|
|
|
cancelActivity: false
|
|
|
|
};
|
2015-07-23 11:59:47 +00:00
|
|
|
|
2018-06-27 13:11:34 +00:00
|
|
|
var eventDefinitions = boundaryBo.eventDefinitions.slice();
|
2015-07-23 11:59:47 +00:00
|
|
|
|
2018-06-27 13:11:34 +00:00
|
|
|
// when
|
|
|
|
var newElement = bpmnReplace.replaceElement(boundaryEvent, newElementData);
|
|
|
|
var newBo = newElement.businessObject;
|
|
|
|
|
|
|
|
// then
|
|
|
|
expect(newElement).to.exist;
|
|
|
|
|
|
|
|
expect(is(newBo, 'bpmn:BoundaryEvent')).to.be.true;
|
|
|
|
|
|
|
|
expect(newBo.eventDefinitions).to.jsonEqual(eventDefinitions, skipId);
|
|
|
|
|
|
|
|
expect(newBo.cancelActivity).to.be.false;
|
|
|
|
})
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
it('<timer> with <signal>',
|
|
|
|
inject(function(elementRegistry, modeling, bpmnReplace, canvas) {
|
|
|
|
|
|
|
|
// given
|
|
|
|
var boundaryEvent = elementRegistry.get('BoundaryEvent_1'),
|
|
|
|
newElementData = {
|
|
|
|
type: 'bpmn:BoundaryEvent',
|
|
|
|
eventDefinitionType: 'bpmn:SignalEventDefinition',
|
|
|
|
cancelActivity: false
|
|
|
|
};
|
|
|
|
|
|
|
|
// when
|
|
|
|
var newElement = bpmnReplace.replaceElement(boundaryEvent, newElementData);
|
|
|
|
|
|
|
|
var newBo = newElement.businessObject;
|
|
|
|
var newEventDefinitions = newBo.eventDefinitions;
|
|
|
|
var newEventDefinition = newEventDefinitions[0];
|
|
|
|
|
|
|
|
// then
|
|
|
|
expect(newElement).to.exist;
|
|
|
|
expect(newEventDefinitions).to.have.length(1);
|
|
|
|
|
|
|
|
expect(is(newBo, 'bpmn:BoundaryEvent')).to.be.true;
|
|
|
|
expect(is(newEventDefinition, 'bpmn:SignalEventDefinition')).to.be.true;
|
|
|
|
|
|
|
|
expect(newBo.cancelActivity).to.be.false;
|
|
|
|
})
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
it('<conditional> with <timer>',
|
|
|
|
inject(function(elementRegistry, modeling, bpmnReplace, canvas) {
|
|
|
|
|
|
|
|
// given
|
|
|
|
var boundaryEvent = elementRegistry.get('BoundaryEvent_2'),
|
|
|
|
newElementData = {
|
|
|
|
type: 'bpmn:BoundaryEvent',
|
|
|
|
eventDefinitionType: 'bpmn:TimerEventDefinition'
|
|
|
|
};
|
|
|
|
|
|
|
|
// when
|
|
|
|
var newElement = bpmnReplace.replaceElement(boundaryEvent, newElementData);
|
|
|
|
|
|
|
|
var newBo = newElement.businessObject;
|
|
|
|
var newEventDefinitions = newBo.eventDefinitions;
|
|
|
|
var newEventDefinition = newEventDefinitions[0];
|
|
|
|
|
|
|
|
// then
|
|
|
|
expect(newElement).to.exist;
|
|
|
|
expect(newEventDefinitions).to.have.length(1);
|
|
|
|
|
|
|
|
expect(is(newBo, 'bpmn:BoundaryEvent')).to.be.true;
|
|
|
|
expect(is(newEventDefinition, 'bpmn:TimerEventDefinition')).to.be.true;
|
|
|
|
|
|
|
|
expect(newBo.cancelActivity).to.be.true;
|
|
|
|
})
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
it('updating host',
|
|
|
|
inject(function(elementRegistry, modeling, bpmnReplace, canvas) {
|
|
|
|
|
|
|
|
// given
|
|
|
|
var boundaryEvent = elementRegistry.get('BoundaryEvent_1'),
|
|
|
|
host = elementRegistry.get('Task_1'),
|
|
|
|
newElementData = {
|
|
|
|
type: 'bpmn:BoundaryEvent',
|
|
|
|
eventDefinitionType: 'bpmn:ErrorEventDefinition'
|
|
|
|
};
|
|
|
|
|
|
|
|
// when
|
|
|
|
var newElement = bpmnReplace.replaceElement(boundaryEvent, newElementData);
|
|
|
|
|
|
|
|
// then
|
|
|
|
expect(newElement.host).to.exist;
|
|
|
|
expect(newElement.host).to.eql(host);
|
|
|
|
})
|
|
|
|
);
|
|
|
|
|
|
|
|
});
|
2015-07-23 11:59:47 +00:00
|
|
|
|
2015-01-19 11:13:39 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
|
2016-03-08 16:21:41 +00:00
|
|
|
describe('should replace in collaboration', function() {
|
|
|
|
|
|
|
|
var diagramXML = require('./BpmnReplace.collaboration.bpmn');
|
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
beforeEach(bootstrapModeler(diagramXML, {
|
2019-08-07 13:17:28 +00:00
|
|
|
modules: testModules,
|
|
|
|
moddleExtensions: {
|
|
|
|
camunda: camundaPackage
|
|
|
|
}
|
2016-06-07 06:46:45 +00:00
|
|
|
}));
|
2016-03-08 16:21:41 +00:00
|
|
|
|
|
|
|
|
|
|
|
it('expanded with collapsed pool', inject(function(elementRegistry, bpmnReplace) {
|
|
|
|
|
|
|
|
// given
|
|
|
|
var shape = elementRegistry.get('Participant_1');
|
|
|
|
|
2020-01-13 13:12:25 +00:00
|
|
|
var messageFlow = elementRegistry.get('MessageFlow_B_to_A');
|
|
|
|
|
2019-04-29 09:09:31 +00:00
|
|
|
var collapsedBounds = assign({}, getBounds(shape), { height: 60 });
|
|
|
|
|
2016-03-08 16:21:41 +00:00
|
|
|
// when
|
2019-04-29 09:09:31 +00:00
|
|
|
var newShape = bpmnReplace.replaceElement(shape, {
|
|
|
|
type: 'bpmn:Participant',
|
|
|
|
isExpanded: false
|
|
|
|
});
|
2016-03-08 16:21:41 +00:00
|
|
|
|
|
|
|
// then
|
|
|
|
expect(isExpanded(newShape)).to.be.false; // collapsed
|
|
|
|
expect(newShape.children).to.be.empty;
|
2019-04-12 12:36:20 +00:00
|
|
|
|
2019-04-29 09:09:31 +00:00
|
|
|
expect(newShape).to.have.bounds(collapsedBounds);
|
2020-01-13 13:12:25 +00:00
|
|
|
|
|
|
|
expect(messageFlow).to.have.waypoints([
|
|
|
|
{ x: 368, y: 436 },
|
|
|
|
{ x: 368, y: newShape.y + collapsedBounds.height }
|
|
|
|
]);
|
2016-03-08 16:21:41 +00:00
|
|
|
}));
|
|
|
|
|
|
|
|
|
2017-01-19 15:12:25 +00:00
|
|
|
it('collapsed with expanded pool', inject(function(elementRegistry, bpmnReplace) {
|
2016-03-08 16:21:41 +00:00
|
|
|
|
|
|
|
// given
|
|
|
|
var shape = elementRegistry.get('Participant_2');
|
|
|
|
|
2019-04-29 11:56:38 +00:00
|
|
|
var expandedBounds = assign({}, getBounds(shape), { height: 250 });
|
|
|
|
|
2016-03-08 16:21:41 +00:00
|
|
|
// when
|
2019-04-29 11:56:38 +00:00
|
|
|
var newShape = bpmnReplace.replaceElement(shape, {
|
|
|
|
type: 'bpmn:Participant',
|
|
|
|
isExpanded: true
|
|
|
|
});
|
2016-03-08 16:21:41 +00:00
|
|
|
|
|
|
|
// then
|
|
|
|
expect(isExpanded(newShape)).to.be.true; // expanded
|
|
|
|
expect(newShape.children).to.be.empty;
|
2019-04-12 12:36:20 +00:00
|
|
|
|
2019-04-29 11:56:38 +00:00
|
|
|
expect(newShape).to.have.bounds(expandedBounds);
|
2016-03-08 16:21:41 +00:00
|
|
|
}));
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
2018-11-29 15:27:12 +00:00
|
|
|
describe('should collapse pool, removing message flows', function() {
|
|
|
|
|
|
|
|
var diagramXML = require('./BpmnReplace.poolMessageFlows.bpmn');
|
|
|
|
|
|
|
|
beforeEach(bootstrapModeler(diagramXML, {
|
2019-08-07 13:17:28 +00:00
|
|
|
modules: testModules,
|
|
|
|
moddleExtensions: {
|
|
|
|
camunda: camundaPackage
|
|
|
|
}
|
2018-11-29 15:27:12 +00:00
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
|
|
it('expanded with collapsed pool', inject(function(elementRegistry, bpmnReplace) {
|
|
|
|
|
|
|
|
// given
|
|
|
|
var shape = elementRegistry.get('Participant_1');
|
|
|
|
|
|
|
|
// when
|
|
|
|
var newShape = bpmnReplace.replaceElement(shape, {
|
|
|
|
type: 'bpmn:Participant',
|
|
|
|
isExpanded: false
|
|
|
|
});
|
|
|
|
|
|
|
|
// then
|
|
|
|
expect(isExpanded(newShape)).to.be.false; // collapsed
|
|
|
|
expect(newShape.children).to.be.empty;
|
|
|
|
|
|
|
|
expect(elementRegistry.get('MessageFlow_1')).not.to.exist;
|
|
|
|
expect(elementRegistry.get('MessageFlow_2')).not.to.exist;
|
|
|
|
}));
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
2017-12-07 22:12:00 +00:00
|
|
|
describe('should replace with data objects', function() {
|
|
|
|
|
|
|
|
var diagramXML = require('./BpmnReplace.dataObjects.bpmn');
|
|
|
|
|
|
|
|
beforeEach(bootstrapModeler(diagramXML, {
|
2019-08-07 13:17:28 +00:00
|
|
|
modules: testModules,
|
|
|
|
moddleExtensions: {
|
|
|
|
camunda: camundaPackage
|
|
|
|
}
|
2017-12-07 22:12:00 +00:00
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
|
|
it('restoring dataAssociations', inject(function(elementRegistry, bpmnReplace) {
|
|
|
|
|
|
|
|
// given
|
|
|
|
var task = elementRegistry.get('Task');
|
|
|
|
|
|
|
|
// when
|
|
|
|
var serviceTask = bpmnReplace.replaceElement(task, { type: 'bpmn:ServiceTask' });
|
|
|
|
var bo = serviceTask.businessObject;
|
|
|
|
|
|
|
|
// then
|
|
|
|
// expect one incoming connection
|
|
|
|
expect(serviceTask.incoming).to.have.length(1);
|
|
|
|
|
|
|
|
var inputAssociations = bo.dataInputAssociations;
|
|
|
|
expect(inputAssociations).to.have.length(1);
|
|
|
|
|
|
|
|
var inputAssociation = inputAssociations[0];
|
|
|
|
|
|
|
|
// expect input association references __target_ref_placeholder property
|
|
|
|
expect(inputAssociation.targetRef).to.equal(bo.properties[0]);
|
|
|
|
|
|
|
|
// ...and
|
|
|
|
// expect one outgoing connection
|
|
|
|
expect(serviceTask.outgoing).to.have.length(1);
|
|
|
|
|
|
|
|
var outputAssociations = bo.dataOutputAssociations;
|
|
|
|
expect(outputAssociations).to.have.length(1);
|
|
|
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
2015-01-19 11:13:39 +00:00
|
|
|
describe('position and size', function() {
|
|
|
|
|
2015-08-11 09:58:30 +00:00
|
|
|
var diagramXML = require('../../../fixtures/bpmn/features/replace/01_replace.bpmn');
|
|
|
|
|
2019-08-07 13:17:28 +00:00
|
|
|
beforeEach(bootstrapModeler(diagramXML, {
|
|
|
|
modules: testModules,
|
|
|
|
moddleExtensions: {
|
|
|
|
camunda: camundaPackage
|
|
|
|
}
|
|
|
|
}));
|
2015-08-11 09:58:30 +00:00
|
|
|
|
|
|
|
|
2015-03-11 15:17:19 +00:00
|
|
|
it('should keep position', inject(function(elementRegistry, bpmnReplace) {
|
2015-01-19 11:13:39 +00:00
|
|
|
|
|
|
|
// given
|
|
|
|
var task = elementRegistry.get('Task_1');
|
2018-02-27 09:08:31 +00:00
|
|
|
var newElementData = {
|
2015-01-19 11:13:39 +00:00
|
|
|
type: 'bpmn:UserTask'
|
|
|
|
};
|
|
|
|
|
|
|
|
// when
|
2015-03-11 15:17:19 +00:00
|
|
|
var newElement = bpmnReplace.replaceElement(task, newElementData);
|
2015-01-19 11:13:39 +00:00
|
|
|
|
|
|
|
// then
|
2015-07-15 15:22:19 +00:00
|
|
|
expect(newElement.x).to.equal(task.x);
|
|
|
|
expect(newElement.y).to.equal(task.y);
|
2015-01-19 11:13:39 +00:00
|
|
|
}));
|
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
|
|
|
|
it('should keep label position', inject(function(elementRegistry, bpmnReplace, modeling) {
|
2016-04-18 11:04:32 +00:00
|
|
|
|
|
|
|
// given
|
2017-03-07 08:30:48 +00:00
|
|
|
var startEvent = elementRegistry.get('StartEvent_1');
|
|
|
|
var label = elementRegistry.get('StartEvent_1_label');
|
2016-04-18 11:04:32 +00:00
|
|
|
|
2018-02-27 09:08:31 +00:00
|
|
|
var newElementData = {
|
2017-03-07 08:30:48 +00:00
|
|
|
type: 'bpmn:EndEvent'
|
2016-04-18 11:04:32 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// when
|
2017-03-07 08:30:48 +00:00
|
|
|
var newElement = bpmnReplace.replaceElement(startEvent, newElementData);
|
2016-04-18 11:04:32 +00:00
|
|
|
|
|
|
|
// then
|
|
|
|
expect(newElement.label.x).to.equal(label.x);
|
|
|
|
expect(newElement.label.y).to.equal(label.y);
|
|
|
|
}));
|
|
|
|
|
2015-01-19 11:13:39 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
|
2015-03-11 15:31:42 +00:00
|
|
|
describe('selection', function() {
|
|
|
|
|
2015-08-11 09:58:30 +00:00
|
|
|
var diagramXML = require('../../../fixtures/bpmn/features/replace/01_replace.bpmn');
|
|
|
|
|
2019-08-07 13:17:28 +00:00
|
|
|
beforeEach(bootstrapModeler(diagramXML, {
|
|
|
|
modules: testModules,
|
|
|
|
moddleExtensions: {
|
|
|
|
camunda: camundaPackage
|
|
|
|
}
|
|
|
|
}));
|
2015-08-11 09:58:30 +00:00
|
|
|
|
|
|
|
|
2015-07-03 08:48:32 +00:00
|
|
|
it('should select after replace',
|
|
|
|
inject(function(elementRegistry, selection, bpmnReplace) {
|
2015-03-11 15:31:42 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// given
|
|
|
|
var task = elementRegistry.get('Task_1');
|
2018-02-27 09:08:31 +00:00
|
|
|
var newElementData = {
|
2016-06-07 06:46:45 +00:00
|
|
|
type: 'bpmn:UserTask'
|
|
|
|
};
|
2015-03-11 15:31:42 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// when
|
|
|
|
var newElement = bpmnReplace.replaceElement(task, newElementData);
|
2015-03-11 15:31:42 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// then
|
|
|
|
expect(selection.get()).to.include(newElement);
|
|
|
|
})
|
|
|
|
);
|
2015-03-11 15:31:42 +00:00
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
2015-01-19 11:13:39 +00:00
|
|
|
describe('label', function() {
|
|
|
|
|
2015-08-11 09:58:30 +00:00
|
|
|
var diagramXML = require('../../../fixtures/bpmn/features/replace/01_replace.bpmn');
|
|
|
|
|
2019-08-07 13:17:28 +00:00
|
|
|
beforeEach(bootstrapModeler(diagramXML, {
|
|
|
|
modules: testModules,
|
|
|
|
moddleExtensions: {
|
|
|
|
camunda: camundaPackage
|
|
|
|
}
|
|
|
|
}));
|
2015-08-11 09:58:30 +00:00
|
|
|
|
2018-04-30 09:06:26 +00:00
|
|
|
it('should keep internal labels',
|
2015-07-03 08:48:32 +00:00
|
|
|
inject(function(elementRegistry, bpmnReplace) {
|
2015-01-19 11:13:39 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// given
|
|
|
|
var task = elementRegistry.get('Task_1');
|
2015-01-19 11:13:39 +00:00
|
|
|
|
2018-02-27 09:08:31 +00:00
|
|
|
var newElementData = {
|
2016-06-07 06:46:45 +00:00
|
|
|
type: 'bpmn:UserTask'
|
|
|
|
};
|
2015-01-19 11:13:39 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// when
|
|
|
|
var newElement = bpmnReplace.replaceElement(task, newElementData);
|
2015-01-19 11:13:39 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// then
|
|
|
|
expect(newElement.businessObject.name).to.equal('Task Caption');
|
|
|
|
})
|
|
|
|
);
|
2015-01-19 11:13:39 +00:00
|
|
|
|
2016-01-04 10:12:53 +00:00
|
|
|
|
2018-04-30 09:06:26 +00:00
|
|
|
it('should keep external labels',
|
2016-01-04 10:12:53 +00:00
|
|
|
inject(function(elementRegistry, bpmnReplace) {
|
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// given
|
|
|
|
var startEvent = elementRegistry.get('StartEvent_1');
|
2016-01-04 10:12:53 +00:00
|
|
|
|
2018-02-27 09:08:31 +00:00
|
|
|
var newElementData = {
|
2016-06-07 06:46:45 +00:00
|
|
|
type: 'bpmn:EndEvent'
|
|
|
|
};
|
2016-01-04 10:12:53 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// when
|
|
|
|
var newElement = bpmnReplace.replaceElement(startEvent, newElementData);
|
2016-01-04 10:12:53 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// then
|
|
|
|
expect(newElement.label.labelTarget).to.equal(newElement);
|
|
|
|
expect(newElement.businessObject.name).to.equal('KEEP ME');
|
|
|
|
})
|
|
|
|
);
|
2016-01-04 10:12:53 +00:00
|
|
|
|
2015-01-19 11:13:39 +00:00
|
|
|
});
|
|
|
|
|
2015-03-11 15:17:19 +00:00
|
|
|
|
2015-01-19 11:13:39 +00:00
|
|
|
describe('undo support', function() {
|
|
|
|
|
2015-08-11 09:58:30 +00:00
|
|
|
var diagramXML = require('../../../fixtures/bpmn/features/replace/01_replace.bpmn');
|
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
beforeEach(bootstrapModeler(diagramXML, {
|
2019-08-07 13:17:28 +00:00
|
|
|
modules: testModules,
|
|
|
|
moddleExtensions: {
|
|
|
|
camunda: camundaPackage
|
|
|
|
}
|
2016-06-07 06:46:45 +00:00
|
|
|
}));
|
2015-08-11 09:58:30 +00:00
|
|
|
|
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
it('should undo', inject(function(elementRegistry, bpmnReplace, commandStack) {
|
2015-01-19 11:13:39 +00:00
|
|
|
|
|
|
|
// given
|
|
|
|
var task = elementRegistry.get('Task_1');
|
2018-02-27 09:08:31 +00:00
|
|
|
var newElementData = {
|
2015-01-19 11:13:39 +00:00
|
|
|
type: 'bpmn:UserTask'
|
|
|
|
};
|
|
|
|
|
2015-03-11 15:17:19 +00:00
|
|
|
bpmnReplace.replaceElement(task, newElementData);
|
2015-01-19 11:13:39 +00:00
|
|
|
|
|
|
|
// when
|
|
|
|
commandStack.undo();
|
|
|
|
|
|
|
|
// then
|
|
|
|
var target = elementRegistry.get('Task_1'),
|
|
|
|
businessObject = target.businessObject;
|
|
|
|
|
2015-12-01 07:27:45 +00:00
|
|
|
expect(target).to.exist;
|
2015-07-15 15:22:19 +00:00
|
|
|
expect(is(businessObject, 'bpmn:Task')).to.be.true;
|
2015-01-19 11:13:39 +00:00
|
|
|
}));
|
|
|
|
|
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
it('should redo', inject(function(elementRegistry, bpmnReplace, commandStack) {
|
2015-01-19 11:13:39 +00:00
|
|
|
|
|
|
|
// given
|
|
|
|
var task = elementRegistry.get('Task_1');
|
2018-02-27 09:08:31 +00:00
|
|
|
var newElementData = {
|
2015-01-19 11:13:39 +00:00
|
|
|
type: 'bpmn:UserTask'
|
|
|
|
};
|
2018-02-27 09:08:31 +00:00
|
|
|
var newElementData2 = {
|
2015-01-19 11:13:39 +00:00
|
|
|
type: 'bpmn:ServiceTask'
|
|
|
|
};
|
|
|
|
|
2015-03-11 15:17:19 +00:00
|
|
|
var usertask = bpmnReplace.replaceElement(task, newElementData);
|
|
|
|
var servicetask = bpmnReplace.replaceElement(usertask, newElementData2);
|
2015-01-19 11:13:39 +00:00
|
|
|
|
|
|
|
commandStack.undo();
|
|
|
|
commandStack.undo();
|
|
|
|
|
|
|
|
// when
|
|
|
|
commandStack.redo();
|
|
|
|
commandStack.redo();
|
|
|
|
|
|
|
|
// then
|
|
|
|
var businessObject = servicetask.businessObject;
|
|
|
|
|
2015-12-01 07:27:45 +00:00
|
|
|
expect(servicetask).to.exist;
|
2015-07-15 15:22:19 +00:00
|
|
|
expect(is(businessObject, 'bpmn:ServiceTask')).to.be.true;
|
2015-01-19 11:13:39 +00:00
|
|
|
}));
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
describe('connection handling', function() {
|
|
|
|
|
2015-08-11 09:58:30 +00:00
|
|
|
var diagramXML = require('../../../fixtures/bpmn/features/replace/01_replace.bpmn');
|
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
beforeEach(bootstrapModeler(diagramXML, {
|
2019-08-07 13:17:28 +00:00
|
|
|
modules: testModules,
|
|
|
|
moddleExtensions: {
|
|
|
|
camunda: camundaPackage
|
|
|
|
}
|
2016-06-07 06:46:45 +00:00
|
|
|
}));
|
2015-08-11 09:58:30 +00:00
|
|
|
|
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
it('should reconnect valid', inject(function(elementRegistry, bpmnReplace) {
|
2015-01-19 11:13:39 +00:00
|
|
|
|
|
|
|
// given
|
|
|
|
var task = elementRegistry.get('Task_1');
|
2018-02-27 09:08:31 +00:00
|
|
|
var newElementData = {
|
2015-01-19 11:13:39 +00:00
|
|
|
type: 'bpmn:UserTask'
|
|
|
|
};
|
|
|
|
|
|
|
|
// when
|
2015-03-11 15:17:19 +00:00
|
|
|
var newElement = bpmnReplace.replaceElement(task, newElementData);
|
2015-01-19 11:13:39 +00:00
|
|
|
|
|
|
|
// then
|
|
|
|
var incoming = newElement.incoming[0],
|
|
|
|
outgoing = newElement.outgoing[0],
|
|
|
|
source = incoming.source,
|
|
|
|
target = outgoing.target;
|
|
|
|
|
2015-12-01 07:27:45 +00:00
|
|
|
expect(incoming).to.exist;
|
|
|
|
expect(outgoing).to.exist;
|
2015-07-15 15:22:19 +00:00
|
|
|
expect(source).to.eql(elementRegistry.get('StartEvent_1'));
|
|
|
|
expect(target).to.eql(elementRegistry.get('ExclusiveGateway_1'));
|
2015-01-19 11:13:39 +00:00
|
|
|
}));
|
|
|
|
|
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
it('should remove invalid (incoming)', inject(function(elementRegistry, bpmnReplace) {
|
2015-01-19 11:13:39 +00:00
|
|
|
|
|
|
|
// given
|
|
|
|
var task = elementRegistry.get('StartEvent_1');
|
2018-02-27 09:08:31 +00:00
|
|
|
var newElementData = {
|
2015-01-19 11:13:39 +00:00
|
|
|
type: 'bpmn:EndEvent'
|
|
|
|
};
|
|
|
|
|
|
|
|
// when
|
2015-03-11 15:17:19 +00:00
|
|
|
var newElement = bpmnReplace.replaceElement(task, newElementData);
|
2015-01-19 11:13:39 +00:00
|
|
|
|
|
|
|
// then
|
2016-06-07 06:46:45 +00:00
|
|
|
expect(newElement.incoming).to.be.empty;
|
2015-01-19 11:13:39 +00:00
|
|
|
}));
|
|
|
|
|
2015-03-11 15:17:19 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
it('should remove invalid (outgoing)', inject(function(elementRegistry, bpmnReplace) {
|
2015-01-19 11:13:39 +00:00
|
|
|
|
|
|
|
// given
|
|
|
|
var task = elementRegistry.get('EndEvent_1');
|
2018-02-27 09:08:31 +00:00
|
|
|
var newElementData = {
|
2015-01-19 11:13:39 +00:00
|
|
|
type: 'bpmn:StartEvent'
|
|
|
|
};
|
|
|
|
|
|
|
|
// when
|
2015-03-11 15:17:19 +00:00
|
|
|
var newElement = bpmnReplace.replaceElement(task, newElementData);
|
2015-01-19 11:13:39 +00:00
|
|
|
|
|
|
|
// then
|
2016-06-07 06:46:45 +00:00
|
|
|
expect(newElement.outgoing).to.be.empty;
|
2015-01-19 11:13:39 +00:00
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
|
|
describe('undo support', function() {
|
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
it('should reconnect valid', inject(function(elementRegistry, bpmnReplace, commandStack) {
|
2015-01-19 11:13:39 +00:00
|
|
|
|
|
|
|
// given
|
|
|
|
var task = elementRegistry.get('Task_1');
|
2018-02-27 09:08:31 +00:00
|
|
|
var newElementData = {
|
2015-01-19 11:13:39 +00:00
|
|
|
type: 'bpmn:UserTask'
|
|
|
|
};
|
2015-03-11 15:17:19 +00:00
|
|
|
|
|
|
|
bpmnReplace.replaceElement(task, newElementData);
|
2015-01-19 11:13:39 +00:00
|
|
|
|
|
|
|
// when
|
|
|
|
commandStack.undo();
|
|
|
|
|
|
|
|
// then
|
|
|
|
var newTask = elementRegistry.get('Task_1');
|
|
|
|
var incoming = newTask.incoming[0],
|
|
|
|
outgoing = newTask.outgoing[0],
|
|
|
|
source = incoming.source,
|
|
|
|
target = outgoing.target;
|
|
|
|
|
2015-12-01 07:27:45 +00:00
|
|
|
expect(incoming).to.exist;
|
|
|
|
expect(outgoing).to.exist;
|
2015-07-15 15:22:19 +00:00
|
|
|
expect(source).to.eql(elementRegistry.get('StartEvent_1'));
|
|
|
|
expect(target).to.eql(elementRegistry.get('ExclusiveGateway_1'));
|
2015-01-19 11:13:39 +00:00
|
|
|
}));
|
|
|
|
|
2015-03-11 15:17:19 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
it('should remove invalid (invalid)',
|
2015-07-03 08:48:32 +00:00
|
|
|
inject(function(elementRegistry, bpmnReplace, commandStack) {
|
2015-01-19 11:13:39 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// given
|
|
|
|
var startEvent = elementRegistry.get('StartEvent_1');
|
2018-02-27 09:08:31 +00:00
|
|
|
var newElementData = {
|
2016-06-07 06:46:45 +00:00
|
|
|
type: 'bpmn:EndEvent'
|
|
|
|
};
|
2015-03-11 15:17:19 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
bpmnReplace.replaceElement(startEvent, newElementData);
|
2015-01-19 11:13:39 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// when
|
|
|
|
commandStack.undo();
|
2015-01-19 11:13:39 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// then
|
|
|
|
var newEvent = elementRegistry.get('StartEvent_1');
|
|
|
|
var incoming = newEvent.incoming[0],
|
|
|
|
outgoing = newEvent.outgoing[0],
|
|
|
|
target = outgoing.target;
|
2015-01-19 11:13:39 +00:00
|
|
|
|
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
expect(incoming).not.to.exist;
|
|
|
|
expect(outgoing).to.exist;
|
|
|
|
expect(target).to.eql(elementRegistry.get('Task_1'));
|
|
|
|
})
|
|
|
|
);
|
2015-01-19 11:13:39 +00:00
|
|
|
|
|
|
|
|
2015-07-03 08:48:32 +00:00
|
|
|
it('should remove invalid outgoing connections',
|
|
|
|
inject(function(elementRegistry, bpmnReplace, commandStack) {
|
2015-01-19 11:13:39 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// given
|
|
|
|
var endEvent = elementRegistry.get('EndEvent_1');
|
2018-02-27 09:08:31 +00:00
|
|
|
var newElementData = {
|
2016-06-07 06:46:45 +00:00
|
|
|
type: 'bpmn:StartEvent'
|
|
|
|
};
|
2015-03-11 15:17:19 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
bpmnReplace.replaceElement(endEvent, newElementData);
|
2015-01-19 11:13:39 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// when
|
|
|
|
commandStack.undo();
|
2015-01-19 11:13:39 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// then
|
|
|
|
var newEvent = elementRegistry.get('EndEvent_1');
|
|
|
|
var incoming = newEvent.incoming[0],
|
|
|
|
outgoing = newEvent.outgoing[0],
|
2018-02-27 09:08:31 +00:00
|
|
|
source = incoming.source;
|
2015-01-19 11:13:39 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
expect(incoming).to.exist;
|
|
|
|
expect(outgoing).not.to.exist;
|
|
|
|
expect(source).to.eql(elementRegistry.get('Transaction_1'));
|
|
|
|
})
|
|
|
|
);
|
2015-01-19 11:13:39 +00:00
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
2015-03-11 15:17:19 +00:00
|
|
|
describe('redo support', function() {
|
2015-01-19 11:13:39 +00:00
|
|
|
|
2015-07-03 08:48:32 +00:00
|
|
|
it('should reconnect valid connections',
|
|
|
|
inject(function(elementRegistry, bpmnReplace, commandStack) {
|
2015-01-19 11:13:39 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// given
|
|
|
|
var task = elementRegistry.get('Task_1');
|
2018-02-27 09:08:31 +00:00
|
|
|
var newElementData = {
|
2016-06-07 06:46:45 +00:00
|
|
|
type: 'bpmn:UserTask'
|
|
|
|
};
|
|
|
|
var newElement = bpmnReplace.replaceElement(task, newElementData);
|
2015-01-19 11:13:39 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// when
|
|
|
|
commandStack.undo();
|
|
|
|
commandStack.redo();
|
2015-01-19 11:13:39 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// then
|
|
|
|
var incoming = newElement.incoming[0],
|
|
|
|
outgoing = newElement.outgoing[0],
|
|
|
|
source = incoming.source,
|
|
|
|
target = outgoing.target;
|
2015-01-19 11:13:39 +00:00
|
|
|
|
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
expect(incoming).to.exist;
|
|
|
|
expect(outgoing).to.exist;
|
|
|
|
expect(source).to.eql(elementRegistry.get('StartEvent_1'));
|
|
|
|
expect(target).to.eql(elementRegistry.get('ExclusiveGateway_1'));
|
|
|
|
})
|
|
|
|
);
|
2015-01-19 11:13:39 +00:00
|
|
|
|
|
|
|
|
2015-07-03 08:48:32 +00:00
|
|
|
it('should remove invalid incoming connections',
|
|
|
|
inject(function(elementRegistry, bpmnReplace, commandStack) {
|
2015-01-19 11:13:39 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// given
|
|
|
|
var startEvent = elementRegistry.get('StartEvent_1');
|
2018-02-27 09:08:31 +00:00
|
|
|
var newElementData = {
|
2016-06-07 06:46:45 +00:00
|
|
|
type: 'bpmn:EndEvent'
|
|
|
|
};
|
|
|
|
var newElement = bpmnReplace.replaceElement(startEvent, newElementData);
|
2015-01-19 11:13:39 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// when
|
|
|
|
commandStack.undo();
|
|
|
|
commandStack.redo();
|
2015-01-19 11:13:39 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// then
|
|
|
|
var incoming = newElement.incoming[0],
|
|
|
|
outgoing = newElement.outgoing[0];
|
2015-01-19 11:13:39 +00:00
|
|
|
|
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
expect(incoming).not.to.exist;
|
|
|
|
expect(outgoing).not.to.exist;
|
|
|
|
})
|
|
|
|
);
|
2015-01-19 11:13:39 +00:00
|
|
|
|
|
|
|
|
2015-07-03 08:48:32 +00:00
|
|
|
it('should remove invalid outgoing connections',
|
|
|
|
inject(function(elementRegistry, bpmnReplace, commandStack) {
|
2015-01-19 11:13:39 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// given
|
|
|
|
var endEvent = elementRegistry.get('EndEvent_1');
|
2018-02-27 09:08:31 +00:00
|
|
|
var newElementData = {
|
2016-06-07 06:46:45 +00:00
|
|
|
type: 'bpmn:StartEvent'
|
|
|
|
};
|
|
|
|
var newElement = bpmnReplace.replaceElement(endEvent, newElementData);
|
2015-01-19 11:13:39 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// when
|
|
|
|
commandStack.undo();
|
|
|
|
commandStack.redo();
|
2015-01-19 11:13:39 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// then
|
|
|
|
var incoming = newElement.incoming[0],
|
|
|
|
outgoing = newElement.outgoing[0];
|
2015-01-19 11:13:39 +00:00
|
|
|
|
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
expect(incoming).not.to.exist;
|
|
|
|
expect(outgoing).not.to.exist;
|
|
|
|
})
|
|
|
|
);
|
2015-03-11 15:17:19 +00:00
|
|
|
|
2015-01-19 11:13:39 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
|
2015-08-11 09:58:30 +00:00
|
|
|
|
2015-07-13 13:18:18 +00:00
|
|
|
describe('children handling', function() {
|
|
|
|
|
2015-08-11 09:58:30 +00:00
|
|
|
var diagramXML = require('../../../fixtures/bpmn/features/replace/01_replace.bpmn');
|
|
|
|
|
2019-08-07 13:17:28 +00:00
|
|
|
beforeEach(bootstrapModeler(diagramXML, {
|
|
|
|
modules: testModules,
|
|
|
|
moddleExtensions: {
|
|
|
|
camunda: camundaPackage
|
|
|
|
}
|
|
|
|
}));
|
2015-08-11 09:58:30 +00:00
|
|
|
|
|
|
|
|
2015-07-13 13:18:18 +00:00
|
|
|
it('should update bpmn containment properly', inject(function(elementRegistry, modeling, bpmnReplace) {
|
|
|
|
|
|
|
|
// given
|
|
|
|
var subProcessShape = elementRegistry.get('SubProcess_1');
|
|
|
|
var startEventShape = elementRegistry.get('StartEvent_2');
|
|
|
|
var taskShape = elementRegistry.get('Task_2');
|
|
|
|
var sequenceFlowConnection = elementRegistry.get('SequenceFlow_4');
|
|
|
|
|
2018-02-27 09:08:31 +00:00
|
|
|
var transactionShapeData = {
|
2015-07-13 13:18:18 +00:00
|
|
|
type: 'bpmn:Transaction'
|
|
|
|
};
|
|
|
|
|
|
|
|
// when
|
|
|
|
var transactionShape = bpmnReplace.replaceElement(subProcessShape, transactionShapeData);
|
|
|
|
|
|
|
|
// then
|
|
|
|
var subProcess = subProcessShape.businessObject,
|
|
|
|
transaction = transactionShape.businessObject;
|
|
|
|
|
|
|
|
var transactionChildren = transaction.get('flowElements');
|
|
|
|
var subProcessChildren = subProcess.get('flowElements');
|
|
|
|
|
2015-07-15 15:22:19 +00:00
|
|
|
expect(transactionChildren).to.include(startEventShape.businessObject);
|
|
|
|
expect(transactionChildren).to.include(taskShape.businessObject);
|
|
|
|
expect(transactionChildren).to.include(sequenceFlowConnection.businessObject);
|
2015-07-13 13:18:18 +00:00
|
|
|
|
2015-07-15 15:22:19 +00:00
|
|
|
expect(subProcessChildren).not.to.include(startEventShape.businessObject);
|
|
|
|
expect(subProcessChildren).not.to.include(taskShape.businessObject);
|
|
|
|
expect(subProcessChildren).not.to.include(sequenceFlowConnection.businessObject);
|
2015-07-13 13:18:18 +00:00
|
|
|
}));
|
|
|
|
|
|
|
|
});
|
|
|
|
|
2015-08-11 09:58:30 +00:00
|
|
|
|
2015-07-03 08:48:32 +00:00
|
|
|
describe('sub processes', function() {
|
|
|
|
|
2015-08-11 09:58:30 +00:00
|
|
|
var diagramXML = require('../../../fixtures/bpmn/features/replace/01_replace.bpmn');
|
|
|
|
|
2019-08-07 13:17:28 +00:00
|
|
|
beforeEach(bootstrapModeler(diagramXML, {
|
|
|
|
modules: testModules,
|
|
|
|
moddleExtensions: {
|
|
|
|
camunda: camundaPackage
|
|
|
|
}
|
|
|
|
}));
|
2015-08-11 09:58:30 +00:00
|
|
|
|
|
|
|
|
2015-07-03 08:48:32 +00:00
|
|
|
it('should allow morphing expanded into expanded ad hoc',
|
|
|
|
inject(function(bpmnReplace, elementRegistry) {
|
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// given
|
|
|
|
var element = elementRegistry.get('SubProcess_1');
|
|
|
|
var newElementData = {
|
|
|
|
type: 'bpmn:AdHocSubProcess'
|
|
|
|
};
|
2015-07-03 08:48:32 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// when
|
|
|
|
var newElement = bpmnReplace.replaceElement(element, newElementData);
|
2015-07-03 08:48:32 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// then
|
|
|
|
expect(is(newElement, 'bpmn:AdHocSubProcess')).to.be.true;
|
|
|
|
expect(isExpanded(newElement)).to.be.true;
|
|
|
|
})
|
|
|
|
);
|
2015-07-03 08:48:32 +00:00
|
|
|
|
|
|
|
|
|
|
|
it('should allow morphing expanded ad hoc into expanded',
|
|
|
|
inject(function(bpmnReplace, elementRegistry) {
|
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// given
|
|
|
|
var element = elementRegistry.get('AdHocSubProcessExpanded');
|
|
|
|
var newElementData = {
|
|
|
|
type: 'bpmn:SubProcess'
|
|
|
|
};
|
2015-07-03 08:48:32 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// when
|
|
|
|
var newElement = bpmnReplace.replaceElement(element, newElementData);
|
2015-07-03 08:48:32 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// then
|
|
|
|
expect(is(newElement, 'bpmn:SubProcess')).to.be.true;
|
|
|
|
expect(is(newElement, 'bpmn:AdHocSubProcess')).to.be.false;
|
|
|
|
expect(isExpanded(newElement)).to.be.true;
|
|
|
|
})
|
|
|
|
);
|
2015-07-03 08:48:32 +00:00
|
|
|
|
|
|
|
|
|
|
|
it('should allow morphing collapsed into collapsed ad hoc',
|
|
|
|
inject(function(bpmnReplace, elementRegistry) {
|
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// given
|
|
|
|
var element = elementRegistry.get('SubProcessCollapsed');
|
|
|
|
var newElementData = {
|
|
|
|
type: 'bpmn:AdHocSubProcess'
|
|
|
|
};
|
2015-07-03 08:48:32 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// when
|
|
|
|
var newElement = bpmnReplace.replaceElement(element, newElementData);
|
2015-07-03 08:48:32 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// then
|
|
|
|
expect(is(newElement, 'bpmn:AdHocSubProcess')).to.be.true;
|
|
|
|
expect(isExpanded(newElement)).not.to.be.true;
|
|
|
|
})
|
|
|
|
);
|
2015-07-03 08:48:32 +00:00
|
|
|
|
|
|
|
|
|
|
|
it('should allow morphing collapsed ad hoc into collapsed',
|
|
|
|
inject(function(bpmnReplace, elementRegistry) {
|
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// given
|
|
|
|
var element = elementRegistry.get('AdHocSubProcessCollapsed');
|
|
|
|
var newElementData = {
|
|
|
|
type: 'bpmn:SubProcess'
|
|
|
|
};
|
2015-07-03 08:48:32 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// when
|
|
|
|
var newElement = bpmnReplace.replaceElement(element, newElementData);
|
2015-07-03 08:48:32 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// then
|
|
|
|
expect(is(newElement, 'bpmn:SubProcess')).to.be.true;
|
|
|
|
expect(is(newElement, 'bpmn:AdHocSubProcess')).to.be.false;
|
|
|
|
expect(isExpanded(newElement)).not.to.be.true;
|
|
|
|
})
|
|
|
|
);
|
2015-07-03 08:48:32 +00:00
|
|
|
|
2017-02-03 13:58:41 +00:00
|
|
|
|
|
|
|
it('should keep size when morphing ad hoc',
|
|
|
|
inject(function(bpmnReplace, elementRegistry, modeling) {
|
|
|
|
|
|
|
|
// given
|
|
|
|
var element = elementRegistry.get('SubProcess_1');
|
|
|
|
var newElementData = {
|
|
|
|
type: 'bpmn:AdHocSubProcess'
|
|
|
|
};
|
|
|
|
|
|
|
|
var width = element.width,
|
|
|
|
height = element.height;
|
|
|
|
|
|
|
|
modeling.resizeShape(element, {
|
|
|
|
x: element.x,
|
|
|
|
y: element.y,
|
|
|
|
width: width + 20,
|
|
|
|
height: height + 20
|
|
|
|
});
|
|
|
|
|
|
|
|
// when
|
|
|
|
var newElement = bpmnReplace.replaceElement(element, newElementData);
|
|
|
|
|
|
|
|
// then
|
|
|
|
expect(is(newElement, 'bpmn:AdHocSubProcess')).to.be.true;
|
|
|
|
expect(isExpanded(newElement)).to.be.true;
|
|
|
|
|
|
|
|
expect(newElement.width).to.equal(width + 20);
|
|
|
|
expect(newElement.height).to.equal(height + 20);
|
|
|
|
})
|
|
|
|
);
|
|
|
|
|
2018-02-13 15:58:46 +00:00
|
|
|
|
|
|
|
it('should remove children of collapsed sub process not morphing into expanded',
|
|
|
|
inject(function(bpmnReplace, elementRegistry, modeling) {
|
|
|
|
|
|
|
|
// given
|
|
|
|
var element = elementRegistry.get('SubProcess_1');
|
|
|
|
var newElementData = {
|
|
|
|
type: 'bpmn:CallActivity'
|
|
|
|
};
|
|
|
|
|
|
|
|
modeling.toggleCollapse(element);
|
|
|
|
|
|
|
|
// when
|
|
|
|
var newElement = bpmnReplace.replaceElement(element, newElementData);
|
|
|
|
|
|
|
|
// then
|
|
|
|
expect(is(newElement, 'bpmn:CallActivity')).to.be.true;
|
|
|
|
}));
|
|
|
|
|
2020-07-29 15:18:38 +00:00
|
|
|
it('should drop event type from start event after moving it into sub process',
|
|
|
|
inject(function(bpmnReplace, elementRegistry, modeling) {
|
|
|
|
|
|
|
|
// given
|
|
|
|
var startEvent = elementRegistry.get('StartEvent_4'),
|
|
|
|
subProcess = elementRegistry.get('SubProcess_2');
|
|
|
|
|
|
|
|
// when
|
|
|
|
modeling.moveElements([startEvent], { x: 100, y: 0 }, subProcess);
|
|
|
|
|
|
|
|
var startEventAfter = elementRegistry.filter(function(element) {
|
|
|
|
return is(element, 'bpmn:StartEvent') && element.parent === subProcess;
|
|
|
|
})[0];
|
|
|
|
|
|
|
|
// then
|
|
|
|
expect(startEventAfter.businessObject.eventDefinitions).to.be.undefined;
|
|
|
|
})
|
|
|
|
);
|
|
|
|
|
|
|
|
it('should not drop event type from start event after moving it into event sub process',
|
|
|
|
inject(function(bpmnReplace, elementRegistry, modeling) {
|
|
|
|
|
|
|
|
// given
|
|
|
|
var startEvent = elementRegistry.get('StartEvent_5'),
|
|
|
|
subProcess = elementRegistry.get('EventSubProcess_2');
|
|
|
|
|
|
|
|
// when
|
|
|
|
modeling.moveElements([startEvent], { x: -100, y: 0 }, subProcess);
|
|
|
|
|
|
|
|
var startEventAfter = elementRegistry.filter(function(element) {
|
|
|
|
return is(element, 'bpmn:StartEvent') && element.parent === subProcess;
|
|
|
|
})[0];
|
|
|
|
|
|
|
|
// then
|
|
|
|
expect(startEventAfter.businessObject.eventDefinitions[0].$type).to.equal('bpmn:MessageEventDefinition');
|
|
|
|
})
|
|
|
|
);
|
|
|
|
|
2015-07-03 08:48:32 +00:00
|
|
|
});
|
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
|
2016-06-16 11:57:32 +00:00
|
|
|
describe('morph task with boundaryEvent', function() {
|
2016-04-13 15:13:10 +00:00
|
|
|
|
|
|
|
var diagramXML = require('../../../fixtures/bpmn/features/replace/01_replace.bpmn');
|
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
beforeEach(bootstrapModeler(diagramXML, {
|
2019-08-07 13:17:28 +00:00
|
|
|
modules: testModules,
|
|
|
|
moddleExtensions: {
|
|
|
|
camunda: camundaPackage
|
|
|
|
}
|
2016-06-07 06:46:45 +00:00
|
|
|
}));
|
2016-04-13 15:13:10 +00:00
|
|
|
|
|
|
|
|
2016-06-16 11:57:32 +00:00
|
|
|
it('to expanded sub process', inject(function(bpmnReplace, elementRegistry) {
|
2016-04-13 15:13:10 +00:00
|
|
|
|
|
|
|
// given
|
|
|
|
var element = elementRegistry.get('Task_1');
|
|
|
|
var newElementData = {
|
|
|
|
type: 'bpmn:SubProcess',
|
|
|
|
isExpanded: true
|
|
|
|
};
|
|
|
|
|
|
|
|
// when
|
|
|
|
var newElement = bpmnReplace.replaceElement(element, newElementData);
|
|
|
|
|
|
|
|
// then
|
|
|
|
expect(is(newElement, 'bpmn:SubProcess')).to.be.true;
|
|
|
|
expect(isExpanded(newElement)).to.be.true;
|
|
|
|
|
2016-06-16 11:57:32 +00:00
|
|
|
// and keep boundaryEvent
|
|
|
|
expect(newElement.attachers.length).to.be.equal(2);
|
2016-04-13 15:13:10 +00:00
|
|
|
}));
|
|
|
|
|
|
|
|
|
2016-06-16 11:57:32 +00:00
|
|
|
it('to collapsed sub process', inject(function(bpmnReplace, elementRegistry) {
|
2016-04-13 15:13:10 +00:00
|
|
|
|
|
|
|
// given
|
|
|
|
var element = elementRegistry.get('Task_1');
|
|
|
|
var newElementData = {
|
|
|
|
type: 'bpmn:SubProcess',
|
2016-06-16 11:57:32 +00:00
|
|
|
isExpanded: false
|
2016-04-13 15:13:10 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// when
|
|
|
|
var newElement = bpmnReplace.replaceElement(element, newElementData);
|
|
|
|
|
|
|
|
// then
|
|
|
|
expect(is(newElement, 'bpmn:SubProcess')).to.be.true;
|
2016-06-16 11:57:32 +00:00
|
|
|
expect(isExpanded(newElement)).to.be.false;
|
|
|
|
|
|
|
|
// and keep boundaryEvent
|
|
|
|
expect(newElement.attachers.length).to.eql(2);
|
2016-04-13 15:13:10 +00:00
|
|
|
}));
|
|
|
|
|
|
|
|
});
|
2015-08-11 09:58:30 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
|
2016-01-20 10:31:01 +00:00
|
|
|
describe('compensation activity', function() {
|
|
|
|
|
|
|
|
var diagramXML = require('./BpmnReplace.compensation.bpmn');
|
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
beforeEach(bootstrapModeler(diagramXML, {
|
2019-08-07 13:17:28 +00:00
|
|
|
modules: testModules,
|
|
|
|
moddleExtensions: {
|
|
|
|
camunda: camundaPackage
|
|
|
|
}
|
2016-06-07 06:46:45 +00:00
|
|
|
}));
|
2016-01-20 10:31:01 +00:00
|
|
|
|
|
|
|
|
|
|
|
it('should keep isForCompensation attr', inject(function(elementRegistry, bpmnReplace) {
|
|
|
|
|
|
|
|
// given
|
|
|
|
var task = elementRegistry.get('Task_1');
|
2018-02-27 09:08:31 +00:00
|
|
|
var newElementData = {
|
2016-01-20 10:31:01 +00:00
|
|
|
type: 'bpmn:ServiceTask'
|
|
|
|
};
|
|
|
|
|
|
|
|
// when
|
|
|
|
var newElement = bpmnReplace.replaceElement(task, newElementData);
|
|
|
|
|
|
|
|
// then
|
|
|
|
expect(newElement.businessObject.isForCompensation).to.be.true;
|
|
|
|
}));
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
2015-08-11 09:58:30 +00:00
|
|
|
describe('event sub processes', function() {
|
|
|
|
|
|
|
|
var diagramXML = require('./BpmnReplace.eventSubProcesses.bpmn');
|
|
|
|
|
2019-08-07 13:17:28 +00:00
|
|
|
beforeEach(bootstrapModeler(diagramXML, {
|
|
|
|
modules: testModules,
|
|
|
|
moddleExtensions: {
|
|
|
|
camunda: camundaPackage
|
|
|
|
}
|
|
|
|
}));
|
2015-08-11 09:58:30 +00:00
|
|
|
|
|
|
|
|
|
|
|
it('should remove connections',
|
|
|
|
inject(function(elementRegistry, bpmnReplace) {
|
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// given
|
|
|
|
var transaction = elementRegistry.get('SubProcess_1');
|
2018-02-27 09:08:31 +00:00
|
|
|
var newElementData = {
|
2016-06-07 06:46:45 +00:00
|
|
|
type: 'bpmn:SubProcess',
|
|
|
|
triggeredByEvent: true
|
|
|
|
};
|
2015-08-11 09:58:30 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// when
|
|
|
|
var newElement = bpmnReplace.replaceElement(transaction, newElementData);
|
2015-08-11 09:58:30 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// then
|
|
|
|
var incoming = newElement.incoming[0],
|
|
|
|
outgoing = newElement.outgoing[0];
|
2015-08-11 09:58:30 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
expect(incoming).not.to.exist;
|
|
|
|
expect(outgoing).not.to.exist;
|
|
|
|
})
|
|
|
|
);
|
2015-08-11 09:58:30 +00:00
|
|
|
|
|
|
|
|
|
|
|
it('should replace non-interrupting start event after moving it outside event sub process',
|
|
|
|
inject(function(bpmnReplace, elementRegistry, modeling) {
|
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// given
|
|
|
|
var startEvent = elementRegistry.get('StartEvent_2'),
|
|
|
|
root = elementRegistry.get('Process_1');
|
2015-08-11 09:58:30 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// when
|
|
|
|
modeling.moveElements([startEvent], { x: 0, y: 200 }, root);
|
2015-08-11 09:58:30 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
var startEventAfter = elementRegistry.filter(function(element) {
|
|
|
|
return is(element, 'bpmn:StartEvent') && element.parent === root;
|
|
|
|
})[0];
|
2015-08-11 09:58:30 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// then
|
|
|
|
expect(isInterrupting(startEventAfter)).to.be.true;
|
|
|
|
expect(startEventAfter.parent).to.equal(root);
|
2015-08-11 09:58:30 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
})
|
|
|
|
);
|
2015-08-11 09:58:30 +00:00
|
|
|
|
|
|
|
|
|
|
|
it('should replace non-interrupting start event after moving it to a regular sub process',
|
|
|
|
inject(function(bpmnReplace, elementRegistry, modeling) {
|
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// given
|
|
|
|
var startEvent = elementRegistry.get('StartEvent_2'),
|
|
|
|
subProcess = elementRegistry.get('SubProcess_1');
|
2015-08-11 09:58:30 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// when
|
|
|
|
modeling.moveElements([startEvent], { x: 260, y: 60 }, subProcess);
|
2015-08-11 09:58:30 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
var startEventAfter = elementRegistry.filter(function(element) {
|
|
|
|
return is(element, 'bpmn:StartEvent') && element.parent === subProcess;
|
|
|
|
})[0];
|
2015-08-11 09:58:30 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// then
|
|
|
|
expect(isInterrupting(startEventAfter)).to.be.true;
|
|
|
|
expect(startEventAfter.parent).to.equal(subProcess);
|
2015-08-11 09:58:30 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
})
|
|
|
|
);
|
2015-08-11 09:58:30 +00:00
|
|
|
|
|
|
|
|
|
|
|
it('should not replace non-interrupting start event after moving it to another event sub process',
|
|
|
|
inject(function(bpmnReplace, elementRegistry, modeling) {
|
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// given
|
|
|
|
var startEvent = elementRegistry.get('StartEvent_2'),
|
|
|
|
subProcess = elementRegistry.get('SubProcess_1');
|
2015-08-11 09:58:30 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
var eventSubProcess = bpmnReplace.replaceElement(subProcess, {
|
|
|
|
type: 'bpmn:SubProcess',
|
|
|
|
triggeredByEvent: true,
|
|
|
|
isExpanded: true
|
|
|
|
});
|
2015-08-11 09:58:30 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// when
|
|
|
|
modeling.moveElements([startEvent], { x: 260, y: 60 }, eventSubProcess);
|
2015-08-11 09:58:30 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
var startEventAfter = elementRegistry.filter(function(element) {
|
|
|
|
return is(element, 'bpmn:StartEvent') && element.parent === eventSubProcess && element.type !== 'label';
|
|
|
|
})[1];
|
2015-08-11 09:58:30 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// then
|
|
|
|
expect(startEvent.id).to.equal(startEventAfter.id);
|
|
|
|
expect(startEventAfter.parent).to.equal(eventSubProcess);
|
2015-08-11 09:58:30 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
})
|
|
|
|
);
|
2015-08-11 09:58:30 +00:00
|
|
|
|
|
|
|
|
|
|
|
it('should not replace interrupting start event after moving it outside event sub process',
|
|
|
|
inject(function(bpmnReplace, elementRegistry, modeling) {
|
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// given
|
|
|
|
var startEvent = elementRegistry.get('StartEvent_2'),
|
|
|
|
root = elementRegistry.get('Process_1');
|
2015-08-11 09:58:30 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
var interruptingStartEvent = bpmnReplace.replaceElement(startEvent, { type: 'bpmn:StartEvent' });
|
2015-08-11 09:58:30 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// when
|
|
|
|
modeling.moveElements([interruptingStartEvent], { x: 0, y: 200 }, root);
|
2015-08-11 09:58:30 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
var startEventAfter = elementRegistry.filter(function(element) {
|
2016-06-07 14:45:47 +00:00
|
|
|
return is(element, 'bpmn:StartEvent')
|
|
|
|
&& element.type !== 'label'
|
|
|
|
&& element.parent === root;
|
2016-06-07 06:46:45 +00:00
|
|
|
})[0];
|
2015-08-11 09:58:30 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// then
|
|
|
|
expect(startEventAfter).to.equal(interruptingStartEvent);
|
|
|
|
expect(startEventAfter.parent).to.equal(root);
|
2015-08-11 09:58:30 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
})
|
|
|
|
);
|
2015-08-11 09:58:30 +00:00
|
|
|
|
|
|
|
|
|
|
|
it('should replace non-interrupting start event when replacing parent event sub process',
|
2016-06-07 06:46:45 +00:00
|
|
|
inject(function(elementRegistry, bpmnReplace) {
|
2015-08-11 09:58:30 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// given
|
|
|
|
var eventSubProcess = elementRegistry.get('SubProcess_2');
|
2015-08-11 09:58:30 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// when
|
|
|
|
var subProcess = bpmnReplace.replaceElement(eventSubProcess, { type: 'bpmn:SubProcess' });
|
2015-08-11 09:58:30 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// then
|
|
|
|
var replacedStartEvent = elementRegistry.filter(function(element) {
|
|
|
|
return (element.parent === subProcess && element.type !== 'label');
|
|
|
|
})[0];
|
2015-08-11 09:58:30 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
expect(isInterrupting(replacedStartEvent)).to.be.true;
|
|
|
|
expect(replacedStartEvent.parent).to.equal(subProcess);
|
|
|
|
})
|
|
|
|
);
|
2015-08-11 09:58:30 +00:00
|
|
|
|
|
|
|
|
|
|
|
it('should not replace non-interrupting start event when moving parent event sub process',
|
2016-06-07 06:46:45 +00:00
|
|
|
inject(function(elementRegistry, bpmnReplace, modeling) {
|
2015-08-11 09:58:30 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// given
|
|
|
|
var eventSubProcess = elementRegistry.get('SubProcess_2'),
|
|
|
|
startEvent = elementRegistry.get('StartEvent_2');
|
2015-08-11 09:58:30 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// when
|
|
|
|
modeling.moveElements([eventSubProcess], { x: 20, y: 30 });
|
2015-08-11 09:58:30 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// start event after moving parent
|
|
|
|
var startEventAfter = elementRegistry.filter(function(element) {
|
2016-11-09 10:45:12 +00:00
|
|
|
return (element.parent === eventSubProcess && element.type !== 'label');
|
|
|
|
})[0];
|
|
|
|
|
|
|
|
// then
|
|
|
|
expect(startEventAfter).to.equal(startEvent);
|
|
|
|
expect(startEventAfter.parent).to.eql(eventSubProcess);
|
|
|
|
})
|
|
|
|
);
|
|
|
|
|
|
|
|
it('should replace error start event after moving it outside event sub process',
|
|
|
|
inject(function(elementRegistry, bpmnReplace, modeling) {
|
|
|
|
|
|
|
|
// given
|
|
|
|
var startEvent = elementRegistry.get('StartEvent_3'),
|
|
|
|
root = elementRegistry.get('Process_1');
|
|
|
|
|
|
|
|
// when
|
|
|
|
modeling.moveElements([startEvent], { x: 0, y: 200 }, root);
|
|
|
|
|
|
|
|
var startEventAfter = elementRegistry.filter(function(element) {
|
|
|
|
return is(element, 'bpmn:StartEvent') && element.parent === root;
|
|
|
|
})[0];
|
|
|
|
|
|
|
|
// then
|
|
|
|
expect(hasErrorEventDefinition(startEventAfter)).to.be.false;
|
|
|
|
expect(startEventAfter.parent).to.equal(root);
|
|
|
|
})
|
|
|
|
);
|
|
|
|
|
|
|
|
it('should replace error start event after moving it to a regular sub process',
|
|
|
|
inject(function(bpmnReplace, elementRegistry, modeling) {
|
|
|
|
|
|
|
|
// given
|
|
|
|
var startEvent = elementRegistry.get('StartEvent_3'),
|
|
|
|
subProcess = elementRegistry.get('SubProcess_1');
|
|
|
|
|
|
|
|
// when
|
|
|
|
modeling.moveElements([startEvent], { x: 260, y: 60 }, subProcess);
|
|
|
|
|
|
|
|
var startEventAfter = elementRegistry.filter(function(element) {
|
|
|
|
return is(element, 'bpmn:StartEvent') && element.parent === subProcess;
|
|
|
|
})[0];
|
|
|
|
|
|
|
|
// then
|
|
|
|
expect(hasErrorEventDefinition(startEventAfter)).to.be.false;
|
|
|
|
expect(startEventAfter.parent).to.equal(subProcess);
|
|
|
|
|
|
|
|
})
|
|
|
|
);
|
|
|
|
|
|
|
|
it('should not replace error start event after moving it to another event sub process',
|
|
|
|
inject(function(bpmnReplace, elementRegistry, modeling) {
|
|
|
|
|
|
|
|
// given
|
|
|
|
var startEvent = elementRegistry.get('StartEvent_3'),
|
|
|
|
subProcess = elementRegistry.get('SubProcess_1');
|
|
|
|
|
|
|
|
var eventSubProcess = bpmnReplace.replaceElement(subProcess, {
|
|
|
|
type: 'bpmn:SubProcess',
|
|
|
|
triggeredByEvent: true,
|
|
|
|
isExpanded: true
|
|
|
|
});
|
|
|
|
|
|
|
|
// when
|
|
|
|
modeling.moveElements([startEvent], { x: 260, y: 60 }, eventSubProcess);
|
|
|
|
|
|
|
|
var startEventAfter = elementRegistry.filter(function(element) {
|
|
|
|
return is(element, 'bpmn:StartEvent') && element.parent === eventSubProcess && element.type !== 'label';
|
|
|
|
})[1];
|
|
|
|
|
|
|
|
// then
|
|
|
|
expect(hasErrorEventDefinition(startEventAfter)).to.be.true;
|
|
|
|
expect(startEventAfter.parent).to.equal(eventSubProcess);
|
|
|
|
|
|
|
|
})
|
|
|
|
);
|
|
|
|
|
|
|
|
it('should replace error start event when replacing parent event sub process',
|
|
|
|
inject(function(elementRegistry, bpmnReplace) {
|
|
|
|
|
|
|
|
// given
|
|
|
|
var eventSubProcess = elementRegistry.get('SubProcess_3');
|
|
|
|
|
|
|
|
// when
|
|
|
|
var subProcess = bpmnReplace.replaceElement(eventSubProcess, { type: 'bpmn:SubProcess' });
|
|
|
|
|
|
|
|
// then
|
|
|
|
var replacedStartEvent = elementRegistry.filter(function(element) {
|
|
|
|
return (element.parent === subProcess && element.type !== 'label');
|
|
|
|
})[0];
|
|
|
|
|
|
|
|
expect(hasErrorEventDefinition(replacedStartEvent)).to.be.false;
|
|
|
|
expect(replacedStartEvent.parent).to.equal(subProcess);
|
|
|
|
})
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
it('should not replace error start event when moving parent event sub process',
|
|
|
|
inject(function(elementRegistry, bpmnReplace, modeling) {
|
|
|
|
|
|
|
|
// given
|
|
|
|
var eventSubProcess = elementRegistry.get('SubProcess_3'),
|
|
|
|
startEvent = elementRegistry.get('StartEvent_3');
|
|
|
|
|
|
|
|
// when
|
|
|
|
modeling.moveElements([eventSubProcess], { x: 20, y: 30 });
|
|
|
|
|
|
|
|
// start event after moving parent
|
|
|
|
var startEventAfter = elementRegistry.filter(function(element) {
|
2016-06-07 06:46:45 +00:00
|
|
|
return (element.parent === eventSubProcess && element.type !== 'label');
|
|
|
|
})[0];
|
2015-08-11 09:58:30 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
// then
|
|
|
|
expect(startEventAfter).to.equal(startEvent);
|
|
|
|
expect(startEventAfter.parent).to.eql(eventSubProcess);
|
|
|
|
})
|
|
|
|
);
|
2015-08-11 09:58:30 +00:00
|
|
|
|
|
|
|
});
|
|
|
|
|
2015-09-17 07:05:09 +00:00
|
|
|
|
2015-11-19 12:28:39 +00:00
|
|
|
describe('events', function() {
|
|
|
|
|
|
|
|
var diagramXML = require('../../../fixtures/bpmn/basic.bpmn');
|
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
beforeEach(bootstrapModeler(diagramXML, {
|
2019-08-07 13:17:28 +00:00
|
|
|
modules: testModules,
|
|
|
|
moddleExtensions: {
|
|
|
|
camunda: camundaPackage
|
|
|
|
}
|
2016-06-07 06:46:45 +00:00
|
|
|
}));
|
|
|
|
|
2015-11-19 12:28:39 +00:00
|
|
|
|
2018-01-03 13:19:01 +00:00
|
|
|
it('should properly set parent of event definitions', inject(
|
2019-05-23 06:38:54 +00:00
|
|
|
function(elementRegistry, bpmnReplace) {
|
2015-11-19 12:28:39 +00:00
|
|
|
|
2019-05-23 06:38:54 +00:00
|
|
|
// given
|
2018-01-03 13:19:01 +00:00
|
|
|
var startEvent = elementRegistry.get('StartEvent_1');
|
2015-11-19 12:28:39 +00:00
|
|
|
|
2018-01-03 13:19:01 +00:00
|
|
|
var messageEvent = bpmnReplace.replaceElement(startEvent, {
|
|
|
|
type: 'bpmn:StartEvent',
|
|
|
|
eventDefinitionType: 'bpmn:MessageEventDefinition'
|
|
|
|
});
|
2015-11-19 12:28:39 +00:00
|
|
|
|
2018-01-03 13:19:01 +00:00
|
|
|
var parent = messageEvent.businessObject.eventDefinitions[0].$parent;
|
2015-11-19 12:28:39 +00:00
|
|
|
|
2018-01-03 13:19:01 +00:00
|
|
|
expect(parent).to.exist;
|
|
|
|
expect(parent).to.equal(messageEvent.businessObject);
|
|
|
|
})
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
it('should add condition with ConditionalEventDefinition', inject(
|
2019-05-23 06:38:54 +00:00
|
|
|
function(elementRegistry, bpmnReplace) {
|
2018-01-03 13:19:01 +00:00
|
|
|
|
2019-05-23 06:38:54 +00:00
|
|
|
// given
|
2018-01-03 13:19:01 +00:00
|
|
|
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;
|
|
|
|
})
|
|
|
|
);
|
2016-06-07 06:46:45 +00:00
|
|
|
|
2019-05-23 06:38:18 +00:00
|
|
|
|
|
|
|
it('should set host for boundary event if provided',
|
|
|
|
inject(function(elementRegistry, bpmnReplace) {
|
|
|
|
|
|
|
|
// given
|
|
|
|
var startEvent = elementRegistry.get('StartEvent_1'),
|
|
|
|
task = elementRegistry.get('Task_1');
|
|
|
|
|
|
|
|
// when
|
|
|
|
var boundaryEvent = bpmnReplace.replaceElement(startEvent, {
|
|
|
|
type: 'bpmn:BoundaryEvent',
|
|
|
|
host: task
|
|
|
|
});
|
|
|
|
|
|
|
|
// then
|
|
|
|
expect(boundaryEvent).to.exist;
|
|
|
|
expect(boundaryEvent).to.have.property('host', task);
|
|
|
|
expect(task).to.have.property('attachers');
|
|
|
|
expect(task.attachers).to.deep.eql([ boundaryEvent ]);
|
|
|
|
})
|
|
|
|
);
|
|
|
|
|
2015-11-19 12:28:39 +00:00
|
|
|
});
|
|
|
|
|
2017-01-11 14:22:32 +00:00
|
|
|
|
|
|
|
describe('properties', function() {
|
2019-08-07 13:17:28 +00:00
|
|
|
var copyPropertiesXML = require('../../../fixtures/bpmn/features/replace/copy-properties.bpmn');
|
2017-01-11 14:22:32 +00:00
|
|
|
|
2019-08-07 13:17:28 +00:00
|
|
|
beforeEach(bootstrapModeler(copyPropertiesXML, {
|
2017-01-11 14:22:32 +00:00
|
|
|
modules: testModules,
|
|
|
|
moddleExtensions: {
|
|
|
|
camunda: camundaPackage
|
|
|
|
}
|
|
|
|
}));
|
|
|
|
|
2019-08-07 13:17:28 +00:00
|
|
|
it('should copy properties', inject(function(bpmnReplace, elementRegistry) {
|
|
|
|
|
2017-01-11 14:22:32 +00:00
|
|
|
// given
|
|
|
|
var task = elementRegistry.get('Task_1');
|
2019-08-07 13:17:28 +00:00
|
|
|
|
2018-02-27 09:08:31 +00:00
|
|
|
var newElementData = {
|
2017-01-11 14:22:32 +00:00
|
|
|
type: 'bpmn:ServiceTask'
|
|
|
|
};
|
|
|
|
|
|
|
|
// when
|
|
|
|
var newElement = bpmnReplace.replaceElement(task, newElementData);
|
|
|
|
|
|
|
|
// then
|
|
|
|
var businessObject = newElement.businessObject;
|
|
|
|
|
|
|
|
expect(businessObject.asyncBefore).to.be.true;
|
|
|
|
expect(businessObject.jobPriority).to.equal('100');
|
|
|
|
|
2019-08-07 13:17:28 +00:00
|
|
|
var documentation = businessObject.documentation;
|
2017-01-11 14:22:32 +00:00
|
|
|
|
2019-08-07 13:17:28 +00:00
|
|
|
expect(documentation).to.have.length(1);
|
|
|
|
expect(documentation[0]).to.exist;
|
|
|
|
expect(documentation[0].text).to.equal('hello world');
|
2017-01-11 14:22:32 +00:00
|
|
|
|
2019-08-07 13:17:28 +00:00
|
|
|
var extensionElements = businessObject.extensionElements;
|
2017-01-11 14:22:32 +00:00
|
|
|
|
2019-08-07 13:17:28 +00:00
|
|
|
expect(extensionElements.values).to.have.length(4);
|
2017-01-11 14:22:32 +00:00
|
|
|
|
2019-08-07 13:17:28 +00:00
|
|
|
var inputOutput = extensionElements.values[0],
|
|
|
|
properties = extensionElements.values[1],
|
|
|
|
executionListener = extensionElements.values[2],
|
|
|
|
retryCycle = extensionElements.values[3];
|
2017-01-11 14:22:32 +00:00
|
|
|
|
2019-08-07 13:17:28 +00:00
|
|
|
expect(is(inputOutput, 'camunda:InputOutput')).to.be.true;
|
2017-01-11 14:22:32 +00:00
|
|
|
|
2019-08-07 13:17:28 +00:00
|
|
|
expect(is(inputOutput.inputParameters[0], 'camunda:InputParameter')).to.be.true;
|
|
|
|
expect(inputOutput.inputParameters[0].name).to.equal('Input_1');
|
|
|
|
expect(inputOutput.inputParameters[0].value).to.equal('foo');
|
2017-01-11 14:22:32 +00:00
|
|
|
|
2019-08-07 13:17:28 +00:00
|
|
|
expect(is(inputOutput.outputParameters[0], 'camunda:OutputParameter')).to.be.true;
|
|
|
|
expect(inputOutput.outputParameters[0].name).to.equal('Output_1');
|
|
|
|
expect(inputOutput.outputParameters[0].value).to.equal('bar');
|
2017-01-11 14:22:32 +00:00
|
|
|
|
2019-08-07 13:17:28 +00:00
|
|
|
expect(is(properties, 'camunda:Properties')).to.be.true;
|
2017-01-11 14:22:32 +00:00
|
|
|
|
2019-08-07 13:17:28 +00:00
|
|
|
expect(is(properties.values[0], 'camunda:Property')).to.be.true;
|
|
|
|
expect(properties.values[0].name).to.equal('bar');
|
|
|
|
expect(properties.values[0].value).to.equal('foo');
|
2017-01-11 14:22:32 +00:00
|
|
|
|
2019-08-07 13:17:28 +00:00
|
|
|
expect(is(executionListener, 'camunda:ExecutionListener')).to.be.true;
|
2017-01-11 14:22:32 +00:00
|
|
|
|
2019-08-07 13:17:28 +00:00
|
|
|
expect(executionListener.class).to.equal('reallyClassy');
|
|
|
|
expect(executionListener.event).to.equal('start');
|
2017-01-11 14:22:32 +00:00
|
|
|
|
2019-08-07 13:17:28 +00:00
|
|
|
expect(is(retryCycle, 'camunda:FailedJobRetryTimeCycle')).to.be.true;
|
2017-01-11 14:22:32 +00:00
|
|
|
|
2019-08-07 13:17:28 +00:00
|
|
|
expect(retryCycle.body).to.equal('10');
|
2017-01-11 14:22:32 +00:00
|
|
|
}));
|
|
|
|
|
|
|
|
});
|
|
|
|
|
2017-02-03 09:34:16 +00:00
|
|
|
|
|
|
|
describe('colors', function() {
|
|
|
|
|
|
|
|
var diagramXML = require('../../../fixtures/bpmn/features/replace/01_replace.bpmn');
|
|
|
|
|
|
|
|
beforeEach(bootstrapModeler(diagramXML, { modules: testModules }));
|
|
|
|
|
|
|
|
it('should maintain colors', inject(function(elementRegistry, bpmnReplace, modeling) {
|
|
|
|
|
|
|
|
// given
|
|
|
|
var task = elementRegistry.get('Task_1');
|
2018-02-27 09:08:31 +00:00
|
|
|
var newElementData = {
|
2017-02-03 09:34:16 +00:00
|
|
|
type: 'bpmn:UserTask'
|
|
|
|
},
|
2019-08-07 13:17:28 +00:00
|
|
|
fill = 'red',
|
|
|
|
stroke = 'green';
|
2017-02-03 09:34:16 +00:00
|
|
|
|
|
|
|
modeling.setColor(task, { fill: fill, stroke: stroke });
|
|
|
|
|
|
|
|
// when
|
|
|
|
var newElement = bpmnReplace.replaceElement(task, newElementData);
|
|
|
|
|
|
|
|
// then
|
|
|
|
var businessObject = newElement.businessObject;
|
|
|
|
|
|
|
|
expect(businessObject.di.fill).to.equal(fill);
|
|
|
|
expect(businessObject.di.stroke).to.equal(stroke);
|
|
|
|
}));
|
|
|
|
|
|
|
|
});
|
|
|
|
|
2015-01-19 11:13:39 +00:00
|
|
|
});
|
2018-06-27 13:11:34 +00:00
|
|
|
|
|
|
|
|
|
|
|
// helpers ////////////////////////
|
|
|
|
|
|
|
|
function skipId(key, value) {
|
|
|
|
|
|
|
|
if (key === 'id') {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
return value;
|
2019-04-12 12:36:20 +00:00
|
|
|
}
|
2019-04-29 09:09:31 +00:00
|
|
|
|
|
|
|
function getBounds(shape) {
|
|
|
|
return pick(shape, [ 'x', 'y', 'width', 'height' ]);
|
|
|
|
}
|