mirror of
https://github.com/sartography/bpmn-js.git
synced 2025-01-11 17:44:12 +00:00
fix(rules): fix modeling rules for event based gateways
Allow condition and signal catching events after event based gateways. close #213
This commit is contained in:
parent
f527096ac2
commit
225cbb914c
@ -49,8 +49,8 @@ ModelingRules.prototype.init = function() {
|
|||||||
targetBo.eventDefinitions && (
|
targetBo.eventDefinitions && (
|
||||||
targetBo.eventDefinitions[0].$type === 'bpmn:MessageEventDefinition' ||
|
targetBo.eventDefinitions[0].$type === 'bpmn:MessageEventDefinition' ||
|
||||||
targetBo.eventDefinitions[0].$type === 'bpmn:TimerEventDefinition' ||
|
targetBo.eventDefinitions[0].$type === 'bpmn:TimerEventDefinition' ||
|
||||||
targetBo.eventDefinitions[0].$type === 'bpmn:ConditionEventDefinition' ||
|
targetBo.eventDefinitions[0].$type === 'bpmn:ConditionalEventDefinition' ||
|
||||||
targetBo.eventDefinitions[0].$type === 'bpmn:SignalConditionEventDefinition')) {
|
targetBo.eventDefinitions[0].$type === 'bpmn:SignalEventDefinition')) {
|
||||||
|
|
||||||
eventBasedGatewayCheck = false;
|
eventBasedGatewayCheck = false;
|
||||||
}
|
}
|
||||||
|
72
test/fixtures/bpmn/features/rules/event-based-gateway-outgoing-edge.bpmn
vendored
Normal file
72
test/fixtures/bpmn/features/rules/event-based-gateway-outgoing-edge.bpmn
vendored
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL"
|
||||||
|
xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI"
|
||||||
|
xmlns:di="http://www.omg.org/spec/DD/20100524/DI"
|
||||||
|
xmlns:dc="http://www.omg.org/spec/DD/20100524/DC"
|
||||||
|
id="Definitions_1"
|
||||||
|
targetNamespace="http://bpmn.io/schema/bpmn">
|
||||||
|
<bpmn:process id="Process_1" isExecutable="false">
|
||||||
|
<bpmn:eventBasedGateway id="EventBasedGateway_1" name="" />
|
||||||
|
<bpmn:intermediateThrowEvent id="IntermediateThrowEvent_0" />
|
||||||
|
<bpmn:intermediateCatchEvent id="IntermediateCatchEvent_0" name="">
|
||||||
|
<bpmn:messageEventDefinition />
|
||||||
|
</bpmn:intermediateCatchEvent>
|
||||||
|
<bpmn:intermediateCatchEvent id="IntermediateCatchEvent_1" name="">
|
||||||
|
<bpmn:timerEventDefinition />
|
||||||
|
</bpmn:intermediateCatchEvent>
|
||||||
|
<bpmn:intermediateCatchEvent id="IntermediateCatchEvent_2" name="">
|
||||||
|
<bpmn:conditionalEventDefinition />
|
||||||
|
</bpmn:intermediateCatchEvent>
|
||||||
|
<bpmn:intermediateCatchEvent id="IntermediateCatchEvent_3" name="">
|
||||||
|
<bpmn:signalEventDefinition />
|
||||||
|
</bpmn:intermediateCatchEvent>
|
||||||
|
<bpmn:receiveTask id="ReceiveTask_1" name="" />
|
||||||
|
<bpmn:task id="Task_1" />
|
||||||
|
</bpmn:process>
|
||||||
|
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
|
||||||
|
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Process_1">
|
||||||
|
<bpmndi:BPMNShape id="EventBasedGateway_1_di" bpmnElement="EventBasedGateway_1">
|
||||||
|
<dc:Bounds x="46" y="147" width="50" height="50" />
|
||||||
|
<bpmndi:BPMNLabel>
|
||||||
|
<dc:Bounds x="26" y="197" width="90" height="20" />
|
||||||
|
</bpmndi:BPMNLabel>
|
||||||
|
</bpmndi:BPMNShape>
|
||||||
|
<bpmndi:BPMNShape id="IntermediateThrowEvent_0_di" bpmnElement="IntermediateThrowEvent_0">
|
||||||
|
<dc:Bounds x="216" y="36" width="36" height="36" />
|
||||||
|
<bpmndi:BPMNLabel>
|
||||||
|
<dc:Bounds x="189" y="72" width="90" height="20" />
|
||||||
|
</bpmndi:BPMNLabel>
|
||||||
|
</bpmndi:BPMNShape>
|
||||||
|
<bpmndi:BPMNShape id="IntermediateCatchEvent_0_di" bpmnElement="IntermediateCatchEvent_0">
|
||||||
|
<dc:Bounds x="216" y="96" width="36" height="36" />
|
||||||
|
<bpmndi:BPMNLabel>
|
||||||
|
<dc:Bounds x="189" y="132" width="90" height="20" />
|
||||||
|
</bpmndi:BPMNLabel>
|
||||||
|
</bpmndi:BPMNShape>
|
||||||
|
<bpmndi:BPMNShape id="IntermediateCatchEvent_1_di" bpmnElement="IntermediateCatchEvent_1">
|
||||||
|
<dc:Bounds x="216" y="154" width="36" height="36" />
|
||||||
|
<bpmndi:BPMNLabel>
|
||||||
|
<dc:Bounds x="189" y="190" width="90" height="20" />
|
||||||
|
</bpmndi:BPMNLabel>
|
||||||
|
</bpmndi:BPMNShape>
|
||||||
|
<bpmndi:BPMNShape id="IntermediateCatchEvent_2_di" bpmnElement="IntermediateCatchEvent_2">
|
||||||
|
<dc:Bounds x="216" y="218" width="36" height="36" />
|
||||||
|
<bpmndi:BPMNLabel>
|
||||||
|
<dc:Bounds x="189" y="254" width="90" height="20" />
|
||||||
|
</bpmndi:BPMNLabel>
|
||||||
|
</bpmndi:BPMNShape>
|
||||||
|
<bpmndi:BPMNShape id="IntermediateCatchEvent_3_di" bpmnElement="IntermediateCatchEvent_3">
|
||||||
|
<dc:Bounds x="216" y="287" width="36" height="36" />
|
||||||
|
<bpmndi:BPMNLabel>
|
||||||
|
<dc:Bounds x="189" y="323" width="90" height="20" />
|
||||||
|
</bpmndi:BPMNLabel>
|
||||||
|
</bpmndi:BPMNShape>
|
||||||
|
<bpmndi:BPMNShape id="ReceiveTask_1_di" bpmnElement="ReceiveTask_1">
|
||||||
|
<dc:Bounds x="184" y="377" width="100" height="80" />
|
||||||
|
</bpmndi:BPMNShape>
|
||||||
|
<bpmndi:BPMNShape id="Task_1_di" bpmnElement="Task_1">
|
||||||
|
<dc:Bounds x="184" y="483" width="100" height="80" />
|
||||||
|
</bpmndi:BPMNShape>
|
||||||
|
</bpmndi:BPMNPlane>
|
||||||
|
</bpmndi:BPMNDiagram>
|
||||||
|
</bpmn:definitions>
|
@ -19,23 +19,23 @@ describe('features/ModelingRules', function() {
|
|||||||
beforeEach(Matchers.addDeepEquals);
|
beforeEach(Matchers.addDeepEquals);
|
||||||
|
|
||||||
|
|
||||||
var diagramXML = fs.readFileSync('test/fixtures/bpmn/sequence-flows.bpmn', 'utf8');
|
var sequenceXML = fs.readFileSync('test/fixtures/bpmn/sequence-flows.bpmn', 'utf8');
|
||||||
|
var eventGatewaysEdgeXML =
|
||||||
|
fs.readFileSync('test/fixtures/bpmn/features/rules/event-based-gateway-outgoing-edge.bpmn', 'utf8');
|
||||||
|
|
||||||
var testModules = [ coreModule, modelingModule, rulesModule ];
|
var testModules = [ coreModule, modelingModule, rulesModule ];
|
||||||
|
|
||||||
beforeEach(bootstrapModeler(diagramXML, { modules: testModules }));
|
|
||||||
|
|
||||||
|
|
||||||
// See workaround https://github.com/bpmn-io/bpmn-js/issues/176
|
// See workaround https://github.com/bpmn-io/bpmn-js/issues/176
|
||||||
// The wanted behavior until https://github.com/bpmn-io/bpmn-js/issues/176 is fixed
|
// The wanted behavior until https://github.com/bpmn-io/bpmn-js/issues/176 is fixed
|
||||||
describe('connect with source == target', function() {
|
describe('connect with source == target', function() {
|
||||||
|
|
||||||
|
beforeEach(bootstrapModeler(sequenceXML, { modules: testModules }));
|
||||||
|
|
||||||
it('should not allow connection', inject(function(elementRegistry, modeling, rules) {
|
it('should not allow connection', inject(function(elementRegistry, modeling, rules) {
|
||||||
|
|
||||||
// given
|
// given
|
||||||
var taskShape = elementRegistry.get('Task_1'),
|
var taskShape = elementRegistry.get('Task_1');
|
||||||
task = taskShape.businessObject;
|
|
||||||
|
|
||||||
|
|
||||||
// when
|
// when
|
||||||
var allowed = rules.allowed('connection.create', {
|
var allowed = rules.allowed('connection.create', {
|
||||||
@ -49,4 +49,143 @@ describe('features/ModelingRules', function() {
|
|||||||
expect(allowed).toBe(false);
|
expect(allowed).toBe(false);
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('eventbased gateway', function() {
|
||||||
|
|
||||||
|
beforeEach(bootstrapModeler(eventGatewaysEdgeXML, { modules: testModules }));
|
||||||
|
|
||||||
|
it('should allow catching message intermediate event on outgoing edges', inject(function(elementRegistry, modeling, rules) {
|
||||||
|
|
||||||
|
// given
|
||||||
|
var eventGateway = elementRegistry.get('EventBasedGateway_1'),
|
||||||
|
messageEvent = elementRegistry.get('IntermediateCatchEvent_0');
|
||||||
|
|
||||||
|
|
||||||
|
// when
|
||||||
|
var allowed = rules.allowed('connection.create', {
|
||||||
|
connection: null,
|
||||||
|
source: eventGateway,
|
||||||
|
target: messageEvent
|
||||||
|
});
|
||||||
|
|
||||||
|
// then
|
||||||
|
// connection should not be allowed
|
||||||
|
expect(allowed).toBe(true);
|
||||||
|
}));
|
||||||
|
|
||||||
|
it('should allow catching timer intermediate event on outgoing edges', inject(function(elementRegistry, modeling, rules) {
|
||||||
|
|
||||||
|
// given
|
||||||
|
var eventGateway = elementRegistry.get('EventBasedGateway_1'),
|
||||||
|
timerEvent = elementRegistry.get('IntermediateCatchEvent_1');
|
||||||
|
|
||||||
|
|
||||||
|
// when
|
||||||
|
var allowed = rules.allowed('connection.create', {
|
||||||
|
connection: null,
|
||||||
|
source: eventGateway,
|
||||||
|
target: timerEvent
|
||||||
|
});
|
||||||
|
|
||||||
|
// then
|
||||||
|
// connection should not be allowed
|
||||||
|
expect(allowed).toBe(true);
|
||||||
|
}));
|
||||||
|
|
||||||
|
it('should allow catching condition intermediate event on outgoing edges', inject(function(elementRegistry, modeling, rules) {
|
||||||
|
|
||||||
|
// given
|
||||||
|
var eventGateway = elementRegistry.get('EventBasedGateway_1'),
|
||||||
|
conditionEvent = elementRegistry.get('IntermediateCatchEvent_2');
|
||||||
|
|
||||||
|
|
||||||
|
// when
|
||||||
|
var allowed = rules.allowed('connection.create', {
|
||||||
|
connection: null,
|
||||||
|
source: eventGateway,
|
||||||
|
target: conditionEvent
|
||||||
|
});
|
||||||
|
|
||||||
|
// then
|
||||||
|
// connection should not be allowed
|
||||||
|
expect(allowed).toBe(true);
|
||||||
|
}));
|
||||||
|
|
||||||
|
it('should allow catching signal intermediate event on outgoing edges', inject(function(elementRegistry, modeling, rules) {
|
||||||
|
|
||||||
|
// given
|
||||||
|
var eventGateway = elementRegistry.get('EventBasedGateway_1'),
|
||||||
|
signalEvent = elementRegistry.get('IntermediateCatchEvent_3');
|
||||||
|
|
||||||
|
|
||||||
|
// when
|
||||||
|
var allowed = rules.allowed('connection.create', {
|
||||||
|
connection: null,
|
||||||
|
source: eventGateway,
|
||||||
|
target: signalEvent
|
||||||
|
});
|
||||||
|
|
||||||
|
// then
|
||||||
|
// connection should not be allowed
|
||||||
|
expect(allowed).toBe(true);
|
||||||
|
}));
|
||||||
|
|
||||||
|
it('should allow receive task on outgoing edges', inject(function(elementRegistry, modeling, rules) {
|
||||||
|
|
||||||
|
// given
|
||||||
|
var eventGateway = elementRegistry.get('EventBasedGateway_1'),
|
||||||
|
receiveTask = elementRegistry.get('ReceiveTask_1');
|
||||||
|
|
||||||
|
|
||||||
|
// when
|
||||||
|
var allowed = rules.allowed('connection.create', {
|
||||||
|
connection: null,
|
||||||
|
source: eventGateway,
|
||||||
|
target: receiveTask
|
||||||
|
});
|
||||||
|
|
||||||
|
// then
|
||||||
|
// connection should not be allowed
|
||||||
|
expect(allowed).toBe(true);
|
||||||
|
}));
|
||||||
|
|
||||||
|
it('should not allow throw event on outgoing edges', inject(function(elementRegistry, modeling, rules) {
|
||||||
|
|
||||||
|
// given
|
||||||
|
var eventGateway = elementRegistry.get('EventBasedGateway_1'),
|
||||||
|
throwEvent = elementRegistry.get('IntermediateThrowEvent_0');
|
||||||
|
|
||||||
|
|
||||||
|
// when
|
||||||
|
var allowed = rules.allowed('connection.create', {
|
||||||
|
connection: null,
|
||||||
|
source: eventGateway,
|
||||||
|
target: throwEvent
|
||||||
|
});
|
||||||
|
|
||||||
|
// then
|
||||||
|
// connection should not be allowed
|
||||||
|
expect(allowed).toBe(false);
|
||||||
|
}));
|
||||||
|
|
||||||
|
it('should not allow task on outgoing edges', inject(function(elementRegistry, modeling, rules) {
|
||||||
|
|
||||||
|
// given
|
||||||
|
var eventGateway = elementRegistry.get('EventBasedGateway_1'),
|
||||||
|
task = elementRegistry.get('Task_1');
|
||||||
|
|
||||||
|
|
||||||
|
// when
|
||||||
|
var allowed = rules.allowed('connection.create', {
|
||||||
|
connection: null,
|
||||||
|
source: eventGateway,
|
||||||
|
target: task
|
||||||
|
});
|
||||||
|
|
||||||
|
// then
|
||||||
|
// connection should not be allowed
|
||||||
|
expect(allowed).toBe(false);
|
||||||
|
}));
|
||||||
|
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user