X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=integration-test%2Fsrc%2Ftest%2Fgroovy%2Forg%2Fonap%2Fcps%2Fintegration%2Ffunctional%2FCpsDataServiceIntegrationSpec.groovy;h=475d3d2fdb46dfc265a2ada96f4d06491b1cd83d;hb=478c5dac54ed508f0ce97e18e91aac7b821d814f;hp=ebaf9093cbca28f7b577180dd133fb69cba25f16;hpb=f248b5d9b794d5bdff59145406e0398d6fdcafa4;p=cps.git 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 ebaf9093c..475d3d2fd 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 @@ -113,23 +113,49 @@ class CpsDataServiceIntegrationSpec extends FunctionalSpecBase { restoreBookstoreDataAnchor(1) } + def 'Get whole list data' () { + def xpathForWholeList = "/bookstore/categories" + when: 'get data nodes for bookstore container' + def dataNodes = objectUnderTest.getDataNodes(FUNCTIONAL_TEST_DATASPACE_1, BOOKSTORE_ANCHOR_1, xpathForWholeList, FetchDescendantsOption.INCLUDE_ALL_DESCENDANTS) + then: 'the tree consist ouf of #expectNumberOfDataNodes data nodes' + assert dataNodes.size() == 5 + and: 'each datanode contains the list node xpath partially in its xpath' + dataNodes.each {dataNode -> + assert dataNode.xpath.contains(xpathForWholeList) + } + } + + def 'Read (multiple) data nodes with #scenario' () { + when: 'attempt to get data nodes using multiple valid xpaths' + def dataNodes = objectUnderTest.getDataNodesForMultipleXpaths(FUNCTIONAL_TEST_DATASPACE_1, BOOKSTORE_ANCHOR_1, xpath, OMIT_DESCENDANTS) + then: 'expected numer of data nodes are returned' + dataNodes.size() == expectedNumberOfDataNodes + where: 'the following data was used' + scenario | xpath | expectedNumberOfDataNodes + 'container-node xpath' | ['/bookstore'] | 1 + 'list-item' | ['/bookstore/categories[@code=1]'] | 1 + 'parent-list xpath' | ['/bookstore/categories'] | 5 + 'child-list xpath' | ['/bookstore/categories[@code=1]/books'] | 2 + 'both parent and child list xpath' | ['/bookstore/categories', '/bookstore/categories[@code=1]/books'] | 7 + } + def 'Add and Delete a (container) data node using #scenario.'() { - when: 'the new datanode is saved' - objectUnderTest.saveData(FUNCTIONAL_TEST_DATASPACE_1, BOOKSTORE_ANCHOR_1 , parentXpath, json, now) - then: 'it can be retrieved by its normalized xpath' - def result = objectUnderTest.getDataNodes(FUNCTIONAL_TEST_DATASPACE_1, BOOKSTORE_ANCHOR_1, normalizedXpathToNode, DIRECT_CHILDREN_ONLY) - assert result.size() == 1 - assert result[0].xpath == normalizedXpathToNode - and: 'there is now one extra datanode' - assert originalCountBookstoreChildNodes + 1 == countDataNodesInBookstore() - when: 'the new datanode is deleted' - objectUnderTest.deleteDataNode(FUNCTIONAL_TEST_DATASPACE_1, BOOKSTORE_ANCHOR_1, normalizedXpathToNode, now) - then: 'the original number of data nodes is restored' - assert originalCountBookstoreChildNodes == countDataNodesInBookstore() - where: - scenario | parentXpath | json || normalizedXpathToNode - 'normalized parent xpath' | '/bookstore' | '{"webinfo": {"domain-name":"ourbookstore.com", "contact-email":"info@ourbookstore.com" }}' || "/bookstore/webinfo" - 'non-normalized parent xpath' | '/bookstore/categories[ @code="1"]' | '{"books": {"title":"new" }}' || "/bookstore/categories[@code='1']/books[@title='new']" + when: 'the new datanode is saved' + objectUnderTest.saveData(FUNCTIONAL_TEST_DATASPACE_1, BOOKSTORE_ANCHOR_1 , parentXpath, json, now) + then: 'it can be retrieved by its normalized xpath' + def result = objectUnderTest.getDataNodes(FUNCTIONAL_TEST_DATASPACE_1, BOOKSTORE_ANCHOR_1, normalizedXpathToNode, DIRECT_CHILDREN_ONLY) + assert result.size() == 1 + assert result[0].xpath == normalizedXpathToNode + and: 'there is now one extra datanode' + assert originalCountBookstoreChildNodes + 1 == countDataNodesInBookstore() + when: 'the new datanode is deleted' + objectUnderTest.deleteDataNode(FUNCTIONAL_TEST_DATASPACE_1, BOOKSTORE_ANCHOR_1, normalizedXpathToNode, now) + then: 'the original number of data nodes is restored' + assert originalCountBookstoreChildNodes == countDataNodesInBookstore() + where: + scenario | parentXpath | json || normalizedXpathToNode + 'normalized parent xpath' | '/bookstore' | '{"webinfo": {"domain-name":"ourbookstore.com", "contact-email":"info@ourbookstore.com" }}' || "/bookstore/webinfo" + 'non-normalized parent xpath' | '/bookstore/categories[ @code="1"]' | '{"books": {"title":"new" }}' || "/bookstore/categories[@code='1']/books[@title='new']" } def 'Attempt to create a top level data node using root.'() { @@ -183,15 +209,15 @@ class CpsDataServiceIntegrationSpec extends FunctionalSpecBase { 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}]}' + def json = '{"bookstore-address":[{"bookstore-name":"Scholastic","address":"Bangalore,India","postal-code":"560043"}]}' 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) + objectUnderTest.getDataNodes(FUNCTIONAL_TEST_DATASPACE_1, BOOKSTORE_ANCHOR_1 , '/bookstore-address[@bookstore-name="Easons"]', 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) + objectUnderTest.deleteDataNode(FUNCTIONAL_TEST_DATASPACE_1, BOOKSTORE_ANCHOR_1 , '/bookstore-address[@bookstore-name="Easons"]', now) then: 'the original number of datanodes is restored' assert originalCountBookstoreTopLevelListNodes == countTopLevelListDataNodesInBookstore() }