Skip to content

Commit

Permalink
feat(schema): add biodi@2.0 package
Browse files Browse the repository at this point in the history
  • Loading branch information
barmac committed Jul 2, 2020
1 parent f6444fd commit 6bc6b90
Show file tree
Hide file tree
Showing 6 changed files with 149 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/simple.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@ import DcPackage from '../resources/dmn/json/dc.json';
import DiPackage from '../resources/dmn/json/di.json';
import DmnPackage from '../resources/dmn/json/dmn13.json';
import DmnDiPackage from '../resources/dmn/json/dmndi13.json';
import BioDiPackage from '../resources/dmn/bpmn-io/biodi.json';

var packages = {
dc: DcPackage,
di: DiPackage,
dmn: DmnPackage,
dmndi: DmnDiPackage,
biodi: BioDiPackage
};

export default function(additionalPackages, options) {
Expand Down
52 changes: 52 additions & 0 deletions resources/dmn/bpmn-io/biodi.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{
"name": "bpmn.io DI for DMN",
"uri": "http://bpmn.io/schema/dmn/biodi/2.0",
"prefix": "biodi",
"xml": {
"tagAlias": "lowerCase"
},
"types": [
{
"name": "DecisionTable",
"isAbstract": true,
"extends": [
"dmn:DecisionTable"
],
"properties": [
{
"name": "annotationsWidth",
"isAttr": true,
"type": "Integer"
}
]
},
{
"name": "OutputClause",
"isAbstract": true,
"extends": [
"dmn:OutputClause"
],
"properties": [
{
"name": "width",
"isAttr": true,
"type": "Integer"
}
]
},
{
"name": "InputClause",
"isAbstract": true,
"extends": [
"dmn:InputClause"
],
"properties": [
{
"name": "width",
"isAttr": true,
"type": "Integer"
}
]
}
]
}
13 changes: 13 additions & 0 deletions test/fixtures/dmn/biodi/biodi.dmn
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="https://www.omg.org/spec/DMN/20191111/MODEL/" xmlns:biodi="http://bpmn.io/schema/dmn/biodi/2.0" id="Definitions" name="DRD" namespace="http://camunda.org/schema/1.0/dmn" exporter="Camunda Modeler" exporterVersion="4.1.0-dev.20200702">
<decision id="Decision" name="Decision">
<decisionTable id="DecisionTable_046av0s" biodi:annotationsWidth="200">
<input id="InputClause" biodi:width="150">
<inputExpression id="LiteralExpression_17mnp7i" typeRef="string">
<text></text>
</inputExpression>
</input>
<output id="Output" typeRef="string" biodi:width="150" />
</decisionTable>
</decision>
</definitions>
16 changes: 16 additions & 0 deletions test/spec/xml/read.js
Original file line number Diff line number Diff line change
Expand Up @@ -592,4 +592,20 @@ describe('dmn-moddle - read', function() {

});


describe('biodi', function() {

it('should read biodi', async function() {

// when
const definitions = await read('test/fixtures/dmn/biodi/biodi.dmn');

// then
const decisionTable = definitions.get('drgElement')[0].decisionLogic;

expect(decisionTable).to.have.property('annotationsWidth', 200);
expect(decisionTable.input[0]).to.have.property('width', 150);
expect(decisionTable.output[0]).to.have.property('width', 150);
});
});
});
6 changes: 6 additions & 0 deletions test/spec/xml/roundtrip.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ describe('dmn-moddle - roundtrip', function() {

});


describe('biodi', function() {

it('biodi', roundtrip('test/fixtures/dmn/biodi/biodi.dmn'));

});
});


Expand Down
60 changes: 60 additions & 0 deletions test/spec/xml/write.js
Original file line number Diff line number Diff line change
Expand Up @@ -343,4 +343,64 @@ describe('dmn-moddle - write', function() {

});


describe('biodi', function() {

it('should write DecisionTable#annotationsWidth', async function() {

// given
const expected = '<dmn:decisionTable ' +
'xmlns:dmn="https://www.omg.org/spec/DMN/20191111/MODEL/" ' +
'xmlns:biodi="http://bpmn.io/schema/dmn/biodi/2.0" ' +
'biodi:annotationsWidth="200" />';

const decisionTable = moddle.create('dmn:DecisionTable');
decisionTable.set('annotationsWidth', 200);

// when
const xml = await write(decisionTable);

// then
expect(xml).to.equal(expected);
});


it('should write InputClause#width', async function() {

// given
const expected = '<dmn:inputClause ' +
'xmlns:dmn="https://www.omg.org/spec/DMN/20191111/MODEL/" ' +
'xmlns:biodi="http://bpmn.io/schema/dmn/biodi/2.0" ' +
'biodi:width="200" />';

const inputClause = moddle.create('dmn:InputClause');
inputClause.set('width', 200);

// when
const xml = await write(inputClause);

// then
expect(xml).to.equal(expected);
});


it('should write OutputClause#width', async function() {

// given
const expected = '<dmn:outputClause ' +
'xmlns:dmn="https://www.omg.org/spec/DMN/20191111/MODEL/" ' +
'xmlns:biodi="http://bpmn.io/schema/dmn/biodi/2.0" ' +
'biodi:width="200" />';

const outputClause = moddle.create('dmn:OutputClause');
outputClause.set('width', 200);

// when
const xml = await write(outputClause);

// then
expect(xml).to.equal(expected);
});

});
});

0 comments on commit 6bc6b90

Please sign in to comment.