X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=cps-ncmp-service%2Fsrc%2Ftest%2Fgroovy%2Forg%2Fonap%2Fcps%2Fncmp%2Fapi%2Fimpl%2FNetworkCmProxyDataServiceImplRegistrationSpec.groovy;h=1ee1ad2f600d181231c10adddd2889b583d03bc4;hb=9fdaf6c0f472cad13ade1469458822d468fd2d6d;hp=dccba0be48bf93eca8e02a45db17cf2b15647c9d;hpb=71e676dd1cd2ed4ae348cb686dfd6ed96a4fc5b4;p=cps.git 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 dccba0be4..1ee1ad2f6 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 @@ -24,6 +24,7 @@ package org.onap.cps.ncmp.api.impl import com.fasterxml.jackson.databind.ObjectMapper import org.onap.cps.api.CpsModuleService import org.onap.cps.ncmp.api.NetworkCmProxyCmHandlerQueryService +import org.onap.cps.ncmp.api.impl.event.lcm.LcmEventsCmHandleStateHandler 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.yangmodels.YangModelCmHandle @@ -58,6 +59,7 @@ class NetworkCmProxyDataServiceImplRegistrationSpec extends Specification { def mockNetworkCmProxyDataServicePropertyHandler = Mock(NetworkCmProxyDataServicePropertyHandler) def mockInventoryPersistence = Mock(InventoryPersistence) def stubbedNetworkCmProxyCmHandlerQueryService = Stub(NetworkCmProxyCmHandlerQueryService) + def mockLcmEventsCmHandleStateHandler = Mock(LcmEventsCmHandleStateHandler) def objectUnderTest = getObjectUnderTest() def 'DMI Registration: Create, Update & Delete operations are processed in the right order'() { @@ -249,7 +251,11 @@ class NetworkCmProxyDataServiceImplRegistrationSpec extends Specification { { if (!schemaSetExist) { throw new SchemaSetNotFoundException("", "") } } when: 'registration is updated to delete cmhandle' def response = objectUnderTest.updateDmiRegistrationAndSyncModule(dmiPluginRegistration) - then: 'delete list or list element is called' + then: 'the cmHandle state is updated to "DELETING"' + 1 * mockLcmEventsCmHandleStateHandler.updateCmHandleState(_, CmHandleState.DELETING) + and: 'method to delete relevant schema set is called once' + 1 * mockInventoryPersistence.deleteSchemaSetWithCascade(_) + and: 'method to delete relevant list/list element is called once' 1 * mockInventoryPersistence.deleteListOrListElement(_) and: 'successful response is received' assert response.getRemovedCmHandles().size() == 1 @@ -257,6 +263,8 @@ class NetworkCmProxyDataServiceImplRegistrationSpec extends Specification { assert it.status == Status.SUCCESS assert it.cmHandle == 'cmhandle' } + and: 'the cmHandle state is updated to "DELETED"' + 1 * mockLcmEventsCmHandleStateHandler.updateCmHandleState(_, CmHandleState.DELETED) where: scenario | schemaSetExist 'schema-set exists and can be deleted successfully' | true @@ -303,6 +311,8 @@ class NetworkCmProxyDataServiceImplRegistrationSpec extends Specification { noExceptionThrown() and: 'cm-handle is not deleted' 0 * mockInventoryPersistence.deleteListOrListElement(_) + and: 'the cmHandle state is not updated to "DELETED"' + 0 * mockLcmEventsCmHandleStateHandler.updateCmHandleState(_, CmHandleState.DELETED) and: 'a failure response is received' assert response.getRemovedCmHandles().size() == 1 with(response.getRemovedCmHandles().get(0)) { @@ -321,9 +331,7 @@ class NetworkCmProxyDataServiceImplRegistrationSpec extends Specification { mockInventoryPersistence.deleteListOrListElement(_) >> { throw deleteListElementException } when: 'registration is updated to delete cmhandle' def response = objectUnderTest.updateDmiRegistrationAndSyncModule(dmiPluginRegistration) - then: 'no exception is thrown' - noExceptionThrown() - and: 'a failure response is received' + then: 'a failure response is received' assert response.getRemovedCmHandles().size() == 1 with(response.getRemovedCmHandles().get(0)) { assert it.status == Status.FAILURE @@ -331,6 +339,8 @@ class NetworkCmProxyDataServiceImplRegistrationSpec extends Specification { assert it.registrationError == expectedError assert it.errorText == expectedErrorText } + and: 'the cm handle state is not updated to "DELETED"' + 0 * mockLcmEventsCmHandleStateHandler.updateCmHandleState(_, CmHandleState.DELETED) where: scenario | cmHandleId | deleteListElementException || expectedError | expectedErrorText 'cm-handle does not exist' | 'cmhandle' | new DataNodeNotFoundException("", "", "") || CM_HANDLE_DOES_NOT_EXIST | 'cm-handle does not exist' @@ -340,6 +350,7 @@ class NetworkCmProxyDataServiceImplRegistrationSpec extends Specification { def getObjectUnderTest() { return Spy(new NetworkCmProxyDataServiceImpl(spiedJsonObjectMapper, mockDmiDataOperations, - mockNetworkCmProxyDataServicePropertyHandler, mockInventoryPersistence, stubbedNetworkCmProxyCmHandlerQueryService)) + mockNetworkCmProxyDataServicePropertyHandler, mockInventoryPersistence, stubbedNetworkCmProxyCmHandlerQueryService, + mockLcmEventsCmHandleStateHandler)) } }