diff options
author | lukegleeson <luke.gleeson@est.tech> | 2023-04-06 15:36:40 +0100 |
---|---|---|
committer | lukegleeson <luke.gleeson@est.tech> | 2023-04-06 15:52:34 +0100 |
commit | 08154cd815640ba673bad8905d7889e3dca9f591 (patch) | |
tree | 52474dfcc253ab0b4dcfe295c87dc61d5f891933 /cps-ncmp-service | |
parent | dd3643411ed8bb581a3147e07606919c3b1675d3 (diff) |
Toggle subscription persistence for model loader
Current implementation will attempt to persist the subscription model for subscription create events even when the model loader is disabled which causes a persistence error. Subscription Model will now be persisted based on whether the model loader is enabled
Issue-ID: CPS-1394
Signed-off-by: lukegleeson <luke.gleeson@est.tech>
Change-Id: I8f8cfc47996eed6b95fd3958996f16c8395dc341
Diffstat (limited to 'cps-ncmp-service')
2 files changed, 15 insertions, 6 deletions
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/event/avc/SubscriptionEventConsumer.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/event/avc/SubscriptionEventConsumer.java index 1361d98ffc..2685ce4ca9 100644 --- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/event/avc/SubscriptionEventConsumer.java +++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/event/avc/SubscriptionEventConsumer.java @@ -44,6 +44,9 @@ public class SubscriptionEventConsumer { @Value("${notification.enabled:true}") private boolean notificationFeatureEnabled; + @Value("${ncmp.model-loader.subscription:false}") + private boolean subscriptionModelLoaderEnabled; + /** * Consume the specified event. * @@ -60,7 +63,9 @@ public class SubscriptionEventConsumer { } if ("CM".equals(event.getDataType().getDataCategory())) { log.debug("Consuming event {} ...", subscriptionEvent); - persistSubscriptionEvent(subscriptionEvent); + if (subscriptionModelLoaderEnabled) { + persistSubscriptionEvent(subscriptionEvent); + } if ("CREATE".equals(subscriptionEvent.getEventType().value())) { log.info("Subscription for ClientID {} with name {} ...", event.getSubscription().getClientID(), diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/event/avc/SubscriptionEventConsumerSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/event/avc/SubscriptionEventConsumerSpec.groovy index 248eb8bbe2..d801e4ddf7 100644 --- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/event/avc/SubscriptionEventConsumerSpec.groovy +++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/event/avc/SubscriptionEventConsumerSpec.groovy @@ -50,6 +50,8 @@ class SubscriptionEventConsumerSpec extends MessagingBaseSpec { def testEventSent = jsonObjectMapper.convertJsonString(jsonData, SubscriptionEvent.class) and: 'notifications are enabled' objectUnderTest.notificationFeatureEnabled = true + and: 'subscription model loader is enabled' + objectUnderTest.subscriptionModelLoaderEnabled = true when: 'the valid event is consumed' objectUnderTest.consumeSubscriptionEvent(testEventSent) then: 'the event is mapped to a yangModelSubscription' @@ -60,18 +62,20 @@ class SubscriptionEventConsumerSpec extends MessagingBaseSpec { 1 * mockSubscriptionEventForwarder.forwardCreateSubscriptionEvent(testEventSent) } - def 'Consume and persist valid CM create message where notifications are disabled'() { + def 'Consume valid CM create message where notifications and model loader are disabled'() { given: 'an event with data category CM' def jsonData = TestUtils.getResourceFileContent('avcSubscriptionCreationEvent.json') def testEventSent = jsonObjectMapper.convertJsonString(jsonData, SubscriptionEvent.class) and: 'notifications are disabled' objectUnderTest.notificationFeatureEnabled = false + and: 'subscription model loader is disabled' + objectUnderTest.subscriptionModelLoaderEnabled = false when: 'the valid event is consumed' objectUnderTest.consumeSubscriptionEvent(testEventSent) - then: 'the event is mapped to a yangModelSubscription' - 1 * mockSubscriptionEventMapper.toYangModelSubscriptionEvent(testEventSent) >> yangModelSubscriptionEvent - and: 'the event is persisted' - 1 * mockSubscriptionPersistence.saveSubscriptionEvent(yangModelSubscriptionEvent) + then: 'the event is not mapped to a yangModelSubscription' + 0 * mockSubscriptionEventMapper.toYangModelSubscriptionEvent(*_) >> yangModelSubscriptionEvent + and: 'the event is not persisted' + 0 * mockSubscriptionPersistence.saveSubscriptionEvent(*_) and: 'the event is not forwarded' 0 * mockSubscriptionEventForwarder.forwardCreateSubscriptionEvent(*_) } |