From fb61a6c804a26af53a895ecab9083473de419e34 Mon Sep 17 00:00:00 2001 From: "Ricardo M." Date: Fri, 29 Nov 2024 16:11:34 +0100 Subject: [PATCH] fix(Canvas): Valid `otherwise` and `doFinally` fix: https://github.com/KaotoIO/kaoto/issues/1674 --- .../camel-component-default.service.test.ts | 18 ++++++++++++++++++ .../support/camel-component-default.service.ts | 10 ++++++++++ 2 files changed, 28 insertions(+) diff --git a/packages/ui/src/models/visualization/flows/support/camel-component-default.service.test.ts b/packages/ui/src/models/visualization/flows/support/camel-component-default.service.test.ts index f4b86423b..1c5b965cb 100644 --- a/packages/ui/src/models/visualization/flows/support/camel-component-default.service.test.ts +++ b/packages/ui/src/models/visualization/flows/support/camel-component-default.service.test.ts @@ -37,6 +37,24 @@ describe('CamelComponentDefaultService', () => { expect(doTryDefault.doTry?.doCatch?.[0].exception).toHaveLength(1); }); + it('should return the default value for a otherwise processor', () => { + const otherwiseDefault = CamelComponentDefaultService.getDefaultNodeDefinitionValue({ + type: 'processor', + name: 'otherwise', + } as DefinedComponent) as any; + expect(otherwiseDefault).toBeDefined(); + expect(otherwiseDefault.steps[0].log).toBeDefined(); + }); + + it('should return the default value for a doFinally processor', () => { + const doFinallyDefault = CamelComponentDefaultService.getDefaultNodeDefinitionValue({ + type: 'processor', + name: 'doFinally', + } as DefinedComponent) as any; + expect(doFinallyDefault).toBeDefined(); + expect(doFinallyDefault.steps[0].log).toBeDefined(); + }); + it('should return the default value for a log processor', () => { const logDefault = CamelComponentDefaultService.getDefaultNodeDefinitionValue({ type: 'processor', diff --git a/packages/ui/src/models/visualization/flows/support/camel-component-default.service.ts b/packages/ui/src/models/visualization/flows/support/camel-component-default.service.ts index 5603e98b8..15131a4c4 100644 --- a/packages/ui/src/models/visualization/flows/support/camel-component-default.service.ts +++ b/packages/ui/src/models/visualization/flows/support/camel-component-default.service.ts @@ -126,6 +126,16 @@ export class CamelComponentDefaultService { message: "\${body}" `); + case 'otherwise': + case 'doFinally': + return parse(` + id: ${getCamelRandomId(processorName)} + steps: + - log: + id: ${getCamelRandomId('log')} + message: "\${body}" + `); + case 'log': return parse(` log: