summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuke Gleeson <luke.gleeson@est.tech>2023-06-06 08:45:35 +0000
committerGerrit Code Review <gerrit@onap.org>2023-06-06 08:45:35 +0000
commit6da07ba45c3eaae70fcb124e598445cb9fa3a30a (patch)
tree3eef5998ba9a926b48920508687a9f7fdd609953
parent900261c1935dba87179d2e4aa36cede4826186ca (diff)
parentb622c58e41c5f6670c455838c9c19e618c8e3ce0 (diff)
Merge "<,> operators document"
-rw-r--r--docs/cps-path.rst5
-rw-r--r--integration-test/src/test/groovy/org/onap/cps/integration/functional/CpsQueryServiceIntegrationSpec.groovy2
2 files changed, 5 insertions, 2 deletions
diff --git a/docs/cps-path.rst b/docs/cps-path.rst
index 08892e09ec..bb482c2ed0 100644
--- a/docs/cps-path.rst
+++ b/docs/cps-path.rst
@@ -223,7 +223,7 @@ descendant-path
leaf-conditions
---------------
-**Syntax**: ``<xpath> '[' @<leaf-name1> '=' <leaf-value1> ( ' <and|or> ' @<leaf-name> '=' <leaf-value> )* ']'``
+**Syntax**: ``<xpath> '[' @<leaf-name1> '(=|>|<|>=|<=)' <leaf-value1> ( ' <and|or> ' @<leaf-name> '(=|>|<|>=|<=)' <leaf-value> )* ']'``
- ``xpath``: Absolute or descendant or xpath to the (list) node which elements will be queried.
- ``leaf-name``: The name of the leaf which value needs to be compared.
- ``leaf-value``: The required value of the leaf.
@@ -234,6 +234,8 @@ leaf-conditions
- ``//categories[@name='Kids']``
- ``//categories[@code='1']/books/book[@title='Dune' and @price=5]``
- ``//categories[@code='1']/books/book[@title='xyz' or @price=15]``
+ - ``//categories[@code='1']/books/book[@title='xyz' or @price>20]``
+ - ``//categories[@code='1']/books/book[@title='Dune' and @price<=5]``
- ``//categories[@code=1]``
**Limitations**
- Only the last list or container can be queried leaf values. Any ancestor list will have to be referenced by its key name-value pair(s).
@@ -242,6 +244,7 @@ leaf-conditions
- Leaf names are not validated so ``or`` operations with invalid leaf names will silently be ignored.
- Only leaves can be used, leaf-list are not supported.
- Only string and integer values are supported, boolean and float values are not supported.
+ - Using comparative operators with string values will lead to an error at runtime. This error can't be validated earlier as the datatype is unknown until the execution phase.
- The key should be supplied with correct data type for it to be queried from DB. In the last example above the attribute code is of type
Integer so the cps query will not work if the value is passed as string.
eg: ``//categories[@code="1"]`` or ``//categories[@code='1']`` will not work because the key attribute code is treated a string.
diff --git a/integration-test/src/test/groovy/org/onap/cps/integration/functional/CpsQueryServiceIntegrationSpec.groovy b/integration-test/src/test/groovy/org/onap/cps/integration/functional/CpsQueryServiceIntegrationSpec.groovy
index 233c58fb6e..fa0b820459 100644
--- a/integration-test/src/test/groovy/org/onap/cps/integration/functional/CpsQueryServiceIntegrationSpec.groovy
+++ b/integration-test/src/test/groovy/org/onap/cps/integration/functional/CpsQueryServiceIntegrationSpec.groovy
@@ -251,7 +251,7 @@ class CpsQueryServiceIntegrationSpec extends FunctionalSpecBase {
'all' | INCLUDE_ALL_DESCENDANTS || 17
}
- def 'Cps Path query with syntax error throws a CPS Path Exception.'() {
+ def 'Cps Path query with #scenario throws a CPS Path Exception.'() {
when: 'trying to execute a query with a syntax (parsing) error'
objectUnderTest.queryDataNodes(FUNCTIONAL_TEST_DATASPACE_1, BOOKSTORE_ANCHOR_1, cpsPath, OMIT_DESCENDANTS)
then: 'a cps path exception is thrown'