diff options
author | Toine Siebelink <toine.siebelink@est.tech> | 2021-02-05 15:09:58 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2021-02-05 15:09:58 +0000 |
commit | 63804e8712d1bf9050528f57aedc94909f951ad4 (patch) | |
tree | 00cac082bacb960e208e93a3f37541c249f6caad /cps-service/src/test/groovy/org | |
parent | 5e38784aad87c7e06e2d9765d3c7059d2d11017a (diff) | |
parent | a029cf849b06cd45d6909a9808e3cc52031e6644 (diff) |
Merge "Custom Model E2E Network Slicing - RAN Inventory"
Diffstat (limited to 'cps-service/src/test/groovy/org')
-rwxr-xr-x | cps-service/src/test/groovy/org/onap/cps/api/impl/E2ENetworkSliceSpec.groovy | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/cps-service/src/test/groovy/org/onap/cps/api/impl/E2ENetworkSliceSpec.groovy b/cps-service/src/test/groovy/org/onap/cps/api/impl/E2ENetworkSliceSpec.groovy index 904e8263b2..8abc0bf231 100755 --- a/cps-service/src/test/groovy/org/onap/cps/api/impl/E2ENetworkSliceSpec.groovy +++ b/cps-service/src/test/groovy/org/onap/cps/api/impl/E2ENetworkSliceSpec.groovy @@ -25,6 +25,7 @@ import org.onap.cps.api.CpsAdminService import org.onap.cps.spi.CpsDataPersistenceService
import org.onap.cps.spi.CpsModulePersistenceService
import org.onap.cps.spi.model.Anchor
+import org.onap.cps.spi.model.DataNode
import org.onap.cps.yang.YangTextSchemaSourceSetBuilder
import spock.lang.Specification
@@ -86,4 +87,45 @@ class E2ENetworkSliceSpec extends Specification { 1 * mockDataStoreService.storeDataNode(dataspaceName, anchorName,
{dataNode -> dataNode.xpath == '/ran-coverage-area' && dataNode.childDataNodes.size() == 4})
}
+
+ def 'E2E Coverage Area-Tracking Area & TA-Cell mapping data can be parsed for RAN inventory.'() {
+ def dataNodeStored
+ given: 'valid yang resource as name-to-content map'
+ def yangResourcesNameToContentMap = TestUtils.getYangResourcesAsMap(
+ 'e2e/basic/cps-ran-inventory.yang')
+ def schemaContext = YangTextSchemaSourceSetBuilder.of(yangResourcesNameToContentMap).getSchemaContext()
+ and : 'a valid json is provided for the model'
+ def jsonData = TestUtils.getResourceFileContent('e2e/basic/cps-ran-inventory-data.json')
+ and : 'all the further dependencies are mocked '
+ mockCpsAdminService.getAnchor('someDataspace', 'someAnchor') >>
+ new Anchor().builder().name('someAnchor').schemaSetName('someSchemaSet').build()
+ mockYangTextSchemaSourceSetCache.get('someDataspace', 'someSchemaSet') >> YangTextSchemaSourceSetBuilder.of(yangResourcesNameToContentMap)
+ mockModuleStoreService.getYangSchemaResources('someDataspace', 'someSchemaSet') >> schemaContext
+ when: 'saveData method is invoked'
+ cpsDataServiceImple.saveData('someDataspace', 'someAnchor', jsonData)
+ then: 'parameters are validated and processing is delegated to persistence service'
+ 1 * mockDataStoreService.storeDataNode('someDataspace', 'someAnchor', _) >>
+ { args -> dataNodeStored = args[2]}
+ and: 'the size of the tree is correct'
+ def cpsRanInventory = treeToFlatMapByXpath(new HashMap<>(), dataNodeStored)
+ assert cpsRanInventory.size() == 3
+ and: 'ran-inventory contains the correct child node'
+ def ranInventory = cpsRanInventory.get('/ran-inventory')
+ def sliceProfilesList = cpsRanInventory.get('/ran-inventory/sliceProfilesList[@sliceProfileId=\'f33a9dd8-ae51-4acf-8073-c9390c25f6f1\']')
+ def pLMNIdList = cpsRanInventory.get('/ran-inventory/sliceProfilesList[@sliceProfileId=\'f33a9dd8-ae51-4acf-8073-c9390c25f6f1\']/pLMNIdList[@mcc=\'310\' and @mnc=\'410\']')
+ ranInventory.getChildDataNodes().size() == 1
+ ranInventory.getChildDataNodes().find( {it.xpath == sliceProfilesList.xpath})
+ and: 'sliceProfilesList contains the correct child node'
+ sliceProfilesList.getChildDataNodes().size() == 1
+ sliceProfilesList.getChildDataNodes().find( {it.xpath == pLMNIdList.xpath})
+ and: 'pLMNIdList contains the no child nodes'
+ pLMNIdList.getChildDataNodes().size() == 0
+ }
+
+ def static treeToFlatMapByXpath(Map<String, DataNode> flatMap, DataNode dataNodeTree) {
+ flatMap.put(dataNodeTree.getXpath(), dataNodeTree)
+ dataNodeTree.getChildDataNodes()
+ .forEach(childDataNode -> treeToFlatMapByXpath(flatMap, childDataNode))
+ return flatMap
+ }
}
|