karavan-core 4.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (114) hide show
  1. package/.bebelrc +3 -0
  2. package/.mocharc.json +11 -0
  3. package/.prettierignore +9 -0
  4. package/.prettierrc +14 -0
  5. package/package.json +62 -0
  6. package/src/core/api/CamelDefinitionApi.ts +3271 -0
  7. package/src/core/api/CamelDefinitionApiExt.ts +757 -0
  8. package/src/core/api/CamelDefinitionYaml.ts +412 -0
  9. package/src/core/api/CamelDefinitionYamlStep.ts +4733 -0
  10. package/src/core/api/CamelDisplayUtil.ts +143 -0
  11. package/src/core/api/CamelUtil.ts +360 -0
  12. package/src/core/api/ComponentApi.ts +368 -0
  13. package/src/core/api/KameletApi.ts +147 -0
  14. package/src/core/api/MainConfigurationApi.ts +47 -0
  15. package/src/core/api/ProjectModelApi.ts +75 -0
  16. package/src/core/api/SpiBeanApi.ts +104 -0
  17. package/src/core/api/TemplateApi.ts +58 -0
  18. package/src/core/api/TopologyUtils.ts +392 -0
  19. package/src/core/api/VariableUtil.ts +104 -0
  20. package/src/core/model/CamelDefinition.ts +3783 -0
  21. package/src/core/model/CamelMetadata.ts +2714 -0
  22. package/src/core/model/ComponentModels.ts +106 -0
  23. package/src/core/model/IntegrationDefinition.ts +188 -0
  24. package/src/core/model/KameletModels.ts +223 -0
  25. package/src/core/model/MainConfigurationModel.ts +37 -0
  26. package/src/core/model/ProjectModel.ts +43 -0
  27. package/src/core/model/SpiBeanModels.ts +53 -0
  28. package/src/core/model/TopologyDefinition.ts +117 -0
  29. package/test/addStep.spec.ts +124 -0
  30. package/test/addStep1.yaml +27 -0
  31. package/test/allowableValues.camel.yaml +19 -0
  32. package/test/allowableValues.spec.ts +30 -0
  33. package/test/avro-serialize-action.kamelet.yaml +70 -0
  34. package/test/beans.spec.ts +92 -0
  35. package/test/beans1.yaml +36 -0
  36. package/test/beans2.yaml +42 -0
  37. package/test/beans3.yaml +7 -0
  38. package/test/checkRequired.spec.ts +53 -0
  39. package/test/circuitBreaker.spec.ts +57 -0
  40. package/test/circuitBreaker.yaml +19 -0
  41. package/test/cloneDefinition.spec.ts +106 -0
  42. package/test/createKamelet.spec.ts +38 -0
  43. package/test/cxf.json +615 -0
  44. package/test/cxf.spec.ts +44 -0
  45. package/test/cxf.yaml +15 -0
  46. package/test/deleteStep.spec.ts +74 -0
  47. package/test/demo.spec.ts +49 -0
  48. package/test/demo.yaml +32 -0
  49. package/test/doCatchOnWhen.camel.yaml +20 -0
  50. package/test/doCatchOnWhen.spec.ts +36 -0
  51. package/test/errorHandler.spec.ts +38 -0
  52. package/test/errorHandler1.yaml +27 -0
  53. package/test/expression.spec.ts +55 -0
  54. package/test/findStep.spec.ts +112 -0
  55. package/test/findStep.yaml +65 -0
  56. package/test/getElementProperties.spec.ts +32 -0
  57. package/test/getElementPropertiesByName.spec.ts +31 -0
  58. package/test/getExpressionLanguage.spec.ts +40 -0
  59. package/test/hasElementWithId.camel.yaml +98 -0
  60. package/test/hasElementWithId.spec.ts +57 -0
  61. package/test/hasElementWithId1.camel.yaml +16 -0
  62. package/test/hasElementWithIdError.camel.yaml +98 -0
  63. package/test/integration.spec.ts +60 -0
  64. package/test/integration1.yaml +24 -0
  65. package/test/integration2.yaml +23 -0
  66. package/test/integrationToYaml.spec.ts +51 -0
  67. package/test/intercept.spec.ts +62 -0
  68. package/test/intercept.yaml +19 -0
  69. package/test/is-not-integration.yaml +5114 -0
  70. package/test/isIntegration.spec.ts +45 -0
  71. package/test/kamelet.spec.ts +61 -0
  72. package/test/metadata/components.json +697 -0
  73. package/test/metadata/kamelets.yaml +23414 -0
  74. package/test/metadata/spiBeans.json +3094 -0
  75. package/test/multiObjectProperties.spec.ts +46 -0
  76. package/test/multiObjectProperties1.yaml +19 -0
  77. package/test/multiple.spec.ts +38 -0
  78. package/test/multiple.yaml +29 -0
  79. package/test/openapi.spec.ts +48 -0
  80. package/test/openapi.yaml +7 -0
  81. package/test/placeholder.spec.ts +32 -0
  82. package/test/placeholder.yaml +133 -0
  83. package/test/plain-try-catch.yaml +31 -0
  84. package/test/plain.spec.ts +72 -0
  85. package/test/plain1.yaml +22 -0
  86. package/test/plain2.yaml +13 -0
  87. package/test/plain3.yaml +5 -0
  88. package/test/plain4.yaml +5 -0
  89. package/test/postgresql-source.kamelet.yaml +113 -0
  90. package/test/restConfigDsl.yaml +15 -0
  91. package/test/restDsl.spec.ts +83 -0
  92. package/test/restDsl.yaml +29 -0
  93. package/test/routes.spec.ts +37 -0
  94. package/test/routes1.yaml +31 -0
  95. package/test/supported-components.json +1221 -0
  96. package/test/supportedComponents.spec.ts +34 -0
  97. package/test/template1.AggregationStrategy.java +21 -0
  98. package/test/template1.Processor.java +13 -0
  99. package/test/template2.AggregationStrategy.java +21 -0
  100. package/test/template2.Processor.java +13 -0
  101. package/test/templateApi.spec.ts +45 -0
  102. package/test/timer-source.kamelet.yaml +75 -0
  103. package/test/tod.spec.ts +31 -0
  104. package/test/tod.yaml +9 -0
  105. package/test/topology.spec.ts +51 -0
  106. package/test/topology1.camel.yaml +56 -0
  107. package/test/topology2.camel.yaml +44 -0
  108. package/test/topology3.camel.yaml +27 -0
  109. package/test/tsconfig.testing.json +14 -0
  110. package/test/updateStep.spec.ts +72 -0
  111. package/test/variable1.camel.yaml +42 -0
  112. package/test/variable2.camel.yaml +42 -0
  113. package/test/variables.spec.ts +34 -0
  114. package/tsconfig.json +34 -0
@@ -0,0 +1,34 @@
1
+ /*
2
+ * Licensed to the Apache Software Foundation (ASF) under one or more
3
+ * contributor license agreements. See the NOTICE file distributed with
4
+ * this work for additional information regarding copyright ownership.
5
+ * The ASF licenses this file to You under the Apache License, Version 2.0
6
+ * (the "License"); you may not use this file except in compliance with
7
+ * the License. You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ import {expect} from 'chai';
18
+ import * as fs from 'fs';
19
+ import 'mocha';
20
+ import {CamelDefinitionYaml} from "../src/core/api/CamelDefinitionYaml";
21
+ import {ComponentApi} from "../src/core/api/ComponentApi";
22
+ import {SupportedComponent} from "../src/core/model/ComponentModels";
23
+
24
+
25
+ describe('Supported Components List', () => {
26
+
27
+ it('Read Supported Components', () => {
28
+ const json = fs.readFileSync('test/supported-components.json',{encoding:'utf8', flag:'r'});
29
+ ComponentApi.saveSupportedComponents(json);
30
+ const sc = ComponentApi.getSupportedComponents();
31
+ expect(sc.length).to.equal(305);
32
+ });
33
+
34
+ });
@@ -0,0 +1,21 @@
1
+ import org.apache.camel.AggregationStrategy;
2
+ import org.apache.camel.Configuration;
3
+ import org.apache.camel.BindToRegistry;
4
+ import org.apache.camel.Exchange;
5
+
6
+ @Configuration
7
+ @BindToRegistry("${NAME}")
8
+ public class ${NAME} implements AggregationStrategy {
9
+ @Override
10
+ public Exchange aggregate(Exchange oldExchange, Exchange newExchange) {
11
+
12
+ if (oldExchange == null) {
13
+ return newExchange;
14
+ }
15
+
16
+ String oldBody = oldExchange.getIn().getBody(String.class);
17
+ String newBody = newExchange.getIn().getBody(String.class);
18
+ oldExchange.getIn().setBody(oldBody + "+" + newBody);
19
+ return oldExchange;
20
+ }
21
+ }
@@ -0,0 +1,13 @@
1
+ import org.apache.camel.BindToRegistry;
2
+ import org.apache.camel.Configuration;
3
+ import org.apache.camel.Exchange;
4
+ import org.apache.camel.Processor;
5
+
6
+ @Configuration
7
+ @BindToRegistry("${NAME}")
8
+ public class ${NAME} implements Processor {
9
+
10
+ public void process(Exchange exchange) throws Exception {
11
+ exchange.getIn().setBody("Hello World");
12
+ }
13
+ }
@@ -0,0 +1,21 @@
1
+ import org.apache.camel.AggregationStrategy;
2
+ import org.apache.camel.Configuration;
3
+ import org.apache.camel.BindToRegistry;
4
+ import org.apache.camel.Exchange;
5
+
6
+ @Configuration
7
+ @BindToRegistry("CustomAggregationStrategy")
8
+ public class CustomAggregationStrategy implements AggregationStrategy {
9
+ @Override
10
+ public Exchange aggregate(Exchange oldExchange, Exchange newExchange) {
11
+
12
+ if (oldExchange == null) {
13
+ return newExchange;
14
+ }
15
+
16
+ String oldBody = oldExchange.getIn().getBody(String.class);
17
+ String newBody = newExchange.getIn().getBody(String.class);
18
+ oldExchange.getIn().setBody(oldBody + "+" + newBody);
19
+ return oldExchange;
20
+ }
21
+ }
@@ -0,0 +1,13 @@
1
+ import org.apache.camel.BindToRegistry;
2
+ import org.apache.camel.Configuration;
3
+ import org.apache.camel.Exchange;
4
+ import org.apache.camel.Processor;
5
+
6
+ @Configuration
7
+ @BindToRegistry("CustomProcessor")
8
+ public class CustomProcessor implements Processor {
9
+
10
+ public void process(Exchange exchange) throws Exception {
11
+ exchange.getIn().setBody("Hello World");
12
+ }
13
+ }
@@ -0,0 +1,45 @@
1
+ /*
2
+ * Licensed to the Apache Software Foundation (ASF) under one or more
3
+ * contributor license agreements. See the NOTICE file distributed with
4
+ * this work for additional information regarding copyright ownership.
5
+ * The ASF licenses this file to You under the Apache License, Version 2.0
6
+ * (the "License"); you may not use this file except in compliance with
7
+ * the License. You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ import {expect} from 'chai';
18
+ import 'mocha';
19
+ import * as fs from 'fs';
20
+ import { TemplateApi } from '../src/core/api/TemplateApi';
21
+
22
+ describe('TemplateAPI', () => {
23
+
24
+ it('Generate Aggregation Strategy', () => {
25
+
26
+ const aggregator = fs.readFileSync('test/template1.AggregationStrategy.java',{encoding:'utf8', flag:'r'});
27
+ const code2 = fs.readFileSync('test/template2.AggregationStrategy.java',{encoding:'utf8', flag:'r'});
28
+
29
+ TemplateApi.saveTemplate("aggregator", aggregator)
30
+
31
+ const code = TemplateApi.generateCode("aggregator", "CustomAggregationStrategy")
32
+ expect(code2).to.equal(code);
33
+ });
34
+
35
+ it('Generate Processor', () => {
36
+
37
+ const processor = fs.readFileSync('test/template1.Processor.java',{encoding:'utf8', flag:'r'});
38
+ const code2 = fs.readFileSync('test/template2.Processor.java',{encoding:'utf8', flag:'r'});
39
+
40
+ TemplateApi.saveTemplate("processor", processor)
41
+
42
+ const code = TemplateApi.generateCode("processor", "CustomProcessor")
43
+ expect(code2).to.equal(code);
44
+ });
45
+ });
@@ -0,0 +1,75 @@
1
+ # ---------------------------------------------------------------------------
2
+ # Licensed to the Apache Software Foundation (ASF) under one or more
3
+ # contributor license agreements. See the NOTICE file distributed with
4
+ # this work for additional information regarding copyright ownership.
5
+ # The ASF licenses this file to You under the Apache License, Version 2.0
6
+ # (the "License"); you may not use this file except in compliance with
7
+ # the License. You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+ # ---------------------------------------------------------------------------
17
+
18
+ apiVersion: camel.apache.org/v1
19
+ kind: Kamelet
20
+ metadata:
21
+ name: timer-source
22
+ annotations:
23
+ camel.apache.org/kamelet.support.level: "Stable"
24
+ camel.apache.org/catalog.version: "4.2.0-SNAPSHOT"
25
+ camel.apache.org/kamelet.icon: data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4NCjwhLS0gU3ZnIFZlY3RvciBJY29ucyA6IGh0dHA6Ly93d3cub25saW5ld2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Ny43aC0yMzUuMWgtMjM1LjFWMTM3NS4zeiBNNTE2Ni4zLTI5My42YzE0Ni45LTE0NCw0NC4xLTM5Ni43LTE2MS42LTM5Ni43Yy01NS44LDAtMTE3LjUsMjYuNC0xNjEuNiw3My40Yy00Nyw0NC4xLTczLjUsMTA1LjgtNzMuNSwxNjEuNnMyNi40LDExNy41LDczLjUsMTYxLjZjNDQuMSw0NywxMDUuOCw3My41LDE2MS42LDczLjVDNTA2MC41LTIyMC4yLDUxMjIuMi0yNDYuNyw1MTY2LjMtMjkzLjZ6Ii8+PC9nPjwvZz4NCjwvc3ZnPg==
26
+ camel.apache.org/provider: "Apache Software Foundation"
27
+ camel.apache.org/kamelet.group: "Timer"
28
+ camel.apache.org/kamelet.namespace: "Scheduling"
29
+ labels:
30
+ camel.apache.org/kamelet.type: source
31
+ camel.apache.org/kamelet.verified: "true"
32
+ spec:
33
+ definition:
34
+ title: Timer Source
35
+ description: Produces periodic messages with a custom payload.
36
+ required:
37
+ - message
38
+ type: object
39
+ properties:
40
+ period:
41
+ title: Period
42
+ description: "The interval (in milliseconds) to wait between producing the next message."
43
+ type: integer
44
+ default: 1000
45
+ message:
46
+ title: Message
47
+ description: The message to generate.
48
+ type: string
49
+ example: hello world
50
+ contentType:
51
+ title: Content Type
52
+ description: The content type of the generated message.
53
+ type: string
54
+ default: text/plain
55
+ repeatCount:
56
+ title: Repeat Count
57
+ description: Specifies a maximum limit of number of fires
58
+ type: integer
59
+ dependencies:
60
+ - "camel:core"
61
+ - "camel:timer"
62
+ - "camel:kamelet"
63
+ template:
64
+ from:
65
+ uri: timer:tick
66
+ parameters:
67
+ period: "{{period}}"
68
+ repeatCount: "{{?repeatCount}}"
69
+ steps:
70
+ - set-body:
71
+ constant: "{{message}}"
72
+ - set-header:
73
+ name: "Content-Type"
74
+ constant: "{{contentType}}"
75
+ - to: kamelet:sink
@@ -0,0 +1,31 @@
1
+ /*
2
+ * Licensed to the Apache Software Foundation (ASF) under one or more
3
+ * contributor license agreements. See the NOTICE file distributed with
4
+ * this work for additional information regarding copyright ownership.
5
+ * The ASF licenses this file to You under the Apache License, Version 2.0
6
+ * (the "License"); you may not use this file except in compliance with
7
+ * the License. You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ import {expect} from 'chai';
18
+ import * as fs from 'fs';
19
+ import 'mocha';
20
+ import {CamelDefinitionYaml} from "../src/core/api/CamelDefinitionYaml";
21
+
22
+
23
+ describe('ToDynamicDefinition', () => {
24
+
25
+ it('ToDynamicDefinition URI', () => {
26
+ const yaml = fs.readFileSync('test/tod.yaml',{encoding:'utf8', flag:'r'});
27
+ const i = CamelDefinitionYaml.yamlToIntegration("test1.yaml", yaml);
28
+ expect(i.spec.flows?.[0].from.steps[0].uri, 'kafka:${header.foo}')
29
+ });
30
+
31
+ });
package/test/tod.yaml ADDED
@@ -0,0 +1,9 @@
1
+ - route:
2
+ id: route-f435
3
+ from:
4
+ uri: kamelet:timer-source
5
+ id: from-e52c
6
+ steps:
7
+ - toD:
8
+ uri: kafka:${header.foo}
9
+ id: toD-0d39
@@ -0,0 +1,51 @@
1
+ /*
2
+ * Licensed to the Apache Software Foundation (ASF) under one or more
3
+ * contributor license agreements. See the NOTICE file distributed with
4
+ * this work for additional information regarding copyright ownership.
5
+ * The ASF licenses this file to You under the Apache License, Version 2.0
6
+ * (the "License"); you may not use this file except in compliance with
7
+ * the License. You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ import * as fs from 'fs';
18
+ import 'mocha';
19
+ import {CamelDefinitionYaml} from "../src/core/api/CamelDefinitionYaml";
20
+ import { TopologyUtils } from '../src/core/api/TopologyUtils';
21
+ import { KameletApi } from '../src/core/api/KameletApi';
22
+
23
+
24
+ describe('Topology functions', () => {
25
+
26
+ it('Topology find', () => {
27
+ loadKamelets();
28
+ const yaml1 = fs.readFileSync('test/topology1.camel.yaml',{encoding:'utf8', flag:'r'});
29
+ const yaml2 = fs.readFileSync('test/topology2.camel.yaml',{encoding:'utf8', flag:'r'});
30
+ const i1 = CamelDefinitionYaml.yamlToIntegration("test1.yaml", yaml1);
31
+ const i2 = CamelDefinitionYaml.yamlToIntegration("test1.yaml", yaml2);
32
+ const tin = TopologyUtils.findTopologyIncomingNodes([i1, i2]);
33
+ const trn = TopologyUtils.findTopologyRestNodes([i1, i2]);
34
+ const ton = TopologyUtils.findTopologyRouteOutgoingNodes([i1, i2]);
35
+ });
36
+
37
+ it('Topology getUniqueUri', () => {
38
+ loadKamelets();
39
+ const yaml1 = fs.readFileSync('test/topology3.camel.yaml',{encoding:'utf8', flag:'r'});
40
+ const i1 = CamelDefinitionYaml.yamlToIntegration("test1.yaml", yaml1);
41
+ const tin = TopologyUtils.findTopologyRouteOutgoingNodes([i1]);
42
+ });
43
+
44
+ function loadKamelets() {
45
+ const yamls = fs.readFileSync('test/metadata/kamelets.yaml',{encoding:'utf8', flag:'r'});
46
+ const kamelets: string[] = [];
47
+ yamls.split(/\n?---\n?/).map(c => c.trim()).forEach(z => kamelets.push(z));
48
+ KameletApi.saveKamelets(kamelets, true);
49
+ }
50
+
51
+ });
@@ -0,0 +1,56 @@
1
+ - route:
2
+ id: route-c67f1
3
+ description: Timer Scheduler
4
+ from:
5
+ uri: kamelet:timer-source
6
+ id: from-b4181
7
+ parameters:
8
+ message: Hello
9
+ steps:
10
+ - log:
11
+ message: ${body}
12
+ id: log-a68a1
13
+ - route:
14
+ id: route-2cbd1
15
+ from:
16
+ uri: kamelet:aws-cloudtrail-source
17
+ id: from-a3f61
18
+ parameters:
19
+ region: fff
20
+ steps:
21
+ - to:
22
+ uri: kamelet:google-pubsub-sink
23
+ id: to-c27f1
24
+ - route:
25
+ id: route-de2b1
26
+ from:
27
+ uri: amqp
28
+ id: from-1e661
29
+ steps:
30
+ - to:
31
+ uri: direct
32
+ id: to-6a041
33
+ parameters:
34
+ name: xxxx
35
+ - route:
36
+ id: route-ec4e1
37
+ from:
38
+ uri: direct
39
+ id: from-e9181
40
+ parameters:
41
+ name: xxx
42
+ steps:
43
+ - to:
44
+ uri: kamelet:kafka-not-secured-sink
45
+ id: to-a47b1
46
+ - rest:
47
+ id: rest-b499
48
+ get:
49
+ - to: direct:xxx
50
+ id: get-cb63
51
+ post:
52
+ - to: direct:xxx
53
+ id: post-07e4
54
+ put:
55
+ - to: direct:xxx
56
+ id: put-8271
@@ -0,0 +1,44 @@
1
+ - route:
2
+ id: route-c67f
3
+ from:
4
+ uri: kamelet:timer-source
5
+ id: from-b418
6
+ parameters:
7
+ message: Hello
8
+ steps:
9
+ - log:
10
+ message: ${body}
11
+ id: log-a68a
12
+ - route:
13
+ id: route-2cbd
14
+ from:
15
+ uri: kamelet:aws-cloudtrail-source
16
+ id: from-a3f6
17
+ parameters:
18
+ region: fff
19
+ steps:
20
+ - to:
21
+ uri: kamelet:google-pubsub-sink
22
+ id: to-c27f
23
+ - route:
24
+ id: route-de2b
25
+ from:
26
+ uri: amqp
27
+ id: from-1e66
28
+ steps:
29
+ - to:
30
+ uri: direct
31
+ id: to-6a04
32
+ parameters:
33
+ name: xxxx
34
+ - route:
35
+ id: route-ec4e
36
+ from:
37
+ uri: direct
38
+ id: from-e918
39
+ parameters:
40
+ name: xxx
41
+ steps:
42
+ - to:
43
+ uri: kamelet:kafka-not-secured-sink
44
+ id: to-a47b
@@ -0,0 +1,27 @@
1
+ - route:
2
+ id: route-6312
3
+ description: File Send
4
+ nodePrefixId: route-b7f
5
+ autoStartup: true
6
+ from:
7
+ id: file-send-direct
8
+ uri: direct
9
+ parameters:
10
+ name: send-roster-files
11
+ synchronous: false
12
+ steps:
13
+ - log:
14
+ id: log-894b
15
+ message: "DEBUG: Transfer Starting ${date:now:yyyyMMdd hh:mm:ss}"
16
+ - routeConfiguration:
17
+ errorHandler:
18
+ id: errorHandler-1b09
19
+ deadLetterChannel:
20
+ id: deadLetterChannel-2cf3
21
+ deadLetterUri: direct:dlq
22
+ redeliveryPolicy:
23
+ id: redeliveryPolicy-58fe
24
+ maximumRedeliveries: 5
25
+ redeliveryDelay: "60000"
26
+ useOriginalMessage: false
27
+ useOriginalBody: false
@@ -0,0 +1,14 @@
1
+ {
2
+ "compilerOptions": {
3
+ "module": "ES2022",
4
+ "target": "ES2022",
5
+ "lib": [
6
+ "dom",
7
+ "dom.iterable",
8
+ "esnext",
9
+ "ES2021",
10
+ "ES2021.String"
11
+ ]
12
+ },
13
+ "include": ["**/*.spec.ts"]
14
+ }
@@ -0,0 +1,72 @@
1
+ /*
2
+ * Licensed to the Apache Software Foundation (ASF) under one or more
3
+ * contributor license agreements. See the NOTICE file distributed with
4
+ * this work for additional information regarding copyright ownership.
5
+ * The ASF licenses this file to You under the Apache License, Version 2.0
6
+ * (the "License"); you may not use this file except in compliance with
7
+ * the License. You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ import {expect} from 'chai';
18
+ import 'mocha';
19
+ import {FromDefinition, LogDefinition, WhenDefinition, ChoiceDefinition, ExpressionDefinition} from "../src/core/model/CamelDefinition";
20
+ import {CamelUtil} from "../src/core/api/CamelUtil";
21
+ import {CamelDefinitionApiExt} from "../src/core/api/CamelDefinitionApiExt";
22
+ import {FilterDefinition, SimpleExpression} from "../src/core/model/CamelDefinition";
23
+ import {Integration} from "../src/core/model/IntegrationDefinition";
24
+ import {RouteDefinition} from "../src/core/model/CamelDefinition";
25
+
26
+ describe('Update Step', () => {
27
+
28
+ it('Update Expression in When clause', () => {
29
+ const i = Integration.createNew("test")
30
+ const when1 = new WhenDefinition({
31
+ expression:new ExpressionDefinition({simple: new SimpleExpression({expression: '$[body} != null'})}),
32
+ steps:[new LogDefinition({logName: 'log11', message: "hello11"})]
33
+ })
34
+ const choice = new ChoiceDefinition({when:[when1]})
35
+ const flow1 = new FromDefinition({uri: "direct1"});
36
+ flow1.steps?.push(choice);
37
+ i.spec.flows?.push(new RouteDefinition({from: flow1}));
38
+ const when2:WhenDefinition = CamelUtil.cloneStep(when1);
39
+ if (when2 && when2.expression){
40
+ when2.expression.simple = new SimpleExpression({expression: '$[body} == "hello world"'});
41
+ }
42
+ const i2 = CamelDefinitionApiExt.updateIntegrationRouteElement(i, when2);
43
+ if (i2.spec.flows && i2.spec.flows.length > 0){
44
+ const f:FromDefinition = i2.spec.flows[0].from;
45
+ const c:ChoiceDefinition = f.steps ? f.steps[0] : new ChoiceDefinition();
46
+ const w = c.when ? c.when[0] : undefined;
47
+ expect((w?.expression?.simple as SimpleExpression).expression).to.equal('$[body} == "hello world"');
48
+ }
49
+ });
50
+
51
+ it('Update Expression in Filter clause', () => {
52
+ const i = Integration.createNew("test")
53
+ const filter = new FilterDefinition({
54
+ expression:new ExpressionDefinition({simple: new SimpleExpression({expression: '$[body} != null'})}),
55
+ steps:[new LogDefinition({logName: 'log11', message: "hello11"})]
56
+ })
57
+ const flow1 = new FromDefinition({uri: "direct1"});
58
+ flow1.steps?.push(filter);
59
+ i.spec.flows?.push(new RouteDefinition({from: flow1}));
60
+
61
+ const filter1:FilterDefinition = CamelUtil.cloneStep(filter);
62
+ if (filter1 && filter1.expression){
63
+ filter1.expression.simple = new SimpleExpression({expression: '$[body} == "hello world"'});
64
+ }
65
+ const i2 = CamelDefinitionApiExt.updateIntegrationRouteElement(i, filter1);
66
+ if (i2.spec.flows && i2.spec.flows.length > 0){
67
+ const from:FromDefinition = i2.spec.flows[0].from;
68
+ const f:FilterDefinition = from.steps ? from.steps[0] : new FilterDefinition();
69
+ expect((f?.expression?.simple as SimpleExpression).expression).to.equal('$[body} == "hello world"');
70
+ }
71
+ });
72
+ });
@@ -0,0 +1,42 @@
1
+ - route:
2
+ id: route-18e5
3
+ nodePrefixId: route-656
4
+ from:
5
+ id: from-9468
6
+ uri: amqp
7
+ variableReceive: global:variable1
8
+ steps:
9
+ - doTry:
10
+ id: doTry-8bb0
11
+ doCatch:
12
+ - id: doCatch-19a9
13
+ steps:
14
+ - convertVariableTo:
15
+ id: convertVariableTo-b0e5
16
+ name: xxx
17
+ toName: yyy
18
+ steps:
19
+ - multicast:
20
+ id: multicast-ad44
21
+ steps:
22
+ - to:
23
+ id: to-0c20
24
+ variableSend: send1
25
+ variableReceive: receive1
26
+ uri: activemq
27
+ - to:
28
+ id: to-e79a
29
+ variableSend: route:aran1
30
+ variableReceive: route:aran1
31
+ uri: arangodb
32
+ - setVariable:
33
+ id: setVariable-957d
34
+ name: varrr
35
+ expression:
36
+ simple:
37
+ id: simple-cd4b
38
+ - to:
39
+ id: to-60f8
40
+ variableSend: hello
41
+ variableReceive: world
42
+ uri: amqp
@@ -0,0 +1,42 @@
1
+ - route:
2
+ id: route-18e5
3
+ nodePrefixId: route-656
4
+ from:
5
+ id: from-9468
6
+ uri: amqp
7
+ variableReceive: variable2
8
+ steps:
9
+ - doTry:
10
+ id: doTry-8bb0
11
+ doCatch:
12
+ - id: doCatch-19a9
13
+ steps:
14
+ - convertVariableTo:
15
+ id: convertVariableTo-b0e5
16
+ name: xxx2
17
+ toName: yyy2
18
+ steps:
19
+ - multicast:
20
+ id: multicast-ad44
21
+ steps:
22
+ - to:
23
+ id: to-0c20
24
+ variableSend: asend2
25
+ variableReceive: breceive2
26
+ uri: activemq
27
+ - to:
28
+ id: to-e79a
29
+ variableSend: route:aran2
30
+ variableReceive: global:aran2
31
+ uri: arangodb
32
+ - setVariable:
33
+ id: setVariable-957d
34
+ name: varrr2
35
+ expression:
36
+ simple:
37
+ id: simple-cd4b
38
+ - to:
39
+ id: to-60f8
40
+ variableSend: hello2
41
+ variableReceive: world2
42
+ uri: amqp
@@ -0,0 +1,34 @@
1
+ /*
2
+ * Licensed to the Apache Software Foundation (ASF) under one or more
3
+ * contributor license agreements. See the NOTICE file distributed with
4
+ * this work for additional information regarding copyright ownership.
5
+ * The ASF licenses this file to You under the Apache License, Version 2.0
6
+ * (the "License"); you may not use this file except in compliance with
7
+ * the License. You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ import {expect} from 'chai';
18
+ import * as fs from 'fs';
19
+ import 'mocha';
20
+ import { VariableUtil } from '../src/core/api/VariableUtil';
21
+ import { IntegrationFile } from '../src/core/model/IntegrationDefinition';
22
+
23
+ describe('Variables', () => {
24
+
25
+ it('Find Variables', () => {
26
+ const yaml1 = fs.readFileSync('test/variable1.camel.yaml',{encoding:'utf8', flag:'r'});
27
+ const yaml2 = fs.readFileSync('test/variable2.camel.yaml',{encoding:'utf8', flag:'r'});
28
+ const variables = VariableUtil.findVariables([
29
+ new IntegrationFile('variable1.camel.yaml', yaml1)
30
+ , new IntegrationFile('variable2.camel.yaml', yaml2)
31
+ ]);
32
+ expect(variables.length).to.equal(19);
33
+ });
34
+ });