Skip to content

Commit

Permalink
Make not possible to have EventDefinitionOn.NONE and event definition…
Browse files Browse the repository at this point in the history
… kind in the same time
  • Loading branch information
csouchet committed Sep 28, 2023
1 parent 729958b commit e6d431a
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 16 deletions.
57 changes: 41 additions & 16 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 All @@ -1936,6 +1941,21 @@ describe('build json', () => {
});
});

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(`build json of definitions containing one process with ${bpmnKind} (with one messageEventDefinition, name & id)`, () => {
const json = buildDefinitions({
process: {
Expand Down Expand Up @@ -2453,7 +2473,7 @@ describe('build json', () => {
event: [
{
bpmnKind,
eventDefinitionParameter: { eventDefinitionKind: 'message', eventDefinitionOn: EventDefinitionOn.NONE, eventDefinition: {} },
eventDefinitionParameter: { eventDefinitionKind: 'message', eventDefinitionOn: EventDefinitionOn.EVENT, eventDefinition: {} },
isInterrupting: true,
},
],
Expand All @@ -2466,7 +2486,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 @@ -2488,7 +2508,7 @@ describe('build json', () => {
event: [
{
bpmnKind,
eventDefinitionParameter: { eventDefinitionKind: 'message', eventDefinitionOn: EventDefinitionOn.NONE, eventDefinition: {} },
eventDefinitionParameter: { eventDefinitionKind: 'message', eventDefinitionOn: EventDefinitionOn.EVENT, eventDefinition: {} },
isInterrupting: false,
},
],
Expand All @@ -2501,7 +2521,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 @@ -2525,7 +2545,7 @@ describe('build json', () => {
event: [
{
bpmnKind: 'intermediateCatchEvent',
eventDefinitionParameter: { eventDefinitionKind: 'link', eventDefinitionOn: EventDefinitionOn.NONE, eventDefinition: {} },
eventDefinitionParameter: { eventDefinitionKind: 'link', eventDefinitionOn: EventDefinitionOn.DEFINITIONS },
source: 'event_definition_source_id',
},
],
Expand All @@ -2536,9 +2556,10 @@ describe('build json', () => {
definitions: {
targetNamespace: '',
collaboration: { id: 'collaboration_id_0' },
linkEventDefinition: { id: 'event_definition_id' },
process: {
id: '0',
intermediateCatchEvent: { id: 'event_id_0_0', source: 'event_definition_source_id' },
intermediateCatchEvent: { id: 'event_id_0_0', source: 'event_definition_source_id', eventDefinitionRef: 'event_definition_id' },
},
BPMNDiagram: {
name: 'process 0',
Expand All @@ -2560,7 +2581,7 @@ describe('build json', () => {
event: [
{
bpmnKind: 'intermediateCatchEvent',
eventDefinitionParameter: { eventDefinitionKind: 'link', eventDefinitionOn: EventDefinitionOn.NONE, eventDefinition: {} },
eventDefinitionParameter: { eventDefinitionKind: 'link', eventDefinitionOn: EventDefinitionOn.DEFINITIONS },
source: ['event_definition_source_1_id', 'event_definition_source_2_id'],
},
],
Expand All @@ -2571,9 +2592,10 @@ describe('build json', () => {
definitions: {
targetNamespace: '',
collaboration: { id: 'collaboration_id_0' },
linkEventDefinition: { id: 'event_definition_id' },
process: {
id: '0',
intermediateCatchEvent: { id: 'event_id_0_0', source: ['event_definition_source_1_id', 'event_definition_source_2_id'] },
intermediateCatchEvent: { id: 'event_id_0_0', source: ['event_definition_source_1_id', 'event_definition_source_2_id'], eventDefinitionRef: 'event_definition_id' },
},
BPMNDiagram: {
name: 'process 0',
Expand All @@ -2595,7 +2617,7 @@ describe('build json', () => {
event: [
{
bpmnKind: 'intermediateCatchEvent',
eventDefinitionParameter: { eventDefinitionKind: 'message', eventDefinitionOn: EventDefinitionOn.NONE, eventDefinition: {} },
eventDefinitionParameter: { eventDefinitionKind: 'message', eventDefinitionOn: EventDefinitionOn.DEFINITIONS },
source: 'event_definition_source_id',
},
],
Expand All @@ -2606,9 +2628,10 @@ describe('build json', () => {
definitions: {
targetNamespace: '',
collaboration: { id: 'collaboration_id_0' },
messageEventDefinition: { id: 'event_definition_id' },
process: {
id: '0',
intermediateCatchEvent: { id: 'event_id_0_0' },
intermediateCatchEvent: { id: 'event_id_0_0', eventDefinitionRef: 'event_definition_id' },
},
BPMNDiagram: {
name: 'process 0',
Expand All @@ -2632,7 +2655,7 @@ describe('build json', () => {
event: [
{
bpmnKind: 'intermediateThrowEvent',
eventDefinitionParameter: { eventDefinitionKind: 'link', eventDefinitionOn: EventDefinitionOn.NONE, eventDefinition: {} },
eventDefinitionParameter: { eventDefinitionKind: 'link', eventDefinitionOn: EventDefinitionOn.DEFINITIONS },
target: 'event_definition_target_id',
},
],
Expand All @@ -2643,9 +2666,10 @@ describe('build json', () => {
definitions: {
targetNamespace: '',
collaboration: { id: 'collaboration_id_0' },
linkEventDefinition: { id: 'event_definition_id' },
process: {
id: '0',
intermediateThrowEvent: { id: 'event_id_0_0', target: 'event_definition_target_id' },
intermediateThrowEvent: { id: 'event_id_0_0', target: 'event_definition_target_id', eventDefinitionRef: 'event_definition_id' },
},
BPMNDiagram: {
name: 'process 0',
Expand All @@ -2667,7 +2691,7 @@ describe('build json', () => {
event: [
{
bpmnKind: 'intermediateThrowEvent',
eventDefinitionParameter: { eventDefinitionKind: 'message', eventDefinitionOn: EventDefinitionOn.NONE, eventDefinition: {} },
eventDefinitionParameter: { eventDefinitionKind: 'message', eventDefinitionOn: EventDefinitionOn.DEFINITIONS },
target: 'event_definition_target_id',
},
],
Expand All @@ -2678,9 +2702,10 @@ describe('build json', () => {
definitions: {
targetNamespace: '',
collaboration: { id: 'collaboration_id_0' },
messageEventDefinition: { id: 'event_definition_id' },
process: {
id: '0',
intermediateThrowEvent: { id: 'event_id_0_0' },
intermediateThrowEvent: { id: 'event_id_0_0', eventDefinitionRef: 'event_definition_id' },
},
BPMNDiagram: {
name: 'process 0',
Expand Down
3 changes: 3 additions & 0 deletions test/unit/helpers/JsonBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -603,6 +603,9 @@ function addEvent(jsonModel: BpmnJsonModel, { id, bpmnKind, eventDefinitionParam
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

0 comments on commit e6d431a

Please sign in to comment.