From 4760869cc48115b79830dee10c20d4466110d716 Mon Sep 17 00:00:00 2001 From: danielhanrahan Date: Tue, 11 Apr 2023 14:36:31 +0100 Subject: Migrate query tests to integration-test module #5 - Migrate query tests for composite keys to integration-test - Add addresses with composite key to bookstore model Issue-ID: CPS-1597 Signed-off-by: danielhanrahan Change-Id: I6f8dfc2c44ae6ba3bac1cce804841671ef5a009d --- .../functional/CpsDataServiceIntegrationSpec.groovy | 6 +++--- .../CpsQueryServiceIntegrationSpec.groovy | 21 +++++++++++++++++---- 2 files changed, 20 insertions(+), 7 deletions(-) (limited to 'integration-test/src/test/groovy') diff --git a/integration-test/src/test/groovy/org/onap/cps/integration/functional/CpsDataServiceIntegrationSpec.groovy b/integration-test/src/test/groovy/org/onap/cps/integration/functional/CpsDataServiceIntegrationSpec.groovy index 826035af5..25e71f18d 100644 --- a/integration-test/src/test/groovy/org/onap/cps/integration/functional/CpsDataServiceIntegrationSpec.groovy +++ b/integration-test/src/test/groovy/org/onap/cps/integration/functional/CpsDataServiceIntegrationSpec.groovy @@ -41,9 +41,9 @@ class CpsDataServiceIntegrationSpec extends FunctionalSpecBase { where: 'the following option is used' fetchDescendantsOption || expectNumberOfDataNodes FetchDescendantsOption.OMIT_DESCENDANTS || 1 - FetchDescendantsOption.DIRECT_CHILDREN_ONLY || 5 - FetchDescendantsOption.INCLUDE_ALL_DESCENDANTS || 14 - new FetchDescendantsOption(2) || 14 + FetchDescendantsOption.DIRECT_CHILDREN_ONLY || 6 + FetchDescendantsOption.INCLUDE_ALL_DESCENDANTS || 17 + new FetchDescendantsOption(2) || 17 } def 'Read bookstore top-level container(s) has correct dataspace and anchor.'() { 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 6197691c7..1a31cdde3 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 @@ -64,8 +64,8 @@ class CpsQueryServiceIntegrationSpec extends FunctionalSpecBase { 'string and no descendants' | '/bookstore/categories[@code="1"]/books[@title="Matilda"]' | OMIT_DESCENDANTS || 1 | 1 'integer and descendants' | '/bookstore/categories[@code="1"]/books[@price=15]' | INCLUDE_ALL_DESCENDANTS || 1 | 1 'no condition and no descendants' | '/bookstore/categories' | OMIT_DESCENDANTS || 4 | 4 - 'no condition and level 1 descendants' | '/bookstore' | new FetchDescendantsOption(1) || 1 | 5 - 'no condition and level 2 descendants' | '/bookstore' | new FetchDescendantsOption(2) || 1 | 14 + 'no condition and level 1 descendants' | '/bookstore' | new FetchDescendantsOption(1) || 1 | 6 + 'no condition and level 2 descendants' | '/bookstore' | new FetchDescendantsOption(2) || 1 | 17 } def 'Query for attribute by cps path with cps paths that return no data because of #scenario.'() { @@ -136,6 +136,19 @@ class CpsQueryServiceIntegrationSpec extends FunctionalSpecBase { 'leaf and text' | '//books[@price=14]/authors[text()="Terry Pratchett"]' || ['The Light Fantastic'] } + def 'Cps Path query using descendant anywhere with #scenario condition(s) for a list element.'() { + when: 'a query is executed to get a data node by the given cps path' + def result = objectUnderTest.queryDataNodes(FUNCTIONAL_TEST_DATASPACE, BOOKSTORE_ANCHOR, cpsPath, INCLUDE_ALL_DESCENDANTS) + then: 'xpaths of the retrieved data nodes are as expected' + result.xpath.toList() == ["/bookstore/premises/addresses[@house-number='2' and @street='Main Street']"] + where: 'the following data is used' + scenario | cpsPath + 'full composite key' | '//addresses[@house-number=2 and @street="Main Street"]' + 'one partial key leaf' | '//addresses[@house-number=2]' + 'one non key leaf' | '//addresses[@county="Kildare"]' + 'mix of partial key and non key leaf' | '//addresses[@street="Main Street" and @county="Kildare"]' + } + def 'Query for attribute by cps path of type ancestor with #scenario.'() { when: 'the given cps path is parsed' def result = objectUnderTest.queryDataNodes(FUNCTIONAL_TEST_DATASPACE, BOOKSTORE_ANCHOR, cpsPath, OMIT_DESCENDANTS) @@ -162,8 +175,8 @@ class CpsQueryServiceIntegrationSpec extends FunctionalSpecBase { where: 'the following data is used' scenario | fetchDescendantsOption || expectedNumberOfNodes 'no' | OMIT_DESCENDANTS || 1 - 'direct' | DIRECT_CHILDREN_ONLY || 5 - 'all' | INCLUDE_ALL_DESCENDANTS || 14 + 'direct' | DIRECT_CHILDREN_ONLY || 6 + 'all' | INCLUDE_ALL_DESCENDANTS || 17 } def 'Cps Path query with syntax error throws a CPS Path Exception.'() { -- cgit 1.2.3-korg