diff --git a/lib/import/BpmnTreeWalker.js b/lib/import/BpmnTreeWalker.js index 4d5a3038..45b41017 100644 --- a/lib/import/BpmnTreeWalker.js +++ b/lib/import/BpmnTreeWalker.js @@ -76,8 +76,12 @@ function BpmnTreeWalker(handler) { var bpmnElement = di.bpmnElement; if (bpmnElement) { - diRefs.bind(bpmnElement, 'di'); - bpmnElement.di = di; + if (bpmnElement.di) { + logError('multiple DI elements defined for ' + elementToString(bpmnElement), { element: bpmnElement }); + } else { + diRefs.bind(bpmnElement, 'di'); + bpmnElement.di = di; + } } else { logError('no bpmnElement referenced in ' + elementToString(di), { element: di }); } diff --git a/test/fixtures/bpmn/error/multiple-dis.bpmn b/test/fixtures/bpmn/error/multiple-dis.bpmn new file mode 100644 index 00000000..137f72c8 --- /dev/null +++ b/test/fixtures/bpmn/error/multiple-dis.bpmn @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/test/spec/import/ImporterSpec.js b/test/spec/import/ImporterSpec.js index 66574637..f261917c 100644 --- a/test/spec/import/ImporterSpec.js +++ b/test/spec/import/ImporterSpec.js @@ -277,6 +277,23 @@ describe('import - importer', function() { }); }); + + it('should import multiple dis', function(done) { + + // given + var xml = fs.readFileSync('test/fixtures/bpmn/error/multiple-dis.bpmn', 'utf8'); + + // when + runImport(diagram, xml, function(err, warnings) { + + expect(warnings.length).toBe(1); + expect(warnings[0].message).toBe('multiple DI elements defined for '); + + done(err); + }); + }); + + it('should extend missing attribute with default value', function(done) { // given