fix(importer): show better error if no BPMNPlane#bpmnElement
Closes #40
This commit is contained in:
parent
39d66069dc
commit
4b135fd9e7
|
@ -112,6 +112,10 @@ function BpmnTraverser(handler) {
|
|||
|
||||
var rootElement = diagram.plane.bpmnElement;
|
||||
|
||||
if (!rootElement) {
|
||||
throw new Error('no rootElement referenced in BPMNPlane <' + diagram.plane.id + '>');
|
||||
}
|
||||
|
||||
if (is(rootElement, 'bpmn:Process')) {
|
||||
handleProcess(rootElement);
|
||||
} else
|
||||
|
|
|
@ -1,13 +1,10 @@
|
|||
<?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="test" targetNamespace="http://bpmn.io/schema/bpmn">
|
||||
<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="_F2BQoOJhEeOt3puKo8GLGA" targetNamespace="http://activiti.org/bpmn">
|
||||
<!-- Collaboration_2 removed -->
|
||||
<bpmn2:process id="Process_1" isExecutable="false">
|
||||
<bpmn2:startEvent id="StartEvent_1"/>
|
||||
</bpmn2:process>
|
||||
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
|
||||
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Process_1">
|
||||
<bpmndi:BPMNShape id="_BPMNShape_StartEvent_2">
|
||||
<dc:Bounds height="36.0" width="36.0" x="412.0" y="240.0"/>
|
||||
</bpmndi:BPMNShape>
|
||||
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Collaboration_2">
|
||||
</bpmndi:BPMNPlane>
|
||||
</bpmndi:BPMNDiagram>
|
||||
</bpmn2:definitions>
|
|
@ -43,7 +43,7 @@ describe('Viewer', function() {
|
|||
|
||||
describe('error handling', function() {
|
||||
|
||||
it('should handle errors', function(done) {
|
||||
it('should handle non-bpmn input', function(done) {
|
||||
|
||||
var xml = 'invalid stuff';
|
||||
|
||||
|
@ -57,6 +57,22 @@ describe('Viewer', function() {
|
|||
});
|
||||
});
|
||||
|
||||
|
||||
it('should handle invalid BPMNPlane#bpmnElement', function(done) {
|
||||
|
||||
var xml = fs.readFileSync('test/fixtures/bpmn/error/di-plane-no-bpmn-element.bpmn', 'utf8');
|
||||
|
||||
var renderer = new Viewer(container);
|
||||
|
||||
renderer.importXML(xml, function(err) {
|
||||
|
||||
expect(err).toBeDefined();
|
||||
expect(err.message).toEqual('no rootElement referenced in BPMNPlane <BPMNPlane_1>');
|
||||
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue