aboutsummaryrefslogtreecommitdiffstats
path: root/integration-test
diff options
context:
space:
mode:
authorLuke Gleeson <luke.gleeson@est.tech>2023-07-20 09:47:48 +0000
committerGerrit Code Review <gerrit@onap.org>2023-07-20 09:47:48 +0000
commit00113a7e3a3c9ad7ea44258097d82431320f7605 (patch)
tree3e95037dab2c43aa0af4a01548bcb75c5fcf9cf3 /integration-test
parent6a2eca2859d8b2ab88ff04663902eb7cc74b4fc1 (diff)
parentad61e283f7d981c3c8e307af871fb3a63e0cf4f9 (diff)
Merge "Persisting a list element to a parent list (ep2)"
Diffstat (limited to 'integration-test')
-rw-r--r--integration-test/src/test/groovy/org/onap/cps/integration/functional/CpsDataServiceIntegrationSpec.groovy25
-rw-r--r--integration-test/src/test/resources/data/bookstore/bookstore.yang28
-rw-r--r--integration-test/src/test/resources/data/bookstore/bookstoreData.json8
3 files changed, 59 insertions, 2 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 750deb1b36..a3f14397c2 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
@@ -43,11 +43,13 @@ class CpsDataServiceIntegrationSpec extends FunctionalSpecBase {
CpsDataService objectUnderTest
def originalCountBookstoreChildNodes
+ def originalCountBookstoreTopLevelListNodes
def now = OffsetDateTime.now()
def setup() {
objectUnderTest = cpsDataService
originalCountBookstoreChildNodes = countDataNodesInBookstore()
+ originalCountBookstoreTopLevelListNodes = countTopLevelListDataNodesInBookstore()
}
def 'Read bookstore top-level container(s) using #fetchDescendantsOption.'() {
@@ -73,9 +75,9 @@ class CpsDataServiceIntegrationSpec extends FunctionalSpecBase {
when: 'get data nodes for bookstore container'
def result = objectUnderTest.getDataNodes(FUNCTIONAL_TEST_DATASPACE_1, BOOKSTORE_ANCHOR_1, root, OMIT_DESCENDANTS)
then: 'the tree consist ouf of one data node'
- assert countDataNodesInTree(result) == 1
+ assert countDataNodesInTree(result) == 2
and: 'the top level data node has the expected attribute and value'
- assert result.leaves['bookstore-name'] == ['Easons']
+ assert result.leaves.size() == 2
where: 'the following variations of "root" are used'
root << [ '/', '' ]
}
@@ -179,6 +181,21 @@ class CpsDataServiceIntegrationSpec extends FunctionalSpecBase {
thrown(DataNodeNotFoundExceptionBatch)
}
+ def 'Add and Delete top-level list (element) data nodes with root node.'() {
+ given: 'a new (multiple-data-tree:invoice) datanodes'
+ def json = '{"multiple-data-tree:invoice": [{"ProductID": "2","ProductName": "Mango","price": "150","stock": true}]}'
+ when: 'the new list elements are saved'
+ objectUnderTest.saveListElements(FUNCTIONAL_TEST_DATASPACE_1, BOOKSTORE_ANCHOR_1 , '/', json, now)
+ then: 'they can be retrieved by their xpaths'
+ objectUnderTest.getDataNodes(FUNCTIONAL_TEST_DATASPACE_1, BOOKSTORE_ANCHOR_1 , '/invoice[@ProductID ="2"]', INCLUDE_ALL_DESCENDANTS)
+ and: 'there is one extra datanode'
+ assert originalCountBookstoreTopLevelListNodes + 1 == countTopLevelListDataNodesInBookstore()
+ when: 'the new elements are deleted'
+ objectUnderTest.deleteDataNode(FUNCTIONAL_TEST_DATASPACE_1, BOOKSTORE_ANCHOR_1 , '/invoice[@ProductID ="2"]', now)
+ then: 'the original number of datanodes is restored'
+ assert originalCountBookstoreTopLevelListNodes == countTopLevelListDataNodesInBookstore()
+ }
+
def 'Add and Delete list (element) data nodes.'() {
given: 'two new (categories) data nodes'
def json = '{"categories": [ {"code":"new1"}, {"code":"new2" } ] }'
@@ -368,4 +385,8 @@ class CpsDataServiceIntegrationSpec extends FunctionalSpecBase {
def countDataNodesInBookstore() {
return countDataNodesInTree(objectUnderTest.getDataNodes(FUNCTIONAL_TEST_DATASPACE_1, BOOKSTORE_ANCHOR_1, '/bookstore', INCLUDE_ALL_DESCENDANTS))
}
+
+ def countTopLevelListDataNodesInBookstore() {
+ return countDataNodesInTree(objectUnderTest.getDataNodes(FUNCTIONAL_TEST_DATASPACE_1, BOOKSTORE_ANCHOR_1, '/', INCLUDE_ALL_DESCENDANTS))
+ }
}
diff --git a/integration-test/src/test/resources/data/bookstore/bookstore.yang b/integration-test/src/test/resources/data/bookstore/bookstore.yang
index e592a9c5ce..ab384de1c4 100644
--- a/integration-test/src/test/resources/data/bookstore/bookstore.yang
+++ b/integration-test/src/test/resources/data/bookstore/bookstore.yang
@@ -15,6 +15,34 @@ module stores {
}
}
+ list invoice {
+ key "ProductID";
+ leaf ProductID {
+ type uint64;
+ mandatory "true";
+ description
+ "Unique product ID. Example: 001";
+ }
+ leaf ProductName {
+ type string;
+ mandatory "true";
+ description
+ "Name of the Product";
+ }
+ leaf price {
+ type uint64;
+ mandatory "true";
+ description
+ "Price of book";
+ }
+ leaf stock {
+ type boolean;
+ default "false";
+ description
+ "Book in stock or not. Example value: true";
+ }
+ }
+
container bookstore {
leaf bookstore-name {
diff --git a/integration-test/src/test/resources/data/bookstore/bookstoreData.json b/integration-test/src/test/resources/data/bookstore/bookstoreData.json
index 5d22f6d675..5f66a1d002 100644
--- a/integration-test/src/test/resources/data/bookstore/bookstoreData.json
+++ b/integration-test/src/test/resources/data/bookstore/bookstoreData.json
@@ -1,4 +1,12 @@
{
+ "multiple-data-tree:invoice": [
+ {
+ "ProductID": "1",
+ "ProductName": "Apple",
+ "price": "100",
+ "stock": false
+ }
+ ],
"bookstore": {
"bookstore-name": "Easons",
"premises": {