summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--cps-ri/pom.xml2
-rw-r--r--cps-ri/src/test/groovy/org/onap/cps/spi/impl/CpsDataPersistenceQueryDataNodeSpec.groovy17
-rw-r--r--integration-test/src/test/groovy/org/onap/cps/integration/functional/CpsDataServiceIntegrationSpec.groovy6
-rw-r--r--integration-test/src/test/groovy/org/onap/cps/integration/functional/CpsQueryServiceIntegrationSpec.groovy21
-rw-r--r--integration-test/src/test/resources/data/bookstore/bookstore.yang19
-rw-r--r--integration-test/src/test/resources/data/bookstore/bookstoreData.json16
6 files changed, 56 insertions, 25 deletions
diff --git a/cps-ri/pom.xml b/cps-ri/pom.xml
index 3cb41303e3..6ee2d21833 100644
--- a/cps-ri/pom.xml
+++ b/cps-ri/pom.xml
@@ -33,7 +33,7 @@
<artifactId>cps-ri</artifactId>
<properties>
- <minimum-coverage>0.96</minimum-coverage>
+ <minimum-coverage>0.94</minimum-coverage>
</properties>
<dependencies>
diff --git a/cps-ri/src/test/groovy/org/onap/cps/spi/impl/CpsDataPersistenceQueryDataNodeSpec.groovy b/cps-ri/src/test/groovy/org/onap/cps/spi/impl/CpsDataPersistenceQueryDataNodeSpec.groovy
index d5a6be4e80..f025206c3f 100644
--- a/cps-ri/src/test/groovy/org/onap/cps/spi/impl/CpsDataPersistenceQueryDataNodeSpec.groovy
+++ b/cps-ri/src/test/groovy/org/onap/cps/spi/impl/CpsDataPersistenceQueryDataNodeSpec.groovy
@@ -38,23 +38,6 @@ class CpsDataPersistenceQueryDataNodeSpec extends CpsPersistenceSpecBase {
static final String SET_DATA = '/data/cps-path-query.sql'
@Sql([CLEAR_DATA, SET_DATA])
- 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(DATASPACE_NAME, ANCHOR_FOR_SHOP_EXAMPLE, cpsPath, OMIT_DESCENDANTS)
- then: 'the correct number of data nodes are retrieved'
- result.size() == expectedXPaths.size()
- and: 'xpaths of the retrieved data nodes are as expected'
- for (int i = 0; i < result.size(); i++) {
- assert result[i].getXpath() == expectedXPaths[i]
- }
- where: 'the following data is used'
- scenario | cpsPath || expectedXPaths
- 'one partial key leaf' | '//author[@FirstName="Joe"]' || ["/shops/shop[@id='1']/categories[@code='1']/book/author[@FirstName='Joe' and @Surname='Bloggs']", "/shops/shop[@id='1']/categories[@code='2']/book/author[@FirstName='Joe' and @Surname='Smith']"]
- 'one non key leaf' | '//author[@title="Dune"]' || ["/shops/shop[@id='1']/categories[@code='1']/book/author[@FirstName='Joe' and @Surname='Bloggs']"]
- 'mix of partial key and non key leaf' | '//author[@FirstName="Joe" and @title="Dune"]' || ["/shops/shop[@id='1']/categories[@code='1']/book/author[@FirstName='Joe' and @Surname='Bloggs']"]
- }
-
- @Sql([CLEAR_DATA, SET_DATA])
def 'Cps Path query across anchors for leaf value(s) with : #scenario.'() {
when: 'a query is executed to get a data node by the given cps path'
def result = objectUnderTest.queryDataNodesAcrossAnchors(DATASPACE_NAME, cpsPath, includeDescendantsOption)
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 826035af57..25e71f18d6 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 6197691c78..1a31cdde3a 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.'() {
diff --git a/integration-test/src/test/resources/data/bookstore/bookstore.yang b/integration-test/src/test/resources/data/bookstore/bookstore.yang
index c3bfc50dc1..62ebc73201 100644
--- a/integration-test/src/test/resources/data/bookstore/bookstore.yang
+++ b/integration-test/src/test/resources/data/bookstore/bookstore.yang
@@ -21,6 +21,25 @@ module stores {
type string;
}
+ container premises {
+ list addresses {
+ key "house-number street";
+
+ leaf house-number {
+ type uint16;
+ }
+ leaf street {
+ type string;
+ }
+ leaf town {
+ type string;
+ }
+ leaf county {
+ type string;
+ }
+ }
+ }
+
list categories {
key "code";
diff --git a/integration-test/src/test/resources/data/bookstore/bookstoreData.json b/integration-test/src/test/resources/data/bookstore/bookstoreData.json
index 48cf4e4e58..12df20e55b 100644
--- a/integration-test/src/test/resources/data/bookstore/bookstoreData.json
+++ b/integration-test/src/test/resources/data/bookstore/bookstoreData.json
@@ -1,6 +1,22 @@
{
"bookstore": {
"bookstore-name": "Easons",
+ "premises": {
+ "addresses": [
+ {
+ "house-number": 2,
+ "street": "Main Street",
+ "town": "Maynooth",
+ "county": "Kildare"
+ },
+ {
+ "house-number": 24,
+ "street": "Grafton Street",
+ "town": "Dublin",
+ "county": "Dublin"
+ }
+ ]
+ },
"categories": [
{
"code": 1,