From 4a675b378027532db413186ea292daeac087285b Mon Sep 17 00:00:00 2001 From: Nico Rehwaldt Date: Mon, 16 Dec 2019 14:37:09 +0100 Subject: [PATCH] fix(rules): allow associations where data associations are allowed, too Related to https://github.com/camunda/camunda-modeler/issues/1635 --- lib/features/rules/BpmnRules.js | 8 +++- test/spec/features/rules/BpmnRulesSpec.js | 47 +++++++---------------- 2 files changed, 20 insertions(+), 35 deletions(-) diff --git a/lib/features/rules/BpmnRules.js b/lib/features/rules/BpmnRules.js index 6946173c..bd318c37 100644 --- a/lib/features/rules/BpmnRules.js +++ b/lib/features/rules/BpmnRules.js @@ -802,7 +802,13 @@ function canConnectAssociation(source, target) { } // allow connection of associations between and - return isOneTextAnnotation(source, target); + if (isOneTextAnnotation(source, target)) { + return true; + } + + // can connect associations where we can connect + // data associations, too (!) + return !!canConnectDataAssociation(source, target); } function canConnectMessageFlow(source, target) { diff --git a/test/spec/features/rules/BpmnRulesSpec.js b/test/spec/features/rules/BpmnRulesSpec.js index 55941133..e9aa0b18 100644 --- a/test/spec/features/rules/BpmnRulesSpec.js +++ b/test/spec/features/rules/BpmnRulesSpec.js @@ -296,7 +296,7 @@ describe('features/modeling/rules - BpmnRules', function() { expectCanConnect('StartEvent_None', 'DataObjectReference', { sequenceFlow: false, messageFlow: false, - association: false, + association: true, dataAssociation: { type: 'bpmn:DataOutputAssociation' } }); })); @@ -307,7 +307,7 @@ describe('features/modeling/rules - BpmnRules', function() { expectCanConnect('DataObjectReference', 'EndEvent_None', { sequenceFlow: false, messageFlow: false, - association: false, + association: true, dataAssociation: { type: 'bpmn:DataInputAssociation' } }); })); @@ -329,7 +329,7 @@ describe('features/modeling/rules - BpmnRules', function() { expectCanConnect('Task', 'DataObjectReference', { sequenceFlow: false, messageFlow: false, - association: false, + association: true, dataAssociation: { type: 'bpmn:DataOutputAssociation' } }); })); @@ -340,7 +340,7 @@ describe('features/modeling/rules - BpmnRules', function() { expectCanConnect('DataObjectReference', 'Task', { sequenceFlow: false, messageFlow: false, - association: false, + association: true, dataAssociation: { type: 'bpmn:DataInputAssociation' } }); })); @@ -351,7 +351,7 @@ describe('features/modeling/rules - BpmnRules', function() { expectCanConnect('SubProcess', 'DataObjectReference', { sequenceFlow: false, messageFlow: false, - association: false, + association: true, dataAssociation: { type: 'bpmn:DataOutputAssociation' } }); })); @@ -362,7 +362,7 @@ describe('features/modeling/rules - BpmnRules', function() { expectCanConnect('DataObjectReference', 'SubProcess', { sequenceFlow: false, messageFlow: false, - association: false, + association: true, dataAssociation: { type: 'bpmn:DataInputAssociation' } }); })); @@ -428,7 +428,7 @@ describe('features/modeling/rules - BpmnRules', function() { expectCanConnect('StartEvent_None', 'DataStoreReference', { sequenceFlow: false, messageFlow: false, - association: false, + association: true, dataAssociation: { type: 'bpmn:DataOutputAssociation' } }); })); @@ -439,7 +439,7 @@ describe('features/modeling/rules - BpmnRules', function() { expectCanConnect('DataStoreReference', 'EndEvent_None', { sequenceFlow: false, messageFlow: false, - association: false, + association: true, dataAssociation: { type: 'bpmn:DataInputAssociation' } }); })); @@ -461,7 +461,7 @@ describe('features/modeling/rules - BpmnRules', function() { expectCanConnect('Task', 'DataStoreReference', { sequenceFlow: false, messageFlow: false, - association: false, + association: true, dataAssociation: { type: 'bpmn:DataOutputAssociation' } }); })); @@ -472,7 +472,7 @@ describe('features/modeling/rules - BpmnRules', function() { expectCanConnect('DataStoreReference', 'Task', { sequenceFlow: false, messageFlow: false, - association: false, + association: true, dataAssociation: { type: 'bpmn:DataInputAssociation' } }); })); @@ -483,7 +483,7 @@ describe('features/modeling/rules - BpmnRules', function() { expectCanConnect('SubProcess', 'DataStoreReference', { sequenceFlow: false, messageFlow: false, - association: false, + association: true, dataAssociation: { type: 'bpmn:DataOutputAssociation' } }); })); @@ -494,7 +494,7 @@ describe('features/modeling/rules - BpmnRules', function() { expectCanConnect('DataStoreReference', 'SubProcess', { sequenceFlow: false, messageFlow: false, - association: false, + association: true, dataAssociation: { type: 'bpmn:DataInputAssociation' } }); })); @@ -666,17 +666,6 @@ describe('features/modeling/rules - BpmnRules', function() { })); - it('connect EventBasedGateway -> IntermediateCatchEvent_Message', inject(function() { - - expectCanConnect('EventBasedGateway', 'IntermediateCatchEvent_Message', { - sequenceFlow: true, - messageFlow: false, - association: false, - dataAssociation: false - }); - })); - - it('connect EventBasedGateway -> IntermediateCatchEvent_Signal', inject(function() { expectCanConnect('EventBasedGateway', 'IntermediateCatchEvent_Signal', { @@ -764,17 +753,6 @@ describe('features/modeling/rules - BpmnRules', function() { }); })); - - it('connect EventBasedGateway -> ParallelGateway', inject(function() { - - expectCanConnect('EventBasedGateway', 'ParallelGateway', { - sequenceFlow: false, - messageFlow: false, - association: false, - dataAssociation: false - }); - })); - }); describe('Task -> EventBasedGateway target with incoming sequence flow', function() { @@ -1498,6 +1476,7 @@ describe('features/modeling/rules - BpmnRules', function() { move: true }); })); + });