diff options
author | niamhcore <niamh.core@est.tech> | 2021-12-08 14:19:02 +0000 |
---|---|---|
committer | niamhcore <niamh.core@est.tech> | 2021-12-08 15:32:10 +0000 |
commit | 65bc4fdc0264d75a9fc9b468a1ca329cb0b8c260 (patch) | |
tree | 9dd3480075348831214ccdb59c3c3a067e88785b /cps-ncmp-service/src/test/groovy/org | |
parent | 8c9b4a24b4841154a2d08f506e2f7beca4f6fc31 (diff) |
Delete anchor and schema set when a registration is removed
Issue-ID: CPS-783
Signed-off-by: niamhcore <niamh.core@est.tech>
Change-Id: I9644949e00c4de900b2609c1e70744ae5a243582
Diffstat (limited to 'cps-ncmp-service/src/test/groovy/org')
-rw-r--r-- | cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImplRegistrationSpec.groovy | 24 |
1 files changed, 15 insertions, 9 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 86c01b4073..41084541c2 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 @@ -23,6 +23,7 @@ package org.onap.cps.ncmp.api.impl import com.fasterxml.jackson.core.JsonProcessingException import com.fasterxml.jackson.databind.ObjectMapper import org.onap.cps.api.CpsDataService +import org.onap.cps.api.CpsModuleService import org.onap.cps.ncmp.api.impl.exception.NcmpException import org.onap.cps.ncmp.api.models.CmHandle import org.onap.cps.ncmp.api.models.DmiPluginRegistration @@ -31,6 +32,8 @@ import org.onap.cps.spi.exceptions.DataValidationException import spock.lang.Shared import spock.lang.Specification +import static org.onap.cps.spi.CascadeDeleteAllowed.CASCADE_DELETE_ALLOWED + class NetworkCmProxyDataServiceImplRegistrationSpec extends Specification { @Shared @@ -40,6 +43,7 @@ class NetworkCmProxyDataServiceImplRegistrationSpec extends Specification { def cmHandlesArray = ['cmHandle001'] def mockCpsDataService = Mock(CpsDataService) + def mockCpsModuleService = Mock(CpsModuleService) def spyObjectMapper = Spy(ObjectMapper) def noTimestamp = null @@ -62,16 +66,18 @@ class NetworkCmProxyDataServiceImplRegistrationSpec extends Specification { and: 'update node and child data nodes is invoked with correct parameters' expectedCallsToUpdateNode * mockCpsDataService.updateNodeLeavesAndExistingDescendantLeaves('NCMP-Admin', 'ncmp-dmi-registry', '/dmi-registry', expectedJsonData, noTimestamp) - and : 'delete list or list element is invoked with the correct parameters' - expectedCallsToDeleteListElement * mockCpsDataService.deleteListOrListElement('NCMP-Admin', + 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) where: - scenario | createdCmHandles | updatedCmHandles | removedCmHandles || expectedCallsToSaveNode | expectedCallsToUpdateNode | expectedCallsToDeleteListElement - '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 | 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 } def 'Register a DMI Plugin for the given cm-handle(s) without additional properties.'() { @@ -159,7 +165,7 @@ class NetworkCmProxyDataServiceImplRegistrationSpec extends Specification { } def getObjectUnderTestWithModelSyncDisabled() { - def objectUnderTest = Spy(new NetworkCmProxyDataServiceImpl(null, null, null, + def objectUnderTest = Spy(new NetworkCmProxyDataServiceImpl(null, null, mockCpsModuleService, mockCpsDataService, null, null, spyObjectMapper)) objectUnderTest.syncModulesAndCreateAnchor(*_) >> null return objectUnderTest |