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) {
|
||||
return (
|
||||
is(element, 'bpmn:InteractionNode') &&
|
||||
!isForCompensation(element) && (
|
||||
is(element, 'bpmn:InteractionNode') && (
|
||||
!is(element, 'bpmn:Event') || (
|
||||
is(element, 'bpmn:ThrowEvent') &&
|
||||
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() {
|
||||
|
||||
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
|
||||
var boundaryEvent = elementRegistry.get('BoundaryEvent_1'),
|
||||
label = boundaryEvent.label;
|
||||
// when
|
||||
var boundaryEvent = elementRegistry.get('BoundaryEvent_1'),
|
||||
label = boundaryEvent.label;
|
||||
|
||||
var elements = [ label ];
|
||||
var elements = [ label ];
|
||||
|
||||
// then
|
||||
expectCanMove(elements, 'SubProcess_1', {
|
||||
attach: false,
|
||||
move: true
|
||||
});
|
||||
// then
|
||||
expectCanMove(elements, 'SubProcess_1', {
|
||||
attach: false,
|
||||
move: true
|
||||
});
|
||||
|
||||
}));
|
||||
}
|
||||
));
|
||||
|
||||
|
||||
it('attach/move multiple BoundaryEvents -> SubProcess_1', inject(function(elementRegistry) {
|
||||
// when
|
||||
var boundaryEvent = elementRegistry.get('BoundaryEvent_1'),
|
||||
boundaryEvent2 = elementRegistry.get('BoundaryEvent_2');
|
||||
it('attach/move multiple BoundaryEvents -> SubProcess_1', inject(
|
||||
function(elementRegistry) {
|
||||
// when
|
||||
var boundaryEvent = elementRegistry.get('BoundaryEvent_1'),
|
||||
boundaryEvent2 = elementRegistry.get('BoundaryEvent_2');
|
||||
|
||||
// we assume boundary events and labels
|
||||
// to be already filtered during move
|
||||
var elements = [ boundaryEvent, boundaryEvent2 ];
|
||||
// we assume boundary events and labels
|
||||
// to be already filtered during move
|
||||
var elements = [ boundaryEvent, boundaryEvent2 ];
|
||||
|
||||
// then
|
||||
expectCanMove(elements, 'SubProcess_1', {
|
||||
attach: false,
|
||||
move: false
|
||||
});
|
||||
}));
|
||||
// then
|
||||
expectCanMove(elements, 'SubProcess_1', {
|
||||
attach: false,
|
||||
move: false
|
||||
});
|
||||
}
|
||||
));
|
||||
|
||||
|
||||
it('attach/move SubProcess, BoundaryEvent and label -> Process', inject(function(elementRegistry) {
|
||||
// when
|
||||
var subProcess = elementRegistry.get('SubProcess_1'),
|
||||
boundaryEvent = elementRegistry.get('BoundaryEvent_1'),
|
||||
label = boundaryEvent.label;
|
||||
it('attach/move SubProcess, BoundaryEvent and label -> Process', inject(
|
||||
function(elementRegistry) {
|
||||
// when
|
||||
var subProcess = elementRegistry.get('SubProcess_1'),
|
||||
boundaryEvent = elementRegistry.get('BoundaryEvent_1'),
|
||||
label = boundaryEvent.label;
|
||||
|
||||
// we assume boundary events and labels
|
||||
// to be already filtered during move
|
||||
var elements = [ subProcess, boundaryEvent, label ];
|
||||
// we assume boundary events and labels
|
||||
// to be already filtered during move
|
||||
var elements = [ subProcess, boundaryEvent, label ];
|
||||
|
||||
// then
|
||||
expectCanMove(elements, 'Process_1', {
|
||||
attach: false,
|
||||
move: false
|
||||
});
|
||||
}));
|
||||
// then
|
||||
expectCanMove(elements, 'Process_1', {
|
||||
attach: 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
|
||||
var eventShape = elementFactory.createShape({
|
||||
type: 'bpmn:IntermediateThrowEvent',
|
||||
x: 413, y: 254
|
||||
});
|
||||
// given
|
||||
var eventShape = elementFactory.createShape({
|
||||
type: 'bpmn:IntermediateThrowEvent',
|
||||
x: 413, y: 254
|
||||
});
|
||||
|
||||
// then
|
||||
expectCanMove([ eventShape ], 'CompensationTask', {
|
||||
attach: false,
|
||||
move: false
|
||||
});
|
||||
}));
|
||||
// then
|
||||
expectCanMove([ eventShape ], 'CompensationTask', {
|
||||
attach: 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
|
||||
var subProcessElement = elementRegistry.get('SubProcess_1');
|
||||
var eventShape = elementFactory.createShape({
|
||||
type: 'bpmn:IntermediateThrowEvent',
|
||||
x: 413, y: 350
|
||||
});
|
||||
// given
|
||||
var subProcessElement = elementRegistry.get('SubProcess_1');
|
||||
var eventShape = elementFactory.createShape({
|
||||
type: 'bpmn:IntermediateThrowEvent',
|
||||
x: 413, y: 350
|
||||
});
|
||||
|
||||
var position = {
|
||||
x: subProcessElement.x + subProcessElement.width / 2,
|
||||
y: subProcessElement.y + subProcessElement.height / 2
|
||||
};
|
||||
var position = {
|
||||
x: subProcessElement.x + subProcessElement.width / 2,
|
||||
y: subProcessElement.y + subProcessElement.height / 2
|
||||
};
|
||||
|
||||
// when
|
||||
var canAttach = bpmnRules.canAttach([ eventShape ], subProcessElement, null, position);
|
||||
// when
|
||||
var canAttach = bpmnRules.canAttach(
|
||||
[ eventShape ],
|
||||
subProcessElement,
|
||||
null,
|
||||
position
|
||||
);
|
||||
|
||||
// then
|
||||
expect(canAttach).to.be.false;
|
||||
}));
|
||||
// then
|
||||
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
|
||||
var subProcessElement = elementRegistry.get('SubProcess_1');
|
||||
var eventShape = elementFactory.createShape({
|
||||
type: 'bpmn:IntermediateThrowEvent',
|
||||
x: 0, y: 0
|
||||
});
|
||||
// given
|
||||
var subProcessElement = elementRegistry.get('SubProcess_1');
|
||||
var eventShape = elementFactory.createShape({
|
||||
type: 'bpmn:IntermediateThrowEvent',
|
||||
x: 0, y: 0
|
||||
});
|
||||
|
||||
var position = {
|
||||
x: subProcessElement.x + subProcessElement.width / 2,
|
||||
y: subProcessElement.y + subProcessElement.height
|
||||
};
|
||||
var position = {
|
||||
x: subProcessElement.x + subProcessElement.width / 2,
|
||||
y: subProcessElement.y + subProcessElement.height
|
||||
};
|
||||
|
||||
// when
|
||||
var canAttach = bpmnRules.canAttach([ eventShape ], subProcessElement, null, position);
|
||||
// when
|
||||
var canAttach = bpmnRules.canAttach(
|
||||
[ eventShape ],
|
||||
subProcessElement,
|
||||
null,
|
||||
position
|
||||
);
|
||||
|
||||
// then
|
||||
expect(canAttach).to.equal('attach');
|
||||
}));
|
||||
// then
|
||||
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
|
||||
var compensationTask = elementRegistry.get('CompensationTask');
|
||||
var eventShape = elementFactory.createShape({
|
||||
type: 'bpmn:IntermediateThrowEvent',
|
||||
x: 0, y: 0
|
||||
});
|
||||
// given
|
||||
var compensationTask = elementRegistry.get('CompensationTask');
|
||||
var eventShape = elementFactory.createShape({
|
||||
type: 'bpmn:IntermediateThrowEvent',
|
||||
x: 0, y: 0
|
||||
});
|
||||
|
||||
var position = {
|
||||
x: compensationTask.x + compensationTask.width / 2,
|
||||
y: compensationTask.y + compensationTask.height
|
||||
};
|
||||
var position = {
|
||||
x: compensationTask.x + compensationTask.width / 2,
|
||||
y: compensationTask.y + compensationTask.height
|
||||
};
|
||||
|
||||
// when
|
||||
var canAttach = bpmnRules.canAttach([ eventShape ], compensationTask, null, position);
|
||||
// when
|
||||
var canAttach = bpmnRules.canAttach(
|
||||
[ eventShape ],
|
||||
compensationTask,
|
||||
null,
|
||||
position
|
||||
);
|
||||
|
||||
// then
|
||||
expect(canAttach).to.be.false;
|
||||
}));
|
||||
// then
|
||||
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
|
||||
var subProcessElement = elementRegistry.get('SubProcess_1');
|
||||
var eventShape = elementFactory.createShape({
|
||||
type: 'bpmn:IntermediateThrowEvent',
|
||||
x: 413, y: 250
|
||||
});
|
||||
// given
|
||||
var subProcessElement = elementRegistry.get('SubProcess_1');
|
||||
var eventShape = elementFactory.createShape({
|
||||
type: 'bpmn:IntermediateThrowEvent',
|
||||
x: 413, y: 250
|
||||
});
|
||||
|
||||
var position = {
|
||||
x: eventShape.x,
|
||||
y: eventShape.y
|
||||
};
|
||||
var position = {
|
||||
x: eventShape.x,
|
||||
y: eventShape.y
|
||||
};
|
||||
|
||||
// when
|
||||
var canAttach = bpmnRules.canAttach([ eventShape ], subProcessElement, null, position),
|
||||
canCreate = bpmnRules.canCreate(eventShape, subProcessElement, null, position);
|
||||
// when
|
||||
var canAttach = bpmnRules.canAttach(
|
||||
[ eventShape ],
|
||||
subProcessElement,
|
||||
null,
|
||||
position
|
||||
);
|
||||
|
||||
// then
|
||||
expect(canAttach).to.be.false;
|
||||
expect(canCreate).to.be.true;
|
||||
}));
|
||||
var canCreate = bpmnRules.canCreate(
|
||||
eventShape,
|
||||
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 }));
|
||||
|
||||
|
||||
it('append IntermediateEvent from Task', inject(function(elementFactory, elementRegistry, bpmnRules) {
|
||||
it('append IntermediateEvent from Task', inject(
|
||||
function(elementFactory, elementRegistry, bpmnRules) {
|
||||
|
||||
// given
|
||||
var subProcessElement = elementRegistry.get('SubProcess_1'),
|
||||
taskElement = elementRegistry.get('Task_2');
|
||||
// given
|
||||
var subProcessElement = elementRegistry.get('SubProcess_1'),
|
||||
taskElement = elementRegistry.get('Task_2');
|
||||
|
||||
var eventShape = elementFactory.createShape({
|
||||
type: 'bpmn:IntermediateThrowEvent',
|
||||
x: 413, y: 250
|
||||
});
|
||||
var eventShape = elementFactory.createShape({
|
||||
type: 'bpmn:IntermediateThrowEvent',
|
||||
x: 413, y: 250
|
||||
});
|
||||
|
||||
var position = {
|
||||
x: eventShape.x,
|
||||
y: eventShape.y
|
||||
};
|
||||
var position = {
|
||||
x: eventShape.x,
|
||||
y: eventShape.y
|
||||
};
|
||||
|
||||
// when
|
||||
var canAttach = bpmnRules.canAttach([ eventShape ], subProcessElement, taskElement, position),
|
||||
canCreate = bpmnRules.canCreate(eventShape, subProcessElement, taskElement, position);
|
||||
// when
|
||||
var canAttach = bpmnRules.canAttach(
|
||||
[ eventShape ],
|
||||
subProcessElement,
|
||||
taskElement,
|
||||
position
|
||||
);
|
||||
|
||||
// then
|
||||
expect(canAttach).to.be.false;
|
||||
expect(canCreate).to.be.true;
|
||||
}));
|
||||
var canCreate = bpmnRules.canCreate(
|
||||
eventShape,
|
||||
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
|
||||
var boundaryElement = elementRegistry.get('BoundaryEvent_1'),
|
||||
taskElement = elementRegistry.get('Task_2');
|
||||
// given
|
||||
var boundaryElement = elementRegistry.get('BoundaryEvent_1'),
|
||||
taskElement = elementRegistry.get('Task_2');
|
||||
|
||||
var eventShape = elementFactory.createShape({
|
||||
type: 'bpmn:IntermediateThrowEvent',
|
||||
x: 413, y: 250
|
||||
});
|
||||
var eventShape = elementFactory.createShape({
|
||||
type: 'bpmn:IntermediateThrowEvent',
|
||||
x: 413, y: 250
|
||||
});
|
||||
|
||||
// when
|
||||
var canAttach = bpmnRules.canAttach([ eventShape ], taskElement, boundaryElement),
|
||||
canCreate = bpmnRules.canCreate(eventShape, taskElement, boundaryElement);
|
||||
// when
|
||||
var canAttach = bpmnRules.canAttach(
|
||||
[ eventShape ],
|
||||
taskElement,
|
||||
boundaryElement
|
||||
);
|
||||
|
||||
// then
|
||||
expect(canAttach).to.be.false;
|
||||
expect(canCreate).to.be.false;
|
||||
}));
|
||||
var canCreate = bpmnRules.canCreate(
|
||||
eventShape,
|
||||
taskElement,
|
||||
boundaryElement
|
||||
);
|
||||
|
||||
// then
|
||||
expect(canAttach).to.be.false;
|
||||
expect(canCreate).to.be.false;
|
||||
}
|
||||
));
|
||||
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in New Issue