diff --git a/lib/import/BpmnImporter.js b/lib/import/BpmnImporter.js index a8b24955..452bc2b3 100644 --- a/lib/import/BpmnImporter.js +++ b/lib/import/BpmnImporter.js @@ -1,6 +1,5 @@ import { - assign, - map + assign } from 'min-dash'; import { is } from '../util/ModelUtil'; @@ -31,8 +30,15 @@ function elementData(semantic, attrs) { }, attrs); } -function collectWaypoints(waypoints) { - return map(waypoints, function(p) { +function getWaypoints(bo, source, target) { + + var waypoints = bo.di.waypoint; + + if (!waypoints || waypoints.length < 2) { + return [ getMid(source), getMid(target) ]; + } + + return waypoints.map(function(p) { return { x: p.x, y: p.y }; }); } @@ -151,7 +157,7 @@ BpmnImporter.prototype.add = function(semantic, parentElement) { hidden: hidden, source: source, target: target, - waypoints: collectWaypoints(semantic.di.waypoint) + waypoints: getWaypoints(semantic, source, target) })); if (is(semantic, 'bpmn:DataAssociation')) { diff --git a/test/spec/import/ImporterSpec.js b/test/spec/import/ImporterSpec.js index 21f35435..d5c0cb7f 100644 --- a/test/spec/import/ImporterSpec.js +++ b/test/spec/import/ImporterSpec.js @@ -418,6 +418,21 @@ describe('import - Importer', function() { }); + it('should import sequence flow without waypoints', function(done) { + + // given + var xml = require('./sequenceFlow-missingWaypoints.bpmn'); + + // when + runImport(diagram, xml, function(err, warnings) { + + expect(warnings).to.be.empty; + + done(err); + }); + }); + + it('should extend attributes with default value', function(done) { // given diff --git a/test/spec/import/sequenceFlow-missingWaypoints.bpmn b/test/spec/import/sequenceFlow-missingWaypoints.bpmn new file mode 100644 index 00000000..2d653cb7 --- /dev/null +++ b/test/spec/import/sequenceFlow-missingWaypoints.bpmn @@ -0,0 +1,24 @@ + + + + + SequenceFlow + + + SequenceFlow + + + + + + + + + + + + + + + +