diff options
author | Toine Siebelink <toine.siebelink@est.tech> | 2021-02-18 14:46:51 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2021-02-18 14:46:51 +0000 |
commit | 55c4135bff02800659ddc4d2de15222ba229ac51 (patch) | |
tree | 9545a806db63534ac8189f8e3dfd7ef9daa2e21d /cps-service/src/test/groovy | |
parent | 24c72db6b3674bde16eb5a7313d71f507a880de9 (diff) | |
parent | 3b0221cabd6614ed82fe2931948651666300cf39 (diff) |
Merge "E2E RAN Schema Model - yang model vs data test"
Diffstat (limited to 'cps-service/src/test/groovy')
-rwxr-xr-x | cps-service/src/test/groovy/org/onap/cps/api/impl/E2ENetworkSliceSpec.groovy | 22 |
1 files changed, 15 insertions, 7 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 ac4ef278ee..75c98a82d9 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 @@ -26,7 +26,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.utils.YangUtils
import org.onap.cps.yang.YangTextSchemaSourceSetBuilder
import spock.lang.Specification
@@ -121,7 +121,7 @@ class E2ENetworkSliceSpec extends Specification { 1 * mockDataStoreService.storeDataNode('someDataspace', 'someAnchor', _) >>
{ args -> dataNodeStored = args[2]}
and: 'the size of the tree is correct'
- def cpsRanInventory = treeToFlatMapByXpath(new HashMap<>(), dataNodeStored)
+ def cpsRanInventory = TestUtils.getFlattenMapByXpath(dataNodeStored)
assert cpsRanInventory.size() == 3
and: 'ran-inventory contains the correct child node'
def ranInventory = cpsRanInventory.get('/ran-inventory')
@@ -136,10 +136,18 @@ class E2ENetworkSliceSpec extends Specification { 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
+ def 'E2E RAN Schema Model.'(){
+ given: 'yang resources'
+ def yangResourcesNameToContentMap = TestUtils.getYangResourcesAsMap(
+ 'e2e/basic/ietf-inet-types.yang',
+ 'e2e/basic/ietf-yang-types.yang',
+ 'e2e/basic/cps-ran-schema-model@2021-01-28.yang'
+ )
+ and : 'json data'
+ def jsonData = TestUtils.getResourceFileContent('e2e/basic/cps-ran-schema-model-data-v4.json')
+ expect: 'schema context is built with no exception indicating the schema set being valid '
+ def schemaContext = YangTextSchemaSourceSetBuilder.of(yangResourcesNameToContentMap).getSchemaContext()
+ and: 'data is parsed with no exception indicating the model match'
+ YangUtils.parseJsonData(jsonData, schemaContext) != null
}
}
|