Skip to content

Commit

Permalink
fix(copy-paste): do NOT copy generic properties
Browse files Browse the repository at this point in the history
  • Loading branch information
philippfromme committed Sep 25, 2019
1 parent d55e3af commit 4f824fe
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 15 deletions.
4 changes: 4 additions & 0 deletions lib/features/copy-paste/ModdleCopy.js
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,10 @@ ModdleCopy.prototype.copyProperty = function(property, parent, propertyName) {

// copy model elements
if (isObject(property) && property.$type) {
if (this._moddle.getElementDescriptor(property).isGeneric) {
return;
}

copiedProperty = self._bpmnFactory.create(property.$type);

copiedProperty.$parent = parent;
Expand Down
59 changes: 44 additions & 15 deletions test/spec/features/copy-paste/ModdleCopySpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ describe('features/copy-paste/ModdleCopy', function() {

describe('simple', function() {

it('should copy primitive properties', inject(function(moddleCopy, moddle) {
it('should copy primitive properties', inject(function(moddle, moddleCopy) {

// given
var userTask = moddle.create('bpmn:UserTask', {
Expand All @@ -56,7 +56,7 @@ describe('features/copy-paste/ModdleCopy', function() {
}));


it('should copy arrays of properties', inject(function(moddleCopy, moddle) {
it('should copy arrays of properties', inject(function(moddle, moddleCopy) {

// given
var messageEventDefinition = moddle.create('bpmn:MessageEventDefinition'),
Expand All @@ -80,7 +80,7 @@ describe('features/copy-paste/ModdleCopy', function() {


it('should NOT copy properties that are not allowed in target element', inject(
function(moddleCopy, moddle) {
function(moddle, moddleCopy) {

// given
var userTask = moddle.create('bpmn:UserTask', {
Expand All @@ -98,7 +98,7 @@ describe('features/copy-paste/ModdleCopy', function() {
));


it('should NOT copy IDs', inject(function(moddleCopy, moddle) {
it('should NOT copy IDs', inject(function(moddle, moddleCopy) {

// given
var task = moddle.create('bpmn:Task', {
Expand All @@ -115,7 +115,7 @@ describe('features/copy-paste/ModdleCopy', function() {
}));


it('should NOT copy references', inject(function(moddleCopy, moddle) {
it('should NOT copy references', inject(function(moddle, moddleCopy) {

// given
var processRef = moddle.create('bpmn:Process'),
Expand Down Expand Up @@ -169,7 +169,7 @@ describe('features/copy-paste/ModdleCopy', function() {
}));


it('should NOT copy empty extension elements', inject(function(moddleCopy, moddle) {
it('should NOT copy empty extension elements', inject(function(moddle, moddleCopy) {

// given
var connector = moddle.create('camunda:Connector'),
Expand All @@ -194,7 +194,7 @@ describe('features/copy-paste/ModdleCopy', function() {
}));


it('should only copy specified properties', inject(function(moddleCopy, moddle) {
it('should only copy specified properties', inject(function(moddle, moddleCopy) {

// given
var userTask = moddle.create('bpmn:UserTask', {
Expand All @@ -221,7 +221,7 @@ describe('features/copy-paste/ModdleCopy', function() {

describe('nested', function() {

it('should copy documentation', inject(function(moddleCopy, moddle) {
it('should copy documentation', inject(function(moddle, moddleCopy) {

// given
var documentation = [
Expand All @@ -245,7 +245,7 @@ describe('features/copy-paste/ModdleCopy', function() {
}));


it('should copy execution listener', inject(function(moddleCopy, moddle) {
it('should copy execution listener', inject(function(moddle, moddleCopy) {

// given
var script = moddle.create('camunda:Script', {
Expand Down Expand Up @@ -289,7 +289,7 @@ describe('features/copy-paste/ModdleCopy', function() {
}));


it('should copy output parameter', inject(function(moddleCopy, moddle) {
it('should copy output parameter', inject(function(moddle, moddleCopy) {

// given
var outputParameter = moddle.create('camunda:OutputParameter', {
Expand Down Expand Up @@ -360,7 +360,7 @@ describe('features/copy-paste/ModdleCopy', function() {
describe('camunda:Connector', function() {

it('should copy if parent is message event definition and is child of end event', inject(
function(moddleCopy, moddle) {
function(moddle, moddleCopy) {

// given
var connector = moddle.create('camunda:Connector', {
Expand Down Expand Up @@ -399,7 +399,7 @@ describe('features/copy-paste/ModdleCopy', function() {
describe('camunda:Field', function() {

it('should copy if parent is message event definition and is child of end event', inject(
function(moddleCopy, moddle) {
function(moddle, moddleCopy) {

// given
var field = moddle.create('camunda:Field', {
Expand Down Expand Up @@ -438,7 +438,7 @@ describe('features/copy-paste/ModdleCopy', function() {
describe('camunda:FailedJobRetryTimeCycle', function() {

it('should copy if parent is SignalEventDefinition and is intermediate throwing', inject(
function(moddleCopy, moddle) {
function(moddle, moddleCopy) {

// given
var retryCycle = moddle.create('camunda:FailedJobRetryTimeCycle', {
Expand Down Expand Up @@ -475,7 +475,7 @@ describe('features/copy-paste/ModdleCopy', function() {


it('should copy if parent is TimerEventDefinition and is catching', inject(
function(moddleCopy, moddle) {
function(moddle, moddleCopy) {

// given
var retryCycle = moddle.create('camunda:FailedJobRetryTimeCycle', {
Expand Down Expand Up @@ -509,7 +509,7 @@ describe('features/copy-paste/ModdleCopy', function() {
));


it('should copy if parent is call activity', inject(function(moddleCopy, moddle) {
it('should copy if parent is call activity', inject(function(moddle, moddleCopy) {

// given
var retryCycle = moddle.create('camunda:FailedJobRetryTimeCycle', {
Expand Down Expand Up @@ -542,6 +542,35 @@ describe('features/copy-paste/ModdleCopy', function() {

});


describe('generic properties', function() {

it('should not copy generic extension elements', inject(function(moddle, moddleCopy) {

// given
var genericExtensionElement = moddle.createAny('foo:property', {
value: 'foo'
});

var extensionElements = moddle.create('bpmn:ExtensionElements'),
startEvent = moddle.create('bpmn:StartEvent');

genericExtensionElement.$parent = extensionElements;

extensionElements.$parent = startEvent;
extensionElements.values = [ genericExtensionElement ];

startEvent.extensionElements = extensionElements;

// when
var endEvent = moddleCopy.copyElement(startEvent, moddle.create('bpmn:EndEvent'));

// then
expect(endEvent.extensionElements).not.to.exist;
}));

});

});


Expand Down

0 comments on commit 4f824fe

Please sign in to comment.