summaryrefslogtreecommitdiffstats
path: root/integration-test/src
diff options
context:
space:
mode:
authoremaclee <lee.anjella.macabuhay@est.tech>2024-03-19 12:43:51 +0000
committeremaclee <lee.anjella.macabuhay@est.tech>2024-03-22 11:39:52 +0000
commitd259f852e527463b38b3b58398bfc7eec8d868c4 (patch)
treef825654442d27c57ea147d3e5846f7d1533941be /integration-test/src
parent4e2c927201143795748e599d205ebe46679c7e05 (diff)
Save new cm notification subscription
Issue-ID: CPS-2043 Change-Id: If1c066a7d1c1f7e1c154714fe06f2566b727634c Signed-off-by: emaclee <lee.anjella.macabuhay@est.tech>
Diffstat (limited to 'integration-test/src')
-rw-r--r--integration-test/src/test/groovy/org/onap/cps/integration/functional/NcmpCmNotificationSubscriptionSpec.groovy46
1 files changed, 46 insertions, 0 deletions
diff --git a/integration-test/src/test/groovy/org/onap/cps/integration/functional/NcmpCmNotificationSubscriptionSpec.groovy b/integration-test/src/test/groovy/org/onap/cps/integration/functional/NcmpCmNotificationSubscriptionSpec.groovy
new file mode 100644
index 0000000000..df74a05b50
--- /dev/null
+++ b/integration-test/src/test/groovy/org/onap/cps/integration/functional/NcmpCmNotificationSubscriptionSpec.groovy
@@ -0,0 +1,46 @@
+package org.onap.cps.integration.functional
+
+import static org.onap.cps.ncmp.api.impl.operations.DatastoreType.PASSTHROUGH_RUNNING;
+import org.onap.cps.integration.base.CpsIntegrationSpecBase;
+import org.onap.cps.ncmp.api.impl.events.cmsubscription.service.CmNotificationSubscriptionPersistenceService;
+import org.springframework.beans.factory.annotation.Autowired;
+
+class NcmpCmNotificationSubscriptionSpec extends CpsIntegrationSpecBase {
+
+ @Autowired
+ CmNotificationSubscriptionPersistenceService cmNotificationSubscriptionPersistenceService;
+
+ def 'Adding a new cm notification subscription'() {
+ given: 'there is no ongoing cm subscription for the following'
+ def datastoreType = PASSTHROUGH_RUNNING
+ def cmHandleId = 'ch-1'
+ def xpath = '/x/y'
+ assert cmNotificationSubscriptionPersistenceService.
+ getOngoingCmNotificationSubscriptionIds(datastoreType,cmHandleId,xpath).size() == 0
+ when: 'we add a new cm notification subscription'
+ cmNotificationSubscriptionPersistenceService.addOrUpdateCmNotificationSubscription(datastoreType,cmHandleId,xpath,
+ 'subId-1')
+ then: 'there is an ongoing cm subscription for that CM handle and xpath'
+ assert cmNotificationSubscriptionPersistenceService.isOngoingCmNotificationSubscription(datastoreType,cmHandleId,xpath)
+ and: 'only one subscription id is related to now ongoing cm subscription'
+ assert cmNotificationSubscriptionPersistenceService.
+ getOngoingCmNotificationSubscriptionIds(datastoreType,cmHandleId,xpath).size() == 1
+ }
+
+ def 'Adding a cm notification subscription to an already existing'() {
+ given: 'an ongoing cm subscription'
+ def datastoreType = PASSTHROUGH_RUNNING
+ def cmHandleId = 'ch-1'
+ def xpath = '/x/y'
+ cmNotificationSubscriptionPersistenceService.addOrUpdateCmNotificationSubscription(datastoreType,cmHandleId,xpath,
+ 'subId-1')
+ when: 'a new cm notification subscription is made for the SAME CM handle and xpath'
+ cmNotificationSubscriptionPersistenceService.addOrUpdateCmNotificationSubscription(datastoreType,cmHandleId,xpath,
+ 'subId-2')
+ then: 'it is added to the ongoing list of subscription ids'
+ def subscriptionIds = cmNotificationSubscriptionPersistenceService.getOngoingCmNotificationSubscriptionIds(datastoreType,cmHandleId,xpath)
+ assert subscriptionIds.size() == 2
+ and: 'both subscription ids exists for the CM handle and xpath'
+ assert subscriptionIds.contains("subId-1") && subscriptionIds.contains("subId-2")
+ }
+}