fix(modeling/rules): make compensation activity a message flow source
Related to camunda/camunda-modeler#661
This commit is contained in:
parent
b063addb76
commit
25dc30df06
|
@ -241,8 +241,7 @@ function isSameOrganization(a, b) {
|
||||||
|
|
||||||
function isMessageFlowSource(element) {
|
function isMessageFlowSource(element) {
|
||||||
return (
|
return (
|
||||||
is(element, 'bpmn:InteractionNode') &&
|
is(element, 'bpmn:InteractionNode') && (
|
||||||
!isForCompensation(element) && (
|
|
||||||
!is(element, 'bpmn:Event') || (
|
!is(element, 'bpmn:Event') || (
|
||||||
is(element, 'bpmn:ThrowEvent') &&
|
is(element, 'bpmn:ThrowEvent') &&
|
||||||
hasEventDefinitionOrNone(element, 'bpmn:MessageEventDefinition')
|
hasEventDefinitionOrNone(element, 'bpmn:MessageEventDefinition')
|
||||||
|
|
|
@ -0,0 +1,42 @@
|
||||||
|
<?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" id="_9X-DgL31EeWxRuodBysTLQ" targetNamespace="http://activiti.org/bpmn" exporter="camunda modeler" exporterVersion="2.6.0" xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd">
|
||||||
|
<bpmn2:collaboration id="Collaboration_0loy6fl">
|
||||||
|
<bpmn2:participant id="Participant_05lagcz" processRef="Process_1" />
|
||||||
|
<bpmn2:participant id="CollapsedPool" />
|
||||||
|
</bpmn2:collaboration>
|
||||||
|
<bpmn2:process id="Process_1" isExecutable="false">
|
||||||
|
<bpmn2:task id="Task" />
|
||||||
|
<bpmn2:task id="CompensationTask" isForCompensation="true" />
|
||||||
|
<bpmn2:boundaryEvent id="CompensationBoundary" attachedToRef="Task">
|
||||||
|
<bpmn2:compensateEventDefinition id="_CompensateEventDefinition_2" waitForCompletion="false" />
|
||||||
|
</bpmn2:boundaryEvent>
|
||||||
|
<bpmn2:association id="Association_1eqfqtu" associationDirection="One" sourceRef="CompensationBoundary" targetRef="CompensationTask" />
|
||||||
|
</bpmn2:process>
|
||||||
|
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
|
||||||
|
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Collaboration_0loy6fl">
|
||||||
|
<bpmndi:BPMNShape id="Participant_05lagcz_di" bpmnElement="Participant_05lagcz">
|
||||||
|
<dc:Bounds x="50" y="45" width="600" height="250" />
|
||||||
|
</bpmndi:BPMNShape>
|
||||||
|
<bpmndi:BPMNShape id="_BPMNShape_TaskForCompensation" bpmnElement="Task">
|
||||||
|
<dc:Bounds x="100" y="65" width="100" height="80" />
|
||||||
|
</bpmndi:BPMNShape>
|
||||||
|
<bpmndi:BPMNShape id="CompensationTask_di" bpmnElement="CompensationTask">
|
||||||
|
<dc:Bounds x="230" y="185" width="100" height="80" />
|
||||||
|
</bpmndi:BPMNShape>
|
||||||
|
<bpmndi:BPMNShape id="_BPMNShape_BoundaryEvent_2" bpmnElement="CompensationBoundary">
|
||||||
|
<dc:Bounds x="144" y="127" width="36" height="36" />
|
||||||
|
<bpmndi:BPMNLabel>
|
||||||
|
<dc:Bounds x="117" y="97" width="90" height="20" />
|
||||||
|
</bpmndi:BPMNLabel>
|
||||||
|
</bpmndi:BPMNShape>
|
||||||
|
<bpmndi:BPMNEdge id="Association_1eqfqtu_di" bpmnElement="Association_1eqfqtu">
|
||||||
|
<di:waypoint x="162" y="163" />
|
||||||
|
<di:waypoint x="162" y="225" />
|
||||||
|
<di:waypoint x="230" y="225" />
|
||||||
|
</bpmndi:BPMNEdge>
|
||||||
|
<bpmndi:BPMNShape id="Participant_08qzqg7_di" bpmnElement="CollapsedPool">
|
||||||
|
<dc:Bounds x="133" y="368" width="332" height="96" />
|
||||||
|
</bpmndi:BPMNShape>
|
||||||
|
</bpmndi:BPMNPlane>
|
||||||
|
</bpmndi:BPMNDiagram>
|
||||||
|
</bpmn2:definitions>
|
|
@ -670,6 +670,38 @@ describe('features/modeling/rules - BpmnRules', function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
describe('compensation in collaboration', function() {
|
||||||
|
|
||||||
|
var testXML = require('./BpmnRules.compensation-collaboration.bpmn');
|
||||||
|
|
||||||
|
beforeEach(bootstrapModeler(testXML, { modules: testModules }));
|
||||||
|
|
||||||
|
|
||||||
|
it('connect CompensationTask -> CollapsedPool', inject(function() {
|
||||||
|
|
||||||
|
expectCanConnect('CompensationTask', 'CollapsedPool', {
|
||||||
|
sequenceFlow: false,
|
||||||
|
messageFlow: true,
|
||||||
|
association: false,
|
||||||
|
dataAssociation: false
|
||||||
|
});
|
||||||
|
}));
|
||||||
|
|
||||||
|
|
||||||
|
it('connect CollapsedPool -> CompensationTask', inject(function() {
|
||||||
|
|
||||||
|
expectCanConnect('CollapsedPool', 'CompensationTask', {
|
||||||
|
sequenceFlow: false,
|
||||||
|
messageFlow: false,
|
||||||
|
association: false,
|
||||||
|
dataAssociation: false
|
||||||
|
});
|
||||||
|
|
||||||
|
}));
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
describe('on collaboration diagram', function() {
|
describe('on collaboration diagram', function() {
|
||||||
|
|
||||||
var testXML = require('./BpmnRules.collaboration.bpmn');
|
var testXML = require('./BpmnRules.collaboration.bpmn');
|
||||||
|
@ -1052,56 +1084,62 @@ describe('features/modeling/rules - BpmnRules', function() {
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
|
||||||
it('attach/move BoundaryEvent label -> SubProcess', inject(function(elementRegistry) {
|
it('attach/move BoundaryEvent label -> SubProcess', inject(
|
||||||
|
function(elementRegistry) {
|
||||||
|
|
||||||
// when
|
// when
|
||||||
var boundaryEvent = elementRegistry.get('BoundaryEvent_1'),
|
var boundaryEvent = elementRegistry.get('BoundaryEvent_1'),
|
||||||
label = boundaryEvent.label;
|
label = boundaryEvent.label;
|
||||||
|
|
||||||
var elements = [ label ];
|
var elements = [ label ];
|
||||||
|
|
||||||
// then
|
// then
|
||||||
expectCanMove(elements, 'SubProcess_1', {
|
expectCanMove(elements, 'SubProcess_1', {
|
||||||
attach: false,
|
attach: false,
|
||||||
move: true
|
move: true
|
||||||
});
|
});
|
||||||
|
|
||||||
}));
|
}
|
||||||
|
));
|
||||||
|
|
||||||
|
|
||||||
it('attach/move multiple BoundaryEvents -> SubProcess_1', inject(function(elementRegistry) {
|
it('attach/move multiple BoundaryEvents -> SubProcess_1', inject(
|
||||||
// when
|
function(elementRegistry) {
|
||||||
var boundaryEvent = elementRegistry.get('BoundaryEvent_1'),
|
// when
|
||||||
boundaryEvent2 = elementRegistry.get('BoundaryEvent_2');
|
var boundaryEvent = elementRegistry.get('BoundaryEvent_1'),
|
||||||
|
boundaryEvent2 = elementRegistry.get('BoundaryEvent_2');
|
||||||
|
|
||||||
// we assume boundary events and labels
|
// we assume boundary events and labels
|
||||||
// to be already filtered during move
|
// to be already filtered during move
|
||||||
var elements = [ boundaryEvent, boundaryEvent2 ];
|
var elements = [ boundaryEvent, boundaryEvent2 ];
|
||||||
|
|
||||||
// then
|
// then
|
||||||
expectCanMove(elements, 'SubProcess_1', {
|
expectCanMove(elements, 'SubProcess_1', {
|
||||||
attach: false,
|
attach: false,
|
||||||
move: false
|
move: false
|
||||||
});
|
});
|
||||||
}));
|
}
|
||||||
|
));
|
||||||
|
|
||||||
|
|
||||||
it('attach/move SubProcess, BoundaryEvent and label -> Process', inject(function(elementRegistry) {
|
it('attach/move SubProcess, BoundaryEvent and label -> Process', inject(
|
||||||
// when
|
function(elementRegistry) {
|
||||||
var subProcess = elementRegistry.get('SubProcess_1'),
|
// when
|
||||||
boundaryEvent = elementRegistry.get('BoundaryEvent_1'),
|
var subProcess = elementRegistry.get('SubProcess_1'),
|
||||||
label = boundaryEvent.label;
|
boundaryEvent = elementRegistry.get('BoundaryEvent_1'),
|
||||||
|
label = boundaryEvent.label;
|
||||||
|
|
||||||
// we assume boundary events and labels
|
// we assume boundary events and labels
|
||||||
// to be already filtered during move
|
// to be already filtered during move
|
||||||
var elements = [ subProcess, boundaryEvent, label ];
|
var elements = [ subProcess, boundaryEvent, label ];
|
||||||
|
|
||||||
// then
|
// then
|
||||||
expectCanMove(elements, 'Process_1', {
|
expectCanMove(elements, 'Process_1', {
|
||||||
attach: false,
|
attach: false,
|
||||||
move: false
|
move: false
|
||||||
});
|
});
|
||||||
}));
|
}
|
||||||
|
));
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1129,110 +1167,146 @@ describe('features/modeling/rules - BpmnRules', function() {
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
|
||||||
it('not attach IntermediateEvent to CompensationTask', inject(function(elementFactory) {
|
it('not attach IntermediateEvent to CompensationTask', inject(
|
||||||
|
function(elementFactory) {
|
||||||
|
|
||||||
// given
|
// given
|
||||||
var eventShape = elementFactory.createShape({
|
var eventShape = elementFactory.createShape({
|
||||||
type: 'bpmn:IntermediateThrowEvent',
|
type: 'bpmn:IntermediateThrowEvent',
|
||||||
x: 413, y: 254
|
x: 413, y: 254
|
||||||
});
|
});
|
||||||
|
|
||||||
// then
|
// then
|
||||||
expectCanMove([ eventShape ], 'CompensationTask', {
|
expectCanMove([ eventShape ], 'CompensationTask', {
|
||||||
attach: false,
|
attach: false,
|
||||||
move: false
|
move: false
|
||||||
});
|
});
|
||||||
}));
|
}
|
||||||
|
));
|
||||||
|
|
||||||
|
|
||||||
it('attach IntermediateEvent to SubProcess inner', inject(function(elementFactory, elementRegistry, bpmnRules) {
|
it('attach IntermediateEvent to SubProcess inner', inject(
|
||||||
|
function(elementFactory, elementRegistry, bpmnRules) {
|
||||||
|
|
||||||
// given
|
// given
|
||||||
var subProcessElement = elementRegistry.get('SubProcess_1');
|
var subProcessElement = elementRegistry.get('SubProcess_1');
|
||||||
var eventShape = elementFactory.createShape({
|
var eventShape = elementFactory.createShape({
|
||||||
type: 'bpmn:IntermediateThrowEvent',
|
type: 'bpmn:IntermediateThrowEvent',
|
||||||
x: 413, y: 350
|
x: 413, y: 350
|
||||||
});
|
});
|
||||||
|
|
||||||
var position = {
|
var position = {
|
||||||
x: subProcessElement.x + subProcessElement.width / 2,
|
x: subProcessElement.x + subProcessElement.width / 2,
|
||||||
y: subProcessElement.y + subProcessElement.height / 2
|
y: subProcessElement.y + subProcessElement.height / 2
|
||||||
};
|
};
|
||||||
|
|
||||||
// when
|
// when
|
||||||
var canAttach = bpmnRules.canAttach([ eventShape ], subProcessElement, null, position);
|
var canAttach = bpmnRules.canAttach(
|
||||||
|
[ eventShape ],
|
||||||
|
subProcessElement,
|
||||||
|
null,
|
||||||
|
position
|
||||||
|
);
|
||||||
|
|
||||||
// then
|
// then
|
||||||
expect(canAttach).to.be.false;
|
expect(canAttach).to.be.false;
|
||||||
}));
|
}
|
||||||
|
));
|
||||||
|
|
||||||
|
|
||||||
it('attach IntermediateEvent to SubProcess border', inject(function(elementFactory, elementRegistry, bpmnRules) {
|
it('attach IntermediateEvent to SubProcess border', inject(
|
||||||
|
function(elementFactory, elementRegistry, bpmnRules) {
|
||||||
|
|
||||||
// given
|
// given
|
||||||
var subProcessElement = elementRegistry.get('SubProcess_1');
|
var subProcessElement = elementRegistry.get('SubProcess_1');
|
||||||
var eventShape = elementFactory.createShape({
|
var eventShape = elementFactory.createShape({
|
||||||
type: 'bpmn:IntermediateThrowEvent',
|
type: 'bpmn:IntermediateThrowEvent',
|
||||||
x: 0, y: 0
|
x: 0, y: 0
|
||||||
});
|
});
|
||||||
|
|
||||||
var position = {
|
var position = {
|
||||||
x: subProcessElement.x + subProcessElement.width / 2,
|
x: subProcessElement.x + subProcessElement.width / 2,
|
||||||
y: subProcessElement.y + subProcessElement.height
|
y: subProcessElement.y + subProcessElement.height
|
||||||
};
|
};
|
||||||
|
|
||||||
// when
|
// when
|
||||||
var canAttach = bpmnRules.canAttach([ eventShape ], subProcessElement, null, position);
|
var canAttach = bpmnRules.canAttach(
|
||||||
|
[ eventShape ],
|
||||||
|
subProcessElement,
|
||||||
|
null,
|
||||||
|
position
|
||||||
|
);
|
||||||
|
|
||||||
// then
|
// then
|
||||||
expect(canAttach).to.equal('attach');
|
expect(canAttach).to.equal('attach');
|
||||||
}));
|
}
|
||||||
|
));
|
||||||
|
|
||||||
|
|
||||||
it('not attach IntermediateEvent to compensation activity', inject(function(elementFactory, elementRegistry, bpmnRules) {
|
it('not attach IntermediateEvent to compensation activity', inject(
|
||||||
|
function(elementFactory, elementRegistry, bpmnRules) {
|
||||||
|
|
||||||
// given
|
// given
|
||||||
var compensationTask = elementRegistry.get('CompensationTask');
|
var compensationTask = elementRegistry.get('CompensationTask');
|
||||||
var eventShape = elementFactory.createShape({
|
var eventShape = elementFactory.createShape({
|
||||||
type: 'bpmn:IntermediateThrowEvent',
|
type: 'bpmn:IntermediateThrowEvent',
|
||||||
x: 0, y: 0
|
x: 0, y: 0
|
||||||
});
|
});
|
||||||
|
|
||||||
var position = {
|
var position = {
|
||||||
x: compensationTask.x + compensationTask.width / 2,
|
x: compensationTask.x + compensationTask.width / 2,
|
||||||
y: compensationTask.y + compensationTask.height
|
y: compensationTask.y + compensationTask.height
|
||||||
};
|
};
|
||||||
|
|
||||||
// when
|
// when
|
||||||
var canAttach = bpmnRules.canAttach([ eventShape ], compensationTask, null, position);
|
var canAttach = bpmnRules.canAttach(
|
||||||
|
[ eventShape ],
|
||||||
|
compensationTask,
|
||||||
|
null,
|
||||||
|
position
|
||||||
|
);
|
||||||
|
|
||||||
// then
|
// then
|
||||||
expect(canAttach).to.be.false;
|
expect(canAttach).to.be.false;
|
||||||
}));
|
}
|
||||||
|
));
|
||||||
|
|
||||||
|
|
||||||
it('create IntermediateEvent in SubProcess body', inject(function(elementFactory, elementRegistry, bpmnRules) {
|
it('create IntermediateEvent in SubProcess body', inject(
|
||||||
|
function(elementFactory, elementRegistry, bpmnRules) {
|
||||||
|
|
||||||
// given
|
// given
|
||||||
var subProcessElement = elementRegistry.get('SubProcess_1');
|
var subProcessElement = elementRegistry.get('SubProcess_1');
|
||||||
var eventShape = elementFactory.createShape({
|
var eventShape = elementFactory.createShape({
|
||||||
type: 'bpmn:IntermediateThrowEvent',
|
type: 'bpmn:IntermediateThrowEvent',
|
||||||
x: 413, y: 250
|
x: 413, y: 250
|
||||||
});
|
});
|
||||||
|
|
||||||
var position = {
|
var position = {
|
||||||
x: eventShape.x,
|
x: eventShape.x,
|
||||||
y: eventShape.y
|
y: eventShape.y
|
||||||
};
|
};
|
||||||
|
|
||||||
// when
|
// when
|
||||||
var canAttach = bpmnRules.canAttach([ eventShape ], subProcessElement, null, position),
|
var canAttach = bpmnRules.canAttach(
|
||||||
canCreate = bpmnRules.canCreate(eventShape, subProcessElement, null, position);
|
[ eventShape ],
|
||||||
|
subProcessElement,
|
||||||
|
null,
|
||||||
|
position
|
||||||
|
);
|
||||||
|
|
||||||
// then
|
var canCreate = bpmnRules.canCreate(
|
||||||
expect(canAttach).to.be.false;
|
eventShape,
|
||||||
expect(canCreate).to.be.true;
|
subProcessElement,
|
||||||
}));
|
null,
|
||||||
|
position
|
||||||
|
);
|
||||||
|
|
||||||
|
// then
|
||||||
|
expect(canAttach).to.be.false;
|
||||||
|
expect(canCreate).to.be.true;
|
||||||
|
}
|
||||||
|
));
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1244,51 +1318,75 @@ describe('features/modeling/rules - BpmnRules', function() {
|
||||||
beforeEach(bootstrapModeler(testXML, { modules: testModules }));
|
beforeEach(bootstrapModeler(testXML, { modules: testModules }));
|
||||||
|
|
||||||
|
|
||||||
it('append IntermediateEvent from Task', inject(function(elementFactory, elementRegistry, bpmnRules) {
|
it('append IntermediateEvent from Task', inject(
|
||||||
|
function(elementFactory, elementRegistry, bpmnRules) {
|
||||||
|
|
||||||
// given
|
// given
|
||||||
var subProcessElement = elementRegistry.get('SubProcess_1'),
|
var subProcessElement = elementRegistry.get('SubProcess_1'),
|
||||||
taskElement = elementRegistry.get('Task_2');
|
taskElement = elementRegistry.get('Task_2');
|
||||||
|
|
||||||
var eventShape = elementFactory.createShape({
|
var eventShape = elementFactory.createShape({
|
||||||
type: 'bpmn:IntermediateThrowEvent',
|
type: 'bpmn:IntermediateThrowEvent',
|
||||||
x: 413, y: 250
|
x: 413, y: 250
|
||||||
});
|
});
|
||||||
|
|
||||||
var position = {
|
var position = {
|
||||||
x: eventShape.x,
|
x: eventShape.x,
|
||||||
y: eventShape.y
|
y: eventShape.y
|
||||||
};
|
};
|
||||||
|
|
||||||
// when
|
// when
|
||||||
var canAttach = bpmnRules.canAttach([ eventShape ], subProcessElement, taskElement, position),
|
var canAttach = bpmnRules.canAttach(
|
||||||
canCreate = bpmnRules.canCreate(eventShape, subProcessElement, taskElement, position);
|
[ eventShape ],
|
||||||
|
subProcessElement,
|
||||||
|
taskElement,
|
||||||
|
position
|
||||||
|
);
|
||||||
|
|
||||||
// then
|
var canCreate = bpmnRules.canCreate(
|
||||||
expect(canAttach).to.be.false;
|
eventShape,
|
||||||
expect(canCreate).to.be.true;
|
subProcessElement,
|
||||||
}));
|
taskElement,
|
||||||
|
position
|
||||||
|
);
|
||||||
|
|
||||||
|
// then
|
||||||
|
expect(canAttach).to.be.false;
|
||||||
|
expect(canCreate).to.be.true;
|
||||||
|
}
|
||||||
|
));
|
||||||
|
|
||||||
|
|
||||||
it('append IntermediateEvent from BoundaryEvent', inject(function(elementFactory, elementRegistry, bpmnRules) {
|
it('append IntermediateEvent from BoundaryEvent', inject(
|
||||||
|
function(elementFactory, elementRegistry, bpmnRules) {
|
||||||
|
|
||||||
// given
|
// given
|
||||||
var boundaryElement = elementRegistry.get('BoundaryEvent_1'),
|
var boundaryElement = elementRegistry.get('BoundaryEvent_1'),
|
||||||
taskElement = elementRegistry.get('Task_2');
|
taskElement = elementRegistry.get('Task_2');
|
||||||
|
|
||||||
var eventShape = elementFactory.createShape({
|
var eventShape = elementFactory.createShape({
|
||||||
type: 'bpmn:IntermediateThrowEvent',
|
type: 'bpmn:IntermediateThrowEvent',
|
||||||
x: 413, y: 250
|
x: 413, y: 250
|
||||||
});
|
});
|
||||||
|
|
||||||
// when
|
// when
|
||||||
var canAttach = bpmnRules.canAttach([ eventShape ], taskElement, boundaryElement),
|
var canAttach = bpmnRules.canAttach(
|
||||||
canCreate = bpmnRules.canCreate(eventShape, taskElement, boundaryElement);
|
[ eventShape ],
|
||||||
|
taskElement,
|
||||||
|
boundaryElement
|
||||||
|
);
|
||||||
|
|
||||||
// then
|
var canCreate = bpmnRules.canCreate(
|
||||||
expect(canAttach).to.be.false;
|
eventShape,
|
||||||
expect(canCreate).to.be.false;
|
taskElement,
|
||||||
}));
|
boundaryElement
|
||||||
|
);
|
||||||
|
|
||||||
|
// then
|
||||||
|
expect(canAttach).to.be.false;
|
||||||
|
expect(canCreate).to.be.false;
|
||||||
|
}
|
||||||
|
));
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue