aboutsummaryrefslogtreecommitdiffstats
path: root/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImplRegistrationSpec.groovy
diff options
context:
space:
mode:
Diffstat (limited to 'cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImplRegistrationSpec.groovy')
-rw-r--r--cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImplRegistrationSpec.groovy40
1 files changed, 21 insertions, 19 deletions
diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImplRegistrationSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImplRegistrationSpec.groovy
index a475f9c34..e410463af 100644
--- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImplRegistrationSpec.groovy
+++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImplRegistrationSpec.groovy
@@ -28,8 +28,9 @@ import org.onap.cps.api.CpsModuleService
import org.onap.cps.ncmp.api.impl.exception.DmiRequestException
import org.onap.cps.ncmp.api.impl.operations.DmiDataOperations
import org.onap.cps.ncmp.api.impl.operations.DmiModelOperations
-import org.onap.cps.ncmp.api.models.CmHandle
+import org.onap.cps.ncmp.api.impl.operations.YangModelCmHandleRetriever
import org.onap.cps.ncmp.api.models.DmiPluginRegistration
+import org.onap.cps.ncmp.api.models.NcmpServiceCmHandle
import org.onap.cps.spi.exceptions.DataNodeNotFoundException
import org.onap.cps.spi.exceptions.DataValidationException
import org.onap.cps.utils.JsonObjectMapper
@@ -41,7 +42,7 @@ import static org.onap.cps.spi.CascadeDeleteAllowed.CASCADE_DELETE_ALLOWED
class NetworkCmProxyDataServiceImplRegistrationSpec extends Specification {
@Shared
- def persistenceCmHandle = new CmHandle()
+ def ncmpServiceCmHandle = new NcmpServiceCmHandle()
@Shared
def cmHandlesArray = ['cmHandle001']
@@ -53,16 +54,17 @@ class NetworkCmProxyDataServiceImplRegistrationSpec extends Specification {
def mockDmiModelOperations = Mock(DmiModelOperations)
def mockDmiDataOperations = Mock(DmiDataOperations)
def mockNetworkCmProxyDataServicePropertyHandler = Mock(NetworkCmProxyDataServicePropertyHandler)
+ def mockYangModelCmHandleRetriever = Mock(YangModelCmHandleRetriever)
def noTimestamp = null
def 'Register or re-register a DMI Plugin for the given cm-handle(s) with #scenario process.'() {
given: 'a registration'
def objectUnderTest = getObjectUnderTestWithModelSyncDisabled()
- def dmiPluginRegistration = new DmiPluginRegistration(dmiPlugin: 'my-server')
- persistenceCmHandle.cmHandleID = '123'
- persistenceCmHandle.dmiProperties = [dmiProp1: 'dmiValue1', dmiProp2: 'dmiValue2']
- persistenceCmHandle.publicProperties = [publicProp1: 'publicValue1', publicProp2: 'publicValue2']
+ def dmiPluginRegistration = new DmiPluginRegistration(dmiPlugin:'my-server')
+ ncmpServiceCmHandle.cmHandleID = '123'
+ ncmpServiceCmHandle.dmiProperties = [dmiProp1: 'dmiValue1', dmiProp2: 'dmiValue2']
+ ncmpServiceCmHandle.publicProperties = [publicProp1: 'publicValue1', publicProp2: 'publicValue2' ]
dmiPluginRegistration.createdCmHandles = createdCmHandles
dmiPluginRegistration.updatedCmHandles = updatedCmHandles
dmiPluginRegistration.removedCmHandles = removedCmHandles
@@ -81,13 +83,13 @@ class NetworkCmProxyDataServiceImplRegistrationSpec extends Specification {
expectedCallsToDeleteSchemaSetAndListElement * mockCpsModuleService.deleteSchemaSet('NFP-Operational', 'cmHandle001', CASCADE_DELETE_ALLOWED)
and: 'delete list or list element is invoked with the correct parameters'
expectedCallsToDeleteSchemaSetAndListElement * mockCpsDataService.deleteListOrListElement('NCMP-Admin',
- 'ncmp-dmi-registry', "/dmi-registry/cm-handles[@id='cmHandle001']", noTimestamp)
+ 'ncmp-dmi-registry', "/dmi-registry/cm-handles[@id='cmHandle001']", noTimestamp)
where:
scenario | createdCmHandles | updatedCmHandles | removedCmHandles || expectedCallsToSaveNode | expectedCallsToDeleteSchemaSetAndListElement | expectedCallsToUpdateCmHandleProperty
- 'create' | [persistenceCmHandle] | [] | [] || 1 | 0 | 0
- 'update' | [] | [persistenceCmHandle] | [] || 0 | 0 | 1
+ 'create' | [ncmpServiceCmHandle] | [] | [] || 1 | 0 | 0
+ 'update' | [] | [ncmpServiceCmHandle] | [] || 0 | 0 | 1
'delete' | [] | [] | cmHandlesArray || 0 | 1 | 0
- 'create, update and delete' | [persistenceCmHandle] | [persistenceCmHandle] | cmHandlesArray || 1 | 1 | 1
+ 'create, update and delete' | [ncmpServiceCmHandle] | [ncmpServiceCmHandle] | cmHandlesArray || 1 | 1 | 1
'no valid data' | [] | [] | [] || 0 | 0 | 0
}
@@ -95,10 +97,10 @@ class NetworkCmProxyDataServiceImplRegistrationSpec extends Specification {
given: 'a registration without cm-handle properties'
NetworkCmProxyDataServiceImpl objectUnderTest = getObjectUnderTestWithModelSyncDisabled()
def dmiPluginRegistration = new DmiPluginRegistration(dmiPlugin:'my-server')
- persistenceCmHandle.cmHandleID = '123'
- persistenceCmHandle.dmiProperties = Collections.emptyMap()
- persistenceCmHandle.publicProperties = Collections.emptyMap()
- dmiPluginRegistration.createdCmHandles = [persistenceCmHandle]
+ ncmpServiceCmHandle.cmHandleID = '123'
+ ncmpServiceCmHandle.dmiProperties = Collections.emptyMap()
+ ncmpServiceCmHandle.publicProperties = Collections.emptyMap()
+ dmiPluginRegistration.createdCmHandles = [ncmpServiceCmHandle]
def expectedJsonData = '{"cm-handles":[{"id":"123","dmi-service-name":"my-server","dmi-data-service-name":null,"dmi-model-service-name":null,"additional-properties":[],"public-properties":[]}]}'
when: 'registration is updated'
objectUnderTest.updateDmiRegistrationAndSyncModule(dmiPluginRegistration)
@@ -111,7 +113,7 @@ class NetworkCmProxyDataServiceImplRegistrationSpec extends Specification {
given: 'a registration without cm-handle properties '
NetworkCmProxyDataServiceImpl objectUnderTest = getObjectUnderTestWithModelSyncDisabled()
def dmiPluginRegistration = new DmiPluginRegistration(dmiPlugin:'some-plugin')
- dmiPluginRegistration.createdCmHandles = [persistenceCmHandle]
+ dmiPluginRegistration.createdCmHandles = [ncmpServiceCmHandle]
and: 'an json processing exception occurs'
spiedJsonObjectMapper.asJsonString(_) >> { throw (new JsonProcessingException('')) }
when: 'registration is updated and modules are synced'
@@ -151,7 +153,7 @@ class NetworkCmProxyDataServiceImplRegistrationSpec extends Specification {
def objectUnderTest = getObjectUnderTestWithModelSyncDisabled()
def dmiPluginRegistration = new DmiPluginRegistration(dmiPlugin:dmiPlugin, dmiModelPlugin:dmiModelPlugin,
dmiDataPlugin:dmiDataPlugin)
- dmiPluginRegistration.createdCmHandles = [persistenceCmHandle]
+ dmiPluginRegistration.createdCmHandles = [ncmpServiceCmHandle]
when: 'update registration and sync module is called with correct DMI plugin information'
objectUnderTest.updateDmiRegistrationAndSyncModule(dmiPluginRegistration)
then: 'create cm handles registration and sync modules is called with the correct plugin information'
@@ -168,7 +170,7 @@ class NetworkCmProxyDataServiceImplRegistrationSpec extends Specification {
def objectUnderTest = getObjectUnderTestWithModelSyncDisabled()
def dmiPluginRegistration = new DmiPluginRegistration(dmiPlugin:dmiPlugin, dmiModelPlugin:dmiModelPlugin,
dmiDataPlugin:dmiDataPlugin)
- dmiPluginRegistration.createdCmHandles = [persistenceCmHandle]
+ dmiPluginRegistration.createdCmHandles = [ncmpServiceCmHandle]
when: 'registration is called with incorrect DMI plugin information'
objectUnderTest.updateDmiRegistrationAndSyncModule(dmiPluginRegistration)
then: 'a DMI Request Exception is thrown with correct message details'
@@ -194,7 +196,7 @@ class NetworkCmProxyDataServiceImplRegistrationSpec extends Specification {
and: 'dmi plugin registration input update request'
def dmiPluginReg = new DmiPluginRegistration();
dmiPluginReg.dmiPlugin = 'onap.dmap.plugin';
- dmiPluginReg.updatedCmHandles = [new CmHandle(cmHandleID: 'unknownHandle')]
+ dmiPluginReg.updatedCmHandles = [new NcmpServiceCmHandle(cmHandleID: 'unknownHandle')]
and: 'update data node leaves is unable to find data node'
mockNetworkCmProxyDataServicePropertyHandler.updateCmHandleProperties(*_) >> { throw new DataNodeNotFoundException('NCMP-Admin', 'ncmp-dmi-registry') }
when: 'update dmi registration is called'
@@ -206,7 +208,7 @@ class NetworkCmProxyDataServiceImplRegistrationSpec extends Specification {
def getObjectUnderTestWithModelSyncDisabled() {
def objectUnderTest = Spy(new NetworkCmProxyDataServiceImpl(mockCpsDataService, spiedJsonObjectMapper, mockDmiDataOperations, mockDmiModelOperations,
- mockCpsModuleService, mockCpsAdminService, mockNetworkCmProxyDataServicePropertyHandler))
+ mockCpsModuleService, mockCpsAdminService, mockNetworkCmProxyDataServicePropertyHandler,mockYangModelCmHandleRetriever))
objectUnderTest.syncModulesAndCreateAnchor(*_) >> null
return objectUnderTest
}