|
| 1 | +/** |
| 2 | + * Copyright 2020 Bonitasoft S.A. |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + */ |
| 16 | +import { ShapeBpmnElementKind } from '../../../../../src/model/bpmn/shape/ShapeBpmnElementKind'; |
| 17 | +import { parseJsonAndExpectOnlyFlowNodes, verifyShape } from './JsonTestUtils'; |
| 18 | + |
| 19 | +describe('parse bpmn as json for inclusive gateway', () => { |
| 20 | + it('json containing one process with a single inclusive gateway', () => { |
| 21 | + const json = `{ |
| 22 | + "definitions" : { |
| 23 | + "process": { |
| 24 | + "inclusiveGateway": { |
| 25 | + "id":"inclusiveGateway_id_0", |
| 26 | + "name":"inclusiveGateway name" |
| 27 | + } |
| 28 | + }, |
| 29 | + "BPMNDiagram": { |
| 30 | + "name":"process 0", |
| 31 | + "BPMNPlane": { |
| 32 | + "BPMNShape": { |
| 33 | + "id":"shape_inclusiveGateway_id_0", |
| 34 | + "bpmnElement":"inclusiveGateway_id_0", |
| 35 | + "Bounds": { "x": 362, "y": 232, "width": 36, "height": 45 } |
| 36 | + } |
| 37 | + } |
| 38 | + } |
| 39 | + } |
| 40 | + }`; |
| 41 | + |
| 42 | + const model = parseJsonAndExpectOnlyFlowNodes(json, 1); |
| 43 | + |
| 44 | + verifyShape(model.flowNodes[0], { |
| 45 | + shapeId: 'shape_inclusiveGateway_id_0', |
| 46 | + bpmnElementId: 'inclusiveGateway_id_0', |
| 47 | + bpmnElementName: 'inclusiveGateway name', |
| 48 | + bpmnElementKind: ShapeBpmnElementKind.GATEWAY_INCLUSIVE, |
| 49 | + boundsX: 362, |
| 50 | + boundsY: 232, |
| 51 | + boundsWidth: 36, |
| 52 | + boundsHeight: 45, |
| 53 | + }); |
| 54 | + }); |
| 55 | + |
| 56 | + it('json containing one process declared as array with a single inclusive gateway', () => { |
| 57 | + const json = `{ |
| 58 | + "definitions": { |
| 59 | + "process": [ |
| 60 | + { |
| 61 | + "inclusiveGateway": { |
| 62 | + "id":"inclusiveGateway_id_1", |
| 63 | + "name":"inclusiveGateway name" |
| 64 | + } |
| 65 | + } |
| 66 | + ], |
| 67 | + "BPMNDiagram": { |
| 68 | + "name":"process 0", |
| 69 | + "BPMNPlane": { |
| 70 | + "BPMNShape": { |
| 71 | + "id":"shape_inclusiveGateway_id_1", |
| 72 | + "bpmnElement":"inclusiveGateway_id_1", |
| 73 | + "Bounds": { "x": 362, "y": 232, "width": 36, "height": 45 } |
| 74 | + } |
| 75 | + } |
| 76 | + } |
| 77 | + } |
| 78 | + }`; |
| 79 | + |
| 80 | + const model = parseJsonAndExpectOnlyFlowNodes(json, 1); |
| 81 | + |
| 82 | + verifyShape(model.flowNodes[0], { |
| 83 | + shapeId: 'shape_inclusiveGateway_id_1', |
| 84 | + bpmnElementId: 'inclusiveGateway_id_1', |
| 85 | + bpmnElementName: 'inclusiveGateway name', |
| 86 | + bpmnElementKind: ShapeBpmnElementKind.GATEWAY_INCLUSIVE, |
| 87 | + boundsX: 362, |
| 88 | + boundsY: 232, |
| 89 | + boundsWidth: 36, |
| 90 | + boundsHeight: 45, |
| 91 | + }); |
| 92 | + }); |
| 93 | + |
| 94 | + it('json containing one process with an array of inclusive gateways with name & without name', () => { |
| 95 | + const json = `{ |
| 96 | + "definitions" : { |
| 97 | + "process": { |
| 98 | + "inclusiveGateway": [ |
| 99 | + { |
| 100 | + "id":"inclusiveGateway_id_0", |
| 101 | + "name":"inclusiveGateway name" |
| 102 | + }, { |
| 103 | + "id":"inclusiveGateway_id_1" |
| 104 | + } |
| 105 | + ] |
| 106 | + }, |
| 107 | + "BPMNDiagram": { |
| 108 | + "name":"process 0", |
| 109 | + "BPMNPlane": { |
| 110 | + "BPMNShape": [ |
| 111 | + { |
| 112 | + "id":"shape_inclusiveGateway_id_0", |
| 113 | + "bpmnElement":"inclusiveGateway_id_0", |
| 114 | + "Bounds": { "x": 362, "y": 232, "width": 36, "height": 45 } |
| 115 | + }, { |
| 116 | + "id":"shape_inclusiveGateway_id_1", |
| 117 | + "bpmnElement":"inclusiveGateway_id_1", |
| 118 | + "Bounds": { "x": 365, "y": 235, "width": 35, "height": 46 } |
| 119 | + } |
| 120 | + ] |
| 121 | + } |
| 122 | + } |
| 123 | + } |
| 124 | + }`; |
| 125 | + |
| 126 | + const model = parseJsonAndExpectOnlyFlowNodes(json, 2); |
| 127 | + |
| 128 | + verifyShape(model.flowNodes[0], { |
| 129 | + shapeId: 'shape_inclusiveGateway_id_0', |
| 130 | + bpmnElementId: 'inclusiveGateway_id_0', |
| 131 | + bpmnElementName: 'inclusiveGateway name', |
| 132 | + bpmnElementKind: ShapeBpmnElementKind.GATEWAY_INCLUSIVE, |
| 133 | + boundsX: 362, |
| 134 | + boundsY: 232, |
| 135 | + boundsWidth: 36, |
| 136 | + boundsHeight: 45, |
| 137 | + }); |
| 138 | + verifyShape(model.flowNodes[1], { |
| 139 | + shapeId: 'shape_inclusiveGateway_id_1', |
| 140 | + bpmnElementId: 'inclusiveGateway_id_1', |
| 141 | + bpmnElementName: undefined, |
| 142 | + bpmnElementKind: ShapeBpmnElementKind.GATEWAY_INCLUSIVE, |
| 143 | + boundsX: 365, |
| 144 | + boundsY: 235, |
| 145 | + boundsWidth: 35, |
| 146 | + boundsHeight: 46, |
| 147 | + }); |
| 148 | + }); |
| 149 | +}); |
0 commit comments