NCMP fails to start if /subscription-registry already exists 52/135352/2
authordanielhanrahan <daniel.hanrahan@est.tech>
Mon, 10 Jul 2023 09:47:36 +0000 (10:47 +0100)
committerDaniel Hanrahan <daniel.hanrahan@est.tech>
Mon, 10 Jul 2023 12:51:41 +0000 (12:51 +0000)
cpsDataService only throws AlreadyDefinedException, not
AlreadyDefinedExceptionBatch. This causes NcmpStartupException
to be thrown during startup, if /subscription-registry exists.

Issue-ID: CPS-1783
Signed-off-by: danielhanrahan <daniel.hanrahan@est.tech>
Change-Id: I5667d891f855ef47ca2475891f9216be102932ed

cps-ncmp-service/src/main/java/org/onap/cps/ncmp/init/SubscriptionModelLoader.java
cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/init/SubscriptionModelLoaderSpec.groovy

index af9ee72..1be5b2c 100644 (file)
@@ -31,6 +31,7 @@ import org.onap.cps.api.CpsDataService;
 import org.onap.cps.api.CpsModuleService;
 import org.onap.cps.ncmp.api.impl.exception.NcmpStartUpException;
 import org.onap.cps.spi.exceptions.AlreadyDefinedException;
+import org.onap.cps.spi.exceptions.AlreadyDefinedExceptionBatch;
 import org.onap.cps.spi.model.Dataspace;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.boot.SpringApplication;
@@ -157,7 +158,7 @@ public class SubscriptionModelLoader implements ModelLoader {
         final String nodeData = "{\"" + dataNodeName + "\":{}}";
         try {
             cpsDataService.saveData(dataspaceName, anchorName, nodeData, OffsetDateTime.now());
-        } catch (final AlreadyDefinedException exception) {
+        } catch (final AlreadyDefinedExceptionBatch exception) {
             log.info("Creating new data node '{}' failed as data node already exists", dataNodeName);
         } catch (final Exception exception) {
             log.debug("Creating data node for subscription model failed: {}", exception.getMessage());
index b4e7813..128895b 100644 (file)
@@ -28,6 +28,7 @@ import org.onap.cps.api.CpsDataService
 import org.onap.cps.api.CpsModuleService
 import org.onap.cps.ncmp.api.impl.exception.NcmpStartUpException
 import org.onap.cps.spi.exceptions.AlreadyDefinedException
+import org.onap.cps.spi.exceptions.AlreadyDefinedExceptionBatch
 import org.onap.cps.spi.exceptions.DataValidationException
 import org.onap.cps.spi.exceptions.SchemaSetNotFoundException
 import org.onap.cps.spi.model.Dataspace
@@ -198,7 +199,7 @@ class SubscriptionModelLoaderSpec extends Specification {
     def 'Create top level node fails due to an AlreadyDefined exception'() {
         given: 'the saving of the node data will throw an Already Defined exception'
             mockCpsDataService.saveData(*_) >>
-                    { throw AlreadyDefinedException.forDataNode('/xpath', "sampleContextName", null) }
+                    { throw new AlreadyDefinedExceptionBatch(['/xpath']) }
         when: 'the method to onboard model is called'
             objectUnderTest.onboardSubscriptionModel(yangResourceToContentMap)
         then: 'no exception thrown'