karavan-core 4.8.0 → 99.0.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of karavan-core might be problematic. Click here for more details.
- package/index.js +3 -0
- package/package.json +8 -58
- package/.bebelrc +0 -3
- package/.mocharc.json +0 -11
- package/.prettierignore +0 -9
- package/.prettierrc +0 -14
- package/src/core/api/CamelDefinitionApi.ts +0 -3271
- package/src/core/api/CamelDefinitionApiExt.ts +0 -757
- package/src/core/api/CamelDefinitionYaml.ts +0 -412
- package/src/core/api/CamelDefinitionYamlStep.ts +0 -4733
- package/src/core/api/CamelDisplayUtil.ts +0 -143
- package/src/core/api/CamelUtil.ts +0 -360
- package/src/core/api/ComponentApi.ts +0 -368
- package/src/core/api/KameletApi.ts +0 -147
- package/src/core/api/MainConfigurationApi.ts +0 -47
- package/src/core/api/ProjectModelApi.ts +0 -75
- package/src/core/api/SpiBeanApi.ts +0 -104
- package/src/core/api/TemplateApi.ts +0 -58
- package/src/core/api/TopologyUtils.ts +0 -392
- package/src/core/api/VariableUtil.ts +0 -104
- package/src/core/model/CamelDefinition.ts +0 -3783
- package/src/core/model/CamelMetadata.ts +0 -2714
- package/src/core/model/ComponentModels.ts +0 -106
- package/src/core/model/IntegrationDefinition.ts +0 -188
- package/src/core/model/KameletModels.ts +0 -223
- package/src/core/model/MainConfigurationModel.ts +0 -37
- package/src/core/model/ProjectModel.ts +0 -43
- package/src/core/model/SpiBeanModels.ts +0 -53
- package/src/core/model/TopologyDefinition.ts +0 -117
- package/test/addStep.spec.ts +0 -124
- package/test/addStep1.yaml +0 -27
- package/test/allowableValues.camel.yaml +0 -19
- package/test/allowableValues.spec.ts +0 -30
- package/test/avro-serialize-action.kamelet.yaml +0 -70
- package/test/beans.spec.ts +0 -92
- package/test/beans1.yaml +0 -36
- package/test/beans2.yaml +0 -42
- package/test/beans3.yaml +0 -7
- package/test/checkRequired.spec.ts +0 -53
- package/test/circuitBreaker.spec.ts +0 -57
- package/test/circuitBreaker.yaml +0 -19
- package/test/cloneDefinition.spec.ts +0 -106
- package/test/createKamelet.spec.ts +0 -38
- package/test/cxf.json +0 -615
- package/test/cxf.spec.ts +0 -44
- package/test/cxf.yaml +0 -15
- package/test/deleteStep.spec.ts +0 -74
- package/test/demo.spec.ts +0 -49
- package/test/demo.yaml +0 -32
- package/test/doCatchOnWhen.camel.yaml +0 -20
- package/test/doCatchOnWhen.spec.ts +0 -36
- package/test/errorHandler.spec.ts +0 -38
- package/test/errorHandler1.yaml +0 -27
- package/test/expression.spec.ts +0 -55
- package/test/findStep.spec.ts +0 -112
- package/test/findStep.yaml +0 -65
- package/test/getElementProperties.spec.ts +0 -32
- package/test/getElementPropertiesByName.spec.ts +0 -31
- package/test/getExpressionLanguage.spec.ts +0 -40
- package/test/hasElementWithId.camel.yaml +0 -98
- package/test/hasElementWithId.spec.ts +0 -57
- package/test/hasElementWithId1.camel.yaml +0 -16
- package/test/hasElementWithIdError.camel.yaml +0 -98
- package/test/integration.spec.ts +0 -60
- package/test/integration1.yaml +0 -24
- package/test/integration2.yaml +0 -23
- package/test/integrationToYaml.spec.ts +0 -51
- package/test/intercept.spec.ts +0 -62
- package/test/intercept.yaml +0 -19
- package/test/is-not-integration.yaml +0 -5114
- package/test/isIntegration.spec.ts +0 -45
- package/test/kamelet.spec.ts +0 -61
- package/test/metadata/components.json +0 -697
- package/test/metadata/kamelets.yaml +0 -23414
- package/test/metadata/spiBeans.json +0 -3094
- package/test/multiObjectProperties.spec.ts +0 -46
- package/test/multiObjectProperties1.yaml +0 -19
- package/test/multiple.spec.ts +0 -38
- package/test/multiple.yaml +0 -29
- package/test/openapi.spec.ts +0 -48
- package/test/openapi.yaml +0 -7
- package/test/placeholder.spec.ts +0 -32
- package/test/placeholder.yaml +0 -133
- package/test/plain-try-catch.yaml +0 -31
- package/test/plain.spec.ts +0 -72
- package/test/plain1.yaml +0 -22
- package/test/plain2.yaml +0 -13
- package/test/plain3.yaml +0 -5
- package/test/plain4.yaml +0 -5
- package/test/postgresql-source.kamelet.yaml +0 -113
- package/test/restConfigDsl.yaml +0 -15
- package/test/restDsl.spec.ts +0 -83
- package/test/restDsl.yaml +0 -29
- package/test/routes.spec.ts +0 -37
- package/test/routes1.yaml +0 -31
- package/test/supported-components.json +0 -1221
- package/test/supportedComponents.spec.ts +0 -34
- package/test/template1.AggregationStrategy.java +0 -21
- package/test/template1.Processor.java +0 -13
- package/test/template2.AggregationStrategy.java +0 -21
- package/test/template2.Processor.java +0 -13
- package/test/templateApi.spec.ts +0 -45
- package/test/timer-source.kamelet.yaml +0 -75
- package/test/tod.spec.ts +0 -31
- package/test/tod.yaml +0 -9
- package/test/topology.spec.ts +0 -51
- package/test/topology1.camel.yaml +0 -56
- package/test/topology2.camel.yaml +0 -44
- package/test/topology3.camel.yaml +0 -27
- package/test/tsconfig.testing.json +0 -14
- package/test/updateStep.spec.ts +0 -72
- package/test/variable1.camel.yaml +0 -42
- package/test/variable2.camel.yaml +0 -42
- package/test/variables.spec.ts +0 -34
- package/tsconfig.json +0 -34
package/test/deleteStep.spec.ts
DELETED
@@ -1,74 +0,0 @@
|
|
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, RouteDefinition, SimpleExpression} from "../src/core/model/CamelDefinition";
|
23
|
-
import {Integration} from "../src/core/model/IntegrationDefinition";
|
24
|
-
|
25
|
-
describe('Delete Step', () => {
|
26
|
-
|
27
|
-
it('Delete Expression in When clause', () => {
|
28
|
-
const i = Integration.createNew("test")
|
29
|
-
const log1 =new LogDefinition({logName: 'log11', message: "hello11"});
|
30
|
-
const log2 =new LogDefinition({logName: 'log11', message: "hello22"});
|
31
|
-
const log3 =new LogDefinition({logName: 'log11', message: "hello33"});
|
32
|
-
const when1 = new WhenDefinition({
|
33
|
-
expression:new ExpressionDefinition({simple: new SimpleExpression({expression: '$[body} != null'})}),
|
34
|
-
steps:[log1, log2, log3]
|
35
|
-
})
|
36
|
-
const choice = new ChoiceDefinition({when:[when1]})
|
37
|
-
const from1 = new FromDefinition({uri: "direct1"});
|
38
|
-
from1.steps?.push(choice);
|
39
|
-
i.spec.flows?.push(new RouteDefinition({from: from1}));
|
40
|
-
const when2:WhenDefinition = CamelUtil.cloneStep(when1);
|
41
|
-
if (when2 && when2.expression){
|
42
|
-
when2.expression.simple = new SimpleExpression({expression: '$[body} == "hello world"'});
|
43
|
-
}
|
44
|
-
const i2 = CamelDefinitionApiExt.deleteStepFromIntegration(i, log2.uuid);
|
45
|
-
if (i2.spec.flows && i2.spec.flows.length > 0){
|
46
|
-
const f:FromDefinition = i2.spec.flows[0].from;
|
47
|
-
const c:ChoiceDefinition = f.steps ? f.steps[0] : new ChoiceDefinition();
|
48
|
-
const w = c.when ? c.when[0] : undefined;
|
49
|
-
expect(w?.steps?.length).to.equal(2);
|
50
|
-
}
|
51
|
-
});
|
52
|
-
|
53
|
-
it('Delete Step from Filter clause', () => {
|
54
|
-
const i = Integration.createNew("test")
|
55
|
-
const log1 =new LogDefinition({logName: 'log11', message: "hello11"});
|
56
|
-
const log2 =new LogDefinition({logName: 'log11', message: "hello22"});
|
57
|
-
const log3 =new LogDefinition({logName: 'log11', message: "hello33"});
|
58
|
-
const filter = new FilterDefinition({
|
59
|
-
expression:new ExpressionDefinition({simple: new SimpleExpression({expression: '$[body} != null'})}),
|
60
|
-
steps:[log1, log2, log3]
|
61
|
-
})
|
62
|
-
const from = new FromDefinition({uri: "direct1"});
|
63
|
-
from.steps?.push(filter);
|
64
|
-
i.spec.flows?.push(new RouteDefinition({from: from}));
|
65
|
-
|
66
|
-
|
67
|
-
const i2 = CamelDefinitionApiExt.deleteStepFromIntegration(i, log2.uuid);
|
68
|
-
if (i2.spec.flows && i2.spec.flows.length > 0){
|
69
|
-
const from:FromDefinition = i2.spec.flows[0].from;
|
70
|
-
const f:FilterDefinition = from.steps ? from.steps[0] : new FilterDefinition();
|
71
|
-
expect(f.steps?.length).to.equal(2);
|
72
|
-
}
|
73
|
-
});
|
74
|
-
});
|
package/test/demo.spec.ts
DELETED
@@ -1,49 +0,0 @@
|
|
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 {CamelUtil} from "../src/core/api/CamelUtil";
|
21
|
-
import {CamelDefinitionApiExt} from "../src/core/api/CamelDefinitionApiExt";
|
22
|
-
import {CatchDefinition, FromDefinition} from "../src/core/model/CamelDefinition";
|
23
|
-
import {expect} from "chai";
|
24
|
-
import {TryDefinition} from "../src/core/model/CamelDefinition";
|
25
|
-
|
26
|
-
describe('Demo', () => {
|
27
|
-
|
28
|
-
it('Demo', () => {
|
29
|
-
const yaml = fs.readFileSync('test/demo.yaml',{encoding:'utf8', flag:'r'});
|
30
|
-
const i = CamelDefinitionYaml.yamlToIntegration("demo.yaml", yaml);
|
31
|
-
const i2 = CamelUtil.cloneIntegration(i);
|
32
|
-
|
33
|
-
if (i2.spec.flows) {
|
34
|
-
const f: FromDefinition = i2.spec.flows[0].from;
|
35
|
-
const td: TryDefinition = f.steps[0];
|
36
|
-
if (td.doCatch) {
|
37
|
-
const c: CatchDefinition | undefined = td.doCatch[0];
|
38
|
-
const uuid = c.onWhen?.uuid || '';
|
39
|
-
expect(uuid.length).to.above(0)
|
40
|
-
const i3 = CamelDefinitionApiExt.deleteStepFromIntegration(i, uuid);
|
41
|
-
if (i3.spec.flows && i3.spec.flows.length > 0) {
|
42
|
-
const w = i3.spec.flows[0].from.steps[0].doCatch[0].onWhen;
|
43
|
-
expect(w).to.equal(undefined);
|
44
|
-
}
|
45
|
-
}
|
46
|
-
}
|
47
|
-
});
|
48
|
-
|
49
|
-
});
|
package/test/demo.yaml
DELETED
@@ -1,32 +0,0 @@
|
|
1
|
-
apiVersion: camel.apache.org/v1
|
2
|
-
kind: Integration
|
3
|
-
metadata:
|
4
|
-
name: 'demo'
|
5
|
-
spec:
|
6
|
-
flows:
|
7
|
-
- route:
|
8
|
-
from:
|
9
|
-
uri: kamelet:http-secured-source
|
10
|
-
steps:
|
11
|
-
- doTry:
|
12
|
-
steps:
|
13
|
-
- to: "log:when-a"
|
14
|
-
- to: "log:when-b"
|
15
|
-
doCatch:
|
16
|
-
- exception:
|
17
|
-
- "java.io.FileNotFoundException"
|
18
|
-
- "java.io.IOException"
|
19
|
-
onWhen:
|
20
|
-
expression:
|
21
|
-
simple: "${body.size()} == 1"
|
22
|
-
steps:
|
23
|
-
- to: "log:io-error"
|
24
|
-
- choice:
|
25
|
-
when:
|
26
|
-
- expression:
|
27
|
-
simple: "${body.size()} == 1"
|
28
|
-
steps:
|
29
|
-
- toD: "log:xxx"
|
30
|
-
otherwise:
|
31
|
-
steps:
|
32
|
-
- toD: "log:yyy"
|
@@ -1,20 +0,0 @@
|
|
1
|
-
- route:
|
2
|
-
id: route-8a40
|
3
|
-
nodePrefixId: route-78f
|
4
|
-
from:
|
5
|
-
id: from-674b
|
6
|
-
uri: timer
|
7
|
-
parameters:
|
8
|
-
timerName: name
|
9
|
-
steps:
|
10
|
-
- doTry:
|
11
|
-
id: doTry-258c
|
12
|
-
doCatch:
|
13
|
-
- id: doCatch-32ac
|
14
|
-
exception:
|
15
|
-
- java.lang.ArrayIndexOutOfBoundsException
|
16
|
-
onWhen:
|
17
|
-
id: when-b4f0
|
18
|
-
expression:
|
19
|
-
groovy:
|
20
|
-
id: groovy-2d4f
|
@@ -1,36 +0,0 @@
|
|
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 {CamelUtil} from "../src/core/api/CamelUtil";
|
21
|
-
import {CamelDefinitionApiExt} from "../src/core/api/CamelDefinitionApiExt";
|
22
|
-
import {CatchDefinition, FromDefinition} from "../src/core/model/CamelDefinition";
|
23
|
-
import {expect} from "chai";
|
24
|
-
import {TryDefinition} from "../src/core/model/CamelDefinition";
|
25
|
-
|
26
|
-
describe('DoCatch', () => {
|
27
|
-
|
28
|
-
it('on When', () => {
|
29
|
-
const yaml = fs.readFileSync('test/doCatchOnWhen.camel.yaml',{encoding:'utf8', flag:'r'});
|
30
|
-
const i = CamelDefinitionYaml.yamlToIntegration("demo.yaml", yaml);
|
31
|
-
const yaml2 = CamelDefinitionYaml.integrationToYaml(i);
|
32
|
-
|
33
|
-
expect(yaml2).to.equal(yaml);
|
34
|
-
});
|
35
|
-
|
36
|
-
});
|
@@ -1,38 +0,0 @@
|
|
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 * as jsYaml from 'js-yaml';
|
20
|
-
import 'mocha';
|
21
|
-
import {CamelDefinitionYaml} from "../src/core/api/CamelDefinitionYaml";
|
22
|
-
|
23
|
-
|
24
|
-
describe('Global Error Handler', () => {
|
25
|
-
|
26
|
-
it('Read Global Error Handler from plain YAML', () => {
|
27
|
-
const yaml = fs.readFileSync('test/errorHandler1.yaml', {encoding: 'utf8', flag: 'r'});
|
28
|
-
const i = CamelDefinitionYaml.yamlToIntegration("errorHandler1.yaml", yaml);
|
29
|
-
expect(i.metadata.name).to.equal('errorHandler1.yaml');
|
30
|
-
expect(i.spec.flows?.length).to.equal(2);
|
31
|
-
expect(i.type).to.equal('plain');
|
32
|
-
expect(i.spec.flows?.[1].errorHandler.deadLetterChannel.deadLetterUri).to.equal('log:dlq');
|
33
|
-
expect(i.spec.flows?.[1].errorHandler.deadLetterChannel.useOriginalMessage).to.equal(true);
|
34
|
-
expect(i.spec.flows?.[1].errorHandler.deadLetterChannel.level).to.equal('TRACE');
|
35
|
-
const yaml2 = CamelDefinitionYaml.integrationToYaml(i);
|
36
|
-
expect(yaml.replaceAll("\r\n", "\n")).to.equal(yaml2); // replace for Windows compatibility
|
37
|
-
});
|
38
|
-
});
|
package/test/errorHandler1.yaml
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
- route:
|
2
|
-
id: route-1
|
3
|
-
from:
|
4
|
-
id: from-1
|
5
|
-
uri: kamelet:timer-source
|
6
|
-
parameters:
|
7
|
-
period: 1000
|
8
|
-
message: "1"
|
9
|
-
steps:
|
10
|
-
- setBody:
|
11
|
-
id: setBody-1
|
12
|
-
expression:
|
13
|
-
groovy:
|
14
|
-
id: groovy-10a6
|
15
|
-
expression: 1000 / 0
|
16
|
-
- log:
|
17
|
-
id: log-1
|
18
|
-
message: $[body}
|
19
|
-
- routeConfiguration:
|
20
|
-
id: routeConfiguration-1
|
21
|
-
errorHandler:
|
22
|
-
id: errorHandler-1
|
23
|
-
deadLetterChannel:
|
24
|
-
id: deadLetterChannel-1
|
25
|
-
deadLetterUri: log:dlq
|
26
|
-
useOriginalMessage: true
|
27
|
-
level: TRACE
|
package/test/expression.spec.ts
DELETED
@@ -1,55 +0,0 @@
|
|
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 {
|
22
|
-
ChoiceDefinition,
|
23
|
-
ExpressionDefinition,
|
24
|
-
FromDefinition,
|
25
|
-
LogDefinition,
|
26
|
-
OtherwiseDefinition,
|
27
|
-
SimpleExpression,
|
28
|
-
ToDefinition,
|
29
|
-
WhenDefinition
|
30
|
-
} from "../src/core/model/CamelDefinition";
|
31
|
-
import { RouteDefinition} from "../src/core/model/CamelDefinition";
|
32
|
-
import {Integration} from "../src/core/model/IntegrationDefinition";
|
33
|
-
import {AggregateDefinition, ExpressionSubElementDefinition, FilterDefinition} from "../src/core/model/CamelDefinition";
|
34
|
-
|
35
|
-
describe('Expression to yaml', () => {
|
36
|
-
|
37
|
-
it('Aggregate Expression', () => {
|
38
|
-
const i1 = Integration.createNew("test")
|
39
|
-
|
40
|
-
const agg = new AggregateDefinition({
|
41
|
-
correlationExpression: new ExpressionSubElementDefinition({simple: new SimpleExpression({expression:'${body} != null'})}),
|
42
|
-
steps: [new LogDefinition({logName: 'log11', message: "hello11"})]
|
43
|
-
})
|
44
|
-
|
45
|
-
const filter = new FilterDefinition({expression: new ExpressionDefinition({simple: new SimpleExpression({expression:"not null"})})})
|
46
|
-
|
47
|
-
const flow1 = new FromDefinition({uri: "direct1"});
|
48
|
-
flow1.steps?.push(filter);
|
49
|
-
flow1.steps?.push(agg);
|
50
|
-
i1.spec.flows?.push(new RouteDefinition({from: flow1}));
|
51
|
-
|
52
|
-
const yaml1 = CamelDefinitionYaml.integrationToYaml(i1);
|
53
|
-
});
|
54
|
-
|
55
|
-
});
|
package/test/findStep.spec.ts
DELETED
@@ -1,112 +0,0 @@
|
|
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 {
|
20
|
-
FromDefinition,
|
21
|
-
LogDefinition,
|
22
|
-
WhenDefinition,
|
23
|
-
ChoiceDefinition,
|
24
|
-
ExpressionDefinition,
|
25
|
-
SimpleExpression,
|
26
|
-
FilterDefinition, CatchDefinition, TryDefinition, RouteDefinition
|
27
|
-
} from "../src/core/model/CamelDefinition";
|
28
|
-
import {CamelUtil} from "../src/core/api/CamelUtil";
|
29
|
-
import {CamelDefinitionApiExt} from "../src/core/api/CamelDefinitionApiExt";
|
30
|
-
import {Integration} from "../src/core/model/IntegrationDefinition";
|
31
|
-
import * as fs from 'fs';
|
32
|
-
import {CamelDefinitionYaml} from "../src/core/api/CamelDefinitionYaml";
|
33
|
-
import {StepDefinition} from "../src/core/model/CamelDefinition";
|
34
|
-
|
35
|
-
describe('Find Step', () => {
|
36
|
-
|
37
|
-
it('Find Expression in When clause', () => {
|
38
|
-
const i = Integration.createNew("test")
|
39
|
-
const log1 = new LogDefinition({logName: 'log11', message: "hello11"});
|
40
|
-
const log2 = new LogDefinition({logName: 'log11', message: "hello22"});
|
41
|
-
const log3 = new LogDefinition({logName: 'log11', message: "hello33"});
|
42
|
-
const when1 = new WhenDefinition({
|
43
|
-
expression: new ExpressionDefinition({simple: new SimpleExpression({expression: '$[body} != null'})}),
|
44
|
-
steps: [log1, log2, log3]
|
45
|
-
})
|
46
|
-
const choice = new ChoiceDefinition({when: [when1]})
|
47
|
-
const from1 = new FromDefinition({uri: "direct1"});
|
48
|
-
from1.steps?.push(choice);
|
49
|
-
i.spec.flows?.push(new RouteDefinition({from: from1}));
|
50
|
-
const when2: WhenDefinition = CamelUtil.cloneStep(when1);
|
51
|
-
if (when2 && when2.expression) {
|
52
|
-
when2.expression.simple = new SimpleExpression({expression: '$[body} == "hello world"'});
|
53
|
-
}
|
54
|
-
const log: LogDefinition = <LogDefinition> CamelDefinitionApiExt.findElementInIntegration(i, log2.uuid);
|
55
|
-
expect(log.logName).to.equal(log2.logName);
|
56
|
-
expect(log.message).to.equal(log2.message);
|
57
|
-
});
|
58
|
-
|
59
|
-
it('Find Step from Filter clause', () => {
|
60
|
-
const i = Integration.createNew("test")
|
61
|
-
const log1 = new LogDefinition({logName: 'log11', message: "hello11"});
|
62
|
-
const log2 = new LogDefinition({logName: 'log11', message: "hello22"});
|
63
|
-
const log3 = new LogDefinition({logName: 'log11', message: "hello33"});
|
64
|
-
const filter = new FilterDefinition({
|
65
|
-
expression: new ExpressionDefinition({simple: new SimpleExpression({expression: '$[body} != null'})}),
|
66
|
-
steps: [log1, log2, log3]
|
67
|
-
})
|
68
|
-
const from1 = new FromDefinition({uri: "direct1"});
|
69
|
-
from1.steps?.push(filter);
|
70
|
-
i.spec.flows?.push(new RouteDefinition({from: from1}));
|
71
|
-
|
72
|
-
|
73
|
-
const log: LogDefinition = <LogDefinition> CamelDefinitionApiExt.findElementInIntegration(i, log2.uuid);
|
74
|
-
expect(log.logName).to.equal(log2.logName);
|
75
|
-
expect(log.message).to.equal(log2.message);
|
76
|
-
});
|
77
|
-
|
78
|
-
it('Find Step from Try-Catch-Finally clause', () => {
|
79
|
-
const log1 = new LogDefinition({message: "hello1"});
|
80
|
-
const log2 = new LogDefinition({message: "hello2"});
|
81
|
-
const log3 = new LogDefinition({message: "hello3"});
|
82
|
-
const catch1 = new CatchDefinition({exception:['IOException'], steps: [log1, log2, log3]})
|
83
|
-
const log4 = new LogDefinition({message: "hello4"});
|
84
|
-
const log5 = new LogDefinition({message: "hello5"});
|
85
|
-
const log6 = new LogDefinition({message: "hello6"});
|
86
|
-
const catch2 = new CatchDefinition({exception:['NullPointerException'], steps: [log4, log5, log6]})
|
87
|
-
const log7 = new LogDefinition({message: "hello7"});
|
88
|
-
const log8 = new LogDefinition({message: "hello8"});
|
89
|
-
const log9 = new LogDefinition({message: "hello9"});
|
90
|
-
const try1 = new TryDefinition({ doCatch:[catch1, catch2], steps: [log7, log8, log9]})
|
91
|
-
const from = new FromDefinition({uri: "direct1", steps:[try1]});
|
92
|
-
const i = Integration.createNew("test")
|
93
|
-
i.spec.flows?.push(new RouteDefinition({from: from}));
|
94
|
-
|
95
|
-
const log: LogDefinition = <LogDefinition> CamelDefinitionApiExt.findElementInIntegration(i, log2.uuid);
|
96
|
-
expect(log.logName).to.equal(log2.logName);
|
97
|
-
expect(log.message).to.equal(log2.message);
|
98
|
-
});
|
99
|
-
|
100
|
-
it('Find Steps in YAML by Id', () => {
|
101
|
-
const yaml = fs.readFileSync('test/findStep.yaml',{encoding:'utf8', flag:'r'});
|
102
|
-
const i = CamelDefinitionYaml.yamlToIntegration("demo.yaml", yaml);
|
103
|
-
const yaml2 = CamelDefinitionYaml.integrationToYaml(i);
|
104
|
-
expect(yaml.replaceAll("\r\n", "\n")).to.equal(yaml2); // replace for Windows compatibility
|
105
|
-
|
106
|
-
const res1 = CamelDefinitionApiExt.hasElementWithId(i, 'to-6a8b');
|
107
|
-
const res2 = CamelDefinitionApiExt.hasElementWithId(i, 'to-6a81');
|
108
|
-
|
109
|
-
expect(res1).to.equal(1);
|
110
|
-
expect(res2).to.equal(0);
|
111
|
-
});
|
112
|
-
});
|
package/test/findStep.yaml
DELETED
@@ -1,65 +0,0 @@
|
|
1
|
-
- restConfiguration: {}
|
2
|
-
- rest:
|
3
|
-
id: rest-6cff
|
4
|
-
get:
|
5
|
-
- id: get-ea54
|
6
|
-
- route:
|
7
|
-
id: route-66bd
|
8
|
-
from:
|
9
|
-
id: from-6c72
|
10
|
-
uri: kamelet:timer-source
|
11
|
-
parameters:
|
12
|
-
period: 2000
|
13
|
-
message: Hello World
|
14
|
-
steps:
|
15
|
-
- step:
|
16
|
-
id: step-6889
|
17
|
-
steps:
|
18
|
-
- choice:
|
19
|
-
id: choice-5cca
|
20
|
-
- log:
|
21
|
-
id: log-7d33
|
22
|
-
- log:
|
23
|
-
id: log-0023
|
24
|
-
message: ${body}
|
25
|
-
- aggregate:
|
26
|
-
id: aggregate-6615
|
27
|
-
- choice:
|
28
|
-
id: choice-9b86
|
29
|
-
when:
|
30
|
-
- id: when-2521
|
31
|
-
expression: {}
|
32
|
-
steps:
|
33
|
-
- log:
|
34
|
-
id: log-8bc9
|
35
|
-
otherwise:
|
36
|
-
id: otherwise-4843
|
37
|
-
steps:
|
38
|
-
- to:
|
39
|
-
id: to-3d1c
|
40
|
-
uri: arangodb
|
41
|
-
- split:
|
42
|
-
id: split-fe40
|
43
|
-
expression: {}
|
44
|
-
- saga:
|
45
|
-
id: saga-0075
|
46
|
-
- to:
|
47
|
-
id: to-6a8b
|
48
|
-
uri: direct
|
49
|
-
parameters:
|
50
|
-
sObjectId: hello-world
|
51
|
-
- to:
|
52
|
-
id: to-6f22
|
53
|
-
uri: salesforce
|
54
|
-
parameters:
|
55
|
-
sObjectId: xxx
|
56
|
-
sObjectClass: Account
|
57
|
-
operationName: getSObject
|
58
|
-
- route:
|
59
|
-
id: hello-world
|
60
|
-
from:
|
61
|
-
id: from-5a9f
|
62
|
-
uri: direct
|
63
|
-
parameters:
|
64
|
-
name: hello-world
|
65
|
-
- routeConfiguration: {}
|
@@ -1,32 +0,0 @@
|
|
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 {CamelDefinitionApiExt} from "../src/core/api/CamelDefinitionApiExt";
|
20
|
-
import {PropertyMeta} from "../src/core/model/CamelMetadata";
|
21
|
-
|
22
|
-
describe('getElementProperties', () => {
|
23
|
-
|
24
|
-
it('getElementProperties 1', () => {
|
25
|
-
|
26
|
-
const p: PropertyMeta[] = CamelDefinitionApiExt.getElementProperties("FromDefinition");
|
27
|
-
expect(p.length).to.equal(5);
|
28
|
-
|
29
|
-
});
|
30
|
-
|
31
|
-
|
32
|
-
});
|
@@ -1,31 +0,0 @@
|
|
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 {CamelDefinitionApiExt} from "../src/core/api/CamelDefinitionApiExt";
|
20
|
-
import {PropertyMeta} from "../src/core/model/CamelMetadata";
|
21
|
-
|
22
|
-
describe('getElementPropertiesByName', () => {
|
23
|
-
|
24
|
-
it('getElementPropertiesByName 1', () => {
|
25
|
-
|
26
|
-
const p: PropertyMeta[] = CamelDefinitionApiExt.getElementPropertiesByName("json");
|
27
|
-
expect(p.length).to.equal(23);
|
28
|
-
});
|
29
|
-
|
30
|
-
|
31
|
-
});
|
@@ -1,40 +0,0 @@
|
|
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 {
|
20
|
-
ExpressionDefinition
|
21
|
-
} from "../src/core/model/CamelDefinition";
|
22
|
-
import {CamelDefinitionApiExt} from "../src/core/api/CamelDefinitionApiExt";
|
23
|
-
import {SimpleExpression} from "../src/core/model/CamelDefinition";
|
24
|
-
|
25
|
-
describe('Get Expression Language', () => {
|
26
|
-
|
27
|
-
it('Get Expression Language 1', () => {
|
28
|
-
const e: ExpressionDefinition = new ExpressionDefinition({
|
29
|
-
simple: new SimpleExpression({expression:"${body} == null"}
|
30
|
-
)});
|
31
|
-
|
32
|
-
const className = CamelDefinitionApiExt.getExpressionLanguageClassName(e);
|
33
|
-
const language = CamelDefinitionApiExt.getExpressionLanguageName(e);
|
34
|
-
|
35
|
-
expect(className).to.equal("SimpleExpression");
|
36
|
-
expect(language).to.equal("simple");
|
37
|
-
|
38
|
-
});
|
39
|
-
|
40
|
-
});
|