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.groovy45
1 files changed, 30 insertions, 15 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 9f1203d64..00fda149f 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
@@ -26,7 +26,6 @@ import org.onap.cps.api.CpsAdminService
import org.onap.cps.api.CpsDataService
import org.onap.cps.api.CpsModuleService
import org.onap.cps.ncmp.api.impl.exception.DmiRequestException
-import org.onap.cps.ncmp.api.impl.exception.NcmpException
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
@@ -53,16 +52,17 @@ class NetworkCmProxyDataServiceImplRegistrationSpec extends Specification {
def mockCpsAdminService = Mock(CpsAdminService)
def mockDmiModelOperations = Mock(DmiModelOperations)
def mockDmiDataOperations = Mock(DmiDataOperations)
+ def mockNetworkCmProxyDataServicePropertyHandler = Mock(NetworkCmProxyDataServicePropertyHandler)
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')
+ def dmiPluginRegistration = new DmiPluginRegistration(dmiPlugin: 'my-server')
persistenceCmHandle.cmHandleID = '123'
persistenceCmHandle.dmiProperties = [dmiProp1: 'dmiValue1', dmiProp2: 'dmiValue2']
- persistenceCmHandle.publicProperties = [publicProp1: 'publicValue1', publicProp2: 'publicValue2' ]
+ persistenceCmHandle.publicProperties = [publicProp1: 'publicValue1', publicProp2: 'publicValue2']
dmiPluginRegistration.createdCmHandles = createdCmHandles
dmiPluginRegistration.updatedCmHandles = updatedCmHandles
dmiPluginRegistration.removedCmHandles = removedCmHandles
@@ -74,22 +74,21 @@ class NetworkCmProxyDataServiceImplRegistrationSpec extends Specification {
objectUnderTest.updateDmiRegistrationAndSyncModule(dmiPluginRegistration)
then: 'save list elements is invoked with the expected parameters'
expectedCallsToSaveNode * mockCpsDataService.saveListElements('NCMP-Admin', 'ncmp-dmi-registry',
- '/dmi-registry', expectedJsonData, noTimestamp)
- and: 'update node and child data nodes is invoked with correct parameters'
- expectedCallsToUpdateNode * mockCpsDataService.updateNodeLeavesAndExistingDescendantLeaves('NCMP-Admin',
- 'ncmp-dmi-registry', '/dmi-registry', expectedJsonData, noTimestamp)
+ '/dmi-registry', expectedJsonData, noTimestamp)
+ and: 'update data node leaves is called with correct parameters'
+ expectedCallsToPropertyHandler * mockNetworkCmProxyDataServicePropertyHandler.updateCmHandleProperties(updatedCmHandles)
and: 'delete schema set is invoked with the correct parameters'
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 | expectedCallsToUpdateNode | expectedCallsToDeleteSchemaSetAndListElement
- 'create' | [persistenceCmHandle] | [] | [] || 1 | 0 | 0
- 'update' | [] | [persistenceCmHandle] | [] || 0 | 1 | 0
- 'delete' | [] | [] | cmHandlesArray || 0 | 0 | 1
- 'create, update and delete' | [persistenceCmHandle] | [persistenceCmHandle] | cmHandlesArray || 1 | 1 | 1
- 'no valid data' | null | null | null || 0 | 0 | 0
+ scenario | createdCmHandles | updatedCmHandles | removedCmHandles || expectedCallsToSaveNode | expectedCallsToDeleteSchemaSetAndListElement | expectedCallsToPropertyHandler
+ 'create' | [persistenceCmHandle] | [] | [] || 1 | 0 | 1
+ 'update' | [] | [persistenceCmHandle] | [] || 0 | 0 | 1
+ 'delete' | [] | [] | cmHandlesArray || 0 | 1 | 1
+ 'create, update and delete' | [persistenceCmHandle] | [persistenceCmHandle] | cmHandlesArray || 1 | 1 | 1
+ 'no valid data' | null | null | null || 0 | 0 | 0
}
def 'Register a DMI Plugin for the given cm-handle(s) without DMI properties.'() {
@@ -194,9 +193,25 @@ class NetworkCmProxyDataServiceImplRegistrationSpec extends Specification {
'only data DMI plugin' | '' | '' | 'service1' || 'Cannot register just a Data or Model plugin service name'
}
+ def 'Exception thrown on CM-Handle registration update request'() {
+ given: 'a CM-handle registration'
+ def objectUnderTest = getObjectUnderTestWithModelSyncDisabled()
+ and: 'dmi plugin registration input update request'
+ def dmiPluginReg = new DmiPluginRegistration();
+ dmiPluginReg.dmiPlugin = 'onap.dmap.plugin';
+ dmiPluginReg.updatedCmHandles = [new CmHandle(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'
+ objectUnderTest.updateDmiRegistrationAndSyncModule(dmiPluginReg)
+ then: 'data validation exception is thrown'
+ def exceptionThrown = thrown(DataValidationException.class)
+ assert exceptionThrown.getDetails().contains('DataNode not found')
+ }
+
def getObjectUnderTestWithModelSyncDisabled() {
def objectUnderTest = Spy(new NetworkCmProxyDataServiceImpl(mockCpsDataService, spiedJsonObjectMapper, mockDmiDataOperations, mockDmiModelOperations,
- mockCpsModuleService, mockCpsAdminService))
+ mockCpsModuleService, mockCpsAdminService, mockNetworkCmProxyDataServicePropertyHandler))
objectUnderTest.syncModulesAndCreateAnchor(*_) >> null
return objectUnderTest
}