Skip to content

Commit

Permalink
fix: allow escalation boundary event without escalation reference
Browse files Browse the repository at this point in the history
Closes #109
  • Loading branch information
philippfromme authored Jul 25, 2023
1 parent 58439af commit 30044bb
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 9 deletions.
30 changes: 21 additions & 9 deletions rules/camunda-cloud/escalation-reference.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,27 +24,35 @@ module.exports = skipInNonExecutableProcess(function() {
return;
}

let errors = hasProperties(eventDefinition, {
escalationRef: {
required: true
}
}, node);
let errors = [];

if (errors && errors.length) {
reportErrors(node, reporter, errors);
if (!isNoEscalationRefAllowed(node)) {
errors = hasProperties(eventDefinition, {
escalationRef: {
required: true
}
}, node);

return;
if (errors.length) {
reportErrors(node, reporter, errors);

return;
}
}

const escalationRef = eventDefinition.get('escalationRef');

if (!escalationRef) {
return;
}

errors = hasProperties(escalationRef, {
escalationCode: {
required: true
}
}, node);

if (errors && errors.length) {
if (errors.length) {
reportErrors(node, reporter, errors);
}
}
Expand All @@ -53,3 +61,7 @@ module.exports = skipInNonExecutableProcess(function() {
check
};
});

function isNoEscalationRefAllowed(node, version) {
return is(node, 'bpmn:BoundaryEvent');
}
21 changes: 21 additions & 0 deletions test/camunda-cloud/escalation-reference.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,27 @@ const valid = [
<bpmn:escalation id="Escalation_1" escalationCode="foo" />
`))
},
{
name: 'escalation boundary event',
moddleElement: createModdle(createDefinitions(`
<bpmn:process id="Process_1">
<bpmn:callActivity id="CallActivity_1" />
<bpmn:boundaryEvent id="BoundaryEvent_1" attachedToRef="CallActivity_1">
<bpmn:escalationEventDefinition id="EscalationEventDefinition_1" escalationRef="Escalation_1" />
</bpmn:boundaryEvent>
</bpmn:process>
<bpmn:escalation id="Escalation_1" escalationCode="foo" />
`))
},
{
name: 'escalation boundary event (no escalation reference)',
moddleElement: createModdle(createProcess(`
<bpmn:callActivity id="CallActivity_1" />
<bpmn:boundaryEvent id="BoundaryEvent_1" attachedToRef="CallActivity_1">
<bpmn:escalationEventDefinition id="EscalationEventDefinition_1" />
</bpmn:boundaryEvent>
`))
},
{
name: 'end event (message)',
moddleElement: createModdle(createProcess(`
Expand Down

0 comments on commit 30044bb

Please sign in to comment.