diff options
author | 2024-11-21 18:05:05 +0000 | |
---|---|---|
committer | 2024-11-25 18:00:28 +0000 | |
commit | 1ea72e9c1dff6b1fcdd584362d1d2aaa1d9ce28d (patch) | |
tree | 983642f2ca867971f2c4c168ef31bc2635752cc7 /cps-path-parser/src/test/groovy | |
parent | 295495b3f4376f42c5788e89725aef0466a8a578 (diff) |
[Cps Path Parser] Don't quote numbers in comparison
Presently, Cps Path Parser will wrap numbers in quotes when
normalizing or getting parent path, which can lead to invalid paths.
For example:
/books[@price > 15]
will be normalized to:
/books[@price>'15']
This causes trouble when running queries on normalized paths:
(CpsPathException: "can use only > with integer")
Note this patch will still normalize numbers to string for equality:
/books[@price='15']
Much existing code relies on this, and it does not cause problems.
Issue-ID: CPS-2365
Signed-off-by: danielhanrahan <daniel.hanrahan@est.tech>
Change-Id: I15d326ad7db2311b64c636283a4d52623a125176
Diffstat (limited to 'cps-path-parser/src/test/groovy')
-rw-r--r-- | cps-path-parser/src/test/groovy/org/onap/cps/cpspath/parser/CpsPathQuerySpec.groovy | 8 |
1 files changed, 4 insertions, 4 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 16430d2fa5..a1bf28977a 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 @@ -87,10 +87,10 @@ class CpsPathQuerySpec extends Specification { 'yang container' | '/cps-path' || '/cps-path' 'descendant anywhere' | '//cps-path' || '//cps-path' 'descendant with leaf condition' | '//cps-path[@key=1]' || "//cps-path[@key='1']" - 'descendant with leaf condition has ">" operator' | '//cps-path[@key>9]' || "//cps-path[@key>'9']" - 'descendant with leaf condition has "<" operator' | '//cps-path[@key<10]' || "//cps-path[@key<'10']" - 'descendant with leaf condition has ">=" operator' | '//cps-path[@key>=8]' || "//cps-path[@key>='8']" - 'descendant with leaf condition has "<=" operator' | '//cps-path[@key<=12]' || "//cps-path[@key<='12']" + 'descendant with leaf condition has ">" operator' | '//cps-path[@key>9]' || "//cps-path[@key>9]" + 'descendant with leaf condition has "<" operator' | '//cps-path[@key<10]' || "//cps-path[@key<10]" + 'descendant with leaf condition has ">=" operator' | '//cps-path[@key>=8]' || "//cps-path[@key>=8]" + 'descendant with leaf condition has "<=" operator' | '//cps-path[@key<=12]' || "//cps-path[@key<=12]" 'descendant with leaf value and ancestor' | '//cps-path[@key=1]/ancestor::parent[@key=1]' || "//cps-path[@key='1']/ancestor::parent[@key='1']" 'parent & child' | '/parent/child' || '/parent/child' 'parent leaf of type Integer & child' | '/parent/child[@code=1]/child2' || "/parent/child[@code='1']/child2" |