This is an automated email from the ASF dual-hosted git repository.
marat pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-karavan.git
The following commit(s) were added to refs/heads/main by this push:
new f8b5bd84 Fix #1420
f8b5bd84 is described below
commit f8b5bd84624057f6fcf77424a5c0c1b46e6ec570
Author: Marat Gubaidullin <[email protected]>
AuthorDate: Tue Sep 17 14:16:06 2024 -0400
Fix #1420
---
karavan-core/src/core/api/CamelDefinitionYaml.ts | 3 ++
karavan-core/test/doCatchOnWhen.camel.yaml | 20 +++++++++++++
karavan-core/test/doCatchOnWhen.spec.ts | 36 ++++++++++++++++++++++++
karavan-designer/public/example/demo.camel.yaml | 20 ++++++-------
4 files changed, 69 insertions(+), 10 deletions(-)
diff --git a/karavan-core/src/core/api/CamelDefinitionYaml.ts
b/karavan-core/src/core/api/CamelDefinitionYaml.ts
index d4a5ee55..08986acc 100644
--- a/karavan-core/src/core/api/CamelDefinitionYaml.ts
+++ b/karavan-core/src/core/api/CamelDefinitionYaml.ts
@@ -107,6 +107,8 @@ export class CamelDefinitionYaml {
if (object.constructors &&
CamelDefinitionYaml.isEmptyObject(object.constructors)) {
delete object.constructors;
}
+ } else if (object.dslName === 'CatchDefinition' &&
object?.onWhen?.stepName !== undefined) {
+ object.onWhen.stepName = 'onWhen'; //
https://github.com/apache/camel-karavan/issues/1420
}
delete object.uuid;
@@ -195,6 +197,7 @@ export class CamelDefinitionYaml {
stepName === 'resilience4jConfiguration' ||
stepName === 'faultToleranceConfiguration' ||
stepName === 'errorHandler' ||
+ stepName === 'onWhen' || //
https://github.com/apache/camel-karavan/issues/1420
stepName === 'deadLetterChannel' ||
stepName === 'defaultErrorHandler' ||
stepName === 'jtaTransactionErrorHandler' ||
diff --git a/karavan-core/test/doCatchOnWhen.camel.yaml
b/karavan-core/test/doCatchOnWhen.camel.yaml
new file mode 100644
index 00000000..2415f656
--- /dev/null
+++ b/karavan-core/test/doCatchOnWhen.camel.yaml
@@ -0,0 +1,20 @@
+- route:
+ id: route-8a40
+ nodePrefixId: route-78f
+ from:
+ id: from-674b
+ uri: timer
+ parameters:
+ timerName: name
+ steps:
+ - doTry:
+ id: doTry-258c
+ doCatch:
+ - id: doCatch-32ac
+ exception:
+ - java.lang.ArrayIndexOutOfBoundsException
+ onWhen:
+ id: when-b4f0
+ expression:
+ groovy:
+ id: groovy-2d4f
diff --git a/karavan-core/test/doCatchOnWhen.spec.ts
b/karavan-core/test/doCatchOnWhen.spec.ts
new file mode 100644
index 00000000..b42b2614
--- /dev/null
+++ b/karavan-core/test/doCatchOnWhen.spec.ts
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import * as fs from 'fs';
+import 'mocha';
+import {CamelDefinitionYaml} from "../src/core/api/CamelDefinitionYaml";
+import {CamelUtil} from "../src/core/api/CamelUtil";
+import {CamelDefinitionApiExt} from "../src/core/api/CamelDefinitionApiExt";
+import {CatchDefinition, FromDefinition} from
"../src/core/model/CamelDefinition";
+import {expect} from "chai";
+import {TryDefinition} from "../src/core/model/CamelDefinition";
+
+describe('DoCatch', () => {
+
+ it('on When', () => {
+ const yaml =
fs.readFileSync('test/doCatchOnWhen.camel.yaml',{encoding:'utf8', flag:'r'});
+ const i = CamelDefinitionYaml.yamlToIntegration("demo.yaml", yaml);
+ const yaml2 = CamelDefinitionYaml.integrationToYaml(i);
+
+ expect(yaml2).to.equal(yaml);
+ });
+
+});
\ No newline at end of file
diff --git a/karavan-designer/public/example/demo.camel.yaml
b/karavan-designer/public/example/demo.camel.yaml
index cad0fb07..cd66337a 100644
--- a/karavan-designer/public/example/demo.camel.yaml
+++ b/karavan-designer/public/example/demo.camel.yaml
@@ -1,15 +1,15 @@
- route:
- id: route-11b9
- nodePrefixId: route-2ae
+ id: route-8a40
+ nodePrefixId: route-78f
from:
- id: from-d759
+ id: from-674b
uri: timer
parameters:
- timerName: timer
+ timerName: name
steps:
- - aggregate:
- id: aggregate-bf73
- correlationExpression:
- groovy:
- id: groovy-ed69
- expression: saasdsa
\ No newline at end of file
+ - doTry:
+ id: doTry-258c
+ doCatch:
+ - id: doCatch-32ac
+ exception:
+ - java.lang.ArrayIndexOutOfBoundsException