2014-05-21 14:23:52 +00:00
|
|
|
'use strict';
|
|
|
|
|
2014-10-30 11:06:43 +00:00
|
|
|
var TestHelper = require('../../TestHelper');
|
2014-06-18 09:45:30 +00:00
|
|
|
|
2015-07-15 06:50:21 +00:00
|
|
|
/* global bootstrapViewer, inject */
|
|
|
|
|
|
|
|
|
2015-07-15 15:22:19 +00:00
|
|
|
var TestContainer = require('mocha-test-container-support');
|
2014-06-18 09:45:30 +00:00
|
|
|
|
2014-06-11 12:41:55 +00:00
|
|
|
var Diagram = require('diagram-js/lib/Diagram'),
|
2014-08-04 14:32:11 +00:00
|
|
|
BpmnModdle = require('bpmn-moddle'),
|
2014-08-01 05:16:59 +00:00
|
|
|
Importer = require('../../../lib/import/Importer'),
|
|
|
|
Viewer = require('../../../lib/Viewer');
|
2014-04-03 09:47:26 +00:00
|
|
|
|
2014-05-21 14:23:52 +00:00
|
|
|
|
2015-07-15 06:50:21 +00:00
|
|
|
var is = require('../../../lib/util/ModelUtil').is;
|
|
|
|
|
2015-04-21 12:22:03 +00:00
|
|
|
describe('import - Importer', function() {
|
2014-04-03 09:47:26 +00:00
|
|
|
|
2014-08-04 14:32:11 +00:00
|
|
|
var moddle = new BpmnModdle();
|
2014-04-03 09:47:26 +00:00
|
|
|
|
2014-06-18 09:45:30 +00:00
|
|
|
var container;
|
2014-04-03 09:47:26 +00:00
|
|
|
|
|
|
|
beforeEach(function() {
|
2015-07-15 15:22:19 +00:00
|
|
|
container = TestContainer.get(this);
|
2014-04-03 09:47:26 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
function createDiagram() {
|
|
|
|
return new Diagram({
|
|
|
|
canvas: { container: container },
|
2014-06-30 14:58:23 +00:00
|
|
|
modules: Viewer.prototype._modules
|
2014-04-03 09:47:26 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2014-06-23 12:44:03 +00:00
|
|
|
var diagram;
|
2014-05-21 14:23:52 +00:00
|
|
|
|
2014-06-23 12:44:03 +00:00
|
|
|
beforeEach(function() {
|
|
|
|
diagram = createDiagram();
|
|
|
|
});
|
2014-04-03 09:47:26 +00:00
|
|
|
|
|
|
|
|
2014-06-23 12:44:03 +00:00
|
|
|
function runImport(diagram, xml, done) {
|
2014-08-04 14:32:11 +00:00
|
|
|
moddle.fromXML(xml, function(err, definitions) {
|
2014-04-03 09:47:26 +00:00
|
|
|
if (err) {
|
|
|
|
return done(err);
|
|
|
|
}
|
|
|
|
|
2014-06-23 12:44:03 +00:00
|
|
|
Importer.importBpmnDiagram(diagram, definitions, done);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
describe('event emitter', function() {
|
|
|
|
|
2015-07-15 06:50:21 +00:00
|
|
|
it('should fire <bpmnElement.added> during import', function(done) {
|
2014-06-23 12:44:03 +00:00
|
|
|
|
|
|
|
// given
|
2015-07-15 06:50:21 +00:00
|
|
|
var xml = require('../../fixtures/bpmn/import/process.bpmn');
|
2014-06-23 12:44:03 +00:00
|
|
|
|
2014-07-01 09:33:28 +00:00
|
|
|
var eventCount = 0;
|
2014-06-23 12:44:03 +00:00
|
|
|
|
|
|
|
// log events
|
2014-07-16 14:15:23 +00:00
|
|
|
diagram.get('eventBus').on('bpmnElement.added', function(e) {
|
2014-07-01 09:33:28 +00:00
|
|
|
eventCount++;
|
2014-06-23 12:44:03 +00:00
|
|
|
});
|
|
|
|
|
2014-04-03 09:47:26 +00:00
|
|
|
// when
|
2014-06-23 12:44:03 +00:00
|
|
|
runImport(diagram, xml, function(err, warnings) {
|
2014-04-03 09:47:26 +00:00
|
|
|
|
|
|
|
// then
|
2015-07-15 15:22:19 +00:00
|
|
|
expect(eventCount).to.equal(9);
|
2014-04-03 09:47:26 +00:00
|
|
|
|
|
|
|
done(err);
|
|
|
|
});
|
|
|
|
});
|
2014-06-23 12:44:03 +00:00
|
|
|
|
2014-04-03 09:47:26 +00:00
|
|
|
});
|
|
|
|
|
2014-06-18 11:05:32 +00:00
|
|
|
|
2014-06-23 12:44:03 +00:00
|
|
|
describe('basics', function() {
|
2014-06-18 11:05:32 +00:00
|
|
|
|
2015-07-15 06:50:21 +00:00
|
|
|
it('should import process', function(done) {
|
2014-06-18 11:05:32 +00:00
|
|
|
|
2014-06-23 12:44:03 +00:00
|
|
|
// given
|
2015-07-15 06:50:21 +00:00
|
|
|
var xml = require('../../fixtures/bpmn/import/process.bpmn');
|
2014-06-18 11:05:32 +00:00
|
|
|
|
2014-06-23 12:44:03 +00:00
|
|
|
var events = [];
|
2014-06-18 11:05:32 +00:00
|
|
|
|
2014-06-23 12:44:03 +00:00
|
|
|
// log events
|
2014-07-16 14:15:23 +00:00
|
|
|
diagram.get('eventBus').on('bpmnElement.added', function(e) {
|
2014-07-01 09:33:28 +00:00
|
|
|
events.push({
|
|
|
|
type: 'add',
|
2014-07-16 14:15:23 +00:00
|
|
|
semantic: e.element.businessObject.id,
|
|
|
|
di: e.element.businessObject.di.id,
|
|
|
|
diagramElement: e.element && e.element.id
|
2014-07-01 09:33:28 +00:00
|
|
|
});
|
2014-06-23 12:44:03 +00:00
|
|
|
});
|
2014-06-18 11:05:32 +00:00
|
|
|
|
|
|
|
// when
|
2014-06-23 12:44:03 +00:00
|
|
|
runImport(diagram, xml, function(err, warnings) {
|
|
|
|
|
|
|
|
// then
|
2015-07-15 15:22:19 +00:00
|
|
|
expect(events).to.eql([
|
2014-11-28 10:38:06 +00:00
|
|
|
{ type: 'add', semantic: 'Process_1', di: 'BPMNPlane_1', diagramElement: 'Process_1' },
|
|
|
|
{ type: 'add', semantic: 'SubProcess_1', di: '_BPMNShape_SubProcess_2', diagramElement: 'SubProcess_1' },
|
|
|
|
{ type: 'add', semantic: 'StartEvent_1', di: '_BPMNShape_StartEvent_2', diagramElement: 'StartEvent_1' },
|
|
|
|
{ type: 'add', semantic: 'Task_1', di: '_BPMNShape_Task_2', diagramElement: 'Task_1' },
|
|
|
|
{ type: 'add', semantic: 'EndEvent_1', di: '_BPMNShape_EndEvent_2', diagramElement: 'EndEvent_1' },
|
|
|
|
{ type: 'add', semantic: 'StartEvent_2', di: '_BPMNShape_StartEvent_11', diagramElement: 'StartEvent_2' },
|
|
|
|
{ type: 'add', semantic: 'SequenceFlow_1', di: 'BPMNEdge_SequenceFlow_1', diagramElement: 'SequenceFlow_1' },
|
|
|
|
{ type: 'add', semantic: 'SequenceFlow_2', di: 'BPMNEdge_SequenceFlow_2', diagramElement: 'SequenceFlow_2' },
|
|
|
|
{ type: 'add', semantic: 'SequenceFlow_3', di: 'BPMNEdge_SequenceFlow_3', diagramElement: 'SequenceFlow_3' }
|
2014-06-23 12:44:03 +00:00
|
|
|
]);
|
|
|
|
|
|
|
|
done(err);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
it('should import collaboration', function(done) {
|
|
|
|
|
|
|
|
// given
|
2015-07-15 06:50:21 +00:00
|
|
|
var xml = require('../../fixtures/bpmn/import/collaboration.bpmn');
|
2014-06-23 12:44:03 +00:00
|
|
|
|
|
|
|
var events = [];
|
|
|
|
|
|
|
|
// log events
|
2014-07-16 14:15:23 +00:00
|
|
|
diagram.get('eventBus').on('bpmnElement.added', function(e) {
|
2014-07-01 09:33:28 +00:00
|
|
|
events.push({
|
|
|
|
type: 'add',
|
2014-07-16 14:15:23 +00:00
|
|
|
semantic: e.element.businessObject.id,
|
|
|
|
di: e.element.businessObject.di.id,
|
|
|
|
diagramElement: e.element && e.element.id
|
2014-07-01 09:33:28 +00:00
|
|
|
});
|
2014-06-23 12:44:03 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
// when
|
|
|
|
runImport(diagram, xml, function(err, warnings) {
|
|
|
|
|
|
|
|
// then
|
2015-07-15 15:22:19 +00:00
|
|
|
expect(events).to.eql([
|
2014-07-16 14:15:23 +00:00
|
|
|
{ type: 'add', semantic: '_Collaboration_2', di: 'BPMNPlane_1', diagramElement: '_Collaboration_2' },
|
2014-06-23 12:44:03 +00:00
|
|
|
{ type: 'add', semantic: 'Participant_2', di: '_BPMNShape_Participant_2', diagramElement: 'Participant_2' },
|
|
|
|
{ type: 'add', semantic: 'Lane_1', di: '_BPMNShape_Lane_2', diagramElement: 'Lane_1' },
|
|
|
|
{ type: 'add', semantic: 'Lane_2', di: '_BPMNShape_Lane_3', diagramElement: 'Lane_2' },
|
|
|
|
{ type: 'add', semantic: 'Lane_3', di: '_BPMNShape_Lane_4', diagramElement: 'Lane_3' },
|
|
|
|
{ type: 'add', semantic: 'Task_1', di: '_BPMNShape_Task_3', diagramElement: 'Task_1' },
|
|
|
|
{ type: 'add', semantic: 'Participant_1', di: '_BPMNShape_Participant_3', diagramElement: 'Participant_1' },
|
|
|
|
{ type: 'add', semantic: 'StartEvent_1', di: '_BPMNShape_StartEvent_3', diagramElement: 'StartEvent_1' }
|
|
|
|
]);
|
|
|
|
|
|
|
|
done(err);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2014-07-16 14:15:23 +00:00
|
|
|
|
2015-07-15 06:50:21 +00:00
|
|
|
it('should import boundary events', function(done) {
|
2014-07-16 14:15:23 +00:00
|
|
|
|
2015-07-15 06:50:21 +00:00
|
|
|
// given
|
|
|
|
var xml = require('../../fixtures/bpmn/import/boundaryEvent.bpmn');
|
2014-07-16 14:15:23 +00:00
|
|
|
|
2015-07-15 06:50:21 +00:00
|
|
|
var events = [];
|
2014-07-16 14:15:23 +00:00
|
|
|
|
|
|
|
// log events
|
|
|
|
diagram.get('eventBus').on('bpmnElement.added', function(e) {
|
2015-07-15 06:50:21 +00:00
|
|
|
events.push({
|
|
|
|
type: 'add',
|
|
|
|
semantic: e.element.businessObject.id,
|
|
|
|
di: e.element.businessObject.di.id,
|
|
|
|
diagramElement: e.element && e.element.id
|
|
|
|
});
|
2014-07-16 14:15:23 +00:00
|
|
|
});
|
|
|
|
|
2015-07-15 06:50:21 +00:00
|
|
|
// when
|
|
|
|
runImport(diagram, xml, function(err, warnings) {
|
|
|
|
|
|
|
|
// then
|
|
|
|
expect(events).to.eql([
|
|
|
|
{ type: 'add', semantic: 'Process_1', di: 'BPMNPlane_1', diagramElement: 'Process_1'},
|
|
|
|
{ type: 'add', semantic: 'Task_1', di: '_BPMNShape_Task_2', diagramElement: 'Task_1'},
|
|
|
|
{ type: 'add', semantic: 'Task_2', di: '_BPMNShape_Task_3', diagramElement: 'Task_2'},
|
|
|
|
{ type: 'add', semantic: 'BoundaryEvent_1', di: '_BPMNShape_BoundaryEvent_2', diagramElement: 'BoundaryEvent_1'},
|
|
|
|
{ type: 'add', semantic: 'SequenceFlow_1', di: 'BPMNEdge_SequenceFlow_1', diagramElement: 'SequenceFlow_1'}
|
|
|
|
]);
|
|
|
|
|
|
|
|
done(err);
|
|
|
|
});
|
2014-07-16 14:15:23 +00:00
|
|
|
});
|
2015-07-15 06:50:21 +00:00
|
|
|
});
|
2014-06-23 12:44:03 +00:00
|
|
|
|
|
|
|
|
2015-07-15 06:50:21 +00:00
|
|
|
describe('model wiring', function() {
|
2014-11-26 10:49:14 +00:00
|
|
|
|
2015-07-15 06:50:21 +00:00
|
|
|
describe('basics', function() {
|
2014-11-26 10:49:14 +00:00
|
|
|
|
2015-07-15 06:50:21 +00:00
|
|
|
var xml = require('../../fixtures/bpmn/import/process.bpmn');
|
2014-11-26 10:49:14 +00:00
|
|
|
|
2015-07-15 06:50:21 +00:00
|
|
|
beforeEach(bootstrapViewer(xml));
|
2014-11-26 10:49:14 +00:00
|
|
|
|
|
|
|
|
2015-07-15 06:50:21 +00:00
|
|
|
it('should wire root element', inject(function(elementRegistry, canvas) {
|
2014-11-26 10:49:14 +00:00
|
|
|
|
2015-07-15 06:50:21 +00:00
|
|
|
// when
|
|
|
|
var processElement = elementRegistry.get('Process_1');
|
|
|
|
var subProcessShape = elementRegistry.get('SubProcess_1');
|
2014-06-23 12:44:03 +00:00
|
|
|
|
2015-07-15 06:50:21 +00:00
|
|
|
// then
|
|
|
|
expect(subProcessShape.parent).to.eql(processElement);
|
|
|
|
expect(canvas.getRootElement()).to.eql(processElement);
|
2014-06-23 12:44:03 +00:00
|
|
|
|
2015-07-15 06:50:21 +00:00
|
|
|
expect(is(processElement, 'bpmn:Process')).to.be.true;
|
|
|
|
}));
|
2014-08-28 12:27:13 +00:00
|
|
|
|
2014-06-18 11:05:32 +00:00
|
|
|
|
2015-07-15 06:50:21 +00:00
|
|
|
it('should wire parent child relationship', inject(function(elementRegistry) {
|
2014-07-16 14:15:23 +00:00
|
|
|
|
2015-07-15 06:50:21 +00:00
|
|
|
// when
|
|
|
|
var subProcessShape = elementRegistry.get('SubProcess_1');
|
|
|
|
var startEventShape = elementRegistry.get('StartEvent_1');
|
2014-07-16 14:15:23 +00:00
|
|
|
|
2015-07-15 06:50:21 +00:00
|
|
|
// then
|
|
|
|
expect(startEventShape.type).to.equal('bpmn:StartEvent');
|
|
|
|
expect(startEventShape.parent).to.eql(subProcessShape);
|
2014-07-16 14:15:23 +00:00
|
|
|
|
2015-07-15 06:50:21 +00:00
|
|
|
expect(subProcessShape.children.length).to.equal(5);
|
|
|
|
}));
|
2014-07-16 14:15:23 +00:00
|
|
|
|
|
|
|
|
2015-07-15 06:50:21 +00:00
|
|
|
it('should wire label relationship', inject(function(elementRegistry) {
|
2014-07-16 14:15:23 +00:00
|
|
|
|
2015-07-15 06:50:21 +00:00
|
|
|
// when
|
|
|
|
var startEventShape = elementRegistry.get('StartEvent_1');
|
|
|
|
var label = startEventShape.label;
|
2014-07-16 14:15:23 +00:00
|
|
|
|
2015-07-15 06:50:21 +00:00
|
|
|
// then
|
|
|
|
expect(label).to.be.defined;
|
|
|
|
expect(label.id).to.equal(startEventShape.id + '_label');
|
|
|
|
|
|
|
|
expect(label.labelTarget).to.eql(startEventShape);
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
|
|
it('should wire businessObject', inject(function(elementRegistry) {
|
|
|
|
|
|
|
|
// when
|
|
|
|
var subProcessShape = elementRegistry.get('SubProcess_1');
|
|
|
|
var startEventShape = elementRegistry.get('StartEvent_1');
|
|
|
|
|
|
|
|
var subProcess = subProcessShape.businessObject,
|
|
|
|
startEvent = startEventShape.businessObject;
|
|
|
|
|
|
|
|
// then
|
|
|
|
expect(subProcess).to.be.defined;
|
|
|
|
expect(is(subProcess, 'bpmn:SubProcess')).to.be.true;
|
2014-07-16 14:15:23 +00:00
|
|
|
|
2015-07-15 06:50:21 +00:00
|
|
|
expect(startEvent).to.be.defined;
|
|
|
|
expect(is(startEvent, 'bpmn:StartEvent')).to.be.true;
|
|
|
|
}));
|
2014-07-16 14:15:23 +00:00
|
|
|
|
|
|
|
|
2015-07-15 06:50:21 +00:00
|
|
|
it('should wire shape di', inject(function(elementRegistry) {
|
|
|
|
|
|
|
|
// when
|
|
|
|
var subProcessShape = elementRegistry.get('SubProcess_1');
|
|
|
|
|
|
|
|
var subProcess = subProcessShape.businessObject;
|
|
|
|
var subProcessDi = subProcess.di;
|
|
|
|
|
|
|
|
// then
|
|
|
|
expect(subProcessDi).to.be.defined;
|
|
|
|
expect(subProcessDi.bpmnElement).to.eql(subProcess);
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
|
|
it('should wire connection di', inject(function(elementRegistry) {
|
|
|
|
|
|
|
|
// when
|
|
|
|
var sequenceFlowElement = elementRegistry.get('SequenceFlow_1');
|
|
|
|
|
|
|
|
var sequenceFlow = sequenceFlowElement.businessObject;
|
|
|
|
var sequenceFlowDi = sequenceFlow.di;
|
|
|
|
|
|
|
|
// then
|
|
|
|
expect(sequenceFlowDi).to.be.defined;
|
|
|
|
expect(sequenceFlowDi.bpmnElement).to.eql(sequenceFlow);
|
|
|
|
}));
|
|
|
|
|
2014-07-16 14:15:23 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
|
2015-07-15 06:50:21 +00:00
|
|
|
describe('boundary events', function() {
|
2014-07-16 14:15:23 +00:00
|
|
|
|
2015-07-15 06:50:21 +00:00
|
|
|
var xml = require('../../fixtures/bpmn/import/boundaryEvent.bpmn');
|
|
|
|
|
|
|
|
beforeEach(bootstrapViewer(xml));
|
|
|
|
|
|
|
|
|
|
|
|
it('should wire host attacher relationship', inject(function(elementRegistry) {
|
|
|
|
|
|
|
|
// when
|
|
|
|
var boundaryEventShape = elementRegistry.get('BoundaryEvent_1'),
|
|
|
|
boundaryEvent = boundaryEventShape.businessObject;
|
2014-07-16 14:15:23 +00:00
|
|
|
|
2015-07-15 06:50:21 +00:00
|
|
|
var taskShape = elementRegistry.get('Task_1'),
|
|
|
|
task = taskShape.businessObject;
|
2014-07-16 14:15:23 +00:00
|
|
|
|
2015-07-15 06:50:21 +00:00
|
|
|
// assume
|
|
|
|
expect(boundaryEvent.attachedToRef).to.eql(task);
|
2014-07-16 14:15:23 +00:00
|
|
|
|
2015-07-15 06:50:21 +00:00
|
|
|
// then
|
|
|
|
expect(boundaryEventShape.host).to.eql(taskShape);
|
|
|
|
|
|
|
|
expect(taskShape.attachers).to.exist;
|
|
|
|
expect(taskShape.attachers).to.contain(boundaryEventShape);
|
|
|
|
}));
|
2014-07-16 14:15:23 +00:00
|
|
|
|
2014-06-18 11:05:32 +00:00
|
|
|
});
|
2014-06-23 12:44:03 +00:00
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
describe('forgiveness', function() {
|
|
|
|
|
|
|
|
it('should import invalid flowElement', function(done) {
|
|
|
|
|
|
|
|
// given
|
2015-07-15 06:50:21 +00:00
|
|
|
var xml = require('../../fixtures/bpmn/import/error/invalid-flow-element.bpmn');
|
2014-06-23 12:44:03 +00:00
|
|
|
|
|
|
|
// when
|
|
|
|
runImport(diagram, xml, function(err, warnings) {
|
|
|
|
|
2015-07-15 15:22:19 +00:00
|
|
|
expect(warnings.length).to.equal(1);
|
2014-06-23 12:44:03 +00:00
|
|
|
|
|
|
|
done(err);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2014-11-26 19:54:52 +00:00
|
|
|
|
2015-04-21 12:22:03 +00:00
|
|
|
it('should import multiple DIs', function(done) {
|
2014-11-26 19:54:52 +00:00
|
|
|
|
|
|
|
// given
|
2015-07-15 06:50:21 +00:00
|
|
|
var xml = require('../../fixtures/bpmn/import/error/multiple-dis.bpmn');
|
2014-11-26 19:54:52 +00:00
|
|
|
|
|
|
|
// when
|
|
|
|
runImport(diagram, xml, function(err, warnings) {
|
|
|
|
|
2015-02-17 09:55:28 +00:00
|
|
|
var expectedMessage =
|
|
|
|
'multiple DI elements defined for <bpmn:InclusiveGateway id="InclusiveGateway_1" />';
|
|
|
|
|
2015-07-15 15:22:19 +00:00
|
|
|
expect(warnings.length).to.equal(1);
|
|
|
|
expect(warnings[0].message).to.equal(expectedMessage);
|
2014-11-26 19:54:52 +00:00
|
|
|
|
|
|
|
done(err);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
2015-04-21 12:22:03 +00:00
|
|
|
it('should extend attributes with default value', function(done) {
|
2014-08-18 10:38:41 +00:00
|
|
|
|
|
|
|
// given
|
2015-04-21 12:22:03 +00:00
|
|
|
var xml = require('../../fixtures/bpmn/import/default-attrs.bpmn');
|
2014-08-18 10:38:41 +00:00
|
|
|
|
|
|
|
// when
|
|
|
|
runImport(diagram, xml, function(err, warnings) {
|
|
|
|
|
|
|
|
var elementRegistry = diagram.get('elementRegistry');
|
|
|
|
|
2014-11-17 16:36:22 +00:00
|
|
|
var element = elementRegistry.get('GATEWAY_1');
|
2014-08-18 10:38:41 +00:00
|
|
|
|
2015-07-15 15:22:19 +00:00
|
|
|
expect(element.businessObject.eventGatewayType).to.equal('Exclusive');
|
2014-08-18 10:38:41 +00:00
|
|
|
|
|
|
|
done();
|
|
|
|
});
|
2014-10-31 14:05:16 +00:00
|
|
|
});
|
|
|
|
|
2015-07-15 06:50:21 +00:00
|
|
|
|
|
|
|
describe('boundary events', function() {
|
|
|
|
|
|
|
|
it('should handle missing attachToRef', function(done) {
|
|
|
|
|
|
|
|
// given
|
|
|
|
var xml = require('../../fixtures/bpmn/import/error/boundaryEvent-missingAttachToRef.bpmn');
|
|
|
|
|
|
|
|
// when
|
|
|
|
runImport(diagram, xml, function(err, warnings) {
|
|
|
|
|
|
|
|
// then
|
|
|
|
expect(warnings.length).to.eql(2);
|
|
|
|
|
|
|
|
expect(warnings[0].message).to.eql('missing <bpmn:BoundaryEvent id="BoundaryEvent_1" />#attachedToRef');
|
|
|
|
expect(warnings[1].message).to.eql('element <bpmn:BoundaryEvent id="BoundaryEvent_1" /> referenced by <bpmn:SequenceFlow id="SequenceFlow_1" />#sourceRef not yet drawn');
|
|
|
|
|
|
|
|
done(err);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
it('should handle invalid attachToRef', function(done) {
|
|
|
|
|
|
|
|
// given
|
|
|
|
var xml = require('../../fixtures/bpmn/import/error/boundaryEvent-invalidAttachToRef.bpmn');
|
|
|
|
|
|
|
|
// when
|
|
|
|
runImport(diagram, xml, function(err, warnings) {
|
|
|
|
|
|
|
|
// then
|
|
|
|
expect(warnings.length).to.eql(2);
|
|
|
|
|
|
|
|
expect(warnings[0].message).to.eql('missing <bpmn:BoundaryEvent id="BoundaryEvent_1" />#attachedToRef');
|
|
|
|
expect(warnings[1].message).to.eql('element <bpmn:BoundaryEvent id="BoundaryEvent_1" /> referenced by <bpmn:SequenceFlow id="SequenceFlow_1" />#sourceRef not yet drawn');
|
|
|
|
|
|
|
|
done(err);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
|
2014-10-31 14:05:16 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
describe('integration', function() {
|
|
|
|
|
2015-07-20 14:04:58 +00:00
|
|
|
// slightly increase timeout for complex test cases
|
|
|
|
this.timeout(4000);
|
|
|
|
|
|
|
|
|
2014-10-31 14:05:16 +00:00
|
|
|
it('should import complex', function(done) {
|
|
|
|
|
|
|
|
// given
|
2015-03-31 12:17:15 +00:00
|
|
|
var xml = require('../../fixtures/bpmn/complex.bpmn');
|
2014-10-31 14:05:16 +00:00
|
|
|
|
|
|
|
// when
|
|
|
|
runImport(diagram, xml, function(err, warnings) {
|
|
|
|
|
|
|
|
// then
|
2015-07-15 15:22:19 +00:00
|
|
|
expect(warnings.length).to.equal(0);
|
2014-10-31 14:05:16 +00:00
|
|
|
|
|
|
|
done(err);
|
|
|
|
});
|
|
|
|
});
|
2015-01-02 11:56:32 +00:00
|
|
|
|
|
|
|
|
|
|
|
it('should import dangling process message flows', function(done) {
|
|
|
|
|
|
|
|
// given
|
2015-07-15 06:50:21 +00:00
|
|
|
var xml = require('../../fixtures/bpmn/import/error/dangling-process-message-flow.bpmn');
|
2015-01-02 11:56:32 +00:00
|
|
|
|
|
|
|
// when
|
|
|
|
runImport(diagram, xml, function(err, warnings) {
|
|
|
|
|
|
|
|
// then
|
2015-07-15 15:22:19 +00:00
|
|
|
expect(warnings.length).to.equal(0);
|
2015-01-02 11:56:32 +00:00
|
|
|
|
2015-07-15 15:22:19 +00:00
|
|
|
expect(diagram.get('elementRegistry').get('_b467921a-ef7b-44c5-bf78-fd624c400d17')).to.be.defined;
|
|
|
|
expect(diagram.get('elementRegistry').get('_c311cc87-677e-47a4-bdb1-8744c4ec3147')).to.be.defined;
|
2015-01-02 11:56:32 +00:00
|
|
|
|
|
|
|
done(err);
|
|
|
|
});
|
|
|
|
});
|
2015-07-15 06:50:21 +00:00
|
|
|
|
2014-06-18 11:05:32 +00:00
|
|
|
});
|
|
|
|
|
2015-02-17 09:55:28 +00:00
|
|
|
|
2014-12-22 10:44:44 +00:00
|
|
|
describe('position', function() {
|
|
|
|
|
2015-07-15 06:50:21 +00:00
|
|
|
var xml = require('../../fixtures/bpmn/import/position/position-testcase.bpmn');
|
2014-12-22 10:44:44 +00:00
|
|
|
|
|
|
|
it('should round shape\'s x and y coordinates', function(done) {
|
|
|
|
|
|
|
|
// given
|
|
|
|
var events = {};
|
|
|
|
|
|
|
|
// log events
|
|
|
|
diagram.get('eventBus').on('bpmnElement.added', function(e) {
|
|
|
|
|
|
|
|
events[e.element.id] = e.element;
|
|
|
|
});
|
|
|
|
|
2015-07-15 06:50:21 +00:00
|
|
|
runImport(diagram, xml, function(err, warnings) {
|
2014-12-22 10:44:44 +00:00
|
|
|
|
|
|
|
//round up
|
2015-07-15 15:22:19 +00:00
|
|
|
expect(events.ID_End.x).to.equal(Math.round(340.6));
|
|
|
|
expect(events.ID_End.y).to.equal(Math.round(136.6));
|
2014-12-22 10:44:44 +00:00
|
|
|
|
|
|
|
//round down
|
2015-07-15 15:22:19 +00:00
|
|
|
expect(events.ID_Start.x).to.equal(Math.round(120.4));
|
|
|
|
expect(events.ID_Start.y).to.equal(Math.round(135.4));
|
2014-12-22 10:44:44 +00:00
|
|
|
|
|
|
|
done(err);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2015-02-17 09:55:28 +00:00
|
|
|
|
2014-12-22 10:44:44 +00:00
|
|
|
it('should round shape\'s height and width', function(done) {
|
|
|
|
|
|
|
|
// given
|
|
|
|
var events = {};
|
|
|
|
|
|
|
|
// log events
|
|
|
|
diagram.get('eventBus').on('bpmnElement.added', function(e) {
|
|
|
|
|
|
|
|
events[e.element.id] = e.element;
|
|
|
|
});
|
|
|
|
|
2015-07-15 06:50:21 +00:00
|
|
|
runImport(diagram, xml, function(err, warnings) {
|
2014-12-22 10:44:44 +00:00
|
|
|
|
|
|
|
//round down
|
2015-07-15 15:22:19 +00:00
|
|
|
expect(events.ID_Start.height).to.equal(Math.round(30.4));
|
|
|
|
expect(events.ID_Start.width).to.equal(Math.round(30.4));
|
2014-12-22 10:44:44 +00:00
|
|
|
|
|
|
|
done(err);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
2015-02-17 09:55:28 +00:00
|
|
|
|
2014-12-22 10:44:44 +00:00
|
|
|
});
|