summaryrefslogtreecommitdiffstats
path: root/cps-service/src/test/groovy
diff options
context:
space:
mode:
Diffstat (limited to 'cps-service/src/test/groovy')
-rwxr-xr-xcps-service/src/test/groovy/org/onap/cps/api/impl/E2ENetworkSliceSpec.groovy54
1 files changed, 49 insertions, 5 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 d6751bb4e2..904e8263b2 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
@@ -21,25 +21,69 @@
package org.onap.cps.api.impl
import org.onap.cps.TestUtils
+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.yang.YangTextSchemaSourceSetBuilder
import spock.lang.Specification
class E2ENetworkSliceSpec extends Specification {
def mockModuleStoreService = Mock(CpsModulePersistenceService)
+ def mockDataStoreService = Mock(CpsDataPersistenceService)
+ def mockCpsAdminService = Mock(CpsAdminService)
+ def cpsModuleServiceImpl = new CpsModuleServiceImpl()
+ def cpsDataServiceImple = new CpsDataServiceImpl()
def mockYangTextSchemaSourceSetCache = Mock(YangTextSchemaSourceSetCache)
- def objectUnderTest = new CpsModuleServiceImpl()
+
+ def dataspaceName = 'someDataspace'
+ def anchorName = 'someAnchor'
+ def schemaSetName = 'someSchemaSet'
def setup() {
- objectUnderTest.cpsModulePersistenceService = mockModuleStoreService
- objectUnderTest.yangTextSchemaSourceSetCache = mockYangTextSchemaSourceSetCache
+ cpsDataServiceImple.cpsDataPersistenceService = mockDataStoreService
+ cpsDataServiceImple.cpsAdminService = mockCpsAdminService
+ cpsDataServiceImple.yangTextSchemaSourceSetCache = mockYangTextSchemaSourceSetCache
+ cpsModuleServiceImpl.yangTextSchemaSourceSetCache = mockYangTextSchemaSourceSetCache
+ cpsModuleServiceImpl.cpsModulePersistenceService = mockModuleStoreService
}
def 'E2E model can be parsed by CPS.'() {
given: 'Valid yang resource as name-to-content map'
def yangResourcesNameToContentMap = TestUtils.getYangResourcesAsMap('e2e/basic/ietf-inet-types.yang','e2e/basic/ietf-yang-types.yang','e2e/basic/ran-network2020-08-06.yang')
when: 'Create schema set method is invoked'
- objectUnderTest.createSchemaSet('someDataspace', 'someSchemaSet', yangResourcesNameToContentMap)
+ cpsModuleServiceImpl.createSchemaSet(dataspaceName, schemaSetName, yangResourcesNameToContentMap)
+ then: 'Parameters are validated and processing is delegated to persistence service'
+ 1 * mockModuleStoreService.storeSchemaSet(dataspaceName, schemaSetName, yangResourcesNameToContentMap)
+ }
+
+ def 'E2E Coverage Area-Tracking Area & TA-Cell mapping model can be parsed by CPS.'() {
+ given: 'Valid yang resource as name-to-content map'
+ def yangResourcesNameToContentMap = TestUtils.getYangResourcesAsMap(
+ 'e2e/basic/cps-cavsta-onap-internal2021-01-28.yang')
+ when: 'Create schema set method is invoked'
+ cpsModuleServiceImpl.createSchemaSet(dataspaceName, schemaSetName, yangResourcesNameToContentMap)
+ then: 'Parameters are validated and processing is delegated to persistence service'
+ 1 * mockModuleStoreService.storeSchemaSet(dataspaceName, schemaSetName, yangResourcesNameToContentMap)
+ }
+
+ def 'E2E Coverage Area-Tracking Area & TA-Cell mapping data can be parsed by CPS.'() {
+ given: 'Valid yang resource as name-to-content map'
+ def yangResourcesNameToContentMap = TestUtils.getYangResourcesAsMap(
+ 'e2e/basic/cps-cavsta-onap-internal2021-01-28.yang')
+ def schemaContext = YangTextSchemaSourceSetBuilder.of(yangResourcesNameToContentMap).getSchemaContext()
+ and : 'a valid json is provided for the model'
+ def jsonData = TestUtils.getResourceFileContent('e2e/basic/Data.txt')
+ and : 'all the further dependencies are mocked '
+ mockCpsAdminService.getAnchor(dataspaceName, anchorName) >>
+ new Anchor().builder().name(anchorName).schemaSetName(schemaSetName).build()
+ mockYangTextSchemaSourceSetCache.get(dataspaceName, schemaSetName) >>
+ YangTextSchemaSourceSetBuilder.of(yangResourcesNameToContentMap)
+ mockModuleStoreService.getYangSchemaResources(dataspaceName, schemaSetName) >> schemaContext
+ when: 'saveData method is invoked'
+ cpsDataServiceImple.saveData(dataspaceName, anchorName, jsonData)
then: 'Parameters are validated and processing is delegated to persistence service'
- 1 * mockModuleStoreService.storeSchemaSet('someDataspace', 'someSchemaSet', yangResourcesNameToContentMap)
+ 1 * mockDataStoreService.storeDataNode(dataspaceName, anchorName,
+ {dataNode -> dataNode.xpath == '/ran-coverage-area' && dataNode.childDataNodes.size() == 4})
}
}