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;
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.
*
@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);
}
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)