diff --git a/lib/features/modeling/behavior/BoundaryEventBehavior.js b/lib/features/modeling/behavior/BoundaryEventBehavior.js
new file mode 100644
index 00000000..b5dbd225
--- /dev/null
+++ b/lib/features/modeling/behavior/BoundaryEventBehavior.js
@@ -0,0 +1,67 @@
+import inherits from 'inherits';
+
+import CommandInterceptor from 'diagram-js/lib/command/CommandInterceptor';
+
+import { is } from '../../../util/ModelUtil';
+
+import {
+ filter,
+ forEach
+} from 'min-dash';
+
+
+/**
+ * BPMN specific boundary event behavior
+ */
+export default function ConnectEventBasedGatewayBehavior(eventBus, modeling) {
+
+ CommandInterceptor.call(this, eventBus);
+
+ function getBoundaryEvents(element) {
+ return filter(element.attachers, function(attacher) {
+ return is(attacher, 'bpmn:BoundaryEvent');
+ });
+ }
+
+ // remove after connecting to event-based gateway
+ this.postExecute('connection.create', function(event) {
+ var source = event.context.source,
+ target = event.context.target,
+ boundaryEvents = getBoundaryEvents(target);
+
+ if (
+ is(source, 'bpmn:EventBasedGateway') &&
+ is(target, 'bpmn:ReceiveTask') &&
+ boundaryEvents.length > 0
+ ) {
+ modeling.removeElements(boundaryEvents);
+ }
+
+ });
+
+ // remove after replacing connected gateway with event-based gateway
+ this.postExecute('connection.reconnectStart', function(event) {
+ var oldSource = event.context.oldSource,
+ newSource = event.context.newSource;
+
+ if (is(oldSource, 'bpmn:Gateway') &&
+ is(newSource, 'bpmn:EventBasedGateway')) {
+ forEach(newSource.outgoing, function(connection) {
+ var target = connection.target,
+ attachedboundaryEvents = getBoundaryEvents(target);
+
+ if (is(target, 'bpmn:ReceiveTask') &&
+ attachedboundaryEvents.length > 0) {
+ modeling.removeElements(attachedboundaryEvents);
+ }
+ });
+ }
+ });
+}
+
+ConnectEventBasedGatewayBehavior.$inject = [
+ 'eventBus',
+ 'modeling'
+];
+
+inherits(ConnectEventBasedGatewayBehavior, CommandInterceptor);
diff --git a/lib/features/modeling/behavior/ConnectEventBasedGatewayBehavior.js b/lib/features/modeling/behavior/ConnectEventBasedGatewayBehavior.js
deleted file mode 100644
index 20ae70e5..00000000
--- a/lib/features/modeling/behavior/ConnectEventBasedGatewayBehavior.js
+++ /dev/null
@@ -1,47 +0,0 @@
-import inherits from 'inherits';
-
-import CommandInterceptor from 'diagram-js/lib/command/CommandInterceptor';
-
-import { is } from '../../../util/ModelUtil';
-
-import {
- filter
-} from 'min-dash';
-
-
-/**
- * Behavior for deleting boundaries from receive task after connecting them with event based gateway
- */
-export default function ConnectEventBasedGatewayBehavior(eventBus, modeling) {
-
- CommandInterceptor.call(this, eventBus);
-
- function extractBoundaryEvents(element) {
- return filter(element.attachers, function(attacher) {
- return is(attacher, 'bpmn:BoundaryEvent');
- });
- }
-
- this.postExecute('connection.create', function(context) {
- var source = context.context.source,
- target = context.context.target,
- boundaries = extractBoundaryEvents(target);
-
- if (
- is(source, 'bpmn:EventBasedGateway') &&
- is(target, 'bpmn:ReceiveTask') &&
- boundaries.length > 0
- ) {
- modeling.removeElements(boundaries);
- }
-
- });
-}
-
-ConnectEventBasedGatewayBehavior.$inject = [
- 'eventBus',
- 'modeling',
- 'bpmnRules'
-];
-
-inherits(ConnectEventBasedGatewayBehavior, CommandInterceptor);
diff --git a/lib/features/modeling/behavior/index.js b/lib/features/modeling/behavior/index.js
index 51a85a9c..98f05102 100644
--- a/lib/features/modeling/behavior/index.js
+++ b/lib/features/modeling/behavior/index.js
@@ -1,6 +1,6 @@
import AdaptiveLabelPositioningBehavior from './AdaptiveLabelPositioningBehavior';
import AppendBehavior from './AppendBehavior';
-import ConnectEventBasedGatewayBehavior from './ConnectEventBasedGatewayBehavior';
+import BoundaryEventBehavior from './BoundaryEventBehavior';
import CopyPasteBehavior from './CopyPasteBehavior';
import CreateBoundaryEventBehavior from './CreateBoundaryEventBehavior';
import CreateDataObjectBehavior from './CreateDataObjectBehavior';
@@ -26,7 +26,7 @@ export default {
__init__: [
'adaptiveLabelPositioningBehavior',
'appendBehavior',
- 'connectEventBasedGatewayBehavior',
+ 'boundaryEventBehavior',
'copyPasteBehavior',
'createBoundaryEventBehavior',
'createDataObjectBehavior',
@@ -50,7 +50,7 @@ export default {
],
adaptiveLabelPositioningBehavior: [ 'type', AdaptiveLabelPositioningBehavior ],
appendBehavior: [ 'type', AppendBehavior ],
- connectEventBasedGatewayBehavior: [ 'type', ConnectEventBasedGatewayBehavior ],
+ boundaryEventBehavior: [ 'type', BoundaryEventBehavior ],
copyPasteBehavior: [ 'type', CopyPasteBehavior ],
createBoundaryEventBehavior: [ 'type', CreateBoundaryEventBehavior ],
createDataObjectBehavior: [ 'type', CreateDataObjectBehavior ],
diff --git a/test/spec/features/modeling/behavior/ConnectEventBasedGatewayBehavior.bpmn b/test/spec/features/modeling/behavior/BoundaryEvent.bpmn
similarity index 83%
rename from test/spec/features/modeling/behavior/ConnectEventBasedGatewayBehavior.bpmn
rename to test/spec/features/modeling/behavior/BoundaryEvent.bpmn
index f55186a4..2e995b54 100644
--- a/test/spec/features/modeling/behavior/ConnectEventBasedGatewayBehavior.bpmn
+++ b/test/spec/features/modeling/behavior/BoundaryEvent.bpmn
@@ -4,6 +4,7 @@
+
@@ -16,6 +17,9 @@
+
+
+
diff --git a/test/spec/features/modeling/behavior/ConnectEventBasedGatewayBehaviorSpec.js b/test/spec/features/modeling/behavior/BoundaryEventBehaviorSpec.js
similarity index 54%
rename from test/spec/features/modeling/behavior/ConnectEventBasedGatewayBehaviorSpec.js
rename to test/spec/features/modeling/behavior/BoundaryEventBehaviorSpec.js
index 86631196..2333a6df 100644
--- a/test/spec/features/modeling/behavior/ConnectEventBasedGatewayBehaviorSpec.js
+++ b/test/spec/features/modeling/behavior/BoundaryEventBehaviorSpec.js
@@ -7,11 +7,11 @@ import modelingModule from 'lib/features/modeling';
import coreModule from 'lib/core';
-describe('features/modeling/behavior - connect event based gateway to receive task with boundary', function() {
+describe('features/modeling/behavior - boundary event', function() {
var testModules = [ coreModule, modelingModule ];
- var diagramXML = require('./ConnectEventBasedGatewayBehavior.bpmn');
+ var diagramXML = require('./BoundaryEvent.bpmn');
beforeEach(bootstrapModeler(diagramXML, { modules: testModules }));
@@ -33,4 +33,23 @@ describe('features/modeling/behavior - connect event based gateway to receive ta
expect(elementRegistry.get(boundaryEvent.id)).to.be.undefined;
}));
+ it('should remove Boundary from ReceiveTask after changing type of Gateway', inject(function(modeling, elementRegistry, bpmnReplace) {
+
+ // given
+ var gateway = elementRegistry.get('ExclusiveGateway_1'),
+ receiveTask = elementRegistry.get('ReceiveTask_1'),
+ boundaryEvent = elementRegistry.get('BoundaryEvent_1');
+
+ // when
+ modeling.connect(gateway, receiveTask, {
+ type: 'bpmn:SequenceFlow'
+ });
+ bpmnReplace.replaceElement(gateway, {
+ type: 'bpmn:EventBasedGateway'
+ });
+
+ // then
+ expect(elementRegistry.get(boundaryEvent.id)).not.to.exist;
+ }));
+
});
\ No newline at end of file