diff options
author | Toine Siebelink <toine.siebelink@est.tech> | 2021-02-03 15:24:40 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2021-02-03 15:24:40 +0000 |
commit | e7f94478a241f8ee7618da08f6bc8495e9f5a504 (patch) | |
tree | 4ed2a551c5f5378ce91acfe0d1cd694c47834d49 /cps-service/src/test/groovy/org/onap | |
parent | 27add4d028f040a740bed68707c648ee8441eeb2 (diff) | |
parent | e8c429e2bddcb52b6cd563c5308e49e57e457073 (diff) |
Merge "E2E Network Slice test for 'Coverage Area-Tracking Area & TA-Cell mapping'"
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 | 54 |
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})
}
}
|