From d7bc158cd274b3d6cd01bcad86aef258e6880c1c Mon Sep 17 00:00:00 2001 From: Rudrangi Anupriya Date: Mon, 17 Apr 2023 14:19:46 +0530 Subject: Add contains condition support to cps-path Issue-ID: CPS-1272 Change-Id: Ic81d1322cacc64a8752916324b801d02be47d34f Signed-off-by: Rudrangi Anupriya --- .../functional/CpsQueryServiceIntegrationSpec.groovy | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'integration-test/src/test/groovy') 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.'() { -- cgit 1.2.3-korg