You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by lb...@apache.org on 2021/04/13 08:17:33 UTC

[camel-k-runtime] branch master updated: Yaml DSL: add workarounds for backward compatibility issues

This is an automated email from the ASF dual-hosted git repository.

lburgazzoli pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel-k-runtime.git


The following commit(s) were added to refs/heads/master by this push:
     new 7eb849e  Yaml DSL: add workarounds for backward compatibility issues
7eb849e is described below

commit 7eb849e627a5a10b69b2fe85e3d39eca4d3c6900
Author: Luca Burgazzoli <lb...@gmail.com>
AuthorDate: Mon Apr 12 19:01:06 2021 +0200

    Yaml DSL: add workarounds for backward compatibility issues
---
 .../yaml/YamlDeserializerEndpointAwareBase.java    | 73 ++++++++++++++++
 .../yaml/YamlSourceLoaderDeserializerResolver.java | 20 ++---
 .../SagaActionUriDefinitionDeserializer.java       | 74 ++++++++++++++++
 .../deserializers/ToDefinitionDeserializer.java    | 79 +++++++++++++++++
 .../ToDynamicDefinitionDeserializer.java           | 99 ++++++++++++++++++++++
 .../k/loader/yaml/YamlSourceLoaderTest.groovy      | 69 ++++++++++++++-
 .../src/test/resources/yaml/routes_to_dynamic.yaml | 24 ++++++
 .../resources/yaml/routes_to_dynamic_alias.yaml    | 24 ++++++
 .../yaml/routes_to_dynamic_alias_out_of_order.yaml | 24 ++++++
 .../yaml/routes_to_dynamic_out_of_order.yaml       | 24 ++++++
 .../resources/yaml/routes_to_out_of_order.yaml     | 24 ++++++
 11 files changed, 523 insertions(+), 11 deletions(-)

diff --git a/camel-k-loader-yaml/impl/src/main/java/org/apache/camel/k/loader/yaml/YamlDeserializerEndpointAwareBase.java b/camel-k-loader-yaml/impl/src/main/java/org/apache/camel/k/loader/yaml/YamlDeserializerEndpointAwareBase.java
new file mode 100644
index 0000000..644aeb8
--- /dev/null
+++ b/camel-k-loader-yaml/impl/src/main/java/org/apache/camel/k/loader/yaml/YamlDeserializerEndpointAwareBase.java
@@ -0,0 +1,73 @@
+/*
+ * 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.
+ */
+package org.apache.camel.k.loader.yaml;
+
+import java.util.Locale;
+import java.util.Map;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.dsl.yaml.common.YamlDeserializationContext;
+import org.apache.camel.dsl.yaml.common.YamlDeserializerBase;
+import org.apache.camel.util.StringHelper;
+import org.snakeyaml.engine.v2.nodes.MappingNode;
+import org.snakeyaml.engine.v2.nodes.Node;
+import org.snakeyaml.engine.v2.nodes.NodeTuple;
+import org.snakeyaml.engine.v2.nodes.ScalarNode;
+
+public abstract class YamlDeserializerEndpointAwareBase<T> extends YamlDeserializerBase<T> {
+
+    public YamlDeserializerEndpointAwareBase(Class<T> type) {
+        super(type);
+    }
+
+    /**
+     * Set properties from a YAML node to the given target.
+     *
+     * @param node   the node
+     * @param target the target object
+     */
+    protected void setProperties(T target, MappingNode node) {
+        YamlDeserializationContext dc = getDeserializationContext(node);
+
+        Map<String, Object> parameters = null;
+
+        for (NodeTuple tuple : node.getValue()) {
+            final ScalarNode key = (ScalarNode) tuple.getKeyNode();
+            final String propertyName = StringHelper.camelCaseToDash(key.getValue()).toLowerCase(Locale.US);
+            final Node val = tuple.getValueNode();
+
+            setDeserializationContext(val, dc);
+
+            switch (propertyName) {
+                case "parameters":
+                case "properties":
+                    parameters = asScalarMap(tuple.getValueNode());
+                    break;
+                default:
+                    if (!setProperty(target, propertyName, key.getValue(), val)) {
+                        handleUnknownProperty(target, propertyName, key.getValue(), val);
+                    }
+            }
+        }
+
+        if (parameters != null) {
+            setEndpointUri(dc.getCamelContext(), target, parameters);
+        }
+    }
+
+    protected abstract void setEndpointUri(CamelContext context, T target, Map<String, Object> parameters);
+}
diff --git a/camel-k-loader-yaml/impl/src/main/java/org/apache/camel/k/loader/yaml/YamlSourceLoaderDeserializerResolver.java b/camel-k-loader-yaml/impl/src/main/java/org/apache/camel/k/loader/yaml/YamlSourceLoaderDeserializerResolver.java
index 1df3d4b..7018ffe 100644
--- a/camel-k-loader-yaml/impl/src/main/java/org/apache/camel/k/loader/yaml/YamlSourceLoaderDeserializerResolver.java
+++ b/camel-k-loader-yaml/impl/src/main/java/org/apache/camel/k/loader/yaml/YamlSourceLoaderDeserializerResolver.java
@@ -17,7 +17,9 @@
 package org.apache.camel.k.loader.yaml;
 
 import org.apache.camel.dsl.yaml.common.YamlDeserializerResolver;
-import org.apache.camel.dsl.yaml.deserializers.ModelDeserializers;
+import org.apache.camel.k.loader.yaml.deserializers.SagaActionUriDefinitionDeserializer;
+import org.apache.camel.k.loader.yaml.deserializers.ToDefinitionDeserializer;
+import org.apache.camel.k.loader.yaml.deserializers.ToDynamicDefinitionDeserializer;
 import org.snakeyaml.engine.v2.api.ConstructNode;
 import org.snakeyaml.engine.v2.nodes.Node;
 
@@ -37,7 +39,13 @@ public class YamlSourceLoaderDeserializerResolver implements YamlDeserializerRes
                 return new FromDeserializer();
             case "to":
             case "org.apache.camel.model.ToDefinition":
-                return new ToDeserializer();
+                return new ToDefinitionDeserializer();
+            case "tod":
+            case "to-d":
+            case "org.apache.camel.model.ToDynamicDefinition":
+                return new ToDynamicDefinitionDeserializer();
+            case "org.apache.camel.model.SagaActionUriDefinition":
+                return new SagaActionUriDefinitionDeserializer();
             default:
                 return null;
         }
@@ -59,12 +67,4 @@ public class YamlSourceLoaderDeserializerResolver implements YamlDeserializerRes
             );
         }
     }
-    public static class ToDeserializer extends ModelDeserializers.ToDefinitionDeserializer {
-        @Override
-        public Object construct(Node node) {
-            return super.construct(
-                YamlSourceLoaderSupport.properties2parameters(node)
-            );
-        }
-    }
 }
diff --git a/camel-k-loader-yaml/impl/src/main/java/org/apache/camel/k/loader/yaml/deserializers/SagaActionUriDefinitionDeserializer.java b/camel-k-loader-yaml/impl/src/main/java/org/apache/camel/k/loader/yaml/deserializers/SagaActionUriDefinitionDeserializer.java
new file mode 100644
index 0000000..db48973
--- /dev/null
+++ b/camel-k-loader-yaml/impl/src/main/java/org/apache/camel/k/loader/yaml/deserializers/SagaActionUriDefinitionDeserializer.java
@@ -0,0 +1,74 @@
+/*
+ * 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.
+ */
+package org.apache.camel.k.loader.yaml.deserializers;
+
+import java.util.Map;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.dsl.yaml.common.YamlSupport;
+import org.apache.camel.dsl.yaml.deserializers.EndpointProducerDeserializersResolver;
+import org.apache.camel.k.loader.yaml.YamlDeserializerEndpointAwareBase;
+import org.apache.camel.model.SagaActionUriDefinition;
+import org.snakeyaml.engine.v2.nodes.Node;
+
+public class SagaActionUriDefinitionDeserializer  extends YamlDeserializerEndpointAwareBase<SagaActionUriDefinition> {
+    public SagaActionUriDefinitionDeserializer() {
+        super(SagaActionUriDefinition.class);
+    }
+
+    @Override
+    protected SagaActionUriDefinition newInstance() {
+        return new SagaActionUriDefinition();
+    }
+
+    @Override
+    protected SagaActionUriDefinition newInstance(String value) {
+        return new SagaActionUriDefinition(value);
+    }
+
+    @Override
+    protected void setEndpointUri(CamelContext camelContext, SagaActionUriDefinition target, Map<String, Object> parameters) {
+        target.setUri(YamlSupport.createEndpointUri(camelContext, target.getUri(), parameters));
+    }
+
+    @Override
+    protected boolean setProperty(SagaActionUriDefinition target, String propertyKey, String propertyName, Node node) {
+        switch(propertyKey) {
+            case "inherit-error-handler": {
+                String val = asText(node);
+                target.setInheritErrorHandler(Boolean.valueOf(val));
+                break;
+            }
+            case "uri": {
+                String val = asText(node);
+                target.setUri(val);
+                break;
+            }
+            default: {
+                String uri = EndpointProducerDeserializersResolver.resolveEndpointUri(propertyKey, node);
+                if (uri == null) {
+                    return false;
+                }
+                if (target.getUri() != null) {
+                    throw new IllegalStateException("url must not be set when using Endpoint DSL");
+                }
+                target.setUri(uri);
+            }
+        }
+        return true;
+    }
+}
diff --git a/camel-k-loader-yaml/impl/src/main/java/org/apache/camel/k/loader/yaml/deserializers/ToDefinitionDeserializer.java b/camel-k-loader-yaml/impl/src/main/java/org/apache/camel/k/loader/yaml/deserializers/ToDefinitionDeserializer.java
new file mode 100644
index 0000000..81dbbef
--- /dev/null
+++ b/camel-k-loader-yaml/impl/src/main/java/org/apache/camel/k/loader/yaml/deserializers/ToDefinitionDeserializer.java
@@ -0,0 +1,79 @@
+/*
+ * 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.
+ */
+package org.apache.camel.k.loader.yaml.deserializers;
+
+import java.util.Map;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.dsl.yaml.common.YamlSupport;
+import org.apache.camel.dsl.yaml.deserializers.EndpointProducerDeserializersResolver;
+import org.apache.camel.k.loader.yaml.YamlDeserializerEndpointAwareBase;
+import org.apache.camel.model.ToDefinition;
+import org.snakeyaml.engine.v2.nodes.Node;
+
+public class ToDefinitionDeserializer  extends YamlDeserializerEndpointAwareBase<ToDefinition> {
+    public ToDefinitionDeserializer() {
+        super(ToDefinition.class);
+    }
+
+    @Override
+    protected ToDefinition newInstance() {
+        return new ToDefinition();
+    }
+
+    @Override
+    protected ToDefinition newInstance(String value) {
+        return new ToDefinition(value);
+    }
+
+    @Override
+    protected void setEndpointUri(CamelContext camelContext, ToDefinition target, Map<String, Object> parameters) {
+        target.setUri(YamlSupport.createEndpointUri(camelContext, target.getUri(), parameters));
+    }
+
+    @Override
+    protected boolean setProperty(ToDefinition target, String propertyKey, String propertyName, Node node) {
+        switch(propertyKey) {
+            case "inherit-error-handler": {
+                String val = asText(node);
+                target.setInheritErrorHandler(Boolean.valueOf(val));
+                break;
+            }
+            case "pattern": {
+                String val = asText(node);
+                target.setPattern(val);
+                break;
+            }
+            case "uri": {
+                String val = asText(node);
+                target.setUri(val);
+                break;
+            }
+            default: {
+                String uri = EndpointProducerDeserializersResolver.resolveEndpointUri(propertyKey, node);
+                if (uri == null) {
+                    return false;
+                }
+                if (target.getUri() != null) {
+                    throw new IllegalStateException("url must not be set when using Endpoint DSL");
+                }
+                target.setUri(uri);
+            }
+        }
+        return true;
+    }
+}
diff --git a/camel-k-loader-yaml/impl/src/main/java/org/apache/camel/k/loader/yaml/deserializers/ToDynamicDefinitionDeserializer.java b/camel-k-loader-yaml/impl/src/main/java/org/apache/camel/k/loader/yaml/deserializers/ToDynamicDefinitionDeserializer.java
new file mode 100644
index 0000000..401c944
--- /dev/null
+++ b/camel-k-loader-yaml/impl/src/main/java/org/apache/camel/k/loader/yaml/deserializers/ToDynamicDefinitionDeserializer.java
@@ -0,0 +1,99 @@
+/*
+ * 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.
+ */
+package org.apache.camel.k.loader.yaml.deserializers;
+
+import java.util.Map;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.dsl.yaml.common.YamlSupport;
+import org.apache.camel.dsl.yaml.deserializers.EndpointProducerDeserializersResolver;
+import org.apache.camel.k.loader.yaml.YamlDeserializerEndpointAwareBase;
+import org.apache.camel.model.ToDynamicDefinition;
+import org.snakeyaml.engine.v2.nodes.Node;
+
+public class ToDynamicDefinitionDeserializer extends YamlDeserializerEndpointAwareBase<ToDynamicDefinition> {
+    public ToDynamicDefinitionDeserializer() {
+        super(ToDynamicDefinition.class);
+    }
+
+    @Override
+    protected ToDynamicDefinition newInstance() {
+        return new ToDynamicDefinition();
+    }
+
+    @Override
+    protected ToDynamicDefinition newInstance(String value) {
+        return new ToDynamicDefinition(value);
+    }
+
+    @Override
+    protected void setEndpointUri(CamelContext camelContext, ToDynamicDefinition target, Map<String, Object> parameters) {
+        target.setUri(YamlSupport.createEndpointUri(camelContext, target.getUri(), parameters));
+    }
+
+    @Override
+    protected boolean setProperty(ToDynamicDefinition target, String propertyKey, String propertyName, Node node) {
+        switch(propertyKey) {
+            case "allow-optimised-components": {
+                String val = asText(node);
+                target.setAllowOptimisedComponents(val);
+                break;
+            }
+            case "auto-start-components": {
+                String val = asText(node);
+                target.setAutoStartComponents(val);
+                break;
+            }
+            case "cache-size": {
+                String val = asText(node);
+                target.setCacheSize(val);
+                break;
+            }
+            case "ignore-invalid-endpoint": {
+                String val = asText(node);
+                target.setIgnoreInvalidEndpoint(val);
+                break;
+            }
+            case "inherit-error-handler": {
+                String val = asText(node);
+                target.setInheritErrorHandler(Boolean.valueOf(val));
+                break;
+            }
+            case "pattern": {
+                String val = asText(node);
+                target.setPattern(val);
+                break;
+            }
+            case "uri": {
+                String val = asText(node);
+                target.setUri(val);
+                break;
+            }
+            default: {
+                String uri = EndpointProducerDeserializersResolver.resolveEndpointUri(propertyKey, node);
+                if (uri == null) {
+                    return false;
+                }
+                if (target.getUri() != null) {
+                    throw new IllegalStateException("url must not be set when using Endpoint DSL");
+                }
+                target.setUri(uri);
+            }
+        }
+        return true;
+    }
+}
diff --git a/camel-k-loader-yaml/impl/src/test/groovy/org/apache/camel/k/loader/yaml/YamlSourceLoaderTest.groovy b/camel-k-loader-yaml/impl/src/test/groovy/org/apache/camel/k/loader/yaml/YamlSourceLoaderTest.groovy
index 0e27741..dae6386 100644
--- a/camel-k-loader-yaml/impl/src/test/groovy/org/apache/camel/k/loader/yaml/YamlSourceLoaderTest.groovy
+++ b/camel-k-loader-yaml/impl/src/test/groovy/org/apache/camel/k/loader/yaml/YamlSourceLoaderTest.groovy
@@ -20,6 +20,7 @@ import org.apache.camel.component.direct.DirectEndpoint
 import org.apache.camel.component.log.LogEndpoint
 import org.apache.camel.k.loader.yaml.support.TestRuntime
 import org.apache.camel.model.ToDefinition
+import org.apache.camel.model.ToDynamicDefinition
 import spock.lang.AutoCleanup
 import spock.lang.Specification
 
@@ -42,6 +43,73 @@ class YamlSourceLoaderTest extends Specification {
             }
     }
 
+    def "to with out of order parameters"() {
+        expect:
+            runtime.loadRoutes('classpath:yaml/routes_to_out_of_order.yaml')
+            runtime.start()
+
+            with(runtime.context.routeDefinitions) {
+                it[0].input.endpointUri ==~ /direct:.*start/
+                it[0].outputs[0] instanceof ToDefinition
+            }
+            with(runtime.context.endpoints.find {it instanceof LogEndpoint}, LogEndpoint) {
+                it.showAll
+                it.multiline
+            }
+    }
+
+    def "to dynamic with parameters"() {
+        expect:
+            runtime.loadRoutes('classpath:yaml/routes_to_dynamic.yaml')
+            runtime.start()
+
+            with(runtime.context.routeDefinitions) {
+                it[0].input.endpointUri ==~ /direct:.*start/
+                with (it[0].outputs[0], ToDynamicDefinition) {
+                    it.uri == 'log:info?multiline=true&showAll=true'
+                }
+            }
+    }
+
+    def "to dynamic with out of order parameters"() {
+        expect:
+            runtime.loadRoutes('classpath:yaml/routes_to_dynamic_out_of_order.yaml')
+            runtime.start()
+
+            with(runtime.context.routeDefinitions) {
+                it[0].input.endpointUri ==~ /direct:.*start/
+                with (it[0].outputs[0], ToDynamicDefinition) {
+                    it.uri == 'log:info?multiline=true&showAll=true'
+                }
+            }
+    }
+
+    def "to dynamic alias with parameters"() {
+        expect:
+            runtime.loadRoutes('classpath:yaml/routes_to_dynamic_alias.yaml')
+            runtime.start()
+
+            with(runtime.context.routeDefinitions) {
+                it[0].input.endpointUri ==~ /direct:.*start/
+                with (it[0].outputs[0], ToDynamicDefinition) {
+                    it.uri == 'log:info?multiline=true&showAll=true'
+                }
+            }
+    }
+
+    def "to dynamic alias with out of order parameters"() {
+        expect:
+            runtime.loadRoutes('classpath:yaml/routes_to_dynamic_alias_out_of_order.yaml')
+            runtime.start()
+
+            with(runtime.context.routeDefinitions) {
+                it[0].input.endpointUri ==~ /direct:.*start/
+                with (it[0].outputs[0], ToDynamicDefinition) {
+                    it.uri == 'log:info?multiline=true&showAll=true'
+                }
+            }
+    }
+
     def "from with parameters"() {
         expect:
             runtime.loadRoutes('classpath:yaml/routes_from.yaml')
@@ -70,7 +138,6 @@ class YamlSourceLoaderTest extends Specification {
             }
     }
 
-
     def "all"() {
         expect:
             runtime.loadRoutes('classpath:yaml/routes_all.yaml')
diff --git a/camel-k-loader-yaml/impl/src/test/resources/yaml/routes_to_dynamic.yaml b/camel-k-loader-yaml/impl/src/test/resources/yaml/routes_to_dynamic.yaml
new file mode 100644
index 0000000..3f6bea6
--- /dev/null
+++ b/camel-k-loader-yaml/impl/src/test/resources/yaml/routes_to_dynamic.yaml
@@ -0,0 +1,24 @@
+#
+# 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.
+#
+- from:
+    uri: "direct:start"
+    steps:
+      - to-d:
+          uri: "log:info"
+          parameters:
+            show-all: true
+            multiline: true
\ No newline at end of file
diff --git a/camel-k-loader-yaml/impl/src/test/resources/yaml/routes_to_dynamic_alias.yaml b/camel-k-loader-yaml/impl/src/test/resources/yaml/routes_to_dynamic_alias.yaml
new file mode 100644
index 0000000..0ef99c8
--- /dev/null
+++ b/camel-k-loader-yaml/impl/src/test/resources/yaml/routes_to_dynamic_alias.yaml
@@ -0,0 +1,24 @@
+#
+# 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.
+#
+- from:
+    uri: "direct:start"
+    steps:
+      - tod:
+          uri: "log:info"
+          parameters:
+            show-all: true
+            multiline: true
\ No newline at end of file
diff --git a/camel-k-loader-yaml/impl/src/test/resources/yaml/routes_to_dynamic_alias_out_of_order.yaml b/camel-k-loader-yaml/impl/src/test/resources/yaml/routes_to_dynamic_alias_out_of_order.yaml
new file mode 100644
index 0000000..c93c315
--- /dev/null
+++ b/camel-k-loader-yaml/impl/src/test/resources/yaml/routes_to_dynamic_alias_out_of_order.yaml
@@ -0,0 +1,24 @@
+#
+# 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.
+#
+- from:
+    uri: "direct:start"
+    steps:
+      - tod:
+          parameters:
+            show-all: true
+            multiline: true
+          uri: "log:info"
\ No newline at end of file
diff --git a/camel-k-loader-yaml/impl/src/test/resources/yaml/routes_to_dynamic_out_of_order.yaml b/camel-k-loader-yaml/impl/src/test/resources/yaml/routes_to_dynamic_out_of_order.yaml
new file mode 100644
index 0000000..9eedcfd
--- /dev/null
+++ b/camel-k-loader-yaml/impl/src/test/resources/yaml/routes_to_dynamic_out_of_order.yaml
@@ -0,0 +1,24 @@
+#
+# 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.
+#
+- from:
+    uri: "direct:start"
+    steps:
+      - to-d:
+          parameters:
+            show-all: true
+            multiline: true
+          uri: "log:info"
\ No newline at end of file
diff --git a/camel-k-loader-yaml/impl/src/test/resources/yaml/routes_to_out_of_order.yaml b/camel-k-loader-yaml/impl/src/test/resources/yaml/routes_to_out_of_order.yaml
new file mode 100644
index 0000000..5193868
--- /dev/null
+++ b/camel-k-loader-yaml/impl/src/test/resources/yaml/routes_to_out_of_order.yaml
@@ -0,0 +1,24 @@
+#
+# 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.
+#
+- from:
+    uri: "direct:start"
+    steps:
+      - to:
+          parameters:
+            show-all: true
+            multiline: true
+          uri: "log:info"
\ No newline at end of file