diff options
author | Rudrangi Anupriya <ra00745022@techmahindra.com> | 2023-04-17 14:19:46 +0530 |
---|---|---|
committer | Rudrangi Anupriya <ra00745022@techmahindra.com> | 2023-04-21 13:44:18 +0530 |
commit | d7bc158cd274b3d6cd01bcad86aef258e6880c1c (patch) | |
tree | c94fa03528b6ed4fbb2672267482542dd59f7b73 /integration-test | |
parent | c4621cbcb1f9aad97ba3389468546444d1e9f3dc (diff) |
Add contains condition support to cps-path
Issue-ID: CPS-1272
Change-Id: Ic81d1322cacc64a8752916324b801d02be47d34f
Signed-off-by: Rudrangi Anupriya <ra00745022@techmahindra.com>
Diffstat (limited to 'integration-test')
-rw-r--r-- | integration-test/src/test/groovy/org/onap/cps/integration/functional/CpsQueryServiceIntegrationSpec.groovy | 18 |
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.'() { |