diff options
author | Ruslan Kashapov <ruslan.kashapov@pantheon.tech> | 2021-02-18 12:31:24 +0200 |
---|---|---|
committer | Ruslan Kashapov <ruslan.kashapov@pantheon.tech> | 2021-02-18 12:32:23 +0200 |
commit | 3b0221cabd6614ed82fe2931948651666300cf39 (patch) | |
tree | 9a81908b1284e9e1a4070c54e6b6cfdc653a0168 /cps-service/src/test/groovy/org | |
parent | 6d13f166f2e3d1c357677ad6f37f6e35238aeac6 (diff) |
E2E RAN Schema Model - yang model vs data test
Issue-ID: CPS-196
Change-Id: I0171dfc2f82505c8ae8497ff49fe3eb28e1972a6
Signed-off-by: Ruslan Kashapov <ruslan.kashapov@pantheon.tech>
Diffstat (limited to 'cps-service/src/test/groovy/org')
-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
}
}
|