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,986 +0,0 @@
1
- 'use strict';
2
-
3
- var os = require('os');
4
-
5
- var Helper = require('../../helper');
6
-
7
-
8
- describe('bpmn-moddle - read', function() {
9
-
10
- var moddle = Helper.createModdle();
11
-
12
- function read(xml, root, opts, callback) {
13
- return moddle.fromXML(xml, root, opts, callback);
14
- }
15
-
16
- function fromFile(file, root, opts, callback) {
17
- var contents = Helper.readFile(file);
18
- return read(contents, root, opts, callback);
19
- }
20
-
21
-
22
- describe('should import types', function() {
23
-
24
- describe('bpmn', function() {
25
-
26
- it('SubProcess#flowElements', function(done) {
27
-
28
- // given
29
-
30
- // when
31
- fromFile('test/fixtures/bpmn/sub-process-flow-nodes.part.bpmn', 'bpmn:SubProcess', function(err, result) {
32
-
33
- var expected = {
34
- $type: 'bpmn:SubProcess',
35
- id: 'SubProcess_1',
36
- name: 'Sub Process 1',
37
-
38
- flowElements: [
39
- { $type: 'bpmn:StartEvent', id: 'StartEvent_1', name: 'Start Event 1' },
40
- { $type: 'bpmn:Task', id: 'Task_1', name: 'Task' },
41
- { $type: 'bpmn:SequenceFlow', id: 'SequenceFlow_1', name: '' }
42
- ]
43
- };
44
-
45
- // then
46
- expect(result).to.jsonEqual(expected);
47
-
48
- done(err);
49
- });
50
- });
51
-
52
-
53
- it('SubProcess#flowElements (nested references)', function(done) {
54
-
55
- // given
56
-
57
- // when
58
- fromFile('test/fixtures/bpmn/sub-process.part.bpmn', 'bpmn:SubProcess', function(err, result) {
59
-
60
- var expected = {
61
- $type: 'bpmn:SubProcess',
62
- id: 'SubProcess_1',
63
- name: 'Sub Process 1',
64
-
65
- flowElements: [
66
- { $type: 'bpmn:StartEvent', id: 'StartEvent_1', name: 'Start Event 1' },
67
- { $type: 'bpmn:Task', id: 'Task_1', name: 'Task' },
68
- { $type: 'bpmn:SequenceFlow', id: 'SequenceFlow_1', name: '' }
69
- ]
70
- };
71
-
72
- // then
73
- expect(result).to.jsonEqual(expected);
74
-
75
- done(err);
76
- });
77
- });
78
-
79
-
80
- it('SubProcess#incoming', function(done) {
81
-
82
- // given
83
-
84
- // when
85
- fromFile('test/fixtures/bpmn/subprocess-flow-nodes-outgoing.part.bpmn', 'bpmn:Process', function(err, result) {
86
-
87
- var expectedSequenceFlow = {
88
- $type: 'bpmn:SequenceFlow',
89
- id: 'SequenceFlow_1'
90
- };
91
-
92
- var expectedSubProcess = {
93
- $type: 'bpmn:SubProcess',
94
- id: 'SubProcess_1',
95
- name: 'Sub Process 1',
96
-
97
- flowElements: [
98
- { $type: 'bpmn:Task', id: 'Task_1', name: 'Task' }
99
- ]
100
- };
101
-
102
- var expected = {
103
- $type: 'bpmn:Process',
104
- flowElements: [
105
- expectedSubProcess,
106
- expectedSequenceFlow
107
- ]
108
- };
109
-
110
- // then
111
- expect(result).to.jsonEqual(expected);
112
-
113
-
114
- var subProcess = result.flowElements[0];
115
- var sequenceFlow = result.flowElements[1];
116
-
117
- // expect correctly resolved references
118
- expect(subProcess.incoming).to.jsonEqual([ expectedSequenceFlow ]);
119
- expect(subProcess.outgoing).to.jsonEqual([ expectedSequenceFlow ]);
120
-
121
- expect(sequenceFlow.sourceRef).to.jsonEqual(expectedSubProcess);
122
- expect(sequenceFlow.targetRef).to.jsonEqual(expectedSubProcess);
123
-
124
- done(err);
125
- });
126
- });
127
-
128
-
129
- it('TimerEventDefinition#expression', function(done) {
130
-
131
- // given
132
- var file = 'test/fixtures/bpmn/timerEventDefinition.part.bpmn';
133
-
134
- // when
135
- fromFile(file, 'bpmn:TimerEventDefinition', function(err, result) {
136
-
137
- // then
138
- expect(result).to.jsonEqual({
139
- $type: 'bpmn:TimerEventDefinition',
140
- id: 'Definition_1',
141
- timeCycle: {
142
- $type: 'bpmn:FormalExpression',
143
- id: 'TimeCycle_1',
144
- body: '1w'
145
- }
146
- });
147
-
148
- done(err);
149
- });
150
-
151
- });
152
-
153
-
154
- it('Documentation', function(done) {
155
-
156
- // when
157
- fromFile('test/fixtures/bpmn/documentation.bpmn', function(err, result) {
158
-
159
- // then
160
- expect(result).to.jsonEqual({
161
- $type: 'bpmn:Definitions',
162
- id: 'documentation',
163
- targetNamespace: 'http://bpmn.io/schema/bpmn',
164
- rootElements: [
165
- {
166
- $type: 'bpmn:Process',
167
- id: 'Process_1',
168
- documentation: [
169
- { $type : 'bpmn:Documentation', text : 'THIS IS A PROCESS' }
170
- ],
171
- flowElements: [
172
- {
173
- $type : 'bpmn:SubProcess',
174
- id: 'SubProcess_1',
175
- name : 'Sub Process 1',
176
- documentation : [
177
- {
178
- $type : 'bpmn:Documentation',
179
- text : '\n <h1>THIS IS HTML</h1>\n '
180
- }
181
- ]
182
- }
183
- ]
184
- }
185
- ]
186
- });
187
-
188
- done(err);
189
- });
190
-
191
- });
192
-
193
-
194
- it('ThrowEvent#dataInputAssociations', function(done) {
195
-
196
- // given
197
-
198
- // when
199
- fromFile('test/fixtures/bpmn/throw-event-dataInputAssociations.part.bpmn', 'bpmn:EndEvent', function(err, result) {
200
-
201
- var expected = {
202
- $type: 'bpmn:EndEvent',
203
- id: 'EndEvent_1',
204
-
205
- dataInputAssociations: [
206
- { $type: 'bpmn:DataInputAssociation', id: 'DataInputAssociation_1' }
207
- ]
208
- };
209
-
210
- // then
211
- expect(result).to.jsonEqual(expected);
212
-
213
- done(err);
214
- });
215
- });
216
-
217
-
218
- it('CatchEvent#dataOutputAssociations', function(done) {
219
-
220
- // given
221
-
222
- // when
223
- fromFile('test/fixtures/bpmn/catch-event-dataOutputAssociations.part.bpmn', 'bpmn:StartEvent', function(err, result) {
224
-
225
- var expected = {
226
- $type: 'bpmn:StartEvent',
227
- id: 'StartEvent_1',
228
-
229
- dataOutputAssociations: [
230
- { $type: 'bpmn:DataOutputAssociation', id: 'DataOutputAssociation_1' }
231
- ]
232
- };
233
-
234
- // then
235
- expect(result).to.jsonEqual(expected);
236
-
237
- done(err);
238
- });
239
- });
240
-
241
-
242
- it('Escalation + Error', function(done) {
243
-
244
- // when
245
- fromFile('test/fixtures/bpmn/escalation-error.bpmn', function(err, result) {
246
-
247
- // then
248
- expect(result).to.jsonEqual({
249
- $type: 'bpmn:Definitions',
250
- id: 'test',
251
- targetNamespace: 'http://bpmn.io/schema/bpmn',
252
- rootElements: [
253
- { $type : 'bpmn:Escalation', id : 'escalation' },
254
- { $type : 'bpmn:Error', id : 'error' }
255
- ]
256
- });
257
-
258
- done(err);
259
- });
260
- });
261
-
262
-
263
- it('ExtensionElements', function(done) {
264
-
265
- // when
266
- fromFile('test/fixtures/bpmn/extension-elements.bpmn', function(err, result) {
267
-
268
- expect(result).to.jsonEqual({
269
- $type: 'bpmn:Definitions',
270
- id: 'test',
271
- targetNamespace: 'http://bpmn.io/schema/bpmn',
272
- extensionElements: {
273
- $type : 'bpmn:ExtensionElements',
274
- values : [
275
- { $type: 'vendor:info', key: 'bgcolor', value: '#ffffff' },
276
- { $type: 'vendor:info', key: 'role', value: '[]' }
277
- ]
278
- }
279
- });
280
-
281
- done(err);
282
- });
283
- });
284
-
285
-
286
- it('ScriptTask', function(done) {
287
-
288
- // given
289
-
290
- // when
291
- fromFile('test/fixtures/bpmn/scriptTask-script.part.bpmn', 'bpmn:ScriptTask', function(err, result) {
292
-
293
- // then
294
- expect(result).to.jsonEqual({
295
- $type: 'bpmn:ScriptTask',
296
- id : 'ScriptTask_4',
297
- scriptFormat: 'Javascript',
298
- script: 'context.set("FOO", "BAR");'
299
- });
300
-
301
- done(err);
302
- });
303
- });
304
-
305
-
306
- it('CallActivity#calledElement', function(done) {
307
-
308
- // when
309
- fromFile('test/fixtures/bpmn/callActivity-calledElement.part.bpmn', 'bpmn:CallActivity', function(err, result) {
310
-
311
- // then
312
- expect(result).to.jsonEqual({
313
- $type: 'bpmn:CallActivity',
314
- id: 'CallActivity_1',
315
- calledElement: 'otherProcess'
316
- });
317
-
318
- done(err);
319
- });
320
- });
321
-
322
-
323
- it('ItemDefinition#structureRef', function(done) {
324
-
325
- // when
326
- fromFile('test/fixtures/bpmn/itemDefinition-structureRef.part.bpmn', 'bpmn:ItemDefinition', function(err, result) {
327
-
328
- // then
329
- expect(result).to.jsonEqual({
330
- $type: 'bpmn:ItemDefinition',
331
- id: 'itemDefinition',
332
- structureRef: 'foo:Service'
333
- });
334
-
335
- done(err);
336
- });
337
- });
338
-
339
-
340
- it('Operation#implementationRef', function(done) {
341
-
342
- // when
343
- fromFile('test/fixtures/bpmn/operation-implementationRef.part.bpmn', 'bpmn:Operation', function(err, result) {
344
-
345
- // then
346
- expect(result).to.jsonEqual({
347
- $type: 'bpmn:Operation',
348
- id: 'operation',
349
- implementationRef: 'foo:operation'
350
- });
351
-
352
- done(err);
353
- });
354
- });
355
-
356
-
357
- it('Interface#implementationRef', function(done) {
358
-
359
- // when
360
- fromFile('test/fixtures/bpmn/interface-implementationRef.part.bpmn', 'bpmn:Interface', function(err, result) {
361
-
362
- // then
363
- expect(result).to.jsonEqual({
364
- $type: 'bpmn:Interface',
365
- id: 'interface',
366
- implementationRef: 'foo:interface'
367
- });
368
-
369
- done(err);
370
- });
371
- });
372
-
373
-
374
- it('Lane#childLaneSet', function(done) {
375
-
376
- // when
377
- fromFile('test/fixtures/bpmn/lane-childLaneSets.part.bpmn', 'bpmn:Lane', function(err, result) {
378
-
379
- // then
380
- expect(result).to.jsonEqual({
381
- $type: 'bpmn:Lane',
382
- id: 'Lane_1',
383
- name: 'Lane',
384
- childLaneSet: {
385
- $type: 'bpmn:LaneSet',
386
- id: 'LaneSet_2',
387
- lanes: [
388
- {
389
- $type: 'bpmn:Lane',
390
- id: 'Lane_2',
391
- name: 'Nested Lane'
392
- }
393
- ]
394
- }
395
- });
396
-
397
- done(err);
398
- });
399
- });
400
-
401
-
402
- it('SequenceFlow#conditionExpression', function(done) {
403
-
404
- // when
405
- fromFile('test/fixtures/bpmn/sequenceFlow-conditionExpression.part.bpmn', 'bpmn:SequenceFlow', function(err, result) {
406
-
407
- if (err) {
408
- return done(err);
409
- }
410
-
411
- // then
412
- expect(result).to.jsonEqual({
413
- $type: 'bpmn:SequenceFlow',
414
- id: 'SequenceFlow_1',
415
- conditionExpression: {
416
- $type: 'bpmn:FormalExpression',
417
- body: '${foo > bar}'
418
- }
419
- });
420
-
421
- done(err);
422
- });
423
- });
424
-
425
-
426
- it('Category', function(done) {
427
-
428
- // when
429
- fromFile('test/fixtures/bpmn/category.bpmn', function(err, result) {
430
-
431
- if (err) {
432
- return done(err);
433
- }
434
-
435
- var category = result.rootElements[0];
436
-
437
- // then
438
- expect(category).to.jsonEqual({
439
- $type: "bpmn:Category",
440
- id: "sid-ccc7e63e-916e-4bd0-a9f0-98cbff749195",
441
- categoryValue: [
442
- {
443
- $type: "bpmn:CategoryValue",
444
- id: "sid-afd7e63e-916e-4bd0-a9f0-98cbff749193",
445
- value: "group with label"
446
- }
447
- ]
448
- });
449
-
450
- done(err);
451
- });
452
- });
453
-
454
-
455
- it('MultiInstanceLoopCharacteristics#completionCondition', function(done) {
456
-
457
- // when
458
- fromFile('test/fixtures/bpmn/multiInstanceLoopCharacteristics-completionCondition.part.bpmn', 'bpmn:MultiInstanceLoopCharacteristics', function(err, result) {
459
-
460
- if (err) {
461
- return done(err);
462
- }
463
-
464
- // then
465
- expect(result).to.jsonEqual({
466
- $type: 'bpmn:MultiInstanceLoopCharacteristics',
467
- completionCondition: {
468
- $type: 'bpmn:FormalExpression',
469
- body: '${foo > bar}'
470
- }
471
- });
472
-
473
- done(err);
474
- });
475
- });
476
-
477
-
478
- it('Operation#messageRef', function(done) {
479
-
480
- // when
481
- fromFile('test/fixtures/bpmn/operation-messageRef.bpmn', 'bpmn:Definitions', function(err, result, context) {
482
-
483
- var inMessage = {
484
- property: 'bpmn:inMessageRef',
485
- id: 'fooInMessage',
486
- element: { $type: 'bpmn:Operation', id: 'operation', name: 'foo' }
487
- };
488
-
489
- var outMessage = {
490
- property: 'bpmn:outMessageRef',
491
- id: 'fooOutMessage',
492
- element: { $type: 'bpmn:Operation', id: 'operation', name: 'foo' }
493
- };
494
-
495
- var references = context.references;
496
-
497
- // then
498
- expect(references).to.jsonEqual([ inMessage, outMessage ]);
499
-
500
- done(err);
501
- });
502
- });
503
-
504
- });
505
-
506
-
507
- describe('bpmndi', function() {
508
-
509
- it('Extensions', function(done) {
510
-
511
- // when
512
- fromFile('test/fixtures/bpmn/di/bpmnDiagram-extension.part.bpmn', 'bpmndi:BPMNDiagram', function(err, result) {
513
-
514
- if (err) {
515
- return done(err);
516
- }
517
-
518
- var expected = {
519
- $type: 'bpmndi:BPMNDiagram',
520
- id: 'BPMNDiagram_1',
521
- plane: {
522
- $type: 'bpmndi:BPMNPlane',
523
- id: 'BPMNPlane_1',
524
- extension: {
525
- $type: 'di:Extension',
526
- values: [
527
- {
528
- $type: 'vendor:baz',
529
- baz: 'BAZ'
530
- }
531
- ]
532
- },
533
- planeElement: [
534
- {
535
- $type: 'bpmndi:BPMNShape',
536
- id: 'BPMNShape_1',
537
- extension: {
538
- $type: 'di:Extension',
539
- values: [
540
- {
541
- $type: 'vendor:bar',
542
- $body: 'BAR'
543
- }
544
- ]
545
- }
546
- },
547
- {
548
- $type: 'bpmndi:BPMNEdge',
549
- id: 'BPMNEdge_1',
550
- extension: {
551
- $type: 'di:Extension'
552
- }
553
- }
554
- ]
555
- }
556
- };
557
-
558
- // then
559
- expect(result).to.jsonEqual(expected);
560
-
561
- done(err);
562
- });
563
- });
564
-
565
-
566
- it('BPMNShape#bounds (non-ns-attributes)', function(done) {
567
-
568
- // given
569
-
570
- // when
571
- fromFile('test/fixtures/bpmn/di/bpmnShape.part.bpmn', 'bpmndi:BPMNShape', function(err, result) {
572
-
573
- var expected = {
574
- $type: 'bpmndi:BPMNShape',
575
- id: 'BPMNShape_1',
576
- isExpanded: true,
577
- bounds: { $type: 'dc:Bounds', height: 300.0, width: 300.0, x: 300.0, y: 80.0 }
578
- };
579
-
580
- // then
581
- expect(result).to.jsonEqual(expected);
582
-
583
- done(err);
584
- });
585
- });
586
-
587
-
588
- it('BPMNEdge#waypoint', function(done) {
589
-
590
- // given
591
-
592
- // when
593
- fromFile('test/fixtures/bpmn/di/bpmnEdge-waypoint.part.bpmn', 'bpmndi:BPMNEdge', function(err, result) {
594
-
595
- // then
596
- expect(result).to.jsonEqual({
597
- $type: 'bpmndi:BPMNEdge',
598
- id : 'sid-2365FF07-4092-4B79-976A-AD192FE4E4E9_gui',
599
- waypoint: [
600
- { $type: 'dc:Point', x: 4905.0, y: 1545.0 },
601
- { $type: 'dc:Point', x: 4950.0, y: 1545.0 }
602
- ]
603
- });
604
-
605
- done(err);
606
- });
607
- });
608
-
609
-
610
- it('BPMNEdge#waypoint (explicit xsi:type)', function(done) {
611
-
612
- // given
613
-
614
- // when
615
- fromFile('test/fixtures/bpmn/di/bpmnEdge.part.bpmn', 'bpmndi:BPMNEdge', function(err, result) {
616
-
617
- var expected = {
618
- $type: 'bpmndi:BPMNEdge',
619
- id: 'BPMNEdge_1',
620
- waypoint: [
621
- { $type: 'dc:Point', x: 388.0, y: 260.0 },
622
- { $type: 'dc:Point', x: 420.0, y: 260.0 }
623
- ]
624
- };
625
-
626
- // then
627
- expect(result).to.jsonEqual(expected);
628
-
629
- done(err);
630
- });
631
- });
632
-
633
-
634
- it('BPMNDiagram (nested elements)', function(done) {
635
-
636
- // given
637
-
638
- // when
639
- fromFile('test/fixtures/bpmn/di/bpmnDiagram.part.bpmn', 'bpmndi:BPMNDiagram', function(err, result) {
640
-
641
- var expected = {
642
- $type: 'bpmndi:BPMNDiagram',
643
- id: 'bpmndiagram',
644
-
645
- plane: {
646
- $type: 'bpmndi:BPMNPlane',
647
- id: 'BPMNPlane_1',
648
- planeElement: [
649
- {
650
- $type: 'bpmndi:BPMNShape',
651
- id: 'BPMNShape_1',
652
- isExpanded: true,
653
- bounds: { $type: 'dc:Bounds', height: 300.0, width: 300.0, x: 300.0, y: 80.0 }
654
- },
655
- {
656
- $type: 'bpmndi:BPMNEdge',
657
- id: 'BPMNEdge_1',
658
- waypoint: [
659
- { $type: 'dc:Point', x: 388.0, y: 260.0 },
660
- { $type: 'dc:Point', x: 420.0, y: 260.0 }
661
- ]
662
- }
663
- ]
664
- }
665
- };
666
-
667
- // then
668
- expect(result).to.jsonEqual(expected);
669
-
670
- done(err);
671
- });
672
- });
673
-
674
- });
675
-
676
- });
677
-
678
-
679
- describe('should import references', function() {
680
-
681
- it('via attributes', function(done) {
682
-
683
- // given
684
- var xml = '<bpmn:sequenceFlow xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/bpmnModel" sourceRef="FOO_BAR" />';
685
-
686
- // when
687
- read(xml, 'bpmn:SequenceFlow', function(err, result, context) {
688
-
689
- var expectedReference = {
690
- element: {
691
- $type: 'bpmn:SequenceFlow'
692
- },
693
- property: 'bpmn:sourceRef',
694
- id: 'FOO_BAR'
695
- };
696
-
697
- var references = context.references;
698
-
699
- // then
700
- expect(references).to.jsonEqual([ expectedReference ]);
701
-
702
- done(err);
703
- });
704
- });
705
-
706
-
707
- it('via elements', function(done) {
708
-
709
- // given
710
- var xml =
711
- '<bpmn:serviceTask xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/bpmnModel">' +
712
- '<bpmn:outgoing>OUT_1</bpmn:outgoing>' +
713
- '<bpmn:outgoing>OUT_2</bpmn:outgoing>' +
714
- '</bpmn:serviceTask>';
715
-
716
- // when
717
- read(xml, 'bpmn:ServiceTask', function(err, result, context) {
718
-
719
- var reference1 = {
720
- property: 'bpmn:outgoing',
721
- id: 'OUT_1',
722
- element: { $type: 'bpmn:ServiceTask' }
723
- };
724
-
725
- var reference2 = {
726
- property: 'bpmn:outgoing',
727
- id: 'OUT_2',
728
- element: { $type: 'bpmn:ServiceTask' }
729
- };
730
-
731
- var references = context.references;
732
-
733
- // then
734
- expect(references).to.jsonEqual([ reference1, reference2 ]);
735
-
736
- done(err);
737
- });
738
- });
739
- });
740
-
741
-
742
- describe('should import extensions', function() {
743
-
744
- it('attributes on root', function(done) {
745
-
746
- // given
747
- var xml = '<bpmn:sequenceFlow xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/bpmnModel" ' +
748
- 'xmlns:foo="http://foobar" foo:bar="BAR" />';
749
-
750
- // when
751
- read(xml, 'bpmn:SequenceFlow', function(err, result, context) {
752
-
753
- // then
754
- expect(result.$attrs['foo:bar']).to.eql("BAR");
755
-
756
- done(err);
757
- });
758
-
759
- });
760
-
761
-
762
- it('elements via bpmn:extensionElements', function(done) {
763
-
764
- // when
765
- fromFile('test/fixtures/bpmn/extension-elements.bpmn', function(err, result) {
766
-
767
- expect(result).to.jsonEqual({
768
- $type: 'bpmn:Definitions',
769
- id: 'test',
770
- targetNamespace: 'http://bpmn.io/schema/bpmn',
771
- extensionElements: {
772
- $type : 'bpmn:ExtensionElements',
773
- values : [
774
- { $type: 'vendor:info', key: 'bgcolor', value: '#ffffff' },
775
- { $type: 'vendor:info', key: 'role', value: '[]' }
776
- ]
777
- }
778
- });
779
-
780
- done(err);
781
- });
782
-
783
- });
784
-
785
- });
786
-
787
-
788
- describe('should read xml documents', function() {
789
-
790
- it('empty definitions', function(done) {
791
-
792
- // given
793
-
794
- // when
795
- fromFile('test/fixtures/bpmn/empty-definitions.bpmn', function(err, result) {
796
-
797
- var expected = {
798
- $type: 'bpmn:Definitions',
799
- id: 'empty-definitions',
800
- targetNamespace: 'http://bpmn.io/schema/bpmn'
801
- };
802
-
803
- // then
804
- expect(result).to.jsonEqual(expected);
805
-
806
- done(err);
807
- });
808
- });
809
-
810
-
811
- it('empty definitions (default ns)', function(done) {
812
-
813
- // given
814
-
815
- // when
816
- fromFile('test/fixtures/bpmn/empty-definitions-default-ns.bpmn', function(err, result) {
817
-
818
- var expected = {
819
- $type: 'bpmn:Definitions',
820
- id: 'empty-definitions',
821
- targetNamespace: 'http://bpmn.io/schema/bpmn'
822
- };
823
-
824
- // then
825
- expect(result).to.jsonEqual(expected);
826
-
827
- done(err);
828
- });
829
- });
830
-
831
-
832
- it('simple process', function(done) {
833
-
834
- // given
835
-
836
- // when
837
- fromFile('test/fixtures/bpmn/simple.bpmn', function(err, result) {
838
-
839
- // then
840
- expect(result.id).to.equal('simple');
841
-
842
- done(err);
843
- });
844
- });
845
-
846
-
847
- it('simple process (default ns)', function(done) {
848
-
849
- // given
850
-
851
- // when
852
- fromFile('test/fixtures/bpmn/simple-default-ns.bpmn', function(err, result) {
853
-
854
- expect(result.id).to.equal('simple');
855
-
856
- done(err);
857
- });
858
- });
859
-
860
- });
861
-
862
-
863
- describe('should handle errors', function() {
864
-
865
- it('when importing non-xml text', function(done) {
866
-
867
- // when
868
- fromFile('test/fixtures/bpmn/error/no-xml.txt', function(err, result) {
869
-
870
- expect(err).to.exist;
871
-
872
- done();
873
- });
874
- });
875
-
876
-
877
- it('when importing binary', function(done) {
878
-
879
- // when
880
- fromFile('test/fixtures/bpmn/error/binary.png', function(err, result) {
881
-
882
- expect(err).to.exist;
883
-
884
- done();
885
- });
886
-
887
- });
888
-
889
-
890
- it('when importing bpmn:Extension (missing definition)', function(done) {
891
-
892
- // when
893
- fromFile('test/fixtures/bpmn/error/extension-definition-missing.bpmn', function(err, result, context) {
894
-
895
- var warnings = context.warnings;
896
-
897
- // then
898
- expect(warnings).to.have.length(1);
899
-
900
- expect(warnings[0].message).to.eql('unresolved reference <ino:tInnovator>');
901
-
902
- expect(err).not.to.exist;
903
-
904
- done();
905
- });
906
- });
907
-
908
-
909
- it('when importing invalid bpmn', function(done) {
910
-
911
- // when
912
- fromFile('test/fixtures/bpmn/error/undeclared-ns-child.bpmn', function(err, result, context) {
913
-
914
- var warnings = context.warnings;
915
-
916
- expect(err).not.to.exist;
917
- expect(warnings.length).to.eql(1);
918
-
919
- done();
920
- });
921
- });
922
-
923
-
924
- it('when importing invalid categoryValue / reference', function(done) {
925
-
926
- // when
927
- fromFile('test/fixtures/bpmn/error/categoryValue.bpmn', function(err, result, context) {
928
-
929
- var warnings = context.warnings;
930
-
931
- // then
932
- expect(err).not.to.exist;
933
-
934
- // wrong <categoryValue> + unresolvable reference
935
- expect(warnings.length).to.eql(2);
936
-
937
- var invalidElementWarning = warnings[0];
938
- var unresolvableReferenceWarning = warnings[1];
939
-
940
- expect(invalidElementWarning.message).to.eql(
941
- 'unparsable content <categoryValue> detected\n\t' +
942
- 'line: 2\n\t' +
943
- 'column: 89\n\t' +
944
- 'nested error: unrecognized element <bpmn:categoryValue>');
945
-
946
- expect(unresolvableReferenceWarning.message).to.eql(
947
- 'unresolved reference <sid-afd7e63e-916e-4bd0-a9f0-98cbff749193>');
948
-
949
- done();
950
- });
951
- });
952
-
953
-
954
- it('when importing valid bpmn / unrecognized element', function(done) {
955
-
956
- // when
957
- fromFile('test/fixtures/bpmn/error/unrecognized-child.bpmn', function(err, result, context) {
958
-
959
- var warnings = context.warnings;
960
-
961
- expect(err).not.to.exist;
962
- expect(warnings.length).to.eql(1);
963
-
964
- done();
965
- });
966
- });
967
-
968
-
969
- it('when importing duplicate ids', function(done) {
970
-
971
- // when
972
- fromFile('test/fixtures/bpmn/error/duplicate-ids.bpmn', function(err, result, context) {
973
-
974
- var warnings = context.warnings;
975
-
976
- expect(err).not.to.exist;
977
- expect(warnings.length).to.eql(1);
978
- expect(warnings[0].message).to.contain('duplicate ID <test>');
979
-
980
- done();
981
- });
982
- });
983
-
984
- });
985
-
986
- });