2015-03-12 13:03:28 +00:00
|
|
|
'use strict';
|
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
require('../../../TestHelper');
|
2015-03-12 13:03:28 +00:00
|
|
|
|
|
|
|
/* global bootstrapModeler, inject */
|
|
|
|
|
2018-01-24 10:41:21 +00:00
|
|
|
var modelingModule = require('lib/features/modeling'),
|
|
|
|
replaceModule = require('lib/features/replace'),
|
|
|
|
coreModule = require('lib/core');
|
2015-03-12 13:03:28 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2016-01-20 10:31:01 +00:00
|
|
|
describe('features/replace - rules', function() {
|
2015-03-12 13:03:28 +00:00
|
|
|
|
2015-03-31 12:17:15 +00:00
|
|
|
var diagramXML = require('../../../fixtures/bpmn/features/replace/association-gateways.bpmn');
|
2015-03-12 13:03:28 +00:00
|
|
|
|
|
|
|
var testModules = [ coreModule, modelingModule, replaceModule ];
|
|
|
|
|
|
|
|
beforeEach(bootstrapModeler(diagramXML, { modules: testModules }));
|
|
|
|
|
|
|
|
|
|
|
|
describe('should keep associations', function() {
|
|
|
|
|
|
|
|
it('replacing Gateway -> EventBasedGateway', inject(function(elementRegistry, modeling, bpmnReplace) {
|
|
|
|
|
|
|
|
// given
|
|
|
|
var element = elementRegistry.get('ExclusiveGateway_140v6lc');
|
|
|
|
|
|
|
|
var target = {
|
|
|
|
type: 'bpmn:EventBasedGateway'
|
|
|
|
};
|
|
|
|
|
|
|
|
// when
|
|
|
|
bpmnReplace.replaceElement(element, target);
|
|
|
|
|
|
|
|
// then
|
2015-12-01 07:27:45 +00:00
|
|
|
expect(elementRegistry.get('Association_0gzxvep')).to.exist;
|
|
|
|
expect(elementRegistry.get('SequenceFlow_1rme11l')).to.exist;
|
|
|
|
expect(elementRegistry.get('SequenceFlow_0608fzs')).not.to.exist;
|
2015-03-12 13:03:28 +00:00
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
|
|
it('replacing StartEvent -> EndEvent', inject(function(elementRegistry, modeling, bpmnReplace) {
|
|
|
|
|
|
|
|
// given
|
|
|
|
var element = elementRegistry.get('StartEvent_1');
|
|
|
|
var target = {
|
|
|
|
type: 'bpmn:EndEvent'
|
|
|
|
};
|
|
|
|
|
|
|
|
// when
|
|
|
|
bpmnReplace.replaceElement(element, target);
|
|
|
|
|
|
|
|
// then
|
2015-12-01 07:27:45 +00:00
|
|
|
expect(elementRegistry.get('Association_1ncsghq')).to.exist;
|
|
|
|
expect(elementRegistry.get('SequenceFlow_0fn1a6r')).not.to.exist;
|
2015-03-12 13:03:28 +00:00
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
|
|
it('replacing EndEvent -> StartEvent', inject(function(elementRegistry, modeling, bpmnReplace) {
|
|
|
|
|
|
|
|
// given
|
|
|
|
var element = elementRegistry.get('EndEvent_1');
|
|
|
|
var target = {
|
|
|
|
type: 'bpmn:StartEvent'
|
|
|
|
};
|
|
|
|
|
|
|
|
// when
|
|
|
|
bpmnReplace.replaceElement(element, target);
|
|
|
|
|
|
|
|
// then
|
2015-12-01 07:27:45 +00:00
|
|
|
expect(elementRegistry.get('Association_06tpzma')).to.exist;
|
|
|
|
expect(elementRegistry.get('SequenceFlow_19u6x8u')).not.to.exist;
|
2015-03-12 13:03:28 +00:00
|
|
|
}));
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|