parent
c14a87e5ad
commit
087506cc9a
|
@ -5,7 +5,11 @@ var forEach = require('lodash/collection/forEach'),
|
||||||
|
|
||||||
var CommandInterceptor = require('diagram-js/lib/command/CommandInterceptor');
|
var CommandInterceptor = require('diagram-js/lib/command/CommandInterceptor');
|
||||||
|
|
||||||
function DropBehavior(eventBus, modeling) {
|
var is = require('../ModelingUtil').is,
|
||||||
|
getSharedParent = require('../ModelingUtil').getSharedParent;
|
||||||
|
|
||||||
|
|
||||||
|
function DropBehavior(eventBus, modeling, bpmnRules) {
|
||||||
|
|
||||||
CommandInterceptor.call(this, eventBus);
|
CommandInterceptor.call(this, eventBus);
|
||||||
|
|
||||||
|
@ -19,16 +23,67 @@ function DropBehavior(eventBus, modeling) {
|
||||||
|
|
||||||
forEach(allConnections, function(c) {
|
forEach(allConnections, function(c) {
|
||||||
|
|
||||||
// remove sequence flows having source / target on different parents
|
var source = c.source,
|
||||||
if (c.businessObject.$instanceOf('bpmn:SequenceFlow') && c.source.parent !== c.target.parent) {
|
target = c.target;
|
||||||
|
|
||||||
|
var replacementType,
|
||||||
|
remove;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if incoming or outgoing connections
|
||||||
|
* can stay or could be substituted with an
|
||||||
|
* appropriate replacement.
|
||||||
|
*
|
||||||
|
* This holds true for SequenceFlow <> MessageFlow.
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (is(c, 'bpmn:SequenceFlow')) {
|
||||||
|
if (!bpmnRules.canConnectSequenceFlow(source, target)) {
|
||||||
|
remove = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bpmnRules.canConnectMessageFlow(source, target)) {
|
||||||
|
replacementType = 'bpmn:MessageFlow';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// transform message flows into sequence flows, if possible
|
||||||
|
|
||||||
|
if (is(c, 'bpmn:MessageFlow')) {
|
||||||
|
|
||||||
|
if (!bpmnRules.canConnectMessageFlow(source, target)) {
|
||||||
|
remove = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bpmnRules.canConnectSequenceFlow(source, target)) {
|
||||||
|
replacementType = 'bpmn:SequenceFlow';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (is(c, 'bpmn:Association') && !bpmnRules.canConnectAssociation(source, target)) {
|
||||||
|
remove = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// remove invalid connection
|
||||||
|
if (remove) {
|
||||||
modeling.removeConnection(c);
|
modeling.removeConnection(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// replace SequenceFlow <> MessageFlow
|
||||||
|
|
||||||
|
if (replacementType) {
|
||||||
|
modeling.createConnection(source, target, {
|
||||||
|
type: replacementType,
|
||||||
|
waypoints: c.waypoints.slice()
|
||||||
|
}, getSharedParent(source, target));
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}, true);
|
}, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
inherits(DropBehavior, CommandInterceptor);
|
inherits(DropBehavior, CommandInterceptor);
|
||||||
|
|
||||||
DropBehavior.$inject = [ 'eventBus', 'modeling' ];
|
DropBehavior.$inject = [ 'eventBus', 'modeling', 'bpmnRules' ];
|
||||||
|
|
||||||
module.exports = DropBehavior;
|
module.exports = DropBehavior;
|
|
@ -0,0 +1,27 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<bpmn2:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bpmn2="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd" id="_biH3sOTeEeS2YerRfpjPrw" exporter="camunda modeler" exporterVersion="2.6.0" targetNamespace="http://activiti.org/bpmn">
|
||||||
|
<bpmn2:collaboration id="_Collaboration_3">
|
||||||
|
<bpmn2:participant id="Participant_1" name="Pool" processRef="Process_1"/>
|
||||||
|
</bpmn2:collaboration>
|
||||||
|
<bpmn2:process id="Process_1" isExecutable="false">
|
||||||
|
<bpmn2:textAnnotation id="TextAnnotation_1"/>
|
||||||
|
<bpmn2:association id="Association_1" sourceRef="TextAnnotation_1" targetRef="Participant_1"/>
|
||||||
|
</bpmn2:process>
|
||||||
|
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
|
||||||
|
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="_Collaboration_3">
|
||||||
|
<bpmndi:BPMNShape id="_BPMNShape_Participant_3" bpmnElement="Participant_1" isHorizontal="true">
|
||||||
|
<dc:Bounds height="241.0" width="445.0" x="168.0" y="72.0"/>
|
||||||
|
</bpmndi:BPMNShape>
|
||||||
|
<bpmndi:BPMNShape id="_BPMNShape_TextAnnotation_2" bpmnElement="TextAnnotation_1">
|
||||||
|
<dc:Bounds height="105.0" width="133.0" x="708.0" y="72.0"/>
|
||||||
|
</bpmndi:BPMNShape>
|
||||||
|
<bpmndi:BPMNEdge id="BPMNEdge_Association_1" bpmnElement="Association_1" sourceElement="_BPMNShape_TextAnnotation_2" targetElement="_BPMNShape_Participant_3">
|
||||||
|
<di:waypoint xsi:type="dc:Point" x="708.0" y="136.0"/>
|
||||||
|
<di:waypoint xsi:type="dc:Point" x="612.0" y="153.0"/>
|
||||||
|
</bpmndi:BPMNEdge>
|
||||||
|
</bpmndi:BPMNPlane>
|
||||||
|
</bpmndi:BPMNDiagram>
|
||||||
|
<bpmndi:BPMNDiagram id="BPMNDiagram_2" name="Unnamed Process">
|
||||||
|
<bpmndi:BPMNPlane id="BPMNPlane_2" bpmnElement="Process_1"/>
|
||||||
|
</bpmndi:BPMNDiagram>
|
||||||
|
</bpmn2:definitions>
|
|
@ -0,0 +1,122 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<bpmn2:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bpmn2="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd" id="_biH3sOTeEeS2YerRfpjPrw" exporter="camunda modeler" exporterVersion="2.6.0" targetNamespace="http://activiti.org/bpmn">
|
||||||
|
<bpmn2:collaboration id="_Collaboration_3">
|
||||||
|
<bpmn2:participant id="Participant_1" name="Pool" processRef="Process_1"/>
|
||||||
|
<bpmn2:participant id="Participant_2" name="Pool" processRef="Process_2"/>
|
||||||
|
<bpmn2:messageFlow id="MessageFlow_1" name="" sourceRef="Task_3" targetRef="Participant_1"/>
|
||||||
|
<bpmn2:messageFlow id="MessageFlow_4" name="" sourceRef="Participant_2" targetRef="StartEvent_1"/>
|
||||||
|
<bpmn2:messageFlow id="MessageFlow_5" name="" sourceRef="Task_2" targetRef="Task_4"/>
|
||||||
|
<bpmn2:messageFlow id="MessageFlow_3" name="" sourceRef="Task_1" targetRef="Participant_2"/>
|
||||||
|
</bpmn2:collaboration>
|
||||||
|
<bpmn2:process id="Process_1" isExecutable="false">
|
||||||
|
<bpmn2:subProcess id="SubProcess_1">
|
||||||
|
<bpmn2:incoming>SequenceFlow_1</bpmn2:incoming>
|
||||||
|
<bpmn2:task id="Task_1">
|
||||||
|
<bpmn2:outgoing>SequenceFlow_2</bpmn2:outgoing>
|
||||||
|
</bpmn2:task>
|
||||||
|
<bpmn2:sequenceFlow id="SequenceFlow_2" name="" sourceRef="Task_1" targetRef="EndEvent_1"/>
|
||||||
|
<bpmn2:endEvent id="EndEvent_1">
|
||||||
|
<bpmn2:incoming>SequenceFlow_2</bpmn2:incoming>
|
||||||
|
</bpmn2:endEvent>
|
||||||
|
</bpmn2:subProcess>
|
||||||
|
<bpmn2:task id="Task_2">
|
||||||
|
<bpmn2:incoming>SequenceFlow_3</bpmn2:incoming>
|
||||||
|
<bpmn2:outgoing>SequenceFlow_1</bpmn2:outgoing>
|
||||||
|
</bpmn2:task>
|
||||||
|
<bpmn2:sequenceFlow id="SequenceFlow_1" name="" sourceRef="Task_2" targetRef="SubProcess_1"/>
|
||||||
|
<bpmn2:startEvent id="StartEvent_1">
|
||||||
|
<bpmn2:outgoing>SequenceFlow_3</bpmn2:outgoing>
|
||||||
|
<bpmn2:messageEventDefinition id="_MessageEventDefinition_2"/>
|
||||||
|
</bpmn2:startEvent>
|
||||||
|
<bpmn2:sequenceFlow id="SequenceFlow_3" name="" sourceRef="StartEvent_1" targetRef="Task_2"/>
|
||||||
|
</bpmn2:process>
|
||||||
|
<bpmn2:process id="Process_2" isExecutable="false">
|
||||||
|
<bpmn2:task id="Task_3"/>
|
||||||
|
<bpmn2:task id="Task_4"/>
|
||||||
|
</bpmn2:process>
|
||||||
|
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
|
||||||
|
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="_Collaboration_3">
|
||||||
|
<bpmndi:BPMNShape id="_BPMNShape_Participant_3" bpmnElement="Participant_1" isHorizontal="true">
|
||||||
|
<dc:Bounds height="265.0" width="697.0" x="168.0" y="72.0"/>
|
||||||
|
</bpmndi:BPMNShape>
|
||||||
|
<bpmndi:BPMNShape id="_BPMNShape_SubProcess_3" bpmnElement="SubProcess_1" isExpanded="true">
|
||||||
|
<dc:Bounds height="205.0" width="248.0" x="576.0" y="96.0"/>
|
||||||
|
</bpmndi:BPMNShape>
|
||||||
|
<bpmndi:BPMNShape id="_BPMNShape_Task_3" bpmnElement="Task_1">
|
||||||
|
<dc:Bounds height="80.0" width="100.0" x="601.0" y="119.0"/>
|
||||||
|
</bpmndi:BPMNShape>
|
||||||
|
<bpmndi:BPMNShape id="_BPMNShape_Task_4" bpmnElement="Task_2">
|
||||||
|
<dc:Bounds height="80.0" width="100.0" x="360.0" y="159.0"/>
|
||||||
|
</bpmndi:BPMNShape>
|
||||||
|
<bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_1" bpmnElement="SequenceFlow_1" sourceElement="_BPMNShape_Task_4" targetElement="_BPMNShape_SubProcess_3">
|
||||||
|
<di:waypoint xsi:type="dc:Point" x="460.0" y="198.0"/>
|
||||||
|
<di:waypoint xsi:type="dc:Point" x="576.0" y="198.0"/>
|
||||||
|
<bpmndi:BPMNLabel>
|
||||||
|
<dc:Bounds height="6.0" width="6.0" x="534.0" y="198.0"/>
|
||||||
|
</bpmndi:BPMNLabel>
|
||||||
|
</bpmndi:BPMNEdge>
|
||||||
|
<bpmndi:BPMNShape id="_BPMNShape_StartEvent_3" bpmnElement="StartEvent_1">
|
||||||
|
<dc:Bounds height="36.0" width="36.0" x="240.0" y="181.0"/>
|
||||||
|
<bpmndi:BPMNLabel>
|
||||||
|
<dc:Bounds height="0.0" width="0.0" x="258.0" y="222.0"/>
|
||||||
|
</bpmndi:BPMNLabel>
|
||||||
|
</bpmndi:BPMNShape>
|
||||||
|
<bpmndi:BPMNShape id="_BPMNShape_EndEvent_3" bpmnElement="EndEvent_1">
|
||||||
|
<dc:Bounds height="36.0" width="36.0" x="768.0" y="141.0"/>
|
||||||
|
<bpmndi:BPMNLabel>
|
||||||
|
<dc:Bounds height="0.0" width="0.0" x="786.0" y="182.0"/>
|
||||||
|
</bpmndi:BPMNLabel>
|
||||||
|
</bpmndi:BPMNShape>
|
||||||
|
<bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_2" bpmnElement="SequenceFlow_2" sourceElement="_BPMNShape_Task_3" targetElement="_BPMNShape_EndEvent_3">
|
||||||
|
<di:waypoint xsi:type="dc:Point" x="701.0" y="159.0"/>
|
||||||
|
<di:waypoint xsi:type="dc:Point" x="768.0" y="159.0"/>
|
||||||
|
<bpmndi:BPMNLabel>
|
||||||
|
<dc:Bounds height="6.0" width="6.0" x="723.0" y="159.0"/>
|
||||||
|
</bpmndi:BPMNLabel>
|
||||||
|
</bpmndi:BPMNEdge>
|
||||||
|
<bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_3" bpmnElement="SequenceFlow_3" sourceElement="_BPMNShape_StartEvent_3" targetElement="_BPMNShape_Task_4">
|
||||||
|
<di:waypoint xsi:type="dc:Point" x="276.0" y="199.0"/>
|
||||||
|
<di:waypoint xsi:type="dc:Point" x="360.0" y="199.0"/>
|
||||||
|
<bpmndi:BPMNLabel>
|
||||||
|
<dc:Bounds height="6.0" width="6.0" x="318.0" y="199.0"/>
|
||||||
|
</bpmndi:BPMNLabel>
|
||||||
|
</bpmndi:BPMNEdge>
|
||||||
|
<bpmndi:BPMNShape id="_BPMNShape_Participant_4" bpmnElement="Participant_2" isHorizontal="true">
|
||||||
|
<dc:Bounds height="345.0" width="697.0" x="168.0" y="456.0"/>
|
||||||
|
</bpmndi:BPMNShape>
|
||||||
|
<bpmndi:BPMNShape id="_BPMNShape_Task_5" bpmnElement="Task_3">
|
||||||
|
<dc:Bounds height="80.0" width="100.0" x="708.0" y="489.0"/>
|
||||||
|
</bpmndi:BPMNShape>
|
||||||
|
<bpmndi:BPMNEdge id="BPMNEdge_MessageFlow_1" bpmnElement="MessageFlow_1" sourceElement="_BPMNShape_Task_5" targetElement="_BPMNShape_Participant_3">
|
||||||
|
<di:waypoint xsi:type="dc:Point" x="758.0" y="489.0"/>
|
||||||
|
<di:waypoint xsi:type="dc:Point" x="758.0" y="413.0"/>
|
||||||
|
<di:waypoint xsi:type="dc:Point" x="758.0" y="413.0"/>
|
||||||
|
<di:waypoint xsi:type="dc:Point" x="758.0" y="336.0"/>
|
||||||
|
</bpmndi:BPMNEdge>
|
||||||
|
<bpmndi:BPMNEdge id="BPMNEdge_MessageFlow_4" bpmnElement="MessageFlow_4" sourceElement="_BPMNShape_Participant_4" targetElement="_BPMNShape_StartEvent_3">
|
||||||
|
<di:waypoint xsi:type="dc:Point" x="258.0" y="456.0"/>
|
||||||
|
<di:waypoint xsi:type="dc:Point" x="258.0" y="337.0"/>
|
||||||
|
<di:waypoint xsi:type="dc:Point" x="258.0" y="337.0"/>
|
||||||
|
<di:waypoint xsi:type="dc:Point" x="258.0" y="217.0"/>
|
||||||
|
</bpmndi:BPMNEdge>
|
||||||
|
<bpmndi:BPMNEdge id="BPMNEdge_MessageFlow_5" bpmnElement="MessageFlow_5" sourceElement="_BPMNShape_Task_4" targetElement="_BPMNShape_Task_7">
|
||||||
|
<di:waypoint xsi:type="dc:Point" x="410.0" y="239.0"/>
|
||||||
|
<di:waypoint xsi:type="dc:Point" x="410.0" y="390.0"/>
|
||||||
|
<di:waypoint xsi:type="dc:Point" x="554.0" y="390.0"/>
|
||||||
|
<di:waypoint xsi:type="dc:Point" x="554.0" y="489.0"/>
|
||||||
|
<bpmndi:BPMNLabel>
|
||||||
|
<dc:Bounds height="6.0" width="6.0" x="407.0" y="348.0"/>
|
||||||
|
</bpmndi:BPMNLabel>
|
||||||
|
</bpmndi:BPMNEdge>
|
||||||
|
<bpmndi:BPMNEdge id="BPMNEdge_MessageFlow_3" bpmnElement="MessageFlow_3" sourceElement="_BPMNShape_Task_3" targetElement="_BPMNShape_Participant_4">
|
||||||
|
<di:waypoint xsi:type="dc:Point" x="651.0" y="199.0"/>
|
||||||
|
<di:waypoint xsi:type="dc:Point" x="651.0" y="327.0"/>
|
||||||
|
<di:waypoint xsi:type="dc:Point" x="651.0" y="327.0"/>
|
||||||
|
<di:waypoint xsi:type="dc:Point" x="651.0" y="456.0"/>
|
||||||
|
</bpmndi:BPMNEdge>
|
||||||
|
<bpmndi:BPMNShape id="_BPMNShape_Task_7" bpmnElement="Task_4">
|
||||||
|
<dc:Bounds height="80.0" width="100.0" x="504.0" y="489.0"/>
|
||||||
|
</bpmndi:BPMNShape>
|
||||||
|
</bpmndi:BPMNPlane>
|
||||||
|
</bpmndi:BPMNDiagram>
|
||||||
|
</bpmn2:definitions>
|
|
@ -0,0 +1,240 @@
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
var TestHelper = require('../../../../TestHelper');
|
||||||
|
|
||||||
|
/* global bootstrapModeler, inject */
|
||||||
|
|
||||||
|
var is = require('../../../../../lib/features/modeling/ModelingUtil').is,
|
||||||
|
find = require('lodash/collection/find');
|
||||||
|
|
||||||
|
var modelingModule = require('../../../../../lib/features/modeling'),
|
||||||
|
coreModule = require('../../../../../lib/core');
|
||||||
|
|
||||||
|
|
||||||
|
function getConnection(source, target, connectionOrType) {
|
||||||
|
return find(source.outgoing, function(c) {
|
||||||
|
return c.target === target &&
|
||||||
|
(typeof connectionOrType === 'string' ? is(c, connectionOrType) : c === connectionOrType);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function expectConnected(source, target, connectionOrType) {
|
||||||
|
expect(getConnection(source, target, connectionOrType)).toBeDefined();
|
||||||
|
}
|
||||||
|
|
||||||
|
function expectNotConnected(source, target, connectionOrType) {
|
||||||
|
expect(getConnection(source, target, connectionOrType)).not.toBeDefined();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
describe('features/modeling - drop behavior', function() {
|
||||||
|
|
||||||
|
var testModules = [ coreModule, modelingModule ];
|
||||||
|
|
||||||
|
|
||||||
|
describe('should replace SequenceFlow <> MessageFlow', function() {
|
||||||
|
|
||||||
|
var processDiagramXML = require('./DropBehavior.message-sequence-flow.bpmn');
|
||||||
|
|
||||||
|
beforeEach(bootstrapModeler(processDiagramXML, { modules: testModules }));
|
||||||
|
|
||||||
|
|
||||||
|
var element;
|
||||||
|
|
||||||
|
beforeEach(inject(function(elementRegistry) {
|
||||||
|
element = function(id) {
|
||||||
|
return elementRegistry.get(id);
|
||||||
|
};
|
||||||
|
}));
|
||||||
|
|
||||||
|
|
||||||
|
describe('moving single shape', function() {
|
||||||
|
|
||||||
|
it('execute', inject(function(modeling, elementRegistry) {
|
||||||
|
|
||||||
|
// given
|
||||||
|
var taskShape = element('Task_2'),
|
||||||
|
targetShape = element('Participant_2');
|
||||||
|
|
||||||
|
// when
|
||||||
|
modeling.moveShapes([ taskShape ], { x: 0, y: 330 }, targetShape);
|
||||||
|
|
||||||
|
// then
|
||||||
|
expect(taskShape.parent).toBe(targetShape);
|
||||||
|
|
||||||
|
expectNotConnected(element('StartEvent_1'), taskShape, 'bpmn:SequenceFlow');
|
||||||
|
|
||||||
|
expectConnected(taskShape, element('Task_4'), 'bpmn:SequenceFlow');
|
||||||
|
expectConnected(taskShape, element('SubProcess_1'), 'bpmn:MessageFlow');
|
||||||
|
}));
|
||||||
|
|
||||||
|
|
||||||
|
it('undo', inject(function(modeling, elementRegistry, commandStack) {
|
||||||
|
|
||||||
|
// given
|
||||||
|
var taskShape = element('Task_2'),
|
||||||
|
targetShape = element('Participant_2'),
|
||||||
|
oldParent = taskShape.parent;
|
||||||
|
|
||||||
|
modeling.moveShapes([ taskShape ], { x: 0, y: 300 }, targetShape);
|
||||||
|
|
||||||
|
// when
|
||||||
|
commandStack.undo();
|
||||||
|
|
||||||
|
// then
|
||||||
|
expect(taskShape.parent).toBe(oldParent);
|
||||||
|
|
||||||
|
expectConnected(element('StartEvent_1'), taskShape, element('SequenceFlow_3'));
|
||||||
|
|
||||||
|
expectConnected(taskShape, element('Task_4'), element('MessageFlow_5'));
|
||||||
|
expectConnected(taskShape, element('SubProcess_1'), element('SequenceFlow_1'));
|
||||||
|
}));
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
describe('moving multiple shapes', function() {
|
||||||
|
|
||||||
|
it('execute', inject(function(modeling, elementRegistry) {
|
||||||
|
|
||||||
|
// given
|
||||||
|
var startEventShape = element('StartEvent_1'),
|
||||||
|
taskShape = element('Task_2'),
|
||||||
|
targetShape = element('Participant_2');
|
||||||
|
|
||||||
|
// when
|
||||||
|
modeling.moveShapes([ startEventShape, taskShape ], { x: 0, y: 330 }, targetShape);
|
||||||
|
|
||||||
|
// then
|
||||||
|
expect(taskShape.parent).toBe(targetShape);
|
||||||
|
expect(startEventShape.parent).toBe(targetShape);
|
||||||
|
|
||||||
|
expectConnected(startEventShape, taskShape, element('SequenceFlow_3'));
|
||||||
|
|
||||||
|
expectNotConnected(element('Participant_2'), startEventShape, 'bpmn:MessageFlow');
|
||||||
|
expectConnected(taskShape, element('SubProcess_1'), 'bpmn:MessageFlow');
|
||||||
|
}));
|
||||||
|
|
||||||
|
|
||||||
|
it('undo', inject(function(modeling, elementRegistry, commandStack) {
|
||||||
|
|
||||||
|
// given
|
||||||
|
var taskShape = element('Task_2'),
|
||||||
|
targetShape = element('Participant_2'),
|
||||||
|
oldParent = taskShape.parent;
|
||||||
|
|
||||||
|
modeling.moveShapes([ taskShape ], { x: 0, y: 300 }, targetShape);
|
||||||
|
|
||||||
|
// when
|
||||||
|
commandStack.undo();
|
||||||
|
|
||||||
|
// then
|
||||||
|
expect(taskShape.parent).toBe(oldParent);
|
||||||
|
|
||||||
|
expectConnected(element('StartEvent_1'), taskShape, element('SequenceFlow_3'));
|
||||||
|
|
||||||
|
expectConnected(taskShape, element('Task_4'), element('MessageFlow_5'));
|
||||||
|
expectConnected(taskShape, element('SubProcess_1'), element('SequenceFlow_1'));
|
||||||
|
|
||||||
|
expectConnected(element('Participant_2'), element('StartEvent_1'), element('MessageFlow_4'));
|
||||||
|
}));
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
describe('moving nested shapes', function() {
|
||||||
|
|
||||||
|
it('execute', inject(function(modeling, elementRegistry) {
|
||||||
|
|
||||||
|
// given
|
||||||
|
var subProcessShape = element('SubProcess_1'),
|
||||||
|
targetShape = element('Participant_2');
|
||||||
|
|
||||||
|
// when
|
||||||
|
modeling.moveShapes([ subProcessShape ], { x: 0, y: 530 }, targetShape);
|
||||||
|
|
||||||
|
// then
|
||||||
|
expect(subProcessShape.parent).toBe(targetShape);
|
||||||
|
|
||||||
|
expectConnected(element('Task_2'), subProcessShape, 'bpmn:MessageFlow');
|
||||||
|
|
||||||
|
expectNotConnected(element('Task_1'), element('Participant_2'), 'bpmn:MessageFlow');
|
||||||
|
}));
|
||||||
|
|
||||||
|
|
||||||
|
it('undo', inject(function(modeling, elementRegistry, commandStack) {
|
||||||
|
|
||||||
|
// given
|
||||||
|
var subProcessShape = element('SubProcess_1'),
|
||||||
|
targetShape = element('Participant_2');
|
||||||
|
|
||||||
|
modeling.moveShapes([ subProcessShape ], { x: 0, y: 530 }, targetShape);
|
||||||
|
|
||||||
|
// when
|
||||||
|
commandStack.undo();
|
||||||
|
|
||||||
|
// then
|
||||||
|
expectConnected(element('Task_2'), subProcessShape, element('SequenceFlow_1'));
|
||||||
|
|
||||||
|
expectConnected(element('Task_1'), element('Participant_2'), element('MessageFlow_3'));
|
||||||
|
}));
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
describe('should replace SequenceFlow <> MessageFlow', function() {
|
||||||
|
|
||||||
|
var processDiagramXML = require('./DropBehavior.association.bpmn');
|
||||||
|
|
||||||
|
beforeEach(bootstrapModeler(processDiagramXML, { modules: testModules }));
|
||||||
|
|
||||||
|
|
||||||
|
var element;
|
||||||
|
|
||||||
|
beforeEach(inject(function(elementRegistry) {
|
||||||
|
element = function(id) {
|
||||||
|
return elementRegistry.get(id);
|
||||||
|
};
|
||||||
|
}));
|
||||||
|
|
||||||
|
|
||||||
|
describe('moving text-annotation to participant', function() {
|
||||||
|
|
||||||
|
it('execute', inject(function(modeling, elementRegistry) {
|
||||||
|
|
||||||
|
// given
|
||||||
|
var textAnnotationShape = element('TextAnnotation_1'),
|
||||||
|
targetShape = element('Participant_1');
|
||||||
|
|
||||||
|
// when
|
||||||
|
modeling.moveShapes([ textAnnotationShape ], { x: -200, y: 40 }, targetShape);
|
||||||
|
|
||||||
|
// then
|
||||||
|
expect(textAnnotationShape.parent).toBe(targetShape);
|
||||||
|
|
||||||
|
expectNotConnected(textAnnotationShape, targetShape, 'bpmn:TextAnnotation');
|
||||||
|
}));
|
||||||
|
|
||||||
|
|
||||||
|
it('undo', inject(function(modeling, elementRegistry, commandStack) {
|
||||||
|
|
||||||
|
// given
|
||||||
|
var textAnnotationShape = element('TextAnnotation_1'),
|
||||||
|
targetShape = element('Participant_1');
|
||||||
|
|
||||||
|
modeling.moveShapes([ textAnnotationShape ], { x: -200, y: 40 }, targetShape);
|
||||||
|
|
||||||
|
// when
|
||||||
|
commandStack.undo();
|
||||||
|
|
||||||
|
// then
|
||||||
|
expectConnected(textAnnotationShape, targetShape, element('Association_1'));
|
||||||
|
}));
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
Loading…
Reference in New Issue