diff --git a/lib/utils/error-messages.js b/lib/utils/error-messages.js index 557e79f..156c0aa 100644 --- a/lib/utils/error-messages.js +++ b/lib/utils/error-messages.js @@ -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; } @@ -660,4 +664,12 @@ function getElementPropertyValueDuplicatedErrorMessage(report) { } return message; +} + +function getLoopNotAllowedErrorMessage(report) { + const { data } = report; + + const { elements } = data; + + return `A is not allowed to contain a straight-through processing loop: ${ elements.map(element => `<${ element }>`).join(', ') }`; } \ No newline at end of file diff --git a/test/spec/utils/error-messages.spec.js b/test/spec/utils/error-messages.spec.js index 562f6de..0448a69 100644 --- a/test/spec/utils/error-messages.spec.js +++ b/test/spec/utils/error-messages.spec.js @@ -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 is not allowed to contain a straight-through processing loop: , '); + }); + + }); + });