diff options
author | emaclee <lee.anjella.macabuhay@est.tech> | 2024-03-27 12:46:39 +0000 |
---|---|---|
committer | emaclee <lee.anjella.macabuhay@est.tech> | 2024-04-17 12:47:33 +0100 |
commit | edae744d54e3bbb97fe1e1ef8df743e9ca33e862 (patch) | |
tree | 8703bf2858b46b5f3cc5958285750dc76d873983 /integration-test/src | |
parent | c35b43ac28eeb9a88e21d4ec9f38401e540f3d1a (diff) |
Cm Subscription: Remove subscription method
- method to remove a subscription Id from leaflist
- condition if subscription list is empty, remove subscription
all together
Issue-ID: CPS-2164
Change-Id: Id694f441f9675fa9a048e3b824e1f02fae73f87e
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.groovy | 41 |
1 files changed, 35 insertions, 6 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 index df74a05b50..9129f09fb5 100644 --- 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 @@ -18,7 +18,7 @@ class NcmpCmNotificationSubscriptionSpec extends CpsIntegrationSpecBase { assert cmNotificationSubscriptionPersistenceService. getOngoingCmNotificationSubscriptionIds(datastoreType,cmHandleId,xpath).size() == 0 when: 'we add a new cm notification subscription' - cmNotificationSubscriptionPersistenceService.addOrUpdateCmNotificationSubscription(datastoreType,cmHandleId,xpath, + cmNotificationSubscriptionPersistenceService.addCmNotificationSubscription(datastoreType,cmHandleId,xpath, 'subId-1') then: 'there is an ongoing cm subscription for that CM handle and xpath' assert cmNotificationSubscriptionPersistenceService.isOngoingCmNotificationSubscription(datastoreType,cmHandleId,xpath) @@ -27,15 +27,13 @@ class NcmpCmNotificationSubscriptionSpec extends CpsIntegrationSpecBase { getOngoingCmNotificationSubscriptionIds(datastoreType,cmHandleId,xpath).size() == 1 } - def 'Adding a cm notification subscription to an already existing'() { - given: 'an ongoing cm subscription' + def 'Adding a cm notification subscription to the already existing'() { + given: 'an ongoing cm subscription with the following details' 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, + cmNotificationSubscriptionPersistenceService.addCmNotificationSubscription(datastoreType,cmHandleId,xpath, 'subId-2') then: 'it is added to the ongoing list of subscription ids' def subscriptionIds = cmNotificationSubscriptionPersistenceService.getOngoingCmNotificationSubscriptionIds(datastoreType,cmHandleId,xpath) @@ -43,4 +41,35 @@ class NcmpCmNotificationSubscriptionSpec extends CpsIntegrationSpecBase { and: 'both subscription ids exists for the CM handle and xpath' assert subscriptionIds.contains("subId-1") && subscriptionIds.contains("subId-2") } + + def 'Removing cm notification subscriber among other subscribers'() { + given: 'an ongoing cm subscription with the following details' + def datastoreType = PASSTHROUGH_RUNNING + def cmHandleId = 'ch-1' + def xpath = '/x/y' + and: 'the number of subscribers is as follows' + def originalNumberOfSubscribers = + cmNotificationSubscriptionPersistenceService.getOngoingCmNotificationSubscriptionIds(datastoreType,cmHandleId,xpath).size() + when: 'a subscriber is removed' + cmNotificationSubscriptionPersistenceService.removeCmNotificationSubscription(datastoreType,cmHandleId,xpath,'subId-2') + then: 'the number of subscribers is reduced by 1' + def updatedNumberOfSubscribers = + cmNotificationSubscriptionPersistenceService.getOngoingCmNotificationSubscriptionIds(datastoreType,cmHandleId,xpath).size() + assert updatedNumberOfSubscribers == originalNumberOfSubscribers-1 + } + + def 'Removing the LAST cm notification subscriber for a given cm handle, datastore and xpath'() { + given: 'an ongoing cm subscription with the following details' + def datastoreType = PASSTHROUGH_RUNNING + def cmHandleId = 'ch-1' + def xpath = '/x/y' + and: 'there is only one subscriber' + assert cmNotificationSubscriptionPersistenceService + .getOngoingCmNotificationSubscriptionIds(datastoreType,cmHandleId,xpath).size() == 1 + when: 'only subscriber is removed' + cmNotificationSubscriptionPersistenceService.removeCmNotificationSubscription(datastoreType,cmHandleId,xpath,'subId-1') + then: 'there are no longer any subscriptions for the cm handle, datastore and xpath' + assert !cmNotificationSubscriptionPersistenceService.isOngoingCmNotificationSubscription(datastoreType, cmHandleId, xpath) + } + } |