diff options
author | 2021-02-03 16:10:37 +0000 | |
---|---|---|
committer | 2021-02-05 11:57:03 +0000 | |
commit | a029cf849b06cd45d6909a9808e3cc52031e6644 (patch) | |
tree | 3a0d853d36201260b7e01986f685c6a91e51f695 /cps-service/src/test/groovy/org/onap | |
parent | 20983922daff86e3282bc5e2da900a8ab1cc82ed (diff) |
Custom Model E2E Network Slicing - RAN Inventory
Issue-ID: CPS-200
Signed-off-by: niamhcore <niamh.core@est.tech>
Change-Id: I846ff2928de6e1fae1483ced05d66cfd1e44615e
Diffstat (limited to 'cps-service/src/test/groovy/org/onap')
-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 904e8263b..8abc0bf23 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
+ }
}
|