diff --git a/packages/workit-bpm-client/src/camundaMessage.ts b/packages/workit-bpm-client/src/camundaMessage.ts index 4146c14c..68e03389 100644 --- a/packages/workit-bpm-client/src/camundaMessage.ts +++ b/packages/workit-bpm-client/src/camundaMessage.ts @@ -60,7 +60,7 @@ export class CamundaMessage { errorDetails: stringify(error), retries, // TODO: Add to configuration - retryTimeoutInMs + retryTimeout: retryTimeoutInMs }); this.hasBeenThreated = true; } diff --git a/packages/workit-bpm-client/tests/functionals/__snapshots__/camundaMessage.spec.ts.snap b/packages/workit-bpm-client/tests/functionals/__snapshots__/camundaMessage.spec.ts.snap index f2ca3f50..d8e2f92a 100644 --- a/packages/workit-bpm-client/tests/functionals/__snapshots__/camundaMessage.spec.ts.snap +++ b/packages/workit-bpm-client/tests/functionals/__snapshots__/camundaMessage.spec.ts.snap @@ -13,3 +13,12 @@ Variables { "setTyped": [Function], } `; + +exports[`camundaMessage wrap 1`] = ` +Object { + "errorDetails": "{\\"name\\":\\"error\\",\\"message\\":\\"Oopps\\",\\"retries\\":0,\\"retryTimeout\\":15000}", + "errorMessage": "Oopps", + "retries": 0, + "retryTimeout": 15000, +} +`; diff --git a/packages/workit-bpm-client/tests/functionals/camundaMessage.spec.ts b/packages/workit-bpm-client/tests/functionals/camundaMessage.spec.ts index ae701af0..a39d767f 100644 --- a/packages/workit-bpm-client/tests/functionals/camundaMessage.spec.ts +++ b/packages/workit-bpm-client/tests/functionals/camundaMessage.spec.ts @@ -5,6 +5,7 @@ */ import { CamundaMessage } from '../../src/camundaMessage'; +import { Variables } from '../../src/variables'; describe('camundaMessage', () => { it('unmap', () => { @@ -29,4 +30,19 @@ describe('camundaMessage', () => { const camundaObject = CamundaMessage.unwrap(message); expect(camundaObject).toMatchSnapshot(); }); + + it('wrap', () => { + const camundaPayload = { + task: { processInstanceId: '38963', processDefinitionId: 'xxxxx', variables: new Variables() } as any, + taskService: { + handleFailure: jest.fn(), + complete: jest.fn() + } + }; + const [, service] = CamundaMessage.wrap(camundaPayload); + service.nack({ name: 'error', message: 'Oopps', retries: 0, retryTimeout: 15_000 }); + expect(camundaPayload.taskService.handleFailure).toBeCalledTimes(1); + expect(camundaPayload.taskService.complete).toBeCalledTimes(0); + expect(camundaPayload.taskService.handleFailure.mock.calls[0][1]).toMatchSnapshot(); + }); });