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

davsclaus pushed a commit to branch worktree-snazzy-petting-map
in repository https://gitbox.apache.org/repos/asf/camel.git

commit e53f2dd3fba159cd127dc7b8d7af1e3b05ccf7c2
Author: Claus Ibsen <[email protected]>
AuthorDate: Sat Jul 11 10:36:24 2026 +0200

    CAMEL-23981: camel-yaml-dsl - Add unit tests for YAML DSL bug fixes
    
    Tests added:
    - ErrorHandlerTest: springTransactionErrorHandler creates correct 
definition type (CAMEL-23981)
    - RoutesTest: from note property is parsed correctly (CAMEL-23987)
    - NodeAtTest: nodeAt() handles leading slash, multi-level paths, and 
missing segments (CAMEL-23989)
    
    Co-Authored-By: Claude Opus 4.6 <[email protected]>
    Signed-off-by: Claus Ibsen <[email protected]>
---
 .../apache/camel/dsl/yaml/common/NodeAtTest.groovy | 107 +++++++++++++++++++++
 .../apache/camel/dsl/yaml/ErrorHandlerTest.groovy  |  16 +++
 .../org/apache/camel/dsl/yaml/RoutesTest.groovy    |  26 +++++
 3 files changed, 149 insertions(+)

diff --git 
a/dsl/camel-yaml-dsl/camel-yaml-dsl-common/src/test/groovy/org/apache/camel/dsl/yaml/common/NodeAtTest.groovy
 
b/dsl/camel-yaml-dsl/camel-yaml-dsl-common/src/test/groovy/org/apache/camel/dsl/yaml/common/NodeAtTest.groovy
new file mode 100644
index 000000000000..9df80f30ca8a
--- /dev/null
+++ 
b/dsl/camel-yaml-dsl/camel-yaml-dsl-common/src/test/groovy/org/apache/camel/dsl/yaml/common/NodeAtTest.groovy
@@ -0,0 +1,107 @@
+/*
+ * 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.dsl.yaml.common
+
+import org.snakeyaml.engine.v2.common.FlowStyle
+import org.snakeyaml.engine.v2.common.ScalarStyle
+import org.snakeyaml.engine.v2.nodes.MappingNode
+import org.snakeyaml.engine.v2.nodes.NodeTuple
+import org.snakeyaml.engine.v2.nodes.ScalarNode
+import org.snakeyaml.engine.v2.nodes.Tag
+import spock.lang.Specification
+
+class NodeAtTest extends Specification {
+
+    private static ScalarNode scalar(String value) {
+        return new ScalarNode(Tag.STR, value, ScalarStyle.PLAIN)
+    }
+
+    private static MappingNode mapping(Map<String, Object> entries) {
+        def tuples = entries.collect { k, v ->
+            def valNode = v instanceof Map ? mapping(v as Map<String, Object>) 
: scalar(v.toString())
+            new NodeTuple(scalar(k), valNode)
+        }
+        return new MappingNode(Tag.MAP, tuples, FlowStyle.BLOCK)
+    }
+
+    def "nodeAt with leading slash"() {
+        given:
+            def root = mapping(foo: [bar: 'hello'])
+        when:
+            def result = YamlDeserializerSupport.nodeAt(root, "/foo/bar")
+        then:
+            result instanceof ScalarNode
+            (result as ScalarNode).value == 'hello'
+    }
+
+    def "nodeAt without leading slash"() {
+        given:
+            def root = mapping(foo: [bar: 'hello'])
+        when:
+            def result = YamlDeserializerSupport.nodeAt(root, "foo/bar")
+        then:
+            result instanceof ScalarNode
+            (result as ScalarNode).value == 'hello'
+    }
+
+    def "nodeAt single segment"() {
+        given:
+            def root = mapping(foo: 'hello')
+        when:
+            def result = YamlDeserializerSupport.nodeAt(root, "/foo")
+        then:
+            result instanceof ScalarNode
+            (result as ScalarNode).value == 'hello'
+    }
+
+    def "nodeAt returns null for missing path"() {
+        given:
+            def root = mapping(foo: [bar: 'hello'])
+        when:
+            def result = YamlDeserializerSupport.nodeAt(root, "/foo/missing")
+        then:
+            result == null
+    }
+
+    def "nodeAt with empty pointer returns root"() {
+        given:
+            def root = mapping(foo: 'hello')
+        when:
+            def result = YamlDeserializerSupport.nodeAt(root, "")
+        then:
+            result == root
+    }
+
+    def "nodeAt three levels deep"() {
+        given:
+            def root = mapping(a: [b: [c: 'deep']])
+        when:
+            def result = YamlDeserializerSupport.nodeAt(root, "/a/b/c")
+        then:
+            result instanceof ScalarNode
+            (result as ScalarNode).value == 'deep'
+    }
+
+    def "nodeAt stops at first missing segment"() {
+        given:
+            def root = mapping(a: [b: [c: 'deep']])
+        when:
+            def result = YamlDeserializerSupport.nodeAt(root, "/a/missing/c")
+        then:
+            result == null
+    }
+}
diff --git 
a/dsl/camel-yaml-dsl/camel-yaml-dsl/src/test/groovy/org/apache/camel/dsl/yaml/ErrorHandlerTest.groovy
 
b/dsl/camel-yaml-dsl/camel-yaml-dsl/src/test/groovy/org/apache/camel/dsl/yaml/ErrorHandlerTest.groovy
index 0cbeaddfdf54..39cdaba9fda8 100644
--- 
a/dsl/camel-yaml-dsl/camel-yaml-dsl/src/test/groovy/org/apache/camel/dsl/yaml/ErrorHandlerTest.groovy
+++ 
b/dsl/camel-yaml-dsl/camel-yaml-dsl/src/test/groovy/org/apache/camel/dsl/yaml/ErrorHandlerTest.groovy
@@ -23,6 +23,7 @@ import 
org.apache.camel.model.errorhandler.DeadLetterChannelDefinition
 import org.apache.camel.model.errorhandler.DefaultErrorHandlerDefinition
 import org.apache.camel.model.errorhandler.NoErrorHandlerDefinition
 import org.apache.camel.model.errorhandler.RefErrorHandlerDefinition
+import 
org.apache.camel.model.errorhandler.SpringTransactionErrorHandlerDefinition
 import org.junit.jupiter.api.Assertions
 
 class ErrorHandlerTest extends YamlTestSupport {
@@ -172,6 +173,21 @@ class ErrorHandlerTest extends YamlTestSupport {
         }
     }
 
+    def "errorHandler (springTransactionErrorHandler)"() {
+        setup:
+            loadRoutesNoValidate """
+                - errorHandler:
+                    springTransactionErrorHandler:
+                      transactedPolicyRef: "myTxPolicy"
+            """
+        when:
+            context.start()
+        then:
+            with(context.getCamelContextExtension().getErrorHandlerFactory(), 
SpringTransactionErrorHandlerDefinition) {
+                transactedPolicyRef == 'myTxPolicy'
+            }
+    }
+
     def "Error: duplicate errorHandler"() {
         when:
         var route = """
diff --git 
a/dsl/camel-yaml-dsl/camel-yaml-dsl/src/test/groovy/org/apache/camel/dsl/yaml/RoutesTest.groovy
 
b/dsl/camel-yaml-dsl/camel-yaml-dsl/src/test/groovy/org/apache/camel/dsl/yaml/RoutesTest.groovy
index 9811203fe2bd..eadf95a40c0c 100644
--- 
a/dsl/camel-yaml-dsl/camel-yaml-dsl/src/test/groovy/org/apache/camel/dsl/yaml/RoutesTest.groovy
+++ 
b/dsl/camel-yaml-dsl/camel-yaml-dsl/src/test/groovy/org/apache/camel/dsl/yaml/RoutesTest.groovy
@@ -365,6 +365,32 @@ class RoutesTest extends YamlTestSupport {
         }
     }
 
+    def "load from note"() {
+        when:
+        loadRoutes '''
+                - from:
+                    id: from-demo
+                    description: from something cool
+                    note: a developer note
+                    uri: "direct:info"
+                    steps:
+                      - log: "message"
+            '''
+        then:
+        context.routeDefinitions.size() == 1
+
+        with(context.routeDefinitions[0], RouteDefinition) {
+            input.id == 'from-demo'
+            input.description == 'from something cool'
+            input.note == 'a developer note'
+            input.endpointUri == 'direct:info'
+
+            with (outputs[0], LogDefinition) {
+                message == 'message'
+            }
+        }
+    }
+
     def "load route with from description"() {
         when:
         loadRoutes '''

Reply via email to