Skip to content

Commit

Permalink
chore(no-loop): adjust error message
Browse files Browse the repository at this point in the history
  • Loading branch information
philippfromme committed Sep 8, 2023
1 parent 1e5a9c7 commit 7d32d9e
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 0 deletions.
12 changes: 12 additions & 0 deletions lib/utils/error-messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,10 @@ export function getErrorMessage(report, executionPlatform, executionPlatformVers
return getSecretExpressionFormatDeprecatedErrorMessage(report);
}

if (type === ERROR_TYPES.LOOP_NOT_ALLOWED) {
return getLoopNotAllowedErrorMessage(report);
}

return message;
}

Expand Down Expand Up @@ -660,4 +664,12 @@ function getElementPropertyValueDuplicatedErrorMessage(report) {
}

return message;
}

function getLoopNotAllowedErrorMessage(report) {
const { data } = report;

const { elements } = data;

return `A <Process> is not allowed to contain a straight-through processing loop: ${ elements.map(element => `<${ element }>`).join(', ') }`;
}
56 changes: 56 additions & 0 deletions test/spec/utils/error-messages.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1871,6 +1871,62 @@ describe('utils/error-messages', function() {

});


describe('loop not allowed', function() {

it('should adjust', async function() {

// given
const task = createElement('bpmn:Task', {
id: 'Task_1'
});

const manualTask = createElement('bpmn:ManualTask', {
id: 'ManualTask_1'
});

const sequenceFlow1 = createElement('bpmn:SequenceFlow', {
id: 'SequenceFlow_1',
sourceRef: task,
targetRef: manualTask
});

const sequenceFlow2 = createElement('bpmn:SequenceFlow', {
id: 'SequenceFlow_2',
sourceRef: manualTask,
targetRef: task
});

task.set('incoming', [ sequenceFlow2 ]);
task.set('outgoing', [ sequenceFlow1 ]);

manualTask.set('incoming', [ sequenceFlow1 ]);
manualTask.set('outgoing', [ sequenceFlow2 ]);

const process = createElement('bpmn:Process', {
id: 'Process_1',
isExecutable: true,
flowElements: [
task,
manualTask,
sequenceFlow1,
sequenceFlow2
]
});

const { default: rule } = await import('bpmnlint-plugin-camunda-compat/rules/camunda-cloud/no-loop');

const report = await getLintError(process, rule);

// when
const errorMessage = getErrorMessage(report);

// then
expect(errorMessage).to.equal('A <Process> is not allowed to contain a straight-through processing loop: <Task_1>, <ManualTask_1>');
});

});

});


Expand Down

0 comments on commit 7d32d9e

Please sign in to comment.