fix(import): import elements with missing #flowNodeRef
We now properly import lane children with missing #flowNodeRef. Closes #340
This commit is contained in:
parent
34bd632544
commit
f8d6658c10
|
@ -37,7 +37,7 @@ function findDisplayCandidate(definitions) {
|
||||||
function BpmnTreeWalker(handler) {
|
function BpmnTreeWalker(handler) {
|
||||||
|
|
||||||
// list of containers already walked
|
// list of containers already walked
|
||||||
var handledProcesses = [];
|
var handledElements = {};
|
||||||
|
|
||||||
// list of elements to handle deferred to ensure
|
// list of elements to handle deferred to ensure
|
||||||
// prerequisites are drawn
|
// prerequisites are drawn
|
||||||
|
@ -51,6 +51,14 @@ function BpmnTreeWalker(handler) {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function handled(element) {
|
||||||
|
handledElements[element.id] = element;
|
||||||
|
}
|
||||||
|
|
||||||
|
function isHandled(element) {
|
||||||
|
return handledElements[element.id];
|
||||||
|
}
|
||||||
|
|
||||||
function visit(element, ctx) {
|
function visit(element, ctx) {
|
||||||
|
|
||||||
var gfx = element.gfx;
|
var gfx = element.gfx;
|
||||||
|
@ -69,8 +77,13 @@ function BpmnTreeWalker(handler) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function visitIfDi(element, ctx) {
|
function visitIfDi(element, ctx) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return element.di && visit(element, ctx);
|
var gfx = element.di && visit(element, ctx);
|
||||||
|
|
||||||
|
handled(element);
|
||||||
|
|
||||||
|
return gfx;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
logError(e.message, { element: element, error: e });
|
logError(e.message, { element: element, error: e });
|
||||||
|
|
||||||
|
@ -194,7 +207,7 @@ function BpmnTreeWalker(handler) {
|
||||||
handleArtifacts(process.artifacts, context);
|
handleArtifacts(process.artifacts, context);
|
||||||
|
|
||||||
// log process handled
|
// log process handled
|
||||||
handledProcesses.push(process);
|
handled(process);
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleUnhandledProcesses(rootElements) {
|
function handleUnhandledProcesses(rootElements) {
|
||||||
|
@ -203,7 +216,7 @@ function BpmnTreeWalker(handler) {
|
||||||
// if they contain lanes with DI information.
|
// if they contain lanes with DI information.
|
||||||
// we do this to pass the free-floating lane test cases in the MIWG test suite
|
// we do this to pass the free-floating lane test cases in the MIWG test suite
|
||||||
var processes = filter(rootElements, function(e) {
|
var processes = filter(rootElements, function(e) {
|
||||||
return is(e, 'bpmn:Process') && e.laneSets && handledProcesses.indexOf(e) === -1;
|
return !isHandled(e) && is(e, 'bpmn:Process') && e.laneSets;
|
||||||
});
|
});
|
||||||
|
|
||||||
processes.forEach(contextual(handleProcess));
|
processes.forEach(contextual(handleProcess));
|
||||||
|
@ -272,6 +285,17 @@ function BpmnTreeWalker(handler) {
|
||||||
if (is(flowNode, 'bpmn:SubProcess')) {
|
if (is(flowNode, 'bpmn:SubProcess')) {
|
||||||
handleSubProcess(flowNode, childCtx || context);
|
handleSubProcess(flowNode, childCtx || context);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (is(flowNode, 'bpmn:Activity')) {
|
||||||
|
|
||||||
|
handleIoSpecification(flowNode.ioSpecification, context);
|
||||||
|
|
||||||
|
// defer handling of associations
|
||||||
|
deferred.push(function() {
|
||||||
|
forEach(flowNode.dataInputAssociations, contextual(handleDataAssociation, context));
|
||||||
|
forEach(flowNode.dataOutputAssociations, contextual(handleDataAssociation, context));
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleSequenceFlow(sequenceFlow, context) {
|
function handleSequenceFlow(sequenceFlow, context) {
|
||||||
|
@ -311,7 +335,7 @@ function BpmnTreeWalker(handler) {
|
||||||
|
|
||||||
if (container.laneSets) {
|
if (container.laneSets) {
|
||||||
handleLaneSets(container.laneSets, context);
|
handleLaneSets(container.laneSets, context);
|
||||||
handleNonFlowNodes(container.flowElements);
|
handleNonFlowNodes(container.flowElements, context);
|
||||||
} else {
|
} else {
|
||||||
handleFlowElements(container.flowElements, context);
|
handleFlowElements(container.flowElements, context);
|
||||||
}
|
}
|
||||||
|
@ -319,6 +343,11 @@ function BpmnTreeWalker(handler) {
|
||||||
|
|
||||||
function handleNonFlowNodes(flowElements, context) {
|
function handleNonFlowNodes(flowElements, context) {
|
||||||
forEach(flowElements, function(e) {
|
forEach(flowElements, function(e) {
|
||||||
|
|
||||||
|
if (isHandled(e)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (is(e, 'bpmn:SequenceFlow')) {
|
if (is(e, 'bpmn:SequenceFlow')) {
|
||||||
deferred.push(function() {
|
deferred.push(function() {
|
||||||
handleSequenceFlow(e, context);
|
handleSequenceFlow(e, context);
|
||||||
|
@ -327,6 +356,8 @@ function BpmnTreeWalker(handler) {
|
||||||
deferred.unshift(function() {
|
deferred.unshift(function() {
|
||||||
handleBoundaryEvent(e, context);
|
handleBoundaryEvent(e, context);
|
||||||
});
|
});
|
||||||
|
} else if (is(e, 'bpmn:FlowNode')) {
|
||||||
|
handleFlowNode(e, context);
|
||||||
} else if (is(e, 'bpmn:DataObject')) {
|
} else if (is(e, 'bpmn:DataObject')) {
|
||||||
// SKIP (assume correct referencing via DataObjectReference)
|
// SKIP (assume correct referencing via DataObjectReference)
|
||||||
} else if (is(e, 'bpmn:DataStoreReference')) {
|
} else if (is(e, 'bpmn:DataStoreReference')) {
|
||||||
|
@ -349,17 +380,6 @@ function BpmnTreeWalker(handler) {
|
||||||
});
|
});
|
||||||
} else if (is(e, 'bpmn:FlowNode')) {
|
} else if (is(e, 'bpmn:FlowNode')) {
|
||||||
handleFlowNode(e, context);
|
handleFlowNode(e, context);
|
||||||
|
|
||||||
if (is(e, 'bpmn:Activity')) {
|
|
||||||
|
|
||||||
handleIoSpecification(e.ioSpecification, context);
|
|
||||||
|
|
||||||
// defer handling of associations
|
|
||||||
deferred.push(function() {
|
|
||||||
forEach(e.dataInputAssociations, contextual(handleDataAssociation, context));
|
|
||||||
forEach(e.dataOutputAssociations, contextual(handleDataAssociation, context));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
} else if (is(e, 'bpmn:DataObject')) {
|
} else if (is(e, 'bpmn:DataObject')) {
|
||||||
// SKIP (assume correct referencing via DataObjectReference)
|
// SKIP (assume correct referencing via DataObjectReference)
|
||||||
} else if (is(e, 'bpmn:DataStoreReference')) {
|
} else if (is(e, 'bpmn:DataStoreReference')) {
|
||||||
|
|
|
@ -331,7 +331,7 @@ describe('Viewer', function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it('should export complex svg', function(done) {
|
it('should export huge svg', function(done) {
|
||||||
|
|
||||||
// given
|
// given
|
||||||
var xml = require('../fixtures/bpmn/complex.bpmn');
|
var xml = require('../fixtures/bpmn/complex.bpmn');
|
||||||
|
|
|
@ -0,0 +1,96 @@
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
var TestHelper = require('../../../../TestHelper');
|
||||||
|
|
||||||
|
/* global bootstrapModeler, inject */
|
||||||
|
|
||||||
|
|
||||||
|
var modelingModule = require('../../../../../lib/features/modeling'),
|
||||||
|
coreModule = require('../../../../../lib/core');
|
||||||
|
|
||||||
|
|
||||||
|
describe('features/modeling - lanes', function() {
|
||||||
|
|
||||||
|
|
||||||
|
describe('should add Task', function() {
|
||||||
|
|
||||||
|
var diagramXML = require('./lane-simple.bpmn');
|
||||||
|
|
||||||
|
var testModules = [ coreModule, modelingModule ];
|
||||||
|
|
||||||
|
beforeEach(bootstrapModeler(diagramXML, { modules: testModules }));
|
||||||
|
|
||||||
|
|
||||||
|
it('execute', inject(function(elementRegistry, modeling) {
|
||||||
|
|
||||||
|
// given
|
||||||
|
var laneShape = elementRegistry.get('Lane'),
|
||||||
|
// lane = laneShape.businessObject,
|
||||||
|
participantShape = elementRegistry.get('Participant_Lane'),
|
||||||
|
bpmnProcess = participantShape.businessObject.processRef;
|
||||||
|
|
||||||
|
// when
|
||||||
|
var newTaskShape = modeling.createShape({ type: 'bpmn:Task' }, { x: 250, y: 150 }, laneShape);
|
||||||
|
|
||||||
|
var newTask = newTaskShape.businessObject;
|
||||||
|
|
||||||
|
// then
|
||||||
|
expect(newTask.$parent).to.equal(bpmnProcess);
|
||||||
|
expect(bpmnProcess.flowElements).to.contain(newTask);
|
||||||
|
|
||||||
|
// TODO(nre): correctly wire flowNodeRef(s)
|
||||||
|
// expect(lane.flowNodeRef).to.contain(newTask);
|
||||||
|
}));
|
||||||
|
|
||||||
|
|
||||||
|
it('undo', inject(function(elementRegistry, commandStack, modeling) {
|
||||||
|
|
||||||
|
// given
|
||||||
|
var laneShape = elementRegistry.get('Lane'),
|
||||||
|
// lane = laneShape.businessObject,
|
||||||
|
participantShape = elementRegistry.get('Participant_Lane'),
|
||||||
|
bpmnProcess = participantShape.businessObject.processRef;
|
||||||
|
|
||||||
|
var newTaskShape = modeling.createShape({ type: 'bpmn:Task' }, { x: 250, y: 150 }, laneShape);
|
||||||
|
|
||||||
|
var newTask = newTaskShape.businessObject;
|
||||||
|
|
||||||
|
// when
|
||||||
|
commandStack.undo();
|
||||||
|
|
||||||
|
// then
|
||||||
|
expect(newTask.$parent).not.to.exist;
|
||||||
|
expect(bpmnProcess.flowElements).not.to.contain(newTask);
|
||||||
|
|
||||||
|
// TODO(nre): correctly wire flowNodeRef(s)
|
||||||
|
// expect(lane.flowNodeRef).not.to.contain(newTask);
|
||||||
|
}));
|
||||||
|
|
||||||
|
|
||||||
|
it('redo', inject(function(elementRegistry, commandStack, modeling) {
|
||||||
|
|
||||||
|
// given
|
||||||
|
var laneShape = elementRegistry.get('Lane'),
|
||||||
|
// lane = laneShape.businessObject,
|
||||||
|
participantShape = elementRegistry.get('Participant_Lane'),
|
||||||
|
bpmnProcess = participantShape.businessObject.processRef;
|
||||||
|
|
||||||
|
var newTaskShape = modeling.createShape({ type: 'bpmn:Task' }, { x: 250, y: 150 }, laneShape);
|
||||||
|
|
||||||
|
var newTask = newTaskShape.businessObject;
|
||||||
|
|
||||||
|
// when
|
||||||
|
commandStack.undo();
|
||||||
|
commandStack.redo();
|
||||||
|
|
||||||
|
// then
|
||||||
|
expect(newTask.$parent).to.equal(bpmnProcess);
|
||||||
|
expect(bpmnProcess.flowElements).to.contain(newTask);
|
||||||
|
|
||||||
|
// TODO(nre): correctly wire flowNodeRef(s)
|
||||||
|
// expect(lane.flowNodeRef).to.contain(newTask);
|
||||||
|
}));
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
|
@ -9,7 +9,7 @@ var modelingModule = require('../../../../../lib/features/modeling'),
|
||||||
coreModule = require('../../../../../lib/core');
|
coreModule = require('../../../../../lib/core');
|
||||||
|
|
||||||
|
|
||||||
describe('features/modeling - create lanes', function() {
|
describe('features/modeling - lanes', function() {
|
||||||
|
|
||||||
|
|
||||||
describe('should add to participant', function() {
|
describe('should add to participant', function() {
|
||||||
|
|
|
@ -0,0 +1,44 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<bpmn2:definitions xmlns:bpmn2="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" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="_4bAZoD9WEeWLcNBL4nCk1A" 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_2">
|
||||||
|
<bpmn2:participant id="Participant_Lane" name="Participant_Lane" processRef="Process_Lane" />
|
||||||
|
</bpmn2:collaboration>
|
||||||
|
<bpmn2:process id="Process_Lane" isExecutable="false">
|
||||||
|
<bpmn2:laneSet id="LaneSet_1" name="Lane Set 1">
|
||||||
|
<bpmn2:lane id="Lane" name="Lane">
|
||||||
|
<bpmn2:flowNodeRef>Other_Task</bpmn2:flowNodeRef>
|
||||||
|
<bpmn2:flowNodeRef>Task</bpmn2:flowNodeRef>
|
||||||
|
</bpmn2:lane>
|
||||||
|
</bpmn2:laneSet>
|
||||||
|
<bpmn2:task id="Other_Task" name="Other_Task">
|
||||||
|
<bpmn2:outgoing>SequenceFlow</bpmn2:outgoing>
|
||||||
|
</bpmn2:task>
|
||||||
|
<bpmn2:sequenceFlow id="SequenceFlow" name="" sourceRef="Other_Task" targetRef="Task" />
|
||||||
|
<bpmn2:task id="Task" name="Task">
|
||||||
|
<bpmn2:incoming>SequenceFlow</bpmn2:incoming>
|
||||||
|
</bpmn2:task>
|
||||||
|
</bpmn2:process>
|
||||||
|
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
|
||||||
|
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="_Collaboration_2">
|
||||||
|
<bpmndi:BPMNShape id="_BPMNShape_Participant_2" bpmnElement="Participant_Lane" isHorizontal="true">
|
||||||
|
<dc:Bounds x="156" y="84" width="540" height="181" />
|
||||||
|
</bpmndi:BPMNShape>
|
||||||
|
<bpmndi:BPMNShape id="_BPMNShape_Task_2" bpmnElement="Other_Task">
|
||||||
|
<dc:Bounds x="348" y="114" width="100" height="80" />
|
||||||
|
</bpmndi:BPMNShape>
|
||||||
|
<bpmndi:BPMNShape id="_BPMNShape_Task_3" bpmnElement="Task">
|
||||||
|
<dc:Bounds x="516" y="114" width="100" height="80" />
|
||||||
|
</bpmndi:BPMNShape>
|
||||||
|
<bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_2" bpmnElement="SequenceFlow" sourceElement="_BPMNShape_Task_2" targetElement="_BPMNShape_Task_3">
|
||||||
|
<di:waypoint xsi:type="dc:Point" x="448" y="154" />
|
||||||
|
<di:waypoint xsi:type="dc:Point" x="516" y="154" />
|
||||||
|
<bpmndi:BPMNLabel>
|
||||||
|
<dc:Bounds x="487" y="154" width="6" height="6" />
|
||||||
|
</bpmndi:BPMNLabel>
|
||||||
|
</bpmndi:BPMNEdge>
|
||||||
|
<bpmndi:BPMNShape id="_BPMNShape_Lane_3" bpmnElement="Lane" isHorizontal="true">
|
||||||
|
<dc:Bounds x="186" y="84" width="510" height="181" />
|
||||||
|
</bpmndi:BPMNShape>
|
||||||
|
</bpmndi:BPMNPlane>
|
||||||
|
</bpmndi:BPMNDiagram>
|
||||||
|
</bpmn2:definitions>
|
|
@ -338,7 +338,7 @@ describe('features/snapping - BpmnSnapping', function() {
|
||||||
dragging.end();
|
dragging.end();
|
||||||
|
|
||||||
expect(participant.width).to.equal(600);
|
expect(participant.width).to.equal(600);
|
||||||
expect(participant.height).to.equal(250);
|
expect(participant.height).to.equal(254);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -13,34 +13,26 @@ var Diagram = require('diagram-js/lib/Diagram'),
|
||||||
Viewer = require('../../../lib/Viewer');
|
Viewer = require('../../../lib/Viewer');
|
||||||
|
|
||||||
|
|
||||||
var is = require('../../../lib/util/ModelUtil').is;
|
|
||||||
|
|
||||||
describe('import - Importer', function() {
|
describe('import - Importer', function() {
|
||||||
|
|
||||||
var moddle = new BpmnModdle();
|
function createDiagram(container, modules) {
|
||||||
|
|
||||||
var container;
|
|
||||||
|
|
||||||
beforeEach(function() {
|
|
||||||
container = TestContainer.get(this);
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
function createDiagram() {
|
|
||||||
return new Diagram({
|
return new Diagram({
|
||||||
canvas: { container: container },
|
canvas: { container: container },
|
||||||
modules: Viewer.prototype._modules
|
modules: modules
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
var diagram;
|
var diagram;
|
||||||
|
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
diagram = createDiagram();
|
diagram = createDiagram(TestContainer.get(this), Viewer.prototype._modules);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
function runImport(diagram, xml, done) {
|
function runImport(diagram, xml, done) {
|
||||||
|
|
||||||
|
var moddle = new BpmnModdle();
|
||||||
|
|
||||||
moddle.fromXML(xml, function(err, definitions) {
|
moddle.fromXML(xml, function(err, definitions) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return done(err);
|
return done(err);
|
||||||
|
@ -152,8 +144,67 @@ describe('import - Importer', function() {
|
||||||
|
|
||||||
done(err);
|
done(err);
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
describe('position', function() {
|
||||||
|
|
||||||
|
var xml = require('../../fixtures/bpmn/import/position/position-testcase.bpmn');
|
||||||
|
|
||||||
|
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;
|
||||||
|
});
|
||||||
|
|
||||||
|
runImport(diagram, xml, function(err, warnings) {
|
||||||
|
|
||||||
|
//round up
|
||||||
|
expect(events.ID_End.x).to.equal(Math.round(340.6));
|
||||||
|
expect(events.ID_End.y).to.equal(Math.round(136.6));
|
||||||
|
|
||||||
|
//round down
|
||||||
|
expect(events.ID_Start.x).to.equal(Math.round(120.4));
|
||||||
|
expect(events.ID_Start.y).to.equal(Math.round(135.4));
|
||||||
|
|
||||||
|
done(err);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
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;
|
||||||
|
});
|
||||||
|
|
||||||
|
runImport(diagram, xml, function(err, warnings) {
|
||||||
|
|
||||||
|
//round down
|
||||||
|
expect(events.ID_Start.height).to.equal(Math.round(30.4));
|
||||||
|
expect(events.ID_Start.width).to.equal(Math.round(30.4));
|
||||||
|
|
||||||
|
done(err);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
describe('elements', function() {
|
||||||
|
|
||||||
it('should import boundary events', function(done) {
|
it('should import boundary events', function(done) {
|
||||||
|
|
||||||
|
@ -187,135 +238,6 @@ describe('import - Importer', function() {
|
||||||
done(err);
|
done(err);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
describe('model wiring', function() {
|
|
||||||
|
|
||||||
describe('basics', function() {
|
|
||||||
|
|
||||||
var xml = require('../../fixtures/bpmn/import/process.bpmn');
|
|
||||||
|
|
||||||
beforeEach(bootstrapViewer(xml));
|
|
||||||
|
|
||||||
|
|
||||||
it('should wire root element', inject(function(elementRegistry, canvas) {
|
|
||||||
|
|
||||||
// when
|
|
||||||
var processElement = elementRegistry.get('Process_1');
|
|
||||||
var subProcessShape = elementRegistry.get('SubProcess_1');
|
|
||||||
|
|
||||||
// then
|
|
||||||
expect(subProcessShape.parent).to.eql(processElement);
|
|
||||||
expect(canvas.getRootElement()).to.eql(processElement);
|
|
||||||
|
|
||||||
expect(is(processElement, 'bpmn:Process')).to.be.true;
|
|
||||||
}));
|
|
||||||
|
|
||||||
|
|
||||||
it('should wire parent child relationship', inject(function(elementRegistry) {
|
|
||||||
|
|
||||||
// when
|
|
||||||
var subProcessShape = elementRegistry.get('SubProcess_1');
|
|
||||||
var startEventShape = elementRegistry.get('StartEvent_1');
|
|
||||||
|
|
||||||
// then
|
|
||||||
expect(startEventShape.type).to.equal('bpmn:StartEvent');
|
|
||||||
expect(startEventShape.parent).to.eql(subProcessShape);
|
|
||||||
|
|
||||||
expect(subProcessShape.children.length).to.equal(5);
|
|
||||||
}));
|
|
||||||
|
|
||||||
|
|
||||||
it('should wire label relationship', inject(function(elementRegistry) {
|
|
||||||
|
|
||||||
// when
|
|
||||||
var startEventShape = elementRegistry.get('StartEvent_1');
|
|
||||||
var label = startEventShape.label;
|
|
||||||
|
|
||||||
// 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;
|
|
||||||
|
|
||||||
expect(startEvent).to.be.defined;
|
|
||||||
expect(is(startEvent, 'bpmn:StartEvent')).to.be.true;
|
|
||||||
}));
|
|
||||||
|
|
||||||
|
|
||||||
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);
|
|
||||||
}));
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
describe('boundary events', function() {
|
|
||||||
|
|
||||||
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;
|
|
||||||
|
|
||||||
var taskShape = elementRegistry.get('Task_1'),
|
|
||||||
task = taskShape.businessObject;
|
|
||||||
|
|
||||||
// assume
|
|
||||||
expect(boundaryEvent.attachedToRef).to.eql(task);
|
|
||||||
|
|
||||||
// then
|
|
||||||
expect(boundaryEventShape.host).to.eql(taskShape);
|
|
||||||
|
|
||||||
expect(taskShape.attachers).to.exist;
|
|
||||||
expect(taskShape.attachers).to.contain(boundaryEventShape);
|
|
||||||
}));
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -421,26 +343,6 @@ describe('import - Importer', function() {
|
||||||
|
|
||||||
describe('integration', function() {
|
describe('integration', function() {
|
||||||
|
|
||||||
// slightly increase timeout for complex test cases
|
|
||||||
this.timeout(4000);
|
|
||||||
|
|
||||||
|
|
||||||
it('should import complex', function(done) {
|
|
||||||
|
|
||||||
// given
|
|
||||||
var xml = require('../../fixtures/bpmn/complex.bpmn');
|
|
||||||
|
|
||||||
// when
|
|
||||||
runImport(diagram, xml, function(err, warnings) {
|
|
||||||
|
|
||||||
// then
|
|
||||||
expect(warnings.length).to.equal(0);
|
|
||||||
|
|
||||||
done(err);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
it('should import dangling process message flows', function(done) {
|
it('should import dangling process message flows', function(done) {
|
||||||
|
|
||||||
// given
|
// given
|
||||||
|
@ -461,58 +363,4 @@ describe('import - Importer', function() {
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
describe('position', function() {
|
|
||||||
|
|
||||||
var xml = require('../../fixtures/bpmn/import/position/position-testcase.bpmn');
|
|
||||||
|
|
||||||
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;
|
|
||||||
});
|
|
||||||
|
|
||||||
runImport(diagram, xml, function(err, warnings) {
|
|
||||||
|
|
||||||
//round up
|
|
||||||
expect(events.ID_End.x).to.equal(Math.round(340.6));
|
|
||||||
expect(events.ID_End.y).to.equal(Math.round(136.6));
|
|
||||||
|
|
||||||
//round down
|
|
||||||
expect(events.ID_Start.x).to.equal(Math.round(120.4));
|
|
||||||
expect(events.ID_Start.y).to.equal(Math.round(135.4));
|
|
||||||
|
|
||||||
done(err);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
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;
|
|
||||||
});
|
|
||||||
|
|
||||||
runImport(diagram, xml, function(err, warnings) {
|
|
||||||
|
|
||||||
//round down
|
|
||||||
expect(events.ID_Start.height).to.equal(Math.round(30.4));
|
|
||||||
expect(events.ID_Start.width).to.equal(Math.round(30.4));
|
|
||||||
|
|
||||||
done(err);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
});
|
});
|
|
@ -0,0 +1,183 @@
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
var TestHelper = require('../../TestHelper');
|
||||||
|
|
||||||
|
/* global bootstrapViewer, inject */
|
||||||
|
|
||||||
|
|
||||||
|
var is = require('../../../lib/util/ModelUtil').is;
|
||||||
|
|
||||||
|
|
||||||
|
describe('import - model wiring', function() {
|
||||||
|
|
||||||
|
|
||||||
|
describe('basics', function() {
|
||||||
|
|
||||||
|
var xml = require('../../fixtures/bpmn/import/process.bpmn');
|
||||||
|
|
||||||
|
beforeEach(bootstrapViewer(xml));
|
||||||
|
|
||||||
|
|
||||||
|
it('should wire root element', inject(function(elementRegistry, canvas) {
|
||||||
|
|
||||||
|
// when
|
||||||
|
var processElement = elementRegistry.get('Process_1');
|
||||||
|
var subProcessShape = elementRegistry.get('SubProcess_1');
|
||||||
|
|
||||||
|
// then
|
||||||
|
expect(subProcessShape.parent).to.eql(processElement);
|
||||||
|
expect(canvas.getRootElement()).to.eql(processElement);
|
||||||
|
|
||||||
|
expect(is(processElement, 'bpmn:Process')).to.be.true;
|
||||||
|
}));
|
||||||
|
|
||||||
|
|
||||||
|
it('should wire parent child relationship', inject(function(elementRegistry) {
|
||||||
|
|
||||||
|
// when
|
||||||
|
var subProcessShape = elementRegistry.get('SubProcess_1');
|
||||||
|
var startEventShape = elementRegistry.get('StartEvent_1');
|
||||||
|
|
||||||
|
// then
|
||||||
|
expect(startEventShape.type).to.equal('bpmn:StartEvent');
|
||||||
|
expect(startEventShape.parent).to.eql(subProcessShape);
|
||||||
|
|
||||||
|
expect(subProcessShape.children.length).to.equal(5);
|
||||||
|
}));
|
||||||
|
|
||||||
|
|
||||||
|
it('should wire label relationship', inject(function(elementRegistry) {
|
||||||
|
|
||||||
|
// when
|
||||||
|
var startEventShape = elementRegistry.get('StartEvent_1');
|
||||||
|
var label = startEventShape.label;
|
||||||
|
|
||||||
|
// 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;
|
||||||
|
|
||||||
|
expect(startEvent).to.be.defined;
|
||||||
|
expect(is(startEvent, 'bpmn:StartEvent')).to.be.true;
|
||||||
|
}));
|
||||||
|
|
||||||
|
|
||||||
|
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);
|
||||||
|
}));
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
describe('host attacher relationship', function() {
|
||||||
|
|
||||||
|
var xml = require('../../fixtures/bpmn/import/boundaryEvent.bpmn');
|
||||||
|
|
||||||
|
beforeEach(bootstrapViewer(xml));
|
||||||
|
|
||||||
|
|
||||||
|
it('should wire boundary event', inject(function(elementRegistry) {
|
||||||
|
|
||||||
|
// when
|
||||||
|
var boundaryEventShape = elementRegistry.get('BoundaryEvent_1'),
|
||||||
|
boundaryEvent = boundaryEventShape.businessObject;
|
||||||
|
|
||||||
|
var taskShape = elementRegistry.get('Task_1'),
|
||||||
|
task = taskShape.businessObject;
|
||||||
|
|
||||||
|
// assume
|
||||||
|
expect(boundaryEvent.attachedToRef).to.eql(task);
|
||||||
|
|
||||||
|
// then
|
||||||
|
expect(boundaryEventShape.host).to.eql(taskShape);
|
||||||
|
|
||||||
|
expect(taskShape.attachers).to.exist;
|
||||||
|
expect(taskShape.attachers).to.contain(boundaryEventShape);
|
||||||
|
}));
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
describe('lanes + flow elements', function() {
|
||||||
|
|
||||||
|
var xml = require('./lane-flowNodes.bpmn');
|
||||||
|
|
||||||
|
beforeEach(bootstrapViewer(xml));
|
||||||
|
|
||||||
|
|
||||||
|
it('should wire parent child relationship', inject(function(elementRegistry) {
|
||||||
|
|
||||||
|
// when
|
||||||
|
var laneShape = elementRegistry.get('Lane'),
|
||||||
|
participantShape = elementRegistry.get('Participant_Lane'),
|
||||||
|
taskShape = elementRegistry.get('Task'),
|
||||||
|
sequenceFlowElement = elementRegistry.get('SequenceFlow');
|
||||||
|
|
||||||
|
// then
|
||||||
|
expect(taskShape.parent).to.eql(laneShape);
|
||||||
|
expect(sequenceFlowElement.parent).to.eql(participantShape);
|
||||||
|
}));
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
describe('lanes + flow elements / missing flowNodeRef', function() {
|
||||||
|
|
||||||
|
var xml = require('./lane-missing-flowNodeRef.bpmn');
|
||||||
|
|
||||||
|
beforeEach(bootstrapViewer(xml));
|
||||||
|
|
||||||
|
|
||||||
|
it('should wire parent child relationship', inject(function(elementRegistry) {
|
||||||
|
|
||||||
|
// when
|
||||||
|
var participantShape = elementRegistry.get('Participant_Lane'),
|
||||||
|
taskShape = elementRegistry.get('Task');
|
||||||
|
|
||||||
|
// then
|
||||||
|
// task is part of participant, as no lane was assigned
|
||||||
|
expect(taskShape.parent).to.eql(participantShape);
|
||||||
|
}));
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
|
@ -0,0 +1,44 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<bpmn2:definitions xmlns:bpmn2="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" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="_4bAZoD9WEeWLcNBL4nCk1A" 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_2">
|
||||||
|
<bpmn2:participant id="Participant_Lane" name="Participant_Lane" processRef="Process_Lane" />
|
||||||
|
</bpmn2:collaboration>
|
||||||
|
<bpmn2:process id="Process_Lane" isExecutable="false">
|
||||||
|
<bpmn2:laneSet id="LaneSet_1" name="Lane Set 1">
|
||||||
|
<bpmn2:lane id="Lane" name="Lane">
|
||||||
|
<bpmn2:flowNodeRef>Other_Task</bpmn2:flowNodeRef>
|
||||||
|
<bpmn2:flowNodeRef>Task</bpmn2:flowNodeRef>
|
||||||
|
</bpmn2:lane>
|
||||||
|
</bpmn2:laneSet>
|
||||||
|
<bpmn2:task id="Other_Task" name="Other_Task">
|
||||||
|
<bpmn2:outgoing>SequenceFlow</bpmn2:outgoing>
|
||||||
|
</bpmn2:task>
|
||||||
|
<bpmn2:sequenceFlow id="SequenceFlow" name="" sourceRef="Other_Task" targetRef="Task" />
|
||||||
|
<bpmn2:task id="Task" name="Task">
|
||||||
|
<bpmn2:incoming>SequenceFlow</bpmn2:incoming>
|
||||||
|
</bpmn2:task>
|
||||||
|
</bpmn2:process>
|
||||||
|
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
|
||||||
|
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="_Collaboration_2">
|
||||||
|
<bpmndi:BPMNShape id="_BPMNShape_Participant_2" bpmnElement="Participant_Lane" isHorizontal="true">
|
||||||
|
<dc:Bounds x="156" y="84" width="540" height="181" />
|
||||||
|
</bpmndi:BPMNShape>
|
||||||
|
<bpmndi:BPMNShape id="_BPMNShape_Task_2" bpmnElement="Other_Task">
|
||||||
|
<dc:Bounds x="348" y="114" width="100" height="80" />
|
||||||
|
</bpmndi:BPMNShape>
|
||||||
|
<bpmndi:BPMNShape id="_BPMNShape_Task_3" bpmnElement="Task">
|
||||||
|
<dc:Bounds x="516" y="114" width="100" height="80" />
|
||||||
|
</bpmndi:BPMNShape>
|
||||||
|
<bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_2" bpmnElement="SequenceFlow" sourceElement="_BPMNShape_Task_2" targetElement="_BPMNShape_Task_3">
|
||||||
|
<di:waypoint xsi:type="dc:Point" x="448" y="154" />
|
||||||
|
<di:waypoint xsi:type="dc:Point" x="516" y="154" />
|
||||||
|
<bpmndi:BPMNLabel>
|
||||||
|
<dc:Bounds x="487" y="154" width="6" height="6" />
|
||||||
|
</bpmndi:BPMNLabel>
|
||||||
|
</bpmndi:BPMNEdge>
|
||||||
|
<bpmndi:BPMNShape id="_BPMNShape_Lane_3" bpmnElement="Lane" isHorizontal="true">
|
||||||
|
<dc:Bounds x="186" y="84" width="510" height="181" />
|
||||||
|
</bpmndi:BPMNShape>
|
||||||
|
</bpmndi:BPMNPlane>
|
||||||
|
</bpmndi:BPMNDiagram>
|
||||||
|
</bpmn2:definitions>
|
|
@ -0,0 +1,25 @@
|
||||||
|
<?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" xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd" id="_4bAZoD9WEeWLcNBL4nCk1A" exporter="camunda modeler" exporterVersion="2.6.0" targetNamespace="http://activiti.org/bpmn">
|
||||||
|
<bpmn2:collaboration id="_Collaboration_2">
|
||||||
|
<bpmn2:participant id="Participant_Lane" name="Participant_Lane" processRef="Process_Lane"/>
|
||||||
|
</bpmn2:collaboration>
|
||||||
|
<bpmn2:process id="Process_Lane" isExecutable="false">
|
||||||
|
<bpmn2:laneSet id="LaneSet_1" name="Lane Set 1">
|
||||||
|
<bpmn2:lane id="Lane" name="Lane"/>
|
||||||
|
</bpmn2:laneSet>
|
||||||
|
<bpmn2:task id="Task" name="Task"/>
|
||||||
|
</bpmn2:process>
|
||||||
|
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
|
||||||
|
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="_Collaboration_2">
|
||||||
|
<bpmndi:BPMNShape id="_BPMNShape_Participant_2" bpmnElement="Participant_Lane" isHorizontal="true">
|
||||||
|
<dc:Bounds height="181.0" width="540.0" x="156.0" y="84.0"/>
|
||||||
|
</bpmndi:BPMNShape>
|
||||||
|
<bpmndi:BPMNShape id="_BPMNShape_Task_3" bpmnElement="Task">
|
||||||
|
<dc:Bounds height="80.0" width="100.0" x="516.0" y="114.0"/>
|
||||||
|
</bpmndi:BPMNShape>
|
||||||
|
<bpmndi:BPMNShape id="_BPMNShape_Lane_3" bpmnElement="Lane" isHorizontal="true">
|
||||||
|
<dc:Bounds height="181.0" width="510.0" x="186.0" y="84.0"/>
|
||||||
|
</bpmndi:BPMNShape>
|
||||||
|
</bpmndi:BPMNPlane>
|
||||||
|
</bpmndi:BPMNDiagram>
|
||||||
|
</bpmn2:definitions>
|
Loading…
Reference in New Issue