Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No namespace reuse #78

Merged
merged 5 commits into from
Apr 28, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,16 @@ All notable changes to [bpmn-moddle](https://github.com/bpmn-io/bpmn-moddle) are

___Note:__ Yet to be released changes appear here._

## 7.0.2

* `FIX`: recursively log nested namespaces as used ([#78](https://github.com/bpmn-io/bpmn-moddle/pull/78))
* `CHORE`: update to `moddle-xml@9.0.2`

## 6.0.6

* `FIX`: recursively log nested namespaces as used ([#78](https://github.com/bpmn-io/bpmn-moddle/pull/78))
* `CHORE`: update to `moddle-xml@8.0.7`

## 6.0.5

* `FIX`: account for local namespace declaration overrides ([#76](https://github.com/bpmn-io/bpmn-moddle/pull/76))
Expand Down
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,6 @@
"dependencies": {
"min-dash": "^3.0.0",
"moddle": "^5.0.1",
"moddle-xml": "^9.0.1"
"moddle-xml": "^9.0.2"
}
}
16 changes: 16 additions & 0 deletions test/fixtures/bpmn/local-ns-no-di.bpmn
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="Definitions_1" targetNamespace="http://bpmn.io/bpmn" exporter="bpmn-js (https://demo.bpmn.io)" exporterVersion="6.4.2">
<process id="Process" isExecutable="false">
<startEvent id="Start" name="hunger noticed">
<outgoing>SequenceFlow</outgoing>
</startEvent>
<task id="Task" name="choose recipe">
<incoming>SequenceFlow</incoming>
</task>
<sequenceFlow id="SequenceFlow" sourceRef="Start" targetRef="Task" />
</process>
<BPMNDiagram id="BpmnDiagram_1" xmlns="http://www.omg.org/spec/BPMN/20100524/DI">
<BPMNPlane id="BpmnPlane_1" bpmnElement="Process" xmlns="http://www.omg.org/spec/BPMN/20100524/DI">
</BPMNPlane>
</BPMNDiagram>
</definitions>
110 changes: 110 additions & 0 deletions test/spec/xml/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {

import {
fromFile as readFromFile,
validate,
toXML
} from '../../xml-helper';

Expand Down Expand Up @@ -73,4 +74,113 @@ describe('bpmn-moddle - edit', function() {
expect(xml).to.contain('<bpmn:dataObjectReference id="DataObjectReference_1" dataObjectRef="dataObject_2" />');
});
});


describe('generate DI', function() {

async function readAndGenerateDI(file) {

var {
rootElement: definitions
} = await fromFile(file);

var process = definitions.rootElements[0];

var flowElements = process.flowElements;

var [
start,
task,
flow
] = flowElements;

var plane = definitions.diagrams[0].plane;

var model = definitions.$model;

var planeElements = plane.get('planeElement');

// when
planeElements.push(
model.create('bpmndi:BPMNEdge', {
id: 'Flow_di',
bpmnElement: flow,
waypoint: [
model.create('dc:Point', { x: 100, y: 100 }),
model.create('dc:Point', { x: 150, y: 150 })
]
}),
model.create('bpmndi:BPMNShape', {
id: 'Start_di',
bpmnElement: start,
bounds: model.create('dc:Bounds', { x: 50, y: 50, width: 100, height: 100 })
}),
model.create('bpmndi:BPMNShape', {
id: 'Task_di',
bpmnElement: task,
bounds: model.create('dc:Bounds', { x: 100, y: 100, width: 100, height: 100 })
})
);

return {
definitions
};
}


it('should auto-add wellknown', async function() {

// given
var {
definitions
} = await readAndGenerateDI('test/fixtures/bpmn/local-ns-no-di.bpmn');

// when
var {
xml
} = await toXML(definitions, { format: true });

// then
expect(xml).to.contain(
'xmlns:di="http://www.omg.org/spec/DD/20100524/DI"'
);

expect(xml).to.contain(
'xmlns:dc="http://www.omg.org/spec/DD/20100524/DC"'
);

await validate(xml);
});


it('should reuse global namespace', async function() {

// given
var {
definitions
} = await readAndGenerateDI('test/fixtures/bpmn/local-ns-no-di.bpmn');

// when
// set global namespace information
definitions.$attrs['xmlns:di'] = 'http://www.omg.org/spec/DD/20100524/DI';
definitions.$attrs['xmlns:dc'] = 'http://www.omg.org/spec/DD/20100524/DC';

var {
xml
} = await toXML(definitions, { format: true });

// then
expect(xml).to.contain(
'xmlns:di="http://www.omg.org/spec/DD/20100524/DI"'
);

expect(xml).to.contain(
'xmlns:dc="http://www.omg.org/spec/DD/20100524/DC"'
);

await validate(xml);
});

});

});
2 changes: 2 additions & 0 deletions test/spec/xml/write.js
Original file line number Diff line number Diff line change
Expand Up @@ -677,6 +677,7 @@ describe('bpmn-moddle - write', function() {
expect(xml).to.eql(expectedXML);
});


it('BPMNShape (colored)', async function() {

// given
Expand All @@ -697,6 +698,7 @@ describe('bpmn-moddle - write', function() {
expect(xml).to.eql(expectedXML);
});


it('BPMNEdge (colored)', async function() {

// given
Expand Down