aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorToine Siebelink <toine.siebelink@est.tech>2021-12-14 15:10:08 +0000
committerGerrit Code Review <gerrit@onap.org>2021-12-14 15:10:08 +0000
commitf71738be13491a91f080c5bf8622c7be59701704 (patch)
tree07502fc8933ece72efcf25cbe8b61538d97c1fa9
parent4207fab422760b17187d37776ebc1867b995bba1 (diff)
parent3aeb338680572b151e88c4065a541fc859f585be (diff)
Merge "Add exception handling to delete schema set when a registration is removed"
-rwxr-xr-xcps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImpl.java12
-rw-r--r--cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImplRegistrationSpec.groovy13
2 files changed, 23 insertions, 2 deletions
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImpl.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImpl.java
index faa2efe3a..62a0922d0 100755
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImpl.java
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImpl.java
@@ -297,8 +297,7 @@ public class NetworkCmProxyDataServiceImpl implements NetworkCmProxyDataService
private void parseAndRemoveCmHandlesInDmiRegistration(final DmiPluginRegistration dmiPluginRegistration) {
for (final String cmHandle : dmiPluginRegistration.getRemovedCmHandles()) {
try {
- cpsModuleService.deleteSchemaSet(NFP_OPERATIONAL_DATASTORE_DATASPACE_NAME, cmHandle,
- CASCADE_DELETE_ALLOWED);
+ attemptToDeleteSchemaSetWithCascade(cmHandle);
cpsDataService.deleteListOrListElement(NCMP_DATASPACE_NAME, NCMP_DMI_REGISTRY_ANCHOR,
"/dmi-registry/cm-handles[@id='" + cmHandle + "']", NO_TIMESTAMP);
} catch (final DataNodeNotFoundException e) {
@@ -307,6 +306,15 @@ public class NetworkCmProxyDataServiceImpl implements NetworkCmProxyDataService
}
}
+ private void attemptToDeleteSchemaSetWithCascade(final String schemaSetName) {
+ try {
+ cpsModuleService.deleteSchemaSet(NFP_OPERATIONAL_DATASTORE_DATASPACE_NAME, schemaSetName,
+ CASCADE_DELETE_ALLOWED);
+ } catch (final Exception e) {
+ log.warn("Schema set {} delete failed, reason {}", schemaSetName, e.getMessage());
+ }
+ }
+
private void syncAndCreateSchemaSet(final PersistenceCmHandle persistenceCmHandle) {
final List<ModuleReference> moduleReferencesFromCmHandle =
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 41084541c..8c3e593da 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
@@ -126,6 +126,19 @@ class NetworkCmProxyDataServiceImplRegistrationSpec extends Specification {
noExceptionThrown()
}
+ def 'Register a DMI Plugin for the given cm-handle(s) with no schema set found during delete process.'() {
+ given: 'a registration'
+ def objectUnderTest = getObjectUnderTestWithModelSyncDisabled()
+ def dmiPluginRegistration = new DmiPluginRegistration(dmiPlugin:'my-server')
+ dmiPluginRegistration.removedCmHandles = cmHandlesArray
+ and: 'an exception occurs during delete schema set process'
+ mockCpsModuleService.deleteSchemaSet(_,_,_) >> { throw (new Exception('')) }
+ when: 'registration is updated and modules are synced'
+ objectUnderTest.updateDmiRegistrationAndSyncModule(dmiPluginRegistration)
+ then: 'delete list or list element is still called'
+ 1 * mockCpsDataService.deleteListOrListElement(_,_,_,_)
+ }
+
def 'Dmi plugin registration with #scenario'() {
given: 'a registration '
def objectUnderTest = getObjectUnderTestWithModelSyncDisabled()