diff options
author | Rishi.Chail <rishi.chail@est.tech> | 2021-04-14 00:51:44 +0100 |
---|---|---|
committer | Rishi.Chail <rishi.chail@est.tech> | 2021-04-26 12:58:17 +0100 |
commit | 2b7d23c2ffa067732df1ecc3879d252646dad2da (patch) | |
tree | d8ef8bcb618aeb10d2917afd49af0f6d7f0d7cd6 /cps-ri/src/test/groovy | |
parent | 964fc0f1f9a19e64aa45c3f3469a8f4d5079724c (diff) |
Get Data under anchor using single root
Issue-ID: CPS-325
Signed-off-by: Rishi.Chail <rishi.chail@est.tech>
Change-Id: Id8da3d767199c5767c625b55d175ac6791dcca48
Diffstat (limited to 'cps-ri/src/test/groovy')
-rwxr-xr-x[-rw-r--r--] | cps-ri/src/test/groovy/org/onap/cps/spi/impl/CpsDataPersistenceServiceSpec.groovy | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/cps-ri/src/test/groovy/org/onap/cps/spi/impl/CpsDataPersistenceServiceSpec.groovy b/cps-ri/src/test/groovy/org/onap/cps/spi/impl/CpsDataPersistenceServiceSpec.groovy index a47bd65d02..ea6b26923a 100644..100755 --- a/cps-ri/src/test/groovy/org/onap/cps/spi/impl/CpsDataPersistenceServiceSpec.groovy +++ b/cps-ri/src/test/groovy/org/onap/cps/spi/impl/CpsDataPersistenceServiceSpec.groovy @@ -167,23 +167,30 @@ class CpsDataPersistenceServiceSpec extends CpsPersistenceSpecBase { return fragmentRepository.findByDataspaceAndAnchorAndXpath(dataspace, anchor, xpath).orElseThrow() } + @Unroll @Sql([CLEAR_DATA, SET_DATA]) def 'Get data node by xpath without descendants.'() { when: 'data node is requested' def result = objectUnderTest.getDataNode(DATASPACE_NAME, ANCHOR_FOR_DATA_NODES_WITH_LEAVES, - XPATH_DATA_NODE_WITH_LEAVES, OMIT_DESCENDANTS) + inputXPath, OMIT_DESCENDANTS) then: 'data node is returned with no descendants' assert result.getXpath() == XPATH_DATA_NODE_WITH_LEAVES and: 'expected leaves' assert result.getChildDataNodes().size() == 0 assertLeavesMaps(result.getLeaves(), expectedLeavesByXpathMap[XPATH_DATA_NODE_WITH_LEAVES]) + where: 'the following data is used' + scenario | inputXPath + 'some xpath' |'/parent-100' + 'root xpath' |'/' + 'empty xpath' |'' } + @Unroll @Sql([CLEAR_DATA, SET_DATA]) def 'Get data node by xpath with all descendants.'() { when: 'data node is requested with all descendants' def result = objectUnderTest.getDataNode(DATASPACE_NAME, ANCHOR_FOR_DATA_NODES_WITH_LEAVES, - XPATH_DATA_NODE_WITH_LEAVES, INCLUDE_ALL_DESCENDANTS) + inputXPath, INCLUDE_ALL_DESCENDANTS) def mappedResult = treeToFlatMapByXpath(new HashMap<>(), result) then: 'data node is returned with all the descendants populated' assert mappedResult.size() == 4 @@ -192,9 +199,12 @@ class CpsDataPersistenceServiceSpec extends CpsPersistenceSpecBase { assert mappedResult.get('/parent-100/child-002').getChildDataNodes().size() == 1 and: 'extracted leaves maps are matching expected' mappedResult.forEach( - (xpath, dataNode) -> - assertLeavesMaps(dataNode.getLeaves(), expectedLeavesByXpathMap[xpath]) - ) + (inputXPath, dataNode) -> assertLeavesMaps(dataNode.getLeaves(), expectedLeavesByXpathMap[inputXPath])) + where: 'the following data is used' + scenario | inputXPath + 'some xpath' |'/parent-100' + 'root xpath' |'/' + 'empty xpath' |'' } def static assertLeavesMaps(actualLeavesMap, expectedLeavesMap) { |