bpmn-moddle 0.14.0 → 0.14.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (89) hide show
  1. package/.travis.yml +2 -5
  2. package/package.json +4 -4
  3. package/resources/bpmn/json/bpmn.json +1 -1
  4. package/resources/bpmn/json/bpmndi.json +1 -1
  5. package/resources/bpmn-io/json/bioc.json +1 -1
  6. package/.npmignore +0 -6
  7. package/test/expect.js +0 -7
  8. package/test/fixtures/bpmn/activity-children.bpmn +0 -23
  9. package/test/fixtures/bpmn/callActivity-calledElement.part.bpmn +0 -7
  10. package/test/fixtures/bpmn/catch-event-dataOutputAssociations.part.bpmn +0 -5
  11. package/test/fixtures/bpmn/category.bpmn +0 -28
  12. package/test/fixtures/bpmn/complex.bpmn +0 -3680
  13. package/test/fixtures/bpmn/conversation-children.bpmn +0 -23
  14. package/test/fixtures/bpmn/data-object-reference.bpmn +0 -17
  15. package/test/fixtures/bpmn/definitions-children.bpmn +0 -13
  16. package/test/fixtures/bpmn/di/bpmnDiagram-extension.part.bpmn +0 -17
  17. package/test/fixtures/bpmn/di/bpmnDiagram.part.bpmn +0 -12
  18. package/test/fixtures/bpmn/di/bpmnEdge-waypoint.part.bpmn +0 -4
  19. package/test/fixtures/bpmn/di/bpmnEdge.part.bpmn +0 -5
  20. package/test/fixtures/bpmn/di/bpmnShape.part.bpmn +0 -4
  21. package/test/fixtures/bpmn/di-extension.bpmn +0 -26
  22. package/test/fixtures/bpmn/documentation-extension-elements.bpmn +0 -15
  23. package/test/fixtures/bpmn/documentation.bpmn +0 -11
  24. package/test/fixtures/bpmn/empty-definitions-default-ns.bpmn +0 -4
  25. package/test/fixtures/bpmn/empty-definitions.bpmn +0 -5
  26. package/test/fixtures/bpmn/error/binary.png +0 -0
  27. package/test/fixtures/bpmn/error/categoryValue.bpmn +0 -27
  28. package/test/fixtures/bpmn/error/di-no-bpmn-element.bpmn +0 -13
  29. package/test/fixtures/bpmn/error/duplicate-ids.bpmn +0 -8
  30. package/test/fixtures/bpmn/error/extension-definition-missing.bpmn +0 -6
  31. package/test/fixtures/bpmn/error/no-xml.txt +0 -1
  32. package/test/fixtures/bpmn/error/undeclared-ns-child.bpmn +0 -6
  33. package/test/fixtures/bpmn/error/unrecognized-child.bpmn +0 -6
  34. package/test/fixtures/bpmn/escalation-error.bpmn +0 -6
  35. package/test/fixtures/bpmn/event-references.part.bpmn +0 -6
  36. package/test/fixtures/bpmn/example-colors.bpmn +0 -40
  37. package/test/fixtures/bpmn/expression-plain.bpmn +0 -40
  38. package/test/fixtures/bpmn/extension/camunda/inputOutput-list.part.bpmn +0 -9
  39. package/test/fixtures/bpmn/extension/camunda/inputOutput-map.part.bpmn +0 -12
  40. package/test/fixtures/bpmn/extension/camunda/inputOutput-mixed.part.bpmn +0 -13
  41. package/test/fixtures/bpmn/extension/camunda/inputOutput-plain.part.bpmn +0 -3
  42. package/test/fixtures/bpmn/extension/camunda/inputOutput-script.part.bpmn +0 -9
  43. package/test/fixtures/bpmn/extension/camunda/inputOutput.bpmn +0 -22
  44. package/test/fixtures/bpmn/extension/drools.part.bpmn +0 -9
  45. package/test/fixtures/bpmn/extension-attributes.bpmn +0 -20
  46. package/test/fixtures/bpmn/extension-elements.bpmn +0 -9
  47. package/test/fixtures/bpmn/inputOutputSpecification-children.bpmn +0 -19
  48. package/test/fixtures/bpmn/interface-implementationRef.part.bpmn +0 -2
  49. package/test/fixtures/bpmn/itemDefinition-structureRef.part.bpmn +0 -2
  50. package/test/fixtures/bpmn/lane-childLaneSets.part.bpmn +0 -8
  51. package/test/fixtures/bpmn/lane-children.bpmn +0 -46
  52. package/test/fixtures/bpmn/multiInstanceLoopCharacteristics-completionCondition.part.bpmn +0 -5
  53. package/test/fixtures/bpmn/multiInstanceLoopCharacteristics.bpmn +0 -181
  54. package/test/fixtures/bpmn/operation-implementationRef.part.bpmn +0 -2
  55. package/test/fixtures/bpmn/operation-messageRef.bpmn +0 -12
  56. package/test/fixtures/bpmn/participant-interfaceRef.bpmn +0 -20
  57. package/test/fixtures/bpmn/potentialOwner.bpmn +0 -11
  58. package/test/fixtures/bpmn/process-children.bpmn +0 -24
  59. package/test/fixtures/bpmn/scriptTask-script.part.bpmn +0 -4
  60. package/test/fixtures/bpmn/sequenceFlow-conditionExpression.part.bpmn +0 -5
  61. package/test/fixtures/bpmn/simple-default-ns.bpmn +0 -31
  62. package/test/fixtures/bpmn/simple.bpmn +0 -31
  63. package/test/fixtures/bpmn/sub-process-flow-nodes.part.bpmn +0 -8
  64. package/test/fixtures/bpmn/sub-process.part.bpmn +0 -10
  65. package/test/fixtures/bpmn/subprocess-flow-nodes-outgoing.part.bpmn +0 -16
  66. package/test/fixtures/bpmn/throw-event-dataInputAssociations.part.bpmn +0 -5
  67. package/test/fixtures/bpmn/timerEventDefinition.part.bpmn +0 -5
  68. package/test/fixtures/bpmn/vendor/signavio-complex-no-extensions.bpmn +0 -2151
  69. package/test/fixtures/bpmn/vendor/yaoqiang-event-definitions.bpmn +0 -396
  70. package/test/fixtures/bpmn/vendor.xsd +0 -14
  71. package/test/fixtures/bpmn/xsi-type.bpmn +0 -61
  72. package/test/fixtures/json/model/camunda.json +0 -224
  73. package/test/fixtures/json/model/drools.json +0 -24
  74. package/test/fixtures/xsd/BPMN20.xsd +0 -39
  75. package/test/fixtures/xsd/Vendor.xsd +0 -14
  76. package/test/helper.js +0 -23
  77. package/test/integration/camunda/read.js +0 -203
  78. package/test/integration/camunda/roundtrip.js +0 -48
  79. package/test/integration/camunda/write.js +0 -249
  80. package/test/integration/misc.js +0 -107
  81. package/test/matchers.js +0 -19
  82. package/test/spec/adapter/cmof/builder.js +0 -194
  83. package/test/spec/adapter/cmof/generate-simple.js +0 -560
  84. package/test/spec/bpmn-moddle.js +0 -208
  85. package/test/spec/xml/edit.js +0 -76
  86. package/test/spec/xml/read.js +0 -986
  87. package/test/spec/xml/roundtrip.js +0 -540
  88. package/test/spec/xml/write.js +0 -980
  89. package/test/xml-helper.js +0 -39
@@ -1,980 +0,0 @@
1
- 'use strict';
2
-
3
- var assign = require('lodash/object/assign'),
4
- isFunction = require('lodash/lang/isFunction');
5
-
6
- var Helper = require('../../helper');
7
-
8
-
9
-
10
- describe('bpmn-moddle - write', function() {
11
-
12
- var moddle = Helper.createModdle();
13
-
14
-
15
- function write(element, options, callback) {
16
- if (isFunction(options)) {
17
- callback = options;
18
- options = {};
19
- }
20
-
21
- // skip preamble for tests
22
- options = assign({ preamble: false }, options);
23
-
24
- moddle.toXML(element, options, callback);
25
- }
26
-
27
-
28
-
29
- describe('should export types', function() {
30
-
31
- describe('bpmn', function() {
32
-
33
- it('Definitions (empty)', function(done) {
34
-
35
- // given
36
- var definitions = moddle.create('bpmn:Definitions');
37
-
38
- var expectedXML =
39
- '<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" />';
40
-
41
- // when
42
- write(definitions, function(err, result) {
43
-
44
- // then
45
- expect(result).to.eql(expectedXML);
46
-
47
- done(err);
48
- });
49
- });
50
-
51
-
52
- it('Definitions (participant + interface)', function(done) {
53
-
54
- // given
55
- var interfaceElement = moddle.create('bpmn:Interface', {
56
- id: 'Interface_1'
57
- });
58
-
59
- var participantElement = moddle.create('bpmn:Participant', {
60
- id: 'Process_1',
61
- interfaceRef: [
62
- interfaceElement
63
- ]
64
- });
65
-
66
- var collaborationElement = moddle.create('bpmn:Collaboration', {
67
- participants: [
68
- participantElement
69
- ]
70
- });
71
-
72
- var definitions = moddle.create('bpmn:Definitions', {
73
- targetNamespace: 'http://bpmn.io/bpmn',
74
- rootElements: [
75
- interfaceElement,
76
- collaborationElement
77
- ]
78
- });
79
-
80
- var expectedXML =
81
- '<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" ' +
82
- 'targetNamespace="http://bpmn.io/bpmn">' +
83
- '<bpmn:interface id="Interface_1" />' +
84
- '<bpmn:collaboration>' +
85
- '<bpmn:participant id="Process_1">' +
86
- '<bpmn:interfaceRef>Interface_1</bpmn:interfaceRef>' +
87
- '</bpmn:participant>' +
88
- '</bpmn:collaboration>' +
89
- '</bpmn:definitions>';
90
-
91
- // when
92
- write(definitions, function(err, result) {
93
-
94
- // then
95
- expect(result).to.eql(expectedXML);
96
-
97
- done(err);
98
- });
99
- });
100
-
101
-
102
- it('ScriptTask#script', function(done) {
103
-
104
- // given
105
- var scriptTask = moddle.create('bpmn:ScriptTask', {
106
- id: 'ScriptTask_1',
107
- scriptFormat: 'JavaScript',
108
- script: 'context.set("FOO", "&nbsp;");'
109
- });
110
-
111
- var expectedXML =
112
- '<bpmn:scriptTask xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" ' +
113
- 'id="ScriptTask_1" scriptFormat="JavaScript">' +
114
- '<bpmn:script><![CDATA[context.set("FOO", "&nbsp;");]]></bpmn:script>' +
115
- '</bpmn:scriptTask>';
116
-
117
- // when
118
- write(scriptTask, function(err, result) {
119
-
120
- // then
121
- expect(result).to.eql(expectedXML);
122
-
123
- done(err);
124
- });
125
- });
126
-
127
- it('Task with null property', function(done) {
128
-
129
- // given
130
- var task = moddle.create('bpmn:Task', {
131
- id: 'Task_1',
132
- default: null
133
- });
134
-
135
- // when
136
- var expectedXML =
137
- '<bpmn:task xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" ' +
138
- 'id="Task_1" />';
139
-
140
- // then
141
- write(task, function(err, result) {
142
-
143
- // then
144
- expect(result).to.eql(expectedXML);
145
-
146
- done(err);
147
- });
148
- });
149
-
150
-
151
- it('SequenceFlow#conditionExpression', function(done) {
152
-
153
- // given
154
- var sequenceFlow = moddle.create('bpmn:SequenceFlow', {
155
- id: 'SequenceFlow_1'
156
- });
157
-
158
- sequenceFlow.conditionExpression = moddle.create('bpmn:FormalExpression', { body: '${ foo < bar }' });
159
-
160
- var expectedXML =
161
- '<bpmn:sequenceFlow xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" ' +
162
- 'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' +
163
- 'id="SequenceFlow_1">\n' +
164
- ' <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression"><![CDATA[${ foo < bar }]]></bpmn:conditionExpression>\n' +
165
- '</bpmn:sequenceFlow>\n';
166
-
167
- // when
168
- write(sequenceFlow, { format: true }, function(err, result) {
169
-
170
- if (err) {
171
- return done(err);
172
- }
173
-
174
- // then
175
- expect(result).to.eql(expectedXML);
176
-
177
- done(err);
178
- });
179
- });
180
-
181
-
182
- it('MultiInstanceLoopCharacteristics', function(done) {
183
-
184
- // given
185
- var loopCharacteristics = moddle.create('bpmn:MultiInstanceLoopCharacteristics', {
186
- loopCardinality: moddle.create('bpmn:FormalExpression', { body: '${ foo < bar }' }),
187
- loopDataInputRef: moddle.create('bpmn:Property', { id: 'loopDataInputRef' }),
188
- loopDataOutputRef: moddle.create('bpmn:Property', { id: 'loopDataOutputRef' }),
189
- inputDataItem: moddle.create('bpmn:DataInput', { id: 'inputDataItem' }),
190
- outputDataItem: moddle.create('bpmn:DataOutput', { id: 'outputDataItem' }),
191
- complexBehaviorDefinition: [
192
- moddle.create('bpmn:ComplexBehaviorDefinition', { id: 'complexBehaviorDefinition' })
193
- ],
194
- completionCondition: moddle.create('bpmn:FormalExpression', { body: '${ done }' }),
195
- isSequential: true,
196
- behavior: 'One',
197
- oneBehaviorEventRef: moddle.create('bpmn:CancelEventDefinition', { id: 'oneBehaviorEventRef' }),
198
- noneBehaviorEventRef: moddle.create('bpmn:MessageEventDefinition', { id: 'noneBehaviorEventRef' })
199
- });
200
-
201
- var expectedXML =
202
- '<bpmn:multiInstanceLoopCharacteristics xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" ' +
203
- 'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' +
204
- 'isSequential="true" ' +
205
- 'behavior="One" ' +
206
- 'oneBehaviorEventRef="oneBehaviorEventRef" ' +
207
- 'noneBehaviorEventRef="noneBehaviorEventRef">' +
208
- '<bpmn:loopCardinality xsi:type="bpmn:tFormalExpression"><![CDATA[${ foo < bar }]]></bpmn:loopCardinality>' +
209
- '<bpmn:loopDataInputRef>loopDataInputRef</bpmn:loopDataInputRef>' +
210
- '<bpmn:loopDataOutputRef>loopDataOutputRef</bpmn:loopDataOutputRef>' +
211
- '<bpmn:inputDataItem id="inputDataItem" />' +
212
- '<bpmn:outputDataItem id="outputDataItem" />' +
213
- '<bpmn:complexBehaviorDefinition id="complexBehaviorDefinition" />' +
214
- '<bpmn:completionCondition xsi:type="bpmn:tFormalExpression">${ done }</bpmn:completionCondition>' +
215
- '</bpmn:multiInstanceLoopCharacteristics>';
216
-
217
- // when
218
- write(loopCharacteristics, function(err, result) {
219
-
220
- if (err) {
221
- return done(err);
222
- }
223
-
224
- // then
225
- expect(result).to.eql(expectedXML);
226
-
227
- done(err);
228
- });
229
- });
230
-
231
-
232
- it('Process', function(done) {
233
-
234
- // given
235
- var processElement = moddle.create('bpmn:Process', {
236
- id: 'Process_1',
237
- flowElements: [
238
- moddle.create('bpmn:Task', { id: 'Task_1' })
239
- ],
240
- properties: [
241
- moddle.create('bpmn:Property', { name: 'foo' })
242
- ],
243
- laneSets: [
244
- moddle.create('bpmn:LaneSet', { id: 'LaneSet_1' })
245
- ],
246
- monitoring: moddle.create('bpmn:Monitoring'),
247
- artifacts: [
248
- moddle.create('bpmn:TextAnnotation', {
249
- id: 'TextAnnotation_1',
250
- text: 'FOOBAR'
251
- })
252
- ],
253
- resources: [
254
- moddle.create('bpmn:PotentialOwner', { name: 'Walter' })
255
- ]
256
- });
257
-
258
- var expectedXML =
259
- '<bpmn:process xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" ' +
260
- 'id="Process_1">' +
261
- '<bpmn:monitoring />' +
262
- '<bpmn:property name="foo" />' +
263
- '<bpmn:laneSet id="LaneSet_1" />' +
264
- '<bpmn:task id="Task_1" />' +
265
- '<bpmn:textAnnotation id="TextAnnotation_1">' +
266
- '<bpmn:text>FOOBAR</bpmn:text>' +
267
- '</bpmn:textAnnotation>' +
268
- '<bpmn:potentialOwner name="Walter" />' +
269
- '</bpmn:process>';
270
-
271
- // when
272
- write(processElement, function(err, result) {
273
-
274
- if (err) {
275
- return done(err);
276
- }
277
-
278
- // then
279
- expect(result).to.eql(expectedXML);
280
-
281
- done(err);
282
- });
283
- });
284
-
285
-
286
- it('Activity', function(done) {
287
-
288
- // given
289
- var activity = moddle.create('bpmn:Activity', {
290
- id: 'Activity_1',
291
- properties: [
292
- moddle.create('bpmn:Property', { name: 'FOO' }),
293
- moddle.create('bpmn:Property', { name: 'BAR' })
294
- ],
295
- resources: [
296
- moddle.create('bpmn:HumanPerformer', { name: 'Walter'} )
297
- ],
298
- dataInputAssociations: [
299
- moddle.create('bpmn:DataInputAssociation', { id: 'Input_1' })
300
- ],
301
- dataOutputAssociations: [
302
- moddle.create('bpmn:DataOutputAssociation', { id: 'Output_1' })
303
- ],
304
- ioSpecification: moddle.create('bpmn:InputOutputSpecification')
305
- });
306
-
307
- var expectedXML =
308
- '<bpmn:activity xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" id="Activity_1">' +
309
- '<bpmn:ioSpecification />' +
310
- '<bpmn:property name="FOO" />' +
311
- '<bpmn:property name="BAR" />' +
312
- '<bpmn:dataInputAssociation id="Input_1" />' +
313
- '<bpmn:dataOutputAssociation id="Output_1" />' +
314
- '<bpmn:humanPerformer name="Walter" />' +
315
- '</bpmn:activity>';
316
-
317
- // when
318
- write(activity, function(err, result) {
319
-
320
- if (err) {
321
- return done(err);
322
- }
323
-
324
- // then
325
- expect(result).to.eql(expectedXML);
326
-
327
- done(err);
328
- });
329
- });
330
-
331
-
332
- it('BaseElement#documentation', function(done) {
333
-
334
- // given
335
- var defs = moddle.create('bpmn:Definitions', {
336
- id: 'Definitions_1'
337
- });
338
-
339
- var docs = defs.get('documentation');
340
-
341
- docs.push(moddle.create('bpmn:Documentation', { textFormat: 'xyz', text: 'FOO\nBAR' }));
342
- docs.push(moddle.create('bpmn:Documentation', { text: '<some /><html></html>' }));
343
-
344
- var expectedXML =
345
- '<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" id="Definitions_1">' +
346
- '<bpmn:documentation textFormat="xyz"><![CDATA[FOO\nBAR]]></bpmn:documentation>' +
347
- '<bpmn:documentation><![CDATA[<some /><html></html>]]></bpmn:documentation>' +
348
- '</bpmn:definitions>';
349
-
350
- // when
351
- write(defs, function(err, result) {
352
-
353
- // then
354
- expect(result).to.eql(expectedXML);
355
-
356
- done(err);
357
- });
358
- });
359
-
360
-
361
- it('CallableElement#ioSpecification', function(done) {
362
-
363
- // given
364
- var callableElement = moddle.create('bpmn:CallableElement', {
365
- id: 'Callable_1',
366
- ioSpecification: moddle.create('bpmn:InputOutputSpecification')
367
- });
368
-
369
- var expectedXML =
370
- '<bpmn:callableElement xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" id="Callable_1">' +
371
- '<bpmn:ioSpecification />' +
372
- '</bpmn:callableElement>';
373
-
374
- // when
375
- write(callableElement, function(err, result) {
376
-
377
- // then
378
- expect(result).to.eql(expectedXML);
379
-
380
- done();
381
- });
382
- });
383
-
384
-
385
- it('ResourceRole#resourceRef', function(done) {
386
-
387
- // given
388
- var role = moddle.create('bpmn:ResourceRole', {
389
- id: 'Callable_1',
390
- resourceRef: moddle.create('bpmn:Resource', { id: 'REF' })
391
- });
392
-
393
- var expectedXML =
394
- '<bpmn:resourceRole xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" id="Callable_1">' +
395
- '<bpmn:resourceRef>REF</bpmn:resourceRef>' +
396
- '</bpmn:resourceRole>';
397
-
398
- // when
399
- write(role, function(err, result) {
400
-
401
- // then
402
- expect(err).not.to.exist;
403
-
404
- expect(result).to.eql(expectedXML);
405
-
406
- done(err);
407
- });
408
- });
409
-
410
-
411
- it('ResourceAssignmentExpression', function(done) {
412
-
413
- // given
414
- var expression = moddle.create('bpmn:FormalExpression', { body: '${ foo < bar }' });
415
-
416
- var assignmentExpression =
417
- moddle.create('bpmn:ResourceAssignmentExpression', {
418
- id: 'FOO BAR',
419
- expression: expression
420
- });
421
-
422
- var expectedXML =
423
- '<bpmn:resourceAssignmentExpression ' +
424
- 'xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" ' +
425
- 'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' +
426
- 'id="FOO BAR">' +
427
- '<bpmn:expression xsi:type="bpmn:tFormalExpression">' +
428
- '<![CDATA[${ foo < bar }]]>' +
429
- '</bpmn:expression>' +
430
- '</bpmn:resourceAssignmentExpression>';
431
-
432
- // when
433
- write(assignmentExpression, function(err, result, context) {
434
-
435
- if (err) {
436
- return done(err);
437
- }
438
-
439
- // then
440
- expect(result).to.eql(expectedXML);
441
-
442
- done(err);
443
- });
444
-
445
- });
446
-
447
-
448
- it('CallActivity#calledElement', function(done) {
449
-
450
- // given
451
- var callActivity = moddle.create('bpmn:CallActivity', {
452
- id: 'CallActivity_1',
453
- calledElement: 'otherProcess'
454
- });
455
-
456
- var expectedXML =
457
- '<bpmn:callActivity ' +
458
- 'xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" ' +
459
- 'id="CallActivity_1" calledElement="otherProcess" />';
460
-
461
- // when
462
- write(callActivity, function(err, result) {
463
-
464
- // then
465
- expect(result).to.eql(expectedXML);
466
-
467
- done(err);
468
- });
469
- });
470
-
471
-
472
- it('ItemDefinition#structureRef', function(done) {
473
-
474
- // given
475
- var itemDefinition = moddle.create('bpmn:ItemDefinition', {
476
- id: 'serviceInput',
477
- structureRef: 'service:CelsiusToFahrenheitSoapIn'
478
- });
479
-
480
- var expectedXML =
481
- '<bpmn:itemDefinition xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" ' +
482
- 'id="serviceInput" ' +
483
- 'structureRef="service:CelsiusToFahrenheitSoapIn" />';
484
-
485
- // when
486
- write(itemDefinition, function(err, result) {
487
-
488
- // then
489
- expect(result).to.eql(expectedXML);
490
-
491
- done(err);
492
- });
493
- });
494
-
495
-
496
- it('ItemDefinition#structureRef with ns', function(done) {
497
-
498
- // given
499
- var itemDefinition = moddle.create('bpmn:ItemDefinition', {
500
- 'xmlns:xs': 'http://xml-types',
501
- id: 'xsdBool',
502
- isCollection: true,
503
- itemKind: 'Information',
504
- structureRef: 'xs:tBool'
505
- });
506
-
507
- var expectedXML =
508
- '<bpmn:itemDefinition xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" ' +
509
- 'xmlns:xs="http://xml-types" ' +
510
- 'id="xsdBool" ' +
511
- 'itemKind="Information" ' +
512
- 'structureRef="xs:tBool" ' +
513
- 'isCollection="true" />';
514
-
515
-
516
- // when
517
- write(itemDefinition, function(err, result) {
518
-
519
- if (err) {
520
- return done(err);
521
- }
522
-
523
- // then
524
- expect(result).to.eql(expectedXML);
525
-
526
- done();
527
- });
528
- });
529
-
530
-
531
- it('Operation#implementationRef', function(done) {
532
-
533
- // given
534
- var operation = moddle.create('bpmn:Operation', {
535
- id: 'operation',
536
- implementationRef: 'foo:operation'
537
- });
538
-
539
- var expectedXML =
540
- '<bpmn:operation xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" ' +
541
- 'id="operation" ' +
542
- 'implementationRef="foo:operation" />';
543
-
544
- // when
545
- write(operation, function(err, result) {
546
-
547
- // then
548
- expect(result).to.eql(expectedXML);
549
-
550
- done(err);
551
- });
552
- });
553
-
554
-
555
- it('Interface#implementationRef', function(done) {
556
-
557
- // given
558
- var iface = moddle.create('bpmn:Interface', {
559
- id: 'interface',
560
- implementationRef: 'foo:interface'
561
- });
562
-
563
- var expectedXML =
564
- '<bpmn:interface xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" ' +
565
- 'id="interface" ' +
566
- 'implementationRef="foo:interface" />';
567
-
568
- // when
569
- write(iface, function(err, result) {
570
-
571
- // then
572
- expect(result).to.eql(expectedXML);
573
-
574
- done(err);
575
- });
576
- });
577
-
578
-
579
- it('Collaboration', function(done) {
580
-
581
- // given
582
-
583
- var participant = moddle.create('bpmn:Participant', {
584
- id: 'Participant_1'
585
- });
586
-
587
- var textAnnotation = moddle.create('bpmn:TextAnnotation', {
588
- id: 'TextAnnotation_1'
589
- });
590
-
591
- var collaboration = moddle.create('bpmn:Collaboration', {
592
- id: 'Collaboration_1',
593
- participants: [ participant ],
594
- artifacts: [ textAnnotation ]
595
- });
596
-
597
- var expectedXML =
598
- '<bpmn:collaboration xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" id="Collaboration_1">' +
599
- '<bpmn:participant id="Participant_1" />' +
600
- '<bpmn:textAnnotation id="TextAnnotation_1" />' +
601
- '</bpmn:collaboration>';
602
-
603
-
604
- // when
605
- write(collaboration, function(err, result) {
606
-
607
- if (err) {
608
- return done(err);
609
- }
610
-
611
- // then
612
- expect(result).to.eql(expectedXML);
613
-
614
- done();
615
- });
616
- });
617
-
618
-
619
- it('ExtensionElements', function(done) {
620
-
621
- // given
622
- var extensionElements = moddle.create('bpmn:ExtensionElements');
623
-
624
- var foo = moddle.createAny('vendor:foo', 'http://vendor', {
625
- key: 'FOO',
626
- value: 'BAR'
627
- });
628
-
629
- extensionElements.get('values').push(foo);
630
-
631
- var definitions = moddle.create('bpmn:Definitions', {
632
- extensionElements: extensionElements
633
- });
634
-
635
- var expectedXML =
636
- '<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" ' +
637
- 'xmlns:vendor="http://vendor">' +
638
- '<bpmn:extensionElements>' +
639
- '<vendor:foo key="FOO" value="BAR" />' +
640
- '</bpmn:extensionElements>' +
641
- '</bpmn:definitions>';
642
-
643
-
644
- // when
645
- write(definitions, function(err, result) {
646
-
647
- // then
648
- expect(result).to.eql(expectedXML);
649
-
650
- done(err);
651
- });
652
- });
653
-
654
-
655
- it('Operation#messageRef', function(done) {
656
- // given
657
- var inMessage = moddle.create('bpmn:Message', {
658
- id: 'fooInMessage'
659
- });
660
-
661
- var outMessage = moddle.create('bpmn:Message', {
662
- id: 'fooOutMessage'
663
- });
664
-
665
- var operation = moddle.create('bpmn:Operation', {
666
- id: 'operation',
667
- inMessageRef: inMessage,
668
- outMessageRef: outMessage
669
- });
670
-
671
- var expectedXML =
672
- '<bpmn:operation xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" id="operation">' +
673
- '<bpmn:inMessageRef>fooInMessage</bpmn:inMessageRef>' +
674
- '<bpmn:outMessageRef>fooOutMessage</bpmn:outMessageRef>' +
675
- '</bpmn:operation>';
676
-
677
- // when
678
- write(operation, function(err, result) {
679
-
680
- // then
681
- expect(result).to.eql(expectedXML);
682
-
683
- done(err);
684
- });
685
- });
686
- });
687
-
688
-
689
- describe('bpmndi', function() {
690
-
691
- it('BPMNDiagram', function(done) {
692
-
693
- // given
694
- var diagram = moddle.create('bpmndi:BPMNDiagram', { name: 'FOO', resolution: 96.5 });
695
-
696
- var expectedXML =
697
- '<bpmndi:BPMNDiagram xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" ' +
698
- 'name="FOO" ' +
699
- 'resolution="96.5" />';
700
-
701
- // when
702
- write(diagram, function(err, result) {
703
-
704
- if (err) {
705
- return done(err);
706
- }
707
-
708
- // then
709
- expect(result).to.eql(expectedXML);
710
-
711
- done(err);
712
- });
713
- });
714
-
715
-
716
- it('BPMNShape', function(done) {
717
-
718
- // given
719
- var bounds = moddle.create('dc:Bounds', { x: 100.0, y: 200.0, width: 50.0, height: 50.0 });
720
- var bpmnShape = moddle.create('bpmndi:BPMNShape', { bounds: bounds });
721
-
722
- var expectedXML =
723
- '<bpmndi:BPMNShape xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" ' +
724
- 'xmlns:di="http://www.omg.org/spec/DD/20100524/DI" ' +
725
- 'xmlns:dc="http://www.omg.org/spec/DD/20100524/DC">' +
726
- '<dc:Bounds x="100" y="200" width="50" height="50" />' +
727
- '</bpmndi:BPMNShape>';
728
-
729
- // when
730
- write(bpmnShape, function(err, result) {
731
-
732
- // then
733
- expect(result).to.eql(expectedXML);
734
-
735
- done(err);
736
- });
737
- });
738
-
739
- it('BPMNShape (colored)', function(done) {
740
-
741
- // given
742
- var bpmnShape = moddle.create('bpmndi:BPMNShape', {
743
- fill: '#ff0000',
744
- stroke: '#00ff00'
745
- });
746
-
747
- var expectedXML =
748
- '<bpmndi:BPMNShape xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" ' +
749
- 'xmlns:bioc="http://bpmn.io/schema/bpmn/biocolor/1.0" ' +
750
- 'bioc:stroke="#00ff00" bioc:fill="#ff0000" />';
751
-
752
- // when
753
- write(bpmnShape, function(err, result) {
754
-
755
- if (err) {
756
- done(err);
757
- }
758
-
759
- // then
760
- expect(result).to.eql(expectedXML);
761
-
762
- done();
763
- });
764
- });
765
-
766
- it('BPMNEdge (colored)', function(done) {
767
-
768
- // given
769
- var bpmnEdge = moddle.create('bpmndi:BPMNEdge', {
770
- fill: '#ff0000',
771
- stroke: '#00ff00'
772
- });
773
-
774
- var expectedXML =
775
- '<bpmndi:BPMNEdge xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" ' +
776
- 'xmlns:bioc="http://bpmn.io/schema/bpmn/biocolor/1.0" ' +
777
- 'bioc:stroke="#00ff00" bioc:fill="#ff0000" />';
778
-
779
- // when
780
- write(bpmnEdge, function(err, result) {
781
-
782
- if (err) {
783
- done(err);
784
- }
785
-
786
- // then
787
- expect(result).to.eql(expectedXML);
788
-
789
- done();
790
- });
791
- });
792
-
793
- });
794
-
795
- });
796
-
797
-
798
- describe('should export extensions', function() {
799
-
800
- it('manually added custom namespace', function(done) {
801
-
802
- // given
803
- var definitions = moddle.create('bpmn:Definitions');
804
-
805
- definitions.set('xmlns:foo', 'http://foobar');
806
-
807
- // or alternatively directly assign it to definitions.$attrs
808
-
809
- var expectedXML =
810
- '<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" ' +
811
- 'xmlns:foo="http://foobar" />';
812
-
813
- // when
814
- write(definitions, function(err, result) {
815
-
816
- if (err) {
817
- return done(err);
818
- }
819
-
820
- // then
821
- expect(result).to.eql(expectedXML);
822
-
823
- done(err);
824
- });
825
- });
826
-
827
-
828
- it('attributes on root', function(done) {
829
-
830
- // given
831
- var definitions = moddle.create('bpmn:Definitions');
832
-
833
- definitions.set('xmlns:foo', 'http://foobar');
834
- definitions.set('foo:bar', 'BAR');
835
-
836
- // or alternatively directly assign it to definitions.$attrs
837
-
838
- var expectedXML =
839
- '<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" ' +
840
- 'xmlns:foo="http://foobar" foo:bar="BAR" />';
841
-
842
- // when
843
- write(definitions, function(err, result) {
844
-
845
- // then
846
- expect(result).to.eql(expectedXML);
847
-
848
- done(err);
849
- });
850
- });
851
-
852
-
853
- it('attributes on nested element', function(done) {
854
-
855
- // given
856
- var signal = moddle.create('bpmn:Signal', {
857
- 'foo:bar': 'BAR'
858
- });
859
-
860
- var definitions = moddle.create('bpmn:Definitions');
861
-
862
- definitions.set('xmlns:foo', 'http://foobar');
863
- definitions.get('rootElements').push(signal);
864
-
865
- // or alternatively directly assign it to definitions.$attrs
866
-
867
- var expectedXML =
868
- '<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" ' +
869
- 'xmlns:foo="http://foobar">' +
870
- '<bpmn:signal foo:bar="BAR" />' +
871
- '</bpmn:definitions>';
872
-
873
- // when
874
- write(definitions, function(err, result) {
875
-
876
- // then
877
- expect(result).to.eql(expectedXML);
878
-
879
- done(err);
880
- });
881
- });
882
-
883
-
884
- it('elements via bpmn:extensionElements', function(done) {
885
-
886
- // given
887
-
888
- var vendorBgColor = moddle.createAny('vendor:info', 'http://vendor', {
889
- key: 'bgcolor',
890
- value: '#ffffff'
891
- });
892
-
893
- var vendorRole = moddle.createAny('vendor:info', 'http://vendor', {
894
- key: 'role',
895
- value: '[]'
896
- });
897
-
898
- var extensionElements = moddle.create('bpmn:ExtensionElements', {
899
- values: [ vendorBgColor, vendorRole ]
900
- });
901
-
902
- var definitions = moddle.create('bpmn:Definitions', { extensionElements: extensionElements });
903
-
904
- var expectedXML =
905
- '<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" ' +
906
- 'xmlns:vendor="http://vendor">' +
907
- '<bpmn:extensionElements>' +
908
- '<vendor:info key="bgcolor" value="#ffffff" />' +
909
- '<vendor:info key="role" value="[]" />' +
910
- '</bpmn:extensionElements>' +
911
- '</bpmn:definitions>';
912
-
913
-
914
- // when
915
- write(definitions, function(err, result) {
916
-
917
- if (err) {
918
- return done(err);
919
- }
920
-
921
- // then
922
- expect(result).to.eql(expectedXML);
923
-
924
- done();
925
- });
926
- });
927
-
928
-
929
- it('nested elements via bpmn:extensionElements', function(done) {
930
-
931
- var camundaNs = 'http://camunda.org/schema/1.0/bpmn';
932
-
933
- // when
934
-
935
- var inputParameter = moddle.createAny('camunda:inputParameter', camundaNs, {
936
- name: 'assigneeEntity',
937
- $body: 'user'
938
- });
939
-
940
- var inputOutput = moddle.createAny('camunda:inputOutput', camundaNs, {
941
- $children: [
942
- inputParameter
943
- ]
944
- });
945
-
946
- var extensionElements = moddle.create('bpmn:ExtensionElements', {
947
- values: [ inputOutput ]
948
- });
949
-
950
- var userTask = moddle.create('bpmn:UserTask', {
951
- extensionElements: extensionElements
952
- });
953
-
954
- var expectedXML =
955
- '<bpmn:userTask xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" ' +
956
- 'xmlns:camunda="' + camundaNs + '">' +
957
- '<bpmn:extensionElements>' +
958
- '<camunda:inputOutput>' +
959
- '<camunda:inputParameter name="assigneeEntity">user</camunda:inputParameter>' +
960
- '</camunda:inputOutput>' +
961
- '</bpmn:extensionElements>' +
962
- '</bpmn:userTask>';
963
-
964
- // when
965
- write(userTask, function(err, result) {
966
-
967
- if (err) {
968
- return done(err);
969
- }
970
-
971
- // then
972
- expect(result).to.eql(expectedXML);
973
-
974
- done();
975
- });
976
- });
977
-
978
- });
979
-
980
- });