summaryrefslogtreecommitdiffstats
path: root/integration-test/src/test
diff options
context:
space:
mode:
authorSourabh Sourabh <sourabh.sourabh@est.tech>2023-04-12 12:14:17 +0000
committerGerrit Code Review <gerrit@onap.org>2023-04-12 12:14:17 +0000
commitbc05c93a30bf7b11707476d3c277623ee5acc729 (patch)
treee031d25a8e5b5d0162005384a578ab352ba52da3 /integration-test/src/test
parent2e4fbdf79514ecf1c6a5387d70045c498e325d8a (diff)
parent96a2f7b1d9891d40cdeeaa657ee84af0d00dcc9b (diff)
Merge "Migrate query tests to integration-test module #2"
Diffstat (limited to 'integration-test/src/test')
-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.groovy43
-rw-r--r--integration-test/src/test/resources/data/bookstore/bookstore.yang48
-rw-r--r--integration-test/src/test/resources/data/bookstore/bookstoreData.json38
-rw-r--r--integration-test/src/test/resources/data/bookstore/largeModelData.json88
5 files changed, 139 insertions, 84 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 ddf8dcf87..d37136821 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 || 4
- FetchDescendantsOption.INCLUDE_ALL_DESCENDANTS || 8
- new FetchDescendantsOption(2) || 8
+ FetchDescendantsOption.DIRECT_CHILDREN_ONLY || 5
+ FetchDescendantsOption.INCLUDE_ALL_DESCENDANTS || 12
+ new FetchDescendantsOption(2) || 12
}
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 1f3a76d6c..ce740b3e5 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
@@ -63,9 +63,9 @@ class CpsQueryServiceIntegrationSpec extends FunctionalSpecBase {
scenario | cpsPath | fetchDescendantsOption || expectedNumberOfParentNodes | expectedTotalNumberOfNodes
'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 || 3 | 3
- 'no condition and level 1 descendants' | '/bookstore' | new FetchDescendantsOption(1) || 1 | 4
- 'no condition and level 2 descendants' | '/bookstore' | new FetchDescendantsOption(2) || 1 | 8
+ '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
}
def 'Query for attribute by cps path with cps paths that return no data because of #scenario.'() {
@@ -92,6 +92,35 @@ class CpsQueryServiceIntegrationSpec extends FunctionalSpecBase {
"/bookstore/categories[@code='1']/books[@title='The Gruffalo']"]
}
+ def 'Cps Path query for all books.'() {
+ 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
+ }
+
+ def 'Cps Path query using descendant anywhere with #scenario.'() {
+ 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: '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 || expectedBookTitles
+ 'string leaf condition' | '//books[@title="Matilda"]' || ["Matilda"]
+ '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 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"]
+ 'match of leaf containing /' | '//books[@lang="N/A"]' || ["Logarithm tables"]
+ 'text condition on leaf containing /' | '//books/lang[text()="N/A"]' || ["Logarithm tables"]
+ 'match of key containing /' | '//books[@title="Debian GNU/Linux"]' || ["Debian GNU/Linux"]
+ 'text condition on key containing /' | '//books/title[text()="Debian GNU/Linux"]' || ["Debian GNU/Linux"]
+ }
+
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)
@@ -99,11 +128,11 @@ class CpsQueryServiceIntegrationSpec extends FunctionalSpecBase {
assert result.xpath.sort() == expectedXPaths.sort()
where: 'the following data is used'
scenario | cpsPath || expectedXPaths
- 'multiple list-ancestors' | '//books/ancestor::categories' || ["/bookstore/categories[@code='1']", "/bookstore/categories[@code='2']", "/bookstore/categories[@code='3']"]
+ 'multiple list-ancestors' | '//books/ancestor::categories' || ["/bookstore/categories[@code='1']", "/bookstore/categories[@code='2']", "/bookstore/categories[@code='3']", "/bookstore/categories[@code='4']"]
'one ancestor with list value' | '//books/ancestor::categories[@code="1"]' || ["/bookstore/categories[@code='1']"]
'top ancestor' | '//books/ancestor::bookstore' || ["/bookstore"]
'list with index value in the xpath prefix' | '//categories[@code="1"]/books/ancestor::bookstore' || ["/bookstore"]
- 'ancestor with parent list' | '//books/ancestor::bookstore/categories' || ["/bookstore/categories[@code='1']", "/bookstore/categories[@code='2']", "/bookstore/categories[@code='3']"]
+ 'ancestor with parent list' | '//books/ancestor::bookstore/categories' || ["/bookstore/categories[@code='1']", "/bookstore/categories[@code='2']", "/bookstore/categories[@code='3']", "/bookstore/categories[@code='4']"]
'ancestor with parent' | '//books/ancestor::bookstore/categories[@code="2"]' || ["/bookstore/categories[@code='2']"]
'ancestor combined with text condition' | '//books/title[text()="Matilda"]/ancestor::bookstore' || ["/bookstore"]
'ancestor with parent that does not exist' | '//books/ancestor::parentDoesNoExist/categories' || []
@@ -118,8 +147,8 @@ class CpsQueryServiceIntegrationSpec extends FunctionalSpecBase {
where: 'the following data is used'
scenario | fetchDescendantsOption || expectedNumberOfNodes
'no' | OMIT_DESCENDANTS || 1
- 'direct' | DIRECT_CHILDREN_ONLY || 4
- 'all' | INCLUDE_ALL_DESCENDANTS || 8
+ 'direct' | DIRECT_CHILDREN_ONLY || 5
+ 'all' | INCLUDE_ALL_DESCENDANTS || 12
}
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 2179fb93d..c3bfc50dc 100644
--- a/integration-test/src/test/resources/data/bookstore/bookstore.yang
+++ b/integration-test/src/test/resources/data/bookstore/bookstore.yang
@@ -21,37 +21,37 @@ module stores {
type string;
}
- list categories {
+ list categories {
- key "code";
+ key "code";
- leaf code {
- type string;
- }
-
- leaf name {
- type string;
- }
-
- list books {
- key title;
-
- leaf title {
+ leaf code {
type string;
}
- leaf lang {
- type string;
- }
- leaf-list authors {
+
+ leaf name {
type string;
}
- leaf pub_year {
- type year;
- }
- leaf price {
- type uint64;
+
+ list books {
+ key title;
+
+ leaf title {
+ type string;
+ }
+ leaf lang {
+ type string;
+ }
+ leaf-list authors {
+ type string;
+ }
+ leaf-list editions {
+ type year;
+ }
+ leaf price {
+ type uint64;
+ }
}
}
}
- }
}
diff --git a/integration-test/src/test/resources/data/bookstore/bookstoreData.json b/integration-test/src/test/resources/data/bookstore/bookstoreData.json
index 1c6cb88f9..f9bac6012 100644
--- a/integration-test/src/test/resources/data/bookstore/bookstoreData.json
+++ b/integration-test/src/test/resources/data/bookstore/bookstoreData.json
@@ -10,14 +10,14 @@
"title": "Matilda",
"lang": "English",
"authors": ["Roald Dahl"],
- "pub_year": 1988,
+ "editions": [1988, 2000],
"price": 10
},
{
"title": "The Gruffalo",
"lang": "English",
"authors": ["Julia Donaldson"],
- "pub_year": 1999,
+ "editions": [1999],
"price": 15
}
]
@@ -30,7 +30,7 @@
"title": "Annihilation",
"lang": "English",
"authors": ["Jeff VanderMeer"],
- "pub_year": 2014,
+ "editions": [2014],
"price": 15
}
]
@@ -43,12 +43,38 @@
"title": "Good Omens",
"lang": "English",
"authors": ["Neil Gaiman", "Terry Pratchett"],
- "pub_year": 2006,
+ "editions": [2006],
"price": 13
+ },
+ {
+ "title": "A Book with No Language",
+ "lang": "",
+ "authors": ["Joe Bloggs"],
+ "editions": [2023],
+ "price": 20
+ }
+ ]
+ },
+ {
+ "code": 4,
+ "name": "Computing",
+ "books" : [
+ {
+ "title": "Debian GNU/Linux",
+ "lang": "German",
+ "authors": ["Peter H. Ganten", "Wulf Alex"],
+ "editions": [2007, 2013, 2021],
+ "price": 39
+ },
+ {
+ "title": "Logarithm tables",
+ "lang": "N/A",
+ "authors": ["Joe Bloggs"],
+ "editions": [2009],
+ "price": 11
}
]
}
-
]
}
-} \ No newline at end of file
+}
diff --git a/integration-test/src/test/resources/data/bookstore/largeModelData.json b/integration-test/src/test/resources/data/bookstore/largeModelData.json
index bdc22a717..4a92a1da7 100644
--- a/integration-test/src/test/resources/data/bookstore/largeModelData.json
+++ b/integration-test/src/test/resources/data/bookstore/largeModelData.json
@@ -10,14 +10,14 @@
"title": "Matilda",
"lang": "English",
"authors": ["Roald Dahl"],
- "pub_year": 1988,
+ "editions": [1988, 2000],
"price": 10
},
{
"title": "The Gruffalo",
"lang": "English",
"authors": ["Julia Donaldson"],
- "pub_year": 1999,
+ "editions": [1999],
"price": 15
}
]
@@ -30,7 +30,7 @@
"title": "Annihilation",
"lang": "English",
"authors": ["Jeff VanderMeer"],
- "pub_year": 2014,
+ "editions": [2014],
"price": 15
}
]
@@ -43,7 +43,7 @@
"title": "Good Omens",
"lang": "English",
"authors": ["Neil Gaiman", "Terry Pratchett"],
- "pub_year": 2006,
+ "editions": [2006],
"price": 13
}
]
@@ -56,14 +56,14 @@
"title": "Matilda",
"lang": "English",
"authors": ["Roald Dahl"],
- "pub_year": 1988,
+ "editions": [1988, 2000],
"price": 10
},
{
"title": "The Gruffalo",
"lang": "English",
"authors": ["Julia Donaldson"],
- "pub_year": 1999,
+ "editions": [1999],
"price": 15
}
]
@@ -76,7 +76,7 @@
"title": "Annihilation",
"lang": "English",
"authors": ["Jeff VanderMeer"],
- "pub_year": 2014,
+ "editions": [2014],
"price": 15
}
]
@@ -89,7 +89,7 @@
"title": "Good Omens",
"lang": "English",
"authors": ["Neil Gaiman", "Terry Pratchett"],
- "pub_year": 2006,
+ "editions": [2006],
"price": 13
}
]
@@ -102,14 +102,14 @@
"title": "Matilda",
"lang": "English",
"authors": ["Roald Dahl"],
- "pub_year": 1988,
+ "editions": [1988, 2000],
"price": 10
},
{
"title": "The Gruffalo",
"lang": "English",
"authors": ["Julia Donaldson"],
- "pub_year": 1999,
+ "editions": [1999],
"price": 15
}
]
@@ -122,7 +122,7 @@
"title": "Annihilation",
"lang": "English",
"authors": ["Jeff VanderMeer"],
- "pub_year": 2014,
+ "editions": [2014],
"price": 15
}
]
@@ -135,7 +135,7 @@
"title": "Good Omens",
"lang": "English",
"authors": ["Neil Gaiman", "Terry Pratchett"],
- "pub_year": 2006,
+ "editions": [2006],
"price": 13
}
]
@@ -148,14 +148,14 @@
"title": "Matilda",
"lang": "English",
"authors": ["Roald Dahl"],
- "pub_year": 1988,
+ "editions": [1988, 2000],
"price": 10
},
{
"title": "The Gruffalo",
"lang": "English",
"authors": ["Julia Donaldson"],
- "pub_year": 1999,
+ "editions": [1999],
"price": 15
}
]
@@ -168,7 +168,7 @@
"title": "Annihilation",
"lang": "English",
"authors": ["Jeff VanderMeer"],
- "pub_year": 2014,
+ "editions": [2014],
"price": 15
}
]
@@ -181,7 +181,7 @@
"title": "Good Omens",
"lang": "English",
"authors": ["Neil Gaiman", "Terry Pratchett"],
- "pub_year": 2006,
+ "editions": [2006],
"price": 13
}
]
@@ -194,14 +194,14 @@
"title": "Matilda",
"lang": "English",
"authors": ["Roald Dahl"],
- "pub_year": 1988,
+ "editions": [1988, 2000],
"price": 10
},
{
"title": "The Gruffalo",
"lang": "English",
"authors": ["Julia Donaldson"],
- "pub_year": 1999,
+ "editions": [1999],
"price": 15
}
]
@@ -214,7 +214,7 @@
"title": "Annihilation",
"lang": "English",
"authors": ["Jeff VanderMeer"],
- "pub_year": 2014,
+ "editions": [2014],
"price": 15
}
]
@@ -227,7 +227,7 @@
"title": "Good Omens",
"lang": "English",
"authors": ["Neil Gaiman", "Terry Pratchett"],
- "pub_year": 2006,
+ "editions": [2006],
"price": 13
}
]
@@ -240,14 +240,14 @@
"title": "Matilda",
"lang": "English",
"authors": ["Roald Dahl"],
- "pub_year": 1988,
+ "editions": [1988, 2000],
"price": 10
},
{
"title": "The Gruffalo",
"lang": "English",
"authors": ["Julia Donaldson"],
- "pub_year": 1999,
+ "editions": [1999],
"price": 15
}
]
@@ -260,7 +260,7 @@
"title": "Annihilation",
"lang": "English",
"authors": ["Jeff VanderMeer"],
- "pub_year": 2014,
+ "editions": [2014],
"price": 15
}
]
@@ -273,7 +273,7 @@
"title": "Good Omens",
"lang": "English",
"authors": ["Neil Gaiman", "Terry Pratchett"],
- "pub_year": 2006,
+ "editions": [2006],
"price": 13
}
]
@@ -286,14 +286,14 @@
"title": "Matilda",
"lang": "English",
"authors": ["Roald Dahl"],
- "pub_year": 1988,
+ "editions": [1988, 2000],
"price": 10
},
{
"title": "The Gruffalo",
"lang": "English",
"authors": ["Julia Donaldson"],
- "pub_year": 1999,
+ "editions": [1999],
"price": 15
}
]
@@ -306,7 +306,7 @@
"title": "Annihilation",
"lang": "English",
"authors": ["Jeff VanderMeer"],
- "pub_year": 2014,
+ "editions": [2014],
"price": 15
}
]
@@ -319,7 +319,7 @@
"title": "Good Omens",
"lang": "English",
"authors": ["Neil Gaiman", "Terry Pratchett"],
- "pub_year": 2006,
+ "editions": [2006],
"price": 13
}
]
@@ -332,14 +332,14 @@
"title": "Matilda",
"lang": "English",
"authors": ["Roald Dahl"],
- "pub_year": 1988,
+ "editions": [1988, 2000],
"price": 10
},
{
"title": "The Gruffalo",
"lang": "English",
"authors": ["Julia Donaldson"],
- "pub_year": 1999,
+ "editions": [1999],
"price": 15
}
]
@@ -352,7 +352,7 @@
"title": "Annihilation",
"lang": "English",
"authors": ["Jeff VanderMeer"],
- "pub_year": 2014,
+ "editions": [2014],
"price": 15
}
]
@@ -365,7 +365,7 @@
"title": "Good Omens",
"lang": "English",
"authors": ["Neil Gaiman", "Terry Pratchett"],
- "pub_year": 2006,
+ "editions": [2006],
"price": 13
}
]
@@ -378,14 +378,14 @@
"title": "Matilda",
"lang": "English",
"authors": ["Roald Dahl"],
- "pub_year": 1988,
+ "editions": [1988, 2000],
"price": 10
},
{
"title": "The Gruffalo",
"lang": "English",
"authors": ["Julia Donaldson"],
- "pub_year": 1999,
+ "editions": [1999],
"price": 15
}
]
@@ -398,7 +398,7 @@
"title": "Annihilation",
"lang": "English",
"authors": ["Jeff VanderMeer"],
- "pub_year": 2014,
+ "editions": [2014],
"price": 15
}
]
@@ -411,7 +411,7 @@
"title": "Good Omens",
"lang": "English",
"authors": ["Neil Gaiman", "Terry Pratchett"],
- "pub_year": 2006,
+ "editions": [2006],
"price": 13
}
]
@@ -424,14 +424,14 @@
"title": "Matilda",
"lang": "English",
"authors": ["Roald Dahl"],
- "pub_year": 1988,
+ "editions": [1988, 2000],
"price": 10
},
{
"title": "The Gruffalo",
"lang": "English",
"authors": ["Julia Donaldson"],
- "pub_year": 1999,
+ "editions": [1999],
"price": 15
}
]
@@ -444,7 +444,7 @@
"title": "Annihilation",
"lang": "English",
"authors": ["Jeff VanderMeer"],
- "pub_year": 2014,
+ "editions": [2014],
"price": 15
}
]
@@ -457,7 +457,7 @@
"title": "Good Omens",
"lang": "English",
"authors": ["Neil Gaiman", "Terry Pratchett"],
- "pub_year": 2006,
+ "editions": [2006],
"price": 13
}
]
@@ -470,14 +470,14 @@
"title": "Matilda",
"lang": "English",
"authors": ["Roald Dahl"],
- "pub_year": 1988,
+ "editions": [1988, 2000],
"price": 10
},
{
"title": "The Gruffalo",
"lang": "English",
"authors": ["Julia Donaldson"],
- "pub_year": 1999,
+ "editions": [1999],
"price": 15
}
]
@@ -490,7 +490,7 @@
"title": "Annihilation",
"lang": "English",
"authors": ["Jeff VanderMeer"],
- "pub_year": 2014,
+ "editions": [2014],
"price": 15
}
]
@@ -503,7 +503,7 @@
"title": "Good Omens",
"lang": "English",
"authors": ["Neil Gaiman", "Terry Pratchett"],
- "pub_year": 2006,
+ "editions": [2006],
"price": 13
}
]