Skip to content

Commit

Permalink
Add unit tests for pool:
Browse files Browse the repository at this point in the history
- with incoming message flow,
- with outgoing message flow,
- with incoming/outgoing message flows
  • Loading branch information
csouchet committed Apr 20, 2023
1 parent 47205b9 commit a11de26
Showing 1 changed file with 57 additions and 0 deletions.
57 changes: 57 additions & 0 deletions test/unit/component/parser/json/BpmnJsonParser.process.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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'],
});
});
});
});

0 comments on commit a11de26

Please sign in to comment.