2015-04-16 07:11:04 +00:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
var TestHelper = require('../../../../TestHelper');
|
|
|
|
|
|
|
|
/* global bootstrapModeler, inject */
|
|
|
|
|
|
|
|
|
|
|
|
var rulesModule = require('../../../../../lib/features/modeling/rules'),
|
|
|
|
coreModule = require('../../../../../lib/core');
|
|
|
|
|
|
|
|
|
|
|
|
function expectCanConnect(source, target, rules) {
|
|
|
|
|
|
|
|
var results = {};
|
|
|
|
|
|
|
|
TestHelper.getBpmnJS().invoke(function(elementRegistry, bpmnRules) {
|
|
|
|
|
|
|
|
source = elementRegistry.get(source);
|
|
|
|
target = elementRegistry.get(target);
|
|
|
|
|
|
|
|
expect(source).toBeDefined();
|
|
|
|
expect(target).toBeDefined();
|
|
|
|
|
|
|
|
if ('sequenceFlow' in rules) {
|
|
|
|
results.sequenceFlow = bpmnRules.canConnectSequenceFlow(source, target);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ('messageFlow' in rules) {
|
|
|
|
results.messageFlow = bpmnRules.canConnectMessageFlow(source, target);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ('association' in rules) {
|
|
|
|
results.association = bpmnRules.canConnectAssociation(source, target);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
expect(results).toEqual(rules);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function expectCanDrop(element, target, expectedResult) {
|
|
|
|
|
|
|
|
var result;
|
|
|
|
|
|
|
|
TestHelper.getBpmnJS().invoke(function(elementRegistry, bpmnRules) {
|
|
|
|
|
|
|
|
element = elementRegistry.get(element);
|
|
|
|
target = elementRegistry.get(target);
|
|
|
|
|
|
|
|
expect(element).toBeDefined();
|
|
|
|
expect(target).toBeDefined();
|
|
|
|
|
|
|
|
result = bpmnRules.canDrop(element, target);
|
|
|
|
});
|
|
|
|
|
|
|
|
expect(result).toEqual(expectedResult);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
describe('features/modeling/rules - BpmnRules', function() {
|
|
|
|
|
|
|
|
var testModules = [ coreModule, rulesModule ];
|
|
|
|
|
|
|
|
|
|
|
|
describe('on process diagram', function() {
|
|
|
|
|
|
|
|
var testXML = require('./BpmnRules.process.bpmn');
|
|
|
|
|
|
|
|
beforeEach(bootstrapModeler(testXML, { modules: testModules }));
|
|
|
|
|
|
|
|
|
2015-05-12 16:03:51 +00:00
|
|
|
it('connect StartEvent_None -> Task', inject(function() {
|
2015-04-16 07:11:04 +00:00
|
|
|
|
|
|
|
expectCanConnect('StartEvent_None', 'Task', {
|
|
|
|
sequenceFlow: true,
|
|
|
|
messageFlow: false,
|
|
|
|
association: true
|
|
|
|
});
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
2015-05-12 16:03:51 +00:00
|
|
|
it('connect StartEvent_None -> TextAnnotation', inject(function() {
|
2015-04-16 07:11:04 +00:00
|
|
|
|
|
|
|
expectCanConnect('StartEvent_None', 'TextAnnotation', {
|
|
|
|
sequenceFlow: false,
|
|
|
|
messageFlow: false,
|
|
|
|
association: true
|
|
|
|
});
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
2015-05-12 16:03:51 +00:00
|
|
|
it('connect Task -> IntermediateThrowEvent_Link', inject(function() {
|
2015-04-16 07:11:04 +00:00
|
|
|
|
|
|
|
expectCanConnect('Task', 'IntermediateThrowEvent_Link', {
|
|
|
|
sequenceFlow: true,
|
|
|
|
messageFlow: false,
|
|
|
|
association: true
|
|
|
|
});
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
2015-05-12 16:03:51 +00:00
|
|
|
it('connect IntermediateThrowEvent_Link -> EndEvent_None', inject(function() {
|
2015-04-16 07:11:04 +00:00
|
|
|
|
|
|
|
expectCanConnect('IntermediateThrowEvent_Link', 'EndEvent_None', {
|
|
|
|
sequenceFlow: false,
|
|
|
|
messageFlow: false,
|
|
|
|
association: true
|
|
|
|
});
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
2015-05-12 16:03:51 +00:00
|
|
|
it('connect StartEvent_None -> IntermediateCatchEvent_Link', inject(function() {
|
2015-04-16 07:11:04 +00:00
|
|
|
|
|
|
|
expectCanConnect('StartEvent_None', 'IntermediateCatchEvent_Link', {
|
|
|
|
sequenceFlow: false,
|
|
|
|
messageFlow: false,
|
|
|
|
association: true
|
|
|
|
});
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
2015-05-12 16:03:51 +00:00
|
|
|
it('connect IntermediateCatchEvent_Link -> Task', inject(function() {
|
2015-04-16 07:11:04 +00:00
|
|
|
|
|
|
|
expectCanConnect('IntermediateCatchEvent_Link', 'Task', {
|
|
|
|
sequenceFlow: true,
|
|
|
|
messageFlow: false,
|
|
|
|
association: true
|
|
|
|
});
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
2015-05-12 16:03:51 +00:00
|
|
|
it('drop TextAnnotation -> Process', inject(function() {
|
2015-04-16 07:11:04 +00:00
|
|
|
|
|
|
|
expectCanDrop('TextAnnotation', 'Process', true);
|
|
|
|
}));
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
describe('event based gateway', function() {
|
|
|
|
|
|
|
|
var testXML = require('./BpmnRules.eventBasedGateway.bpmn');
|
|
|
|
|
|
|
|
beforeEach(bootstrapModeler(testXML, { modules: testModules }));
|
|
|
|
|
|
|
|
|
2015-05-12 16:03:51 +00:00
|
|
|
it('connect EventBasedGateway -> IntermediateCatchEvent_Message', inject(function() {
|
2015-04-16 07:11:04 +00:00
|
|
|
|
|
|
|
expectCanConnect('EventBasedGateway', 'IntermediateCatchEvent_Message', {
|
|
|
|
sequenceFlow: true,
|
|
|
|
messageFlow: false,
|
|
|
|
association: true
|
|
|
|
});
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
2015-05-12 16:03:51 +00:00
|
|
|
it('connect EventBasedGateway -> IntermediateCatchEvent_Message', inject(function() {
|
2015-04-16 07:11:04 +00:00
|
|
|
|
|
|
|
expectCanConnect('EventBasedGateway', 'IntermediateCatchEvent_Message', {
|
|
|
|
sequenceFlow: true,
|
|
|
|
messageFlow: false,
|
|
|
|
association: true
|
|
|
|
});
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
2015-05-12 16:03:51 +00:00
|
|
|
it('connect EventBasedGateway -> IntermediateCatchEvent_Signal', inject(function() {
|
2015-04-16 07:11:04 +00:00
|
|
|
|
|
|
|
expectCanConnect('EventBasedGateway', 'IntermediateCatchEvent_Signal', {
|
|
|
|
sequenceFlow: true,
|
|
|
|
messageFlow: false,
|
|
|
|
association: true
|
|
|
|
});
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
2015-05-12 16:03:51 +00:00
|
|
|
it('connect EventBasedGateway -> IntermediateCatchEvent_Condition', inject(function() {
|
2015-04-16 07:11:04 +00:00
|
|
|
|
|
|
|
expectCanConnect('EventBasedGateway', 'IntermediateCatchEvent_Condition', {
|
|
|
|
sequenceFlow: true,
|
|
|
|
messageFlow: false,
|
|
|
|
association: true
|
|
|
|
});
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
2015-05-12 16:03:51 +00:00
|
|
|
it('connect EventBasedGateway -> IntermediateCatchEvent_Timer', inject(function() {
|
2015-04-16 07:11:04 +00:00
|
|
|
|
|
|
|
expectCanConnect('EventBasedGateway', 'IntermediateCatchEvent_Timer', {
|
|
|
|
sequenceFlow: true,
|
|
|
|
messageFlow: false,
|
|
|
|
association: true
|
|
|
|
});
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
2015-05-12 16:03:51 +00:00
|
|
|
it('connect EventBasedGateway -> IntermediateCatchEvent', inject(function() {
|
2015-04-16 07:11:04 +00:00
|
|
|
|
|
|
|
expectCanConnect('EventBasedGateway', 'IntermediateCatchEvent', {
|
|
|
|
sequenceFlow: false,
|
|
|
|
messageFlow: false,
|
|
|
|
association: true
|
|
|
|
});
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
2015-05-12 16:03:51 +00:00
|
|
|
it('connect EventBasedGateway -> IntermediateThrowEvent_Message', inject(function() {
|
2015-04-16 07:11:04 +00:00
|
|
|
|
|
|
|
expectCanConnect('EventBasedGateway', 'IntermediateThrowEvent_Message', {
|
|
|
|
sequenceFlow: false,
|
|
|
|
messageFlow: false,
|
|
|
|
association: true
|
|
|
|
});
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
2015-05-12 16:03:51 +00:00
|
|
|
it('connect EventBasedGateway -> ReceiveTask', inject(function() {
|
2015-04-16 07:11:04 +00:00
|
|
|
|
|
|
|
expectCanConnect('EventBasedGateway', 'ReceiveTask', {
|
|
|
|
sequenceFlow: true,
|
|
|
|
messageFlow: false,
|
|
|
|
association: true
|
|
|
|
});
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
2015-05-12 16:03:51 +00:00
|
|
|
it('connect EventBasedGateway -> Task_None', inject(function() {
|
2015-04-16 07:11:04 +00:00
|
|
|
|
|
|
|
expectCanConnect('EventBasedGateway', 'Task_None', {
|
|
|
|
sequenceFlow: false,
|
|
|
|
messageFlow: false,
|
|
|
|
association: true
|
|
|
|
});
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
2015-05-12 16:03:51 +00:00
|
|
|
it('connect EventBasedGateway -> ParallelGateway', inject(function() {
|
2015-04-16 07:11:04 +00:00
|
|
|
|
|
|
|
expectCanConnect('EventBasedGateway', 'ParallelGateway', {
|
|
|
|
sequenceFlow: false,
|
|
|
|
messageFlow: false,
|
|
|
|
association: true
|
|
|
|
});
|
|
|
|
}));
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
describe('on collaboration diagram', function() {
|
|
|
|
|
|
|
|
var testXML = require('./BpmnRules.collaboration.bpmn');
|
|
|
|
|
|
|
|
beforeEach(bootstrapModeler(testXML, { modules: testModules }));
|
|
|
|
|
|
|
|
|
2015-05-12 16:03:51 +00:00
|
|
|
it('connect StartEvent_None -> IntermediateEvent', inject(function() {
|
2015-04-16 07:11:04 +00:00
|
|
|
|
|
|
|
expectCanConnect('StartEvent_None', 'IntermediateThrowEvent_Message', {
|
|
|
|
sequenceFlow: true,
|
|
|
|
messageFlow: false,
|
|
|
|
association: true
|
|
|
|
});
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
2015-05-12 16:03:51 +00:00
|
|
|
it('connect StartEvent_None -> OtherParticipant', inject(function() {
|
2015-04-16 07:11:04 +00:00
|
|
|
|
|
|
|
expectCanConnect('StartEvent_None', 'OtherParticipant', {
|
|
|
|
sequenceFlow: false,
|
|
|
|
messageFlow: false,
|
|
|
|
association: true
|
|
|
|
});
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
2015-05-12 16:03:51 +00:00
|
|
|
it('connect OtherParticipant -> StartEvent_None', inject(function() {
|
2015-04-16 07:11:04 +00:00
|
|
|
|
|
|
|
expectCanConnect('OtherParticipant', 'StartEvent_None', {
|
|
|
|
sequenceFlow: false,
|
|
|
|
messageFlow: true,
|
|
|
|
association: true
|
|
|
|
});
|
|
|
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
2015-05-12 16:03:51 +00:00
|
|
|
it('connect OtherParticipant -> StartEvent_Timer', inject(function() {
|
2015-05-11 15:55:06 +00:00
|
|
|
|
|
|
|
expectCanConnect('OtherParticipant', 'StartEvent_Timer', {
|
|
|
|
sequenceFlow: false,
|
|
|
|
messageFlow: false,
|
|
|
|
association: true
|
|
|
|
});
|
|
|
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
2015-05-12 16:03:51 +00:00
|
|
|
it('connect OtherParticipant -> StartEvent_Message', inject(function() {
|
2015-05-11 15:55:06 +00:00
|
|
|
|
|
|
|
expectCanConnect('OtherParticipant', 'StartEvent_Message', {
|
|
|
|
sequenceFlow: false,
|
|
|
|
messageFlow: true,
|
|
|
|
association: true
|
|
|
|
});
|
|
|
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
2015-05-12 16:03:51 +00:00
|
|
|
it('connect EndEvent_None -> OtherParticipant', inject(function() {
|
2015-04-16 07:11:04 +00:00
|
|
|
|
|
|
|
expectCanConnect('EndEvent_None', 'OtherParticipant', {
|
|
|
|
sequenceFlow: false,
|
|
|
|
messageFlow: true,
|
|
|
|
association: true
|
|
|
|
});
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
2015-05-12 16:03:51 +00:00
|
|
|
it('connect EndEvent_Cancel -> OtherParticipant', inject(function() {
|
2015-05-11 15:55:06 +00:00
|
|
|
|
|
|
|
expectCanConnect('EndEvent_Cancel', 'OtherParticipant', {
|
|
|
|
sequenceFlow: false,
|
|
|
|
messageFlow: false,
|
|
|
|
association: true
|
|
|
|
});
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
2015-05-12 16:03:51 +00:00
|
|
|
it('connect EndEvent_Message -> OtherParticipant', inject(function() {
|
2015-05-11 15:55:06 +00:00
|
|
|
|
|
|
|
expectCanConnect('EndEvent_Message', 'OtherParticipant', {
|
|
|
|
sequenceFlow: false,
|
|
|
|
messageFlow: true,
|
|
|
|
association: true
|
|
|
|
});
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
2015-05-12 16:03:51 +00:00
|
|
|
it('connect OtherParticipant -> EndEvent_None', inject(function() {
|
2015-04-16 07:11:04 +00:00
|
|
|
|
|
|
|
expectCanConnect('OtherParticipant', 'EndEvent_None', {
|
|
|
|
sequenceFlow: false,
|
|
|
|
messageFlow: false,
|
|
|
|
association: true
|
|
|
|
});
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
2015-05-12 16:03:51 +00:00
|
|
|
it('connect IntermediateThrowEvent_Message -> OtherParticipant', inject(function() {
|
2015-04-16 07:11:04 +00:00
|
|
|
|
|
|
|
expectCanConnect('IntermediateThrowEvent_Message', 'OtherParticipant', {
|
|
|
|
sequenceFlow: false,
|
|
|
|
messageFlow: true,
|
|
|
|
association: true
|
|
|
|
});
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
2015-05-12 16:03:51 +00:00
|
|
|
it('connect IntermediateThrowEvent_None -> OtherParticipant', inject(function() {
|
2015-05-11 15:55:06 +00:00
|
|
|
|
|
|
|
expectCanConnect('IntermediateThrowEvent_None', 'OtherParticipant', {
|
|
|
|
sequenceFlow: false,
|
|
|
|
messageFlow: true,
|
|
|
|
association: true
|
|
|
|
});
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
2015-05-12 16:03:51 +00:00
|
|
|
it('connect IntermediateThrowEvent_Signal -> OtherParticipant', inject(function() {
|
2015-05-11 15:55:06 +00:00
|
|
|
|
|
|
|
expectCanConnect('IntermediateThrowEvent_Signal', 'OtherParticipant', {
|
|
|
|
sequenceFlow: false,
|
|
|
|
messageFlow: false,
|
|
|
|
association: true
|
|
|
|
});
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
2015-05-12 16:03:51 +00:00
|
|
|
it('connect OtherParticipant -> IntermediateThrowEvent_Message', inject(function() {
|
2015-04-16 07:11:04 +00:00
|
|
|
|
|
|
|
expectCanConnect('OtherParticipant', 'IntermediateThrowEvent_Message', {
|
|
|
|
sequenceFlow: false,
|
|
|
|
messageFlow: false,
|
|
|
|
association: true
|
|
|
|
});
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
2015-05-12 16:03:51 +00:00
|
|
|
it('connect Task_in_SubProcess -> OtherParticipant', inject(function() {
|
2015-04-16 07:11:04 +00:00
|
|
|
|
|
|
|
expectCanConnect('Task_in_SubProcess', 'OtherParticipant', {
|
|
|
|
sequenceFlow: false,
|
|
|
|
messageFlow: true,
|
|
|
|
association: true
|
|
|
|
});
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
2015-05-12 16:03:51 +00:00
|
|
|
it('connect EndEvent_None_in_SubProcess -> OtherParticipant', inject(function() {
|
2015-05-11 15:55:06 +00:00
|
|
|
|
|
|
|
expectCanConnect('EndEvent_None_in_SubProcess', 'OtherParticipant', {
|
|
|
|
sequenceFlow: false,
|
|
|
|
messageFlow: true,
|
|
|
|
association: true
|
|
|
|
});
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
2015-05-12 16:03:51 +00:00
|
|
|
it('connect OtherParticipant -> Task_in_SubProcess', inject(function() {
|
2015-04-16 07:11:04 +00:00
|
|
|
|
|
|
|
expectCanConnect('OtherParticipant', 'Task_in_SubProcess', {
|
|
|
|
sequenceFlow: false,
|
|
|
|
messageFlow: true,
|
|
|
|
association: true
|
|
|
|
});
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
2015-05-12 16:03:51 +00:00
|
|
|
it('connect Participant -> OtherParticipant', inject(function() {
|
2015-04-16 07:11:04 +00:00
|
|
|
|
|
|
|
expectCanConnect('Participant', 'OtherParticipant', {
|
|
|
|
sequenceFlow: false,
|
|
|
|
messageFlow: true,
|
|
|
|
association: true
|
|
|
|
});
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
2015-05-12 16:03:51 +00:00
|
|
|
it('connect StartEvent_None -> TextAnnotation_OtherParticipant', inject(function() {
|
2015-04-16 07:11:04 +00:00
|
|
|
|
|
|
|
expectCanConnect('StartEvent_None', 'TextAnnotation_OtherParticipant', {
|
|
|
|
sequenceFlow: false,
|
|
|
|
messageFlow: false,
|
|
|
|
association: true
|
|
|
|
});
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
2015-05-12 16:03:51 +00:00
|
|
|
it('connect StartEvent_None -> TextAnnotation_Global', inject(function() {
|
2015-04-16 07:11:04 +00:00
|
|
|
|
|
|
|
expectCanConnect('StartEvent_None', 'TextAnnotation_Global', {
|
|
|
|
sequenceFlow: false,
|
|
|
|
messageFlow: false,
|
|
|
|
association: true
|
|
|
|
});
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
2015-05-12 16:03:51 +00:00
|
|
|
it('drop TextAnnotation_Global -> Participant', inject(function() {
|
2015-04-16 07:11:04 +00:00
|
|
|
|
|
|
|
expectCanDrop('TextAnnotation_Global', 'Participant', true);
|
|
|
|
}));
|
|
|
|
|
|
|
|
});
|
|
|
|
|
2015-05-12 16:03:51 +00:00
|
|
|
|
|
|
|
describe('message flows', function() {
|
|
|
|
|
|
|
|
var testXML = require('./BpmnRules.messageFlow.bpmn');
|
|
|
|
|
|
|
|
beforeEach(bootstrapModeler(testXML, { modules: testModules }));
|
|
|
|
|
|
|
|
|
|
|
|
it('drop MessageFlow -> Collaboration', inject(function() {
|
|
|
|
|
|
|
|
expectCanDrop('MessageFlow', 'Collaboration', true);
|
|
|
|
}));
|
|
|
|
|
|
|
|
});
|
|
|
|
|
2015-04-16 07:11:04 +00:00
|
|
|
});
|