summaryrefslogtreecommitdiffstats
path: root/integration-test/src
diff options
context:
space:
mode:
authordanielhanrahan <daniel.hanrahan@est.tech>2023-04-05 17:11:24 +0100
committerSourabh Sourabh <sourabh.sourabh@est.tech>2023-04-12 12:15:37 +0000
commitb99ae09807a2893e0678d2209b4ee08194f95fe8 (patch)
tree964c32565e4bbfde6a83ecfe28caaab991c916ce /integration-test/src
parentbc05c93a30bf7b11707476d3c277623ee5acc729 (diff)
Migrate query tests to integration-test module #3
Issue-ID: CPS-1597 Signed-off-by: danielhanrahan <daniel.hanrahan@est.tech> Change-Id: I1d92355f272271424a7014057d251cf88eac0203
Diffstat (limited to 'integration-test/src')
-rw-r--r--integration-test/src/test/groovy/org/onap/cps/integration/functional/CpsDataServiceIntegrationSpec.groovy4
-rw-r--r--integration-test/src/test/groovy/org/onap/cps/integration/functional/CpsQueryServiceIntegrationSpec.groovy23
-rw-r--r--integration-test/src/test/resources/data/bookstore/bookstoreData.json14
3 files changed, 35 insertions, 6 deletions
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 d371368217..826035af57 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
@@ -42,8 +42,8 @@ class CpsDataServiceIntegrationSpec extends FunctionalSpecBase {
fetchDescendantsOption || expectNumberOfDataNodes
FetchDescendantsOption.OMIT_DESCENDANTS || 1
FetchDescendantsOption.DIRECT_CHILDREN_ONLY || 5
- FetchDescendantsOption.INCLUDE_ALL_DESCENDANTS || 12
- new FetchDescendantsOption(2) || 12
+ FetchDescendantsOption.INCLUDE_ALL_DESCENDANTS || 14
+ new FetchDescendantsOption(2) || 14
}
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 ce740b3e52..6197691c78 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
@@ -65,7 +65,7 @@ class CpsQueryServiceIntegrationSpec extends FunctionalSpecBase {
'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 | 12
+ 'no condition and level 2 descendants' | '/bookstore' | new FetchDescendantsOption(2) || 1 | 14
}
def 'Query for attribute by cps path with cps paths that return no data because of #scenario.'() {
@@ -96,7 +96,7 @@ class CpsQueryServiceIntegrationSpec extends FunctionalSpecBase {
when: 'a query is executed to get all books'
def result = objectUnderTest.queryDataNodes(FUNCTIONAL_TEST_DATASPACE, BOOKSTORE_ANCHOR, '//books', OMIT_DESCENDANTS)
then: 'the expected number of books are returned'
- assert result.size() == 7
+ assert result.size() == 9
}
def 'Cps Path query using descendant anywhere with #scenario.'() {
@@ -111,7 +111,7 @@ class CpsQueryServiceIntegrationSpec extends FunctionalSpecBase {
'text condition on leaf' | '//books/title[text()="Matilda"]' || ["Matilda"]
'text condition case mismatch' | '//books/title[text()="matilda"]' || []
'text condition on int leaf' | '//books/price[text()="10"]' || ["Matilda"]
- 'text condition on leaf-list' | '//books/authors[text()="Terry Pratchett"]' || ["Good Omens"]
+ 'text condition on leaf-list' | '//books/authors[text()="Terry Pratchett"]' || ["Good Omens", "The Colour of Magic", "The Light Fantastic"]
'text condition partial match' | '//books/authors[text()="Terry"]' || []
'text condition (existing) empty string' | '//books/lang[text()=""]' || ["A Book with No Language"]
'text condition on int leaf-list' | '//books/editions[text()="2000"]' || ["Matilda"]
@@ -121,6 +121,21 @@ class CpsQueryServiceIntegrationSpec extends FunctionalSpecBase {
'text condition on key containing /' | '//books/title[text()="Debian GNU/Linux"]' || ["Debian GNU/Linux"]
}
+ 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, BOOKSTORE_ANCHOR, cpsPath, OMIT_DESCENDANTS)
+ then: 'book titles from 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 || expectedBookTitles
+ 'one leaf' | '//books[@price=14]' || ['The Light Fantastic']
+ 'one text' | '//books/authors[text()="Terry Pratchett"]' || ['Good Omens', 'The Colour of Magic', 'The Light Fantastic']
+ 'more than one leaf' | '//books[@price=12 and @lang="English"]' || ['The Colour of Magic']
+ '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']
+ }
+
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)
@@ -148,7 +163,7 @@ class CpsQueryServiceIntegrationSpec extends FunctionalSpecBase {
scenario | fetchDescendantsOption || expectedNumberOfNodes
'no' | OMIT_DESCENDANTS || 1
'direct' | DIRECT_CHILDREN_ONLY || 5
- 'all' | INCLUDE_ALL_DESCENDANTS || 12
+ 'all' | INCLUDE_ALL_DESCENDANTS || 14
}
def 'Cps Path query with syntax error throws a CPS Path Exception.'() {
diff --git a/integration-test/src/test/resources/data/bookstore/bookstoreData.json b/integration-test/src/test/resources/data/bookstore/bookstoreData.json
index f9bac6012c..48cf4e4e58 100644
--- a/integration-test/src/test/resources/data/bookstore/bookstoreData.json
+++ b/integration-test/src/test/resources/data/bookstore/bookstoreData.json
@@ -47,6 +47,20 @@
"price": 13
},
{
+ "title": "The Colour of Magic",
+ "lang": "English",
+ "authors": ["Terry Pratchett"],
+ "editions": [1983],
+ "price": 12
+ },
+ {
+ "title": "The Light Fantastic",
+ "lang": "English",
+ "authors": ["Terry Pratchett"],
+ "editions": [1986],
+ "price": 14
+ },
+ {
"title": "A Book with No Language",
"lang": "",
"authors": ["Joe Bloggs"],