aboutsummaryrefslogtreecommitdiffstats
path: root/integration-test
diff options
context:
space:
mode:
authorLuke Gleeson <luke.gleeson@est.tech>2023-04-21 14:31:07 +0000
committerGerrit Code Review <gerrit@onap.org>2023-04-21 14:31:07 +0000
commitf5d8051bef715762a31f54d052f7e126e8276fd0 (patch)
treefe2b973b045f8b1414f9ae0556c09d90dee557f7 /integration-test
parentb3c3d36266493a93cb40a5d76de9fc5b80fec789 (diff)
parentd7bc158cd274b3d6cd01bcad86aef258e6880c1c (diff)
Merge "Add contains condition support to cps-path"
Diffstat (limited to 'integration-test')
-rw-r--r--integration-test/src/test/groovy/org/onap/cps/integration/functional/CpsQueryServiceIntegrationSpec.groovy18
1 files changed, 18 insertions, 0 deletions
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 bd39605de3..38bb4de573 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
@@ -147,6 +147,22 @@ class CpsQueryServiceIntegrationSpec extends FunctionalSpecBase {
'text condition on key containing /' | '//books/title[text()="Debian GNU/Linux"]' || ["Debian GNU/Linux"]
}
+ def 'Query for attribute by cps path using contains condition #scenario.'() {
+ when: 'a query is executed to get response by the given cps path'
+ def result = objectUnderTest.queryDataNodes(FUNCTIONAL_TEST_DATASPACE_1, BOOKSTORE_ANCHOR_1, cpsPath, OMIT_DESCENDANTS)
+ then: 'the cps-path of queryDataNodes has expected number of nodes'
+ assert result.size() == expectedResultsize
+ and: 'xpaths of the retrieved data nodes are as expected'
+ def bookTitles = result.collect { it.getLeaves().get('title') }
+ assert bookTitles.sort() == expectedBookTitles.sort()
+ where: 'the following data is used'
+ scenario | cpsPath | expectedResultsize || expectedBookTitles
+ 'contains condition with leaf' | '//books[contains(@title,"Mat")]' | 1 || ["Matilda"]
+ 'contains condition with case-sensitive' | '//books[contains(@title,"Ti")]' | 0 || []
+ 'contains condition with Integer Value' | '//books[contains(@price,"15")]' | 2 || ["Annihilation", "The Gruffalo"]
+ 'contains condition with No-value' | '//books[contains(@title,"")]' | 9 || ["A Book with No Language", "Annihilation", "Debian GNU/Linux", "Good Omens", "Logarithm tables", "Matilda", "The Colour of Magic", "The Gruffalo", "The Light Fantastic"]
+ }
+
def 'Cps Path query using descendant anywhere with #scenario condition for a container element.'() {
when: 'a query is executed to get a data node by the given cps path'
def result = objectUnderTest.queryDataNodes(FUNCTIONAL_TEST_DATASPACE_1, BOOKSTORE_ANCHOR_1, cpsPath, OMIT_DESCENDANTS)
@@ -164,6 +180,7 @@ class CpsQueryServiceIntegrationSpec extends FunctionalSpecBase {
'more than one leaf has multiple OR' | '//books[ @title="Matilda" or @price=15 or @edition=2006]' || ['Annihilation', 'Matilda', 'The Gruffalo']
'leaves reversed in order' | '//books[@lang="English" and @price=12]' || ['The Colour of Magic']
'leaf and text' | '//books[@price=14]/authors[text()="Terry Pratchett"]' || ['The Light Fantastic']
+ 'leaf and contains' | '//books[contains(@price,"13")]' || ['Good Omens']
}
def 'Cps Path query using descendant anywhere with #scenario condition(s) for a list element.'() {
@@ -195,6 +212,7 @@ class CpsQueryServiceIntegrationSpec extends FunctionalSpecBase {
'ancestor combined with text condition' | '//books/title[text()="Matilda"]/ancestor::bookstore' || ["/bookstore"]
'ancestor with parent that does not exist' | '//books/ancestor::parentDoesNoExist/categories' || []
'ancestor does not exist' | '//books/ancestor::ancestorDoesNotExist' || []
+ 'ancestor combined with contains condition' | '//books[contains(@title,"Mat")]/ancestor::bookstore' || ["/bookstore"]
}
def 'Query for attribute by cps path of type ancestor with #scenario descendants.'() {