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