Skip to content

Commit

Permalink
Merge branch 'master' into fix/check_empty_string_parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
tbouffard authored Oct 2, 2023
2 parents 50fe18b + 4070159 commit ad2dfb5
Show file tree
Hide file tree
Showing 8 changed files with 303 additions and 244 deletions.
346 changes: 173 additions & 173 deletions package-lock.json

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@
"@types/jest-image-snapshot": "~6.2.1",
"@types/lodash-es": "~4.17.9",
"@types/minimist": "~1.2.2",
"@typescript-eslint/eslint-plugin": "~6.7.2",
"@typescript-eslint/parser": "~6.7.2",
"@typescript-eslint/eslint-plugin": "~6.7.3",
"@typescript-eslint/parser": "~6.7.3",
"autoprefixer": "~10.4.16",
"clipboardy": "~3.0.0",
"cross-env": "~7.0.3",
Expand All @@ -126,7 +126,7 @@
"eslint-config-prettier": "~9.0.0",
"eslint-import-resolver-typescript": "~3.6.1",
"eslint-plugin-import": "~2.28.1",
"eslint-plugin-jest": "~27.4.0",
"eslint-plugin-jest": "~27.4.2",
"eslint-plugin-jest-extended": "^2.0.0",
"eslint-plugin-notice": "~0.9.10",
"eslint-plugin-playwright": "~0.16.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

import type { BuildDefinitionParameter } from '../../../helpers/JsonBuilder';
import type { BuildDefinitionParameter, BuildEventDefinition } from '../../../helpers/JsonBuilder';

import { buildDefinitions, EventDefinitionOn } from '../../../helpers/JsonBuilder';
import { expectAsWarning, parseJsonAndExpectOnlyFlowNodes, parsingMessageCollector } from '../../../helpers/JsonTestUtils';
Expand Down Expand Up @@ -42,7 +42,7 @@ function testMustNotConvertBoundaryEvent(definitionParameter: BuildDefinitionPar
}

describe('for boundaryEvents', () => {
describe.each(eventDefinitionsParameters)(`for %s boundaryEvent`, (eventDefinitionKind: string, expectedEventDefinitionKind: ShapeBpmnEventDefinitionKind) => {
describe.each(eventDefinitionsParameters)(`for %s boundaryEvent`, (eventDefinitionKind: BuildEventDefinition, expectedEventDefinitionKind: ShapeBpmnEventDefinitionKind) => {
if (
expectedEventDefinitionKind === ShapeBpmnEventDefinitionKind.NONE ||
expectedEventDefinitionKind === ShapeBpmnEventDefinitionKind.LINK ||
Expand Down Expand Up @@ -104,7 +104,7 @@ describe('for boundaryEvents', () => {
bpmnElementKind: ShapeBpmnElementKind.EVENT_BOUNDARY,
bpmnElementName: undefined,
eventDefinitionKind: expectedEventDefinitionKind,
isInterrupting: true,
isInterrupting,
},
);
});
Expand All @@ -127,7 +127,7 @@ describe('for boundaryEvents', () => {
});
});

it(`should NOT convert, when 'boundaryEvent' is ${isInterruptingTitle} & attached to no existing activity, ${titleForEventDefinitionIsAttributeOf}`, () => {
it(`should NOT convert, when 'boundaryEvent' is ${isInterruptingTitle} & attached to unexisting activity, ${titleForEventDefinitionIsAttributeOf}`, () => {
testMustNotConvertBoundaryEvent(
{
process: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

import type { OtherBuildEventKind } from '../../../helpers/JsonBuilder';
import type { BuildEventDefinition, OtherBuildEventKind } from '../../../helpers/JsonBuilder';

import { verifyShape } from '../../../helpers/bpmn-model-expect';
import { buildDefinitions, EventDefinitionOn } from '../../../helpers/JsonBuilder';
Expand All @@ -25,14 +25,14 @@ import { ShapeBpmnElementKind, ShapeBpmnEventDefinitionKind } from '@lib/model/b

// None intermediateCatchEvent not supported in BPMN specification
describe.each([
[ShapeBpmnElementKind.EVENT_START, ['message', 'timer', 'conditional', 'signal']],
[ShapeBpmnElementKind.EVENT_END, ['message', 'error', 'escalation', 'cancel', 'compensate', 'signal', 'terminate']],
[ShapeBpmnElementKind.EVENT_INTERMEDIATE_THROW, ['message', 'escalation', 'compensate', 'link', 'signal']],
])('for none %s', (expectedShapeBpmnElementKind: ShapeBpmnElementKind, allDefinitionKinds: string[]) => {
[ShapeBpmnElementKind.EVENT_START, ['message', 'timer', 'conditional', 'signal'] as BuildEventDefinition[]],
[ShapeBpmnElementKind.EVENT_END, ['message', 'error', 'escalation', 'cancel', 'compensate', 'signal', 'terminate'] as BuildEventDefinition[]],
[ShapeBpmnElementKind.EVENT_INTERMEDIATE_THROW, ['message', 'escalation', 'compensate', 'link', 'signal'] as BuildEventDefinition[]],
])('for none %s', (expectedShapeBpmnElementKind: ShapeBpmnElementKind, allDefinitionKinds: BuildEventDefinition[]) => {
executeEventCommonTests(
{
bpmnKind: expectedShapeBpmnElementKind as OtherBuildEventKind | 'startEvent',
eventDefinitionParameter: { eventDefinitionKind: 'none', eventDefinitionOn: EventDefinitionOn.NONE },
eventDefinitionParameter: { eventDefinitionOn: EventDefinitionOn.NONE },
},
{
bpmnElementKind: expectedShapeBpmnElementKind,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

import type { OtherBuildEventKind } from '../../../helpers/JsonBuilder';
import type { BuildEventDefinition, OtherBuildEventKind } from '../../../helpers/JsonBuilder';
import type { TEventDefinition } from '@lib/model/bpmn/json/baseElement/rootElement/eventDefinition';

import { EventDefinitionOn } from '../../../helpers/JsonBuilder';
Expand All @@ -27,7 +27,7 @@ describe.each([ShapeBpmnElementKind.EVENT_START, ShapeBpmnElementKind.EVENT_END,
(expectedShapeBpmnElementKind: ShapeBpmnElementKind) => {
describe.each(eventDefinitionsParameters)(
`for %s ${expectedShapeBpmnElementKind}`,
(eventDefinitionKind: string, expectedEventDefinitionKind: ShapeBpmnEventDefinitionKind) => {
(eventDefinitionKind: BuildEventDefinition, expectedEventDefinitionKind: ShapeBpmnEventDefinitionKind) => {
if (
(expectedShapeBpmnElementKind === ShapeBpmnElementKind.EVENT_START &&
(expectedEventDefinitionKind === ShapeBpmnEventDefinitionKind.ERROR ||
Expand Down
156 changes: 106 additions & 50 deletions test/unit/helpers/JsonBuilder.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1908,7 +1908,7 @@ describe('build json', () => {
event: [
{
bpmnKind,
eventDefinitionParameter: { eventDefinitionKind: 'message', eventDefinitionOn: EventDefinitionOn.NONE, eventDefinition: { id: '9' } },
eventDefinitionParameter: { eventDefinitionKind: 'message', eventDefinitionOn: EventDefinitionOn.EVENT, eventDefinition: { id: '9' } },
},
],
},
Expand All @@ -1920,7 +1920,12 @@ describe('build json', () => {
collaboration: { id: 'collaboration_id_0' },
process: {
id: '0',
[bpmnKind]: { id: 'event_id_0_0' },
[bpmnKind]: {
id: 'event_id_0_0',
messageEventDefinition: {
id: '9',
},
},
},
BPMNDiagram: {
name: 'process 0',
Expand Down Expand Up @@ -2402,14 +2407,109 @@ describe('build json', () => {
});
});

it(`build json of definitions containing one process with none ${bpmnKind}`, () => {
const json = buildDefinitions({
process: {
event: [
{
bpmnKind,
eventDefinitionParameter: { eventDefinitionOn: EventDefinitionOn.NONE },
},
],
},
});

expect(json).toEqual({
definitions: {
targetNamespace: '',
collaboration: { id: 'collaboration_id_0' },
process: {
id: '0',
[bpmnKind]: {
id: 'event_id_0_0',
},
},
BPMNDiagram: {
name: 'process 0',
BPMNPlane: {
BPMNShape: {
id: 'shape_event_id_0_0',
bpmnElement: 'event_id_0_0',
Bounds: { x: 362, y: 232, width: 36, height: 45 },
},
},
},
},
});
});

it(`not possible to have eventDefinitionOn=NONE with defined eventDefinitionKind`, () => {
expect(() => {
buildDefinitions({
process: {
event: [
{
bpmnKind,
eventDefinitionParameter: { eventDefinitionKind: 'message', eventDefinitionOn: EventDefinitionOn.NONE },
},
],
},
});
}).toThrow("Must use another value than NONE for 'eventDefinitionOn' when 'eventDefinitionKind' is set !!");
});

it(`incoming and outgoing for ${bpmnKind}`, () => {
const json = buildDefinitions({
process: {
event: [
{
bpmnKind,
name: 'name',
id: 'another_id',
eventDefinitionParameter: { eventDefinitionKind: 'message', eventDefinitionOn: EventDefinitionOn.EVENT },
incoming: ['incoming_id'],
outgoing: ['outgoing_id'],
},
],
},
});

expect(json).toEqual({
definitions: {
targetNamespace: '',
collaboration: { id: 'collaboration_id_0' },
process: {
id: '0',
[bpmnKind]: {
id: 'another_id',
messageEventDefinition: '',
name: 'name',
incoming: ['incoming_id'],
outgoing: ['outgoing_id'],
},
},
BPMNDiagram: {
name: 'process 0',
BPMNPlane: {
BPMNShape: {
id: 'shape_another_id',
bpmnElement: 'another_id',
Bounds: { x: 362, y: 232, width: 36, height: 45 },
},
},
},
},
});
});

if (bpmnKind === 'startEvent') {
it('build json of definitions containing one process with interrupting startEvent', () => {
const json = buildDefinitions({
process: {
event: [
{
bpmnKind,
eventDefinitionParameter: { eventDefinitionKind: 'message', eventDefinitionOn: EventDefinitionOn.NONE, eventDefinition: {} },
eventDefinitionParameter: { eventDefinitionKind: 'message', eventDefinitionOn: EventDefinitionOn.EVENT, eventDefinition: {} },
isInterrupting: true,
},
],
Expand All @@ -2422,7 +2522,7 @@ describe('build json', () => {
collaboration: { id: 'collaboration_id_0' },
process: {
id: '0',
startEvent: { id: 'event_id_0_0', cancelActivity: true },
startEvent: { id: 'event_id_0_0', messageEventDefinition: {}, cancelActivity: true },
},
BPMNDiagram: {
name: 'process 0',
Expand All @@ -2444,7 +2544,7 @@ describe('build json', () => {
event: [
{
bpmnKind,
eventDefinitionParameter: { eventDefinitionKind: 'message', eventDefinitionOn: EventDefinitionOn.NONE, eventDefinition: {} },
eventDefinitionParameter: { eventDefinitionKind: 'message', eventDefinitionOn: EventDefinitionOn.EVENT, eventDefinition: {} },
isInterrupting: false,
},
],
Expand All @@ -2457,7 +2557,7 @@ describe('build json', () => {
collaboration: { id: 'collaboration_id_0' },
process: {
id: '0',
startEvent: { id: 'event_id_0_0', cancelActivity: false },
startEvent: { id: 'event_id_0_0', cancelActivity: false, messageEventDefinition: {} },
},
BPMNDiagram: {
name: 'process 0',
Expand All @@ -2473,50 +2573,6 @@ describe('build json', () => {
});
});
}

it(`incoming and outgoing for ${bpmnKind}`, () => {
const json = buildDefinitions({
process: {
event: [
{
bpmnKind,
name: 'name',
id: 'another_id',
eventDefinitionParameter: { eventDefinitionKind: 'message', eventDefinitionOn: EventDefinitionOn.EVENT },
incoming: ['incoming_id'],
outgoing: ['outgoing_id'],
},
],
},
});

expect(json).toEqual({
definitions: {
targetNamespace: '',
collaboration: { id: 'collaboration_id_0' },
process: {
id: '0',
[bpmnKind]: {
id: 'another_id',
messageEventDefinition: '',
name: 'name',
incoming: ['incoming_id'],
outgoing: ['outgoing_id'],
},
},
BPMNDiagram: {
name: 'process 0',
BPMNPlane: {
BPMNShape: {
id: 'shape_another_id',
bpmnElement: 'another_id',
Bounds: { x: 362, y: 232, width: 36, height: 45 },
},
},
},
},
});
});
},
);

Expand Down
11 changes: 7 additions & 4 deletions test/unit/helpers/JsonBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,9 @@ type BuildBoundaryEventParameter = {
attachedToRef: string;
} & BuildInterruptingEventParameter;

export type BuildEventDefinition = 'message' | 'signal' | 'timer' | 'error' | 'escalation' | 'cancel' | 'compensate' | 'conditional' | 'link' | 'terminate';
export type BuildEventDefinitionParameter = {
eventDefinitionKind?: string;
eventDefinitionKind?: BuildEventDefinition;
eventDefinitionOn: EventDefinitionOn;
eventDefinition?: BPMNEventDefinition;
withDifferentDefinition?: boolean;
Expand Down Expand Up @@ -486,9 +487,8 @@ function addEventDefinitions(
{ eventDefinitionKind, eventDefinition = '', withDifferentDefinition = false }: BuildEventDefinitionParameter,
differentEventDefinition: TEventDefinition | string = '',
): void {
if (eventDefinitionKind !== 'none') {
event[`${eventDefinitionKind}EventDefinition`] = eventDefinition;
}
event[`${eventDefinitionKind}EventDefinition` as keyof BPMNTEvent] = eventDefinition;

if (withDifferentDefinition) {
const otherEventDefinition = eventDefinitionKind === 'signal' ? 'message' : 'signal';
event[`${otherEventDefinition}EventDefinition`] = differentEventDefinition;
Expand Down Expand Up @@ -579,6 +579,9 @@ function addEvent(
break;
}
case EventDefinitionOn.NONE: {
if (eventDefinitionParameter.eventDefinitionKind) {
throw new Error("Must use another value than NONE for 'eventDefinitionOn' when 'eventDefinitionKind' is set !!");
}
break;
}
}
Expand Down
4 changes: 2 additions & 2 deletions test/unit/helpers/TestUtils.BpmnJsonParser.event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ limitations under the License.
*/

import type { ExpectedBoundaryEventShape, ExpectedEventShape, ExpectedShape } from './bpmn-model-expect';
import type { BuildEventsParameter } from './JsonBuilder';
import type { BuildEventDefinition, BuildEventsParameter } from './JsonBuilder';

import { verifyShape } from './bpmn-model-expect';
import { buildDefinitions, EventDefinitionOn } from './JsonBuilder';
Expand Down Expand Up @@ -214,7 +214,7 @@ export function executeEventCommonTests(buildEventParameter: BuildEventsParamete
}
}

export const eventDefinitionsParameters: [string, ShapeBpmnEventDefinitionKind][] = [
export const eventDefinitionsParameters: [BuildEventDefinition, ShapeBpmnEventDefinitionKind][] = [
['message', ShapeBpmnEventDefinitionKind.MESSAGE],
['timer', ShapeBpmnEventDefinitionKind.TIMER],
['terminate', ShapeBpmnEventDefinitionKind.TERMINATE],
Expand Down

0 comments on commit ad2dfb5

Please sign in to comment.