diff options
author | Rudrangi Anupriya <ra00745022@techmahindra.com> | 2023-07-17 20:20:34 +0530 |
---|---|---|
committer | Lee Anjella Macabuhay <lee.anjella.macabuhay@est.tech> | 2023-07-18 08:42:26 +0000 |
commit | ad61e283f7d981c3c8e307af871fb3a63e0cf4f9 (patch) | |
tree | 1c7670de106a9f157ec0456df8b7c0a1ef43e328 /integration-test/src/test/groovy | |
parent | dcf84ad73f0301ef41049e692b9963f6dcac3661 (diff) |
Persisting a list element to a parent list (ep2)
Post List Element does not allow for create List Element, only appends onto existing node as children
-Add a check in saveListElements to see if the parent xpath is a root path ("/").If root node store list element as top node. Else add passed list element to parent xpath node.
-Add test for scenario for above
-Add test scenario Saving list element data fragment under Root node
-Add Integration Tests Add and Delete top-level list (element) data nodes with root node
-Update bookstore model with TopLevelList datanode
Issue-ID: CPS-1586
Change-Id: Iaa7f59fbeebb03703626132c6d5c2afde0e7ab4b
Signed-off-by: Rudrangi Anupriya <ra00745022@techmahindra.com>
Diffstat (limited to 'integration-test/src/test/groovy')
-rw-r--r-- | integration-test/src/test/groovy/org/onap/cps/integration/functional/CpsDataServiceIntegrationSpec.groovy | 25 |
1 files changed, 23 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 351f3106fb..3651327791 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)) + } } |