summaryrefslogtreecommitdiffstats
path: root/cps-ncmp-service/src
diff options
context:
space:
mode:
authorLee Anjella Macabuhay <lee.anjella.macabuhay@est.tech>2024-02-26 10:37:17 +0000
committerGerrit Code Review <gerrit@onap.org>2024-02-26 10:37:17 +0000
commita167ab14ed2fdaeded5e1a7a9a22614353f47269 (patch)
tree66d716e53fac0cee3b51627218117536003ebe67 /cps-ncmp-service/src
parenta2476b0fab7a68055bd0a4c11487fb11d4706497 (diff)
parentffb7ec84c0a491a26d05ad1017efb1b5fbacf735 (diff)
Merge "Remove subscriptionModelLoader flag"
Diffstat (limited to 'cps-ncmp-service/src')
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/cmsubscription/CmNotificationSubscriptionNcmpInEventConsumer.java9
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/init/CmDataSubscriptionModelLoader.java19
-rw-r--r--cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/cmsubscription/CmNotificationSubscriptionNcmpInEventConsumerSpec.groovy2
-rw-r--r--cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/init/CmDataSubscriptionModelLoaderSpec.groovy35
-rw-r--r--cps-ncmp-service/src/test/resources/application.yml2
5 files changed, 17 insertions, 50 deletions
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/cmsubscription/CmNotificationSubscriptionNcmpInEventConsumer.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/cmsubscription/CmNotificationSubscriptionNcmpInEventConsumer.java
index bc798afeed..d3bde011b3 100644
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/cmsubscription/CmNotificationSubscriptionNcmpInEventConsumer.java
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/cmsubscription/CmNotificationSubscriptionNcmpInEventConsumer.java
@@ -37,9 +37,6 @@ public class CmNotificationSubscriptionNcmpInEventConsumer {
@Value("${notification.enabled:true}")
private boolean notificationFeatureEnabled;
- @Value("${ncmp.model-loader.subscription:false}")
- private boolean subscriptionModelLoaderEnabled;
-
/**
* Consume the specified event.
*
@@ -51,10 +48,8 @@ public class CmNotificationSubscriptionNcmpInEventConsumer {
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());
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/init/CmDataSubscriptionModelLoader.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/init/CmDataSubscriptionModelLoader.java
index 7cee87a2a0..4c31719a29 100644
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/init/CmDataSubscriptionModelLoader.java
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/init/CmDataSubscriptionModelLoader.java
@@ -32,7 +32,6 @@ import org.onap.cps.api.CpsModuleService;
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
@@ -45,24 +44,16 @@ public class CmDataSubscriptionModelLoader extends AbstractModelLoader {
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() {
diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/cmsubscription/CmNotificationSubscriptionNcmpInEventConsumerSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/cmsubscription/CmNotificationSubscriptionNcmpInEventConsumerSpec.groovy
index 6a3d4bef7b..1074229489 100644
--- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/cmsubscription/CmNotificationSubscriptionNcmpInEventConsumerSpec.groovy
+++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/cmsubscription/CmNotificationSubscriptionNcmpInEventConsumerSpec.groovy
@@ -71,8 +71,6 @@ class CmNotificationSubscriptionNcmpInEventConsumerSpec extends MessagingBaseSpe
def consumerRecord = new ConsumerRecord<String, CloudEvent>('topic-name', 0, 0, 'event-key', testCloudEventSent)
and: 'notifications are enabled'
objectUnderTest.notificationFeatureEnabled = true
- and: 'subscription model loader is enabled'
- objectUnderTest.subscriptionModelLoaderEnabled = true
when: 'the valid event is consumed'
objectUnderTest.consumeSubscriptionEvent(consumerRecord)
then: 'an event is logged with level INFO'
diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/init/CmDataSubscriptionModelLoaderSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/init/CmDataSubscriptionModelLoaderSpec.groovy
index bde9961c2f..f3b405b117 100644
--- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/init/CmDataSubscriptionModelLoaderSpec.groovy
+++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/init/CmDataSubscriptionModelLoaderSpec.groovy
@@ -20,24 +20,23 @@
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)
@@ -67,9 +66,7 @@ class CmDataSubscriptionModelLoaderSpec extends Specification {
}
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))
@@ -81,14 +78,14 @@ class CmDataSubscriptionModelLoaderSpec extends Specification {
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')
@@ -110,16 +107,4 @@ class CmDataSubscriptionModelLoaderSpec extends Specification {
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')
- }
-
}
diff --git a/cps-ncmp-service/src/test/resources/application.yml b/cps-ncmp-service/src/test/resources/application.yml
index a4bb4e8124..a3283ff40f 100644
--- a/cps-ncmp-service/src/test/resources/application.yml
+++ b/cps-ncmp-service/src/test/resources/application.yml
@@ -50,8 +50,6 @@ ncmp:
async-executor:
parallelism-level: 3
- model-loader:
- subscription: true
# Custom Hazelcast Config.
hazelcast: