@Value("${notification.enabled:true}")
private boolean notificationFeatureEnabled;
- @Value("${ncmp.model-loader.subscription:false}")
- private boolean subscriptionModelLoaderEnabled;
-
/**
* Consume the specified event.
*
final CloudEvent cloudEvent = subscriptionEventConsumerRecord.value();
final CmNotificationSubscriptionNcmpInEvent cmNotificationSubscriptionNcmpInEvent =
toTargetEvent(cloudEvent, CmNotificationSubscriptionNcmpInEvent.class);
- if (subscriptionModelLoaderEnabled) {
- log.info("Subscription with name {} to be mapped to hazelcast object...",
- cmNotificationSubscriptionNcmpInEvent.getData().getSubscriptionId());
- }
+ log.info("Subscription with name {} to be mapped to hazelcast object...",
+ cmNotificationSubscriptionNcmpInEvent.getData().getSubscriptionId());
if ("subscriptionCreated".equals(cloudEvent.getType()) && cmNotificationSubscriptionNcmpInEvent != null) {
log.info("Subscription for ClientID {} with name {} ...", cloudEvent.getSource(),
cmNotificationSubscriptionNcmpInEvent.getData().getSubscriptionId());
import org.onap.cps.ncmp.api.impl.exception.NcmpStartUpException;
import org.onap.cps.ncmp.api.impl.operations.DatastoreType;
import org.onap.cps.spi.exceptions.AlreadyDefinedException;
-import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
@Slf4j
private static final String REGISTRY_DATANODE_NAME = "datastores";
public CmDataSubscriptionModelLoader(final CpsDataspaceService cpsDataspaceService,
- final CpsModuleService cpsModuleService,
- final CpsAnchorService cpsAnchorService,
- final CpsDataService cpsDataService) {
+ final CpsModuleService cpsModuleService, final CpsAnchorService cpsAnchorService,
+ final CpsDataService cpsDataService) {
super(cpsDataspaceService, cpsModuleService, cpsAnchorService, cpsDataService);
}
- @Value("${ncmp.model-loader.subscription:true}")
- private boolean subscriptionModelLoaderEnabled;
-
@Override
public void onboardOrUpgradeModel() {
- if (subscriptionModelLoaderEnabled) {
- waitUntilDataspaceIsAvailable(NCMP_DATASPACE_NAME);
- onboardSubscriptionModels();
- log.info("Subscription Models onboarded successfully");
- } else {
- log.info("Subscription Model Loader is disabled");
- }
+ waitUntilDataspaceIsAvailable(NCMP_DATASPACE_NAME);
+ onboardSubscriptionModels();
+ log.info("Subscription Models onboarded successfully");
}
private void onboardSubscriptionModels() {
package org.onap.cps.ncmp.init
-import org.onap.cps.api.CpsAnchorService
-import org.onap.cps.ncmp.api.impl.exception.NcmpStartUpException
-import org.onap.cps.spi.exceptions.AlreadyDefinedException
-
-import static org.onap.cps.ncmp.api.impl.ncmppersistence.NcmpPersistence.NCMP_DATASPACE_NAME
-
import ch.qos.logback.classic.Level
import ch.qos.logback.classic.Logger
import ch.qos.logback.core.read.ListAppender
-import org.onap.cps.api.CpsDataspaceService
+import org.onap.cps.api.CpsAnchorService
import org.onap.cps.api.CpsDataService
+import org.onap.cps.api.CpsDataspaceService
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.model.Dataspace
import org.slf4j.LoggerFactory
import org.springframework.boot.context.event.ApplicationReadyEvent
import org.springframework.context.annotation.AnnotationConfigApplicationContext
import spock.lang.Specification
+import static org.onap.cps.ncmp.api.impl.ncmppersistence.NcmpPersistence.NCMP_DATASPACE_NAME
+
class CmDataSubscriptionModelLoaderSpec extends Specification {
def mockCpsDataspaceService = Mock(CpsDataspaceService)
}
def 'Onboard subscription model via application ready event.'() {
- given:'model loader is enabled'
- objectUnderTest.subscriptionModelLoaderEnabled = true
- and: 'dataspace is ready for use'
+ given: 'dataspace is ready for use'
mockCpsDataspaceService.getDataspace(NCMP_DATASPACE_NAME) >> new Dataspace('')
when: 'the application is ready'
objectUnderTest.onApplicationEvent(Mock(ApplicationReadyEvent))
1 * mockCpsDataService.saveData(NCMP_DATASPACE_NAME, 'cm-data-subscriptions', '{"datastores":{}}', _)
and: 'the data service is called once to create datastore for Passthrough-operational'
1 * mockCpsDataService.saveData(NCMP_DATASPACE_NAME, 'cm-data-subscriptions', '/datastores',
- '{"datastore":[{"name":"ncmp-datastore:passthrough-operational","cm-handles":{}}]}', _, _)
+ '{"datastore":[{"name":"ncmp-datastore:passthrough-operational","cm-handles":{}}]}', _, _)
and: 'the data service is called once to create datastore for Passthrough-running'
1 * mockCpsDataService.saveData(NCMP_DATASPACE_NAME, 'cm-data-subscriptions', '/datastores',
- '{"datastore":[{"name":"ncmp-datastore:passthrough-running","cm-handles":{}}]}', _, _)
+ '{"datastore":[{"name":"ncmp-datastore:passthrough-running","cm-handles":{}}]}', _, _)
}
def 'Create node for datastore with already defined exception.'() {
- given:'the data service throws an Already Defined exception'
+ given: 'the data service throws an Already Defined exception'
mockCpsDataService.saveData(*_) >> { throw AlreadyDefinedException.forDataNodes([], 'some context') }
when: 'attempt to create datastore'
objectUnderTest.createDatastore('some datastore')
assert thrown.details.contains('test message')
}
- def 'Subscription model loader disabled.' () {
- given: 'model loader is disabled'
- objectUnderTest.subscriptionModelLoaderEnabled = false
- when: 'application is ready'
- objectUnderTest.onApplicationEvent(Mock(ApplicationReadyEvent))
- then: 'no interaction with admin service'
- 0 * mockCpsDataspaceService.getDataspace(_)
- then: 'a message is logged that the function is disabled'
- def logs = loggingListAppender.list.toString()
- assert logs.contains('Subscription Model Loader is disabled')
- }
-
}