aboutsummaryrefslogtreecommitdiffstats
path: root/cps-path-parser/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'cps-path-parser/src/test')
-rw-r--r--cps-path-parser/src/test/groovy/org/onap/cps/cpspath/parser/CpsPathQuerySpec.groovy19
1 files changed, 18 insertions, 1 deletions
diff --git a/cps-path-parser/src/test/groovy/org/onap/cps/cpspath/parser/CpsPathQuerySpec.groovy b/cps-path-parser/src/test/groovy/org/onap/cps/cpspath/parser/CpsPathQuerySpec.groovy
index ae7ee598ab..15f6b11823 100644
--- a/cps-path-parser/src/test/groovy/org/onap/cps/cpspath/parser/CpsPathQuerySpec.groovy
+++ b/cps-path-parser/src/test/groovy/org/onap/cps/cpspath/parser/CpsPathQuerySpec.groovy
@@ -1,6 +1,6 @@
/*
* ============LICENSE_START=======================================================
- * Copyright (C) 2021-2023 Nordix Foundation
+ * Copyright (C) 2021-2024 Nordix Foundation
* Modifications Copyright (C) 2023 TechMahindra Ltd
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -253,4 +253,21 @@ class CpsPathQuerySpec extends Specification {
'/test[@name2="value2" and @name1="value1"]' || 'name2' | 'name1'
}
+ def 'Ancestor axis matching prefix'() {
+ when: 'building a cps path query'
+ def result = parseXPathAndBuild(xpath)
+ then: 'ancestor axis is removed when same as prefix'
+ assert result.hasAncestorAxis() == expectAncestorAxis
+ where: 'the following xpaths are used'
+ xpath || expectAncestorAxis
+ '//abc/def/ancestor::abc' || true
+ '//abc/def/ancestor::def' || false
+ '//abc/def/ancestor::ef' || true
+ }
+
+ def parseXPathAndBuild(xpath) {
+ def cpsPathBuilder = CpsPathUtil.getCpsPathBuilder(xpath)
+ cpsPathBuilder.build()
+ }
+
}