summaryrefslogtreecommitdiffstats
path: root/cps-ncmp-service
diff options
context:
space:
mode:
Diffstat (limited to 'cps-ncmp-service')
-rw-r--r--cps-ncmp-service/pom.xml2
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/init/SubscriptionModelLoader.java12
-rw-r--r--cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/init/SubscriptionModelLoaderSpec.groovy4
-rw-r--r--cps-ncmp-service/src/test/resources/application.yml5
4 files changed, 18 insertions, 5 deletions
diff --git a/cps-ncmp-service/pom.xml b/cps-ncmp-service/pom.xml
index 67bc313585..57cd1c6fd5 100644
--- a/cps-ncmp-service/pom.xml
+++ b/cps-ncmp-service/pom.xml
@@ -27,7 +27,7 @@
<parent>
<groupId>org.onap.cps</groupId>
<artifactId>cps-parent</artifactId>
- <version>3.2.4-SNAPSHOT</version>
+ <version>3.2.6-SNAPSHOT</version>
<relativePath>../cps-parent/pom.xml</relativePath>
</parent>
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/init/SubscriptionModelLoader.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/init/SubscriptionModelLoader.java
index 6713491e6e..0d82bb5c1c 100644
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/init/SubscriptionModelLoader.java
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/init/SubscriptionModelLoader.java
@@ -30,6 +30,7 @@ import org.onap.cps.api.CpsAdminService;
import org.onap.cps.api.CpsModuleService;
import org.onap.cps.ncmp.api.impl.exception.NcmpStartUpException;
import org.onap.cps.spi.exceptions.AlreadyDefinedException;
+import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.context.event.ApplicationReadyEvent;
import org.springframework.stereotype.Component;
@@ -45,6 +46,9 @@ public class SubscriptionModelLoader implements ModelLoader {
private static final String SUBSCRIPTION_ANCHOR_NAME = "AVC-Subscriptions";
private static final String SUBSCRIPTION_SCHEMASET_NAME = "subscriptions";
+ @Value("${ncmp.model-loader.subscription:false}")
+ private boolean subscriptionModelLoaderEnabled;
+
/**
* Method calls boarding subscription model when Application is ready.
*
@@ -53,7 +57,11 @@ public class SubscriptionModelLoader implements ModelLoader {
@Override
public void onApplicationEvent(@NonNull final ApplicationReadyEvent applicationReadyEvent) {
try {
- onboardSubscriptionModel();
+ if (subscriptionModelLoaderEnabled) {
+ onboardSubscriptionModel();
+ } else {
+ log.info("Subscription Model Loader is disabled");
+ }
} catch (final NcmpStartUpException ncmpStartUpException) {
log.debug("Onboarding model for NCMP failed: {} ", ncmpStartUpException.getMessage());
SpringApplication.exit(applicationReadyEvent.getApplicationContext(), () -> 1);
@@ -109,7 +117,7 @@ public class SubscriptionModelLoader implements ModelLoader {
}
private String getFileContentAsString() {
- try (InputStream inputStream = ClassLoader.getSystemClassLoader()
+ try (InputStream inputStream = getClass().getClassLoader()
.getResourceAsStream("model/subscription.yang")) {
return new String(inputStream.readAllBytes(), StandardCharsets.UTF_8);
} catch (final Exception exception) {
diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/init/SubscriptionModelLoaderSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/init/SubscriptionModelLoaderSpec.groovy
index 65c0497c9a..0e647ad871 100644
--- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/init/SubscriptionModelLoaderSpec.groovy
+++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/init/SubscriptionModelLoaderSpec.groovy
@@ -67,7 +67,9 @@ class SubscriptionModelLoaderSpec extends Specification {
}
def 'Onboard subscription model successfully via application ready event'() {
- when: 'the application is ready'
+ when:'model loader is enabled'
+ objectUnderTest.subscriptionModelLoaderEnabled = true
+ and: 'the application is ready'
objectUnderTest.onApplicationEvent(applicationReadyEvent)
then: 'the module service to create schema set is called once'
1 * mockCpsModuleService.createSchemaSet(SUBSCRIPTION_DATASPACE_NAME, SUBSCRIPTION_SCHEMASET_NAME,sampleYangContentMap)
diff --git a/cps-ncmp-service/src/test/resources/application.yml b/cps-ncmp-service/src/test/resources/application.yml
index e8b4be4bcf..b7dfe86c10 100644
--- a/cps-ncmp-service/src/test/resources/application.yml
+++ b/cps-ncmp-service/src/test/resources/application.yml
@@ -31,4 +31,7 @@ ncmp:
modules-sync-watchdog:
async-executor:
- parallelism-level: 3 \ No newline at end of file
+ parallelism-level: 3
+
+ model-loader:
+ subscription: true \ No newline at end of file