From 3b0221cabd6614ed82fe2931948651666300cf39 Mon Sep 17 00:00:00 2001 From: Ruslan Kashapov Date: Thu, 18 Feb 2021 12:31:24 +0200 Subject: E2E RAN Schema Model - yang model vs data test Issue-ID: CPS-196 Change-Id: I0171dfc2f82505c8ae8497ff49fe3eb28e1972a6 Signed-off-by: Ruslan Kashapov --- .../onap/cps/api/impl/E2ENetworkSliceSpec.groovy | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) (limited to 'cps-service/src/test/groovy') 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 ac4ef278e..75c98a82d 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 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 } } -- cgit 1.2.3-korg