From ca53ab56bbbbd9709833b2e0a274ada405761f49 Mon Sep 17 00:00:00 2001 From: Philipp Fromme Date: Wed, 6 Nov 2019 14:07:05 +0100 Subject: [PATCH] feat(modeling): replace connection on reconnect --- .../behavior/ReplaceConnectionBehavior.js | 1 + .../behavior/ReplaceConnectionBehaviorSpec.js | 70 +++++++++++++------ 2 files changed, 50 insertions(+), 21 deletions(-) diff --git a/lib/features/modeling/behavior/ReplaceConnectionBehavior.js b/lib/features/modeling/behavior/ReplaceConnectionBehavior.js index 5e96d218..d69e4cbb 100644 --- a/lib/features/modeling/behavior/ReplaceConnectionBehavior.js +++ b/lib/features/modeling/behavior/ReplaceConnectionBehavior.js @@ -147,6 +147,7 @@ export default function ReplaceConnectionBehavior(eventBus, modeling, bpmnRules, }, true); this.preExecute([ + 'connection.reconnect', 'connection.reconnectStart', 'connection.reconnectEnd' ], replaceReconnectedConnection); diff --git a/test/spec/features/modeling/behavior/ReplaceConnectionBehaviorSpec.js b/test/spec/features/modeling/behavior/ReplaceConnectionBehaviorSpec.js index d819433e..755342aa 100644 --- a/test/spec/features/modeling/behavior/ReplaceConnectionBehaviorSpec.js +++ b/test/spec/features/modeling/behavior/ReplaceConnectionBehaviorSpec.js @@ -69,7 +69,55 @@ describe('features/modeling - replace connection', function() { describe('after reconnecting', function() { - it('sequence flow to another task', inject(function(elementRegistry, modeling) { + it('sequence flow from a participant', inject(function(modeling) { + + // given + var participant2 = element('Participant_2'), + subProcess1 = element('SubProcess_1'), + connection = element('SequenceFlow_1'); + + var newWaypoints = [ + { x: participant2.x + 200, y: participant2.y }, + { x: subProcess1.x, y: subProcess1.y + 50 } + ]; + + // when + modeling.reconnect(connection, participant2, connection.target, newWaypoints); + + // then + expectConnected(participant2, subProcess1, 'bpmn:MessageFlow'); + })); + + }); + + + describe('after reconnecting start', function() { + + it('sequence flow from a participant', inject(function(modeling) { + + // given + var participant2 = element('Participant_2'), + subProcess1 = element('SubProcess_1'), + connection = element('SequenceFlow_1'); + + var newWaypoints = [ + { x: participant2.x + 200, y: participant2.y }, + { x: subProcess1.x, y: subProcess1.y + 50 } + ]; + + // when + modeling.reconnectStart(connection, participant2, newWaypoints); + + // then + expectConnected(participant2, subProcess1, 'bpmn:MessageFlow'); + })); + + }); + + + describe('after reconnecting end', function() { + + it('sequence flow to another task', inject(function(modeling) { // given var task4Shape = element('Task_4'); @@ -116,26 +164,6 @@ describe('features/modeling - replace connection', function() { expectConnected(element('Task_2'), participant2, 'bpmn:MessageFlow'); })); - - it('sequence flow from a participant', inject(function(elementRegistry, modeling) { - - // given - var participant2 = element('Participant_2'), - subProcess1 = element('SubProcess_1'), - connection = element('SequenceFlow_1'); - - var newWaypoints = [ - { x: participant2.x + 200, y: participant2.y }, - { x: subProcess1.x, y: subProcess1.y + 50 } - ]; - - // when - modeling.reconnectStart(connection, participant2, newWaypoints); - - // then - expectConnected(participant2, subProcess1, 'bpmn:MessageFlow'); - })); - });