From a11de261a56daad235e3d25231bb1c6232542cc6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Souchet=20C=C3=A9line?= Date: Thu, 20 Apr 2023 17:13:49 +0200 Subject: [PATCH] Add unit tests for pool: - with incoming message flow, - with outgoing message flow, - with incoming/outgoing message flows --- .../json/BpmnJsonParser.process.test.ts | 57 +++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/test/unit/component/parser/json/BpmnJsonParser.process.test.ts b/test/unit/component/parser/json/BpmnJsonParser.process.test.ts index 39e9a769eb..5d670464c8 100644 --- a/test/unit/component/parser/json/BpmnJsonParser.process.test.ts +++ b/test/unit/component/parser/json/BpmnJsonParser.process.test.ts @@ -14,7 +14,9 @@ See the License for the specific language governing permissions and limitations under the License. */ +import { buildDefinitions } from '../../../helpers/JsonBuilder'; import { parseJsonAndExpect, parseJsonAndExpectOnlyPools, parseJsonAndExpectOnlyPoolsAndFlowNodes, parseJsonAndExpectOnlyPoolsAndLanes } from '../../../helpers/JsonTestUtils'; +import type { ExpectedShape } from '../../../helpers/bpmn-model-expect'; import { verifyShape } from '../../../helpers/bpmn-model-expect'; import { ShapeBpmnElementKind } from '../../../../../src/model/bpmn/internal'; @@ -832,4 +834,59 @@ describe('parse bpmn as json for process/pool', () => { model.flowNodes.map(flowNode => flowNode.bpmnElement).forEach(bpmnElement => expect(bpmnElement.parentId).toBeUndefined()); }); + + describe(`incoming/outgoing management for participant referencing a process`, () => { + it.each` + title | expectedAttribute + ${'incoming'} | ${'bpmnElementIncomingIds'} + ${'outgoing'} | ${'bpmnElementOutgoingIds'} + `( + `should convert as Shape, when a participant referencing a process with $title message flow`, + ({ title, expectedAttribute }: { title: string; expectedAttribute: keyof ExpectedShape }) => { + const json = buildDefinitions({ + process: { withParticipant: true, id: 'process_O' }, + messageFlows: { + id: `flow_${title}`, + sourceRef: title === 'incoming' ? 'unknown' : 'process_O', + targetRef: title === 'incoming' ? 'process_O' : 'unknown', + }, + }); + + const model = parseJsonAndExpect(json, 1, 0, 0, 1); + + verifyShape(model.flowNodes[0], { + shapeId: 'shape_process_O', + bpmnElementId: 'process_O', + bpmnElementName: undefined, + bpmnElementKind: ShapeBpmnElementKind.POOL, + bounds: { x: 346, y: 856, width: 45, height: 56 }, + [expectedAttribute]: `flow_${title}`, + }); + }, + ); + + it(`should convert as Shape, when a participant referencing a process with incoming/outgoing message flows`, () => { + const json = buildDefinitions({ + process: { withParticipant: true, id: 'process_O' }, + messageFlows: [ + { id: 'flow_in_1', sourceRef: 'unknown', targetRef: 'call_activity_id_0' }, + { id: 'flow_in_2', sourceRef: 'unknown', targetRef: 'call_activity_id_0' }, + { id: 'flow_out_2', sourceRef: 'call_activity_id_0', targetRef: 'unknown' }, + { id: 'flow_out_3', sourceRef: 'call_activity_id_0', targetRef: 'unknown' }, + ], + }); + + const model = parseJsonAndExpect(json, 1, 0, 0, 4); + + verifyShape(model.flowNodes[0], { + shapeId: 'shape_process_O', + bpmnElementId: 'process_O', + bpmnElementName: undefined, + bpmnElementKind: ShapeBpmnElementKind.POOL, + bounds: { x: 346, y: 856, width: 45, height: 56 }, + bpmnElementIncomingIds: ['flow_in_1', 'flow_in_2'], + bpmnElementOutgoingIds: ['flow_out_2', 'flow_out_3'], + }); + }); + }); });