X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=integration-test%2Fsrc%2Ftest%2Fgroovy%2Forg%2Fonap%2Fcps%2Fintegration%2Ffunctional%2FNcmpCmNotificationSubscriptionSpec.groovy;h=302c7e512c24fe05b5b58596fa4c5786daaa58fa;hb=HEAD;hp=df74a05b50da3b0389321022dfe39996b4c33648;hpb=bdc3fae4230ea23accfae66f250526d51f3b3210;p=cps.git 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 df74a05b5..1f0032ac6 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 @@ -1,3 +1,23 @@ +/* + * ============LICENSE_START======================================================= + * Copyright (C) 2024 Nordix Foundation + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the 'License'); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + package org.onap.cps.integration.functional import static org.onap.cps.ncmp.api.impl.operations.DatastoreType.PASSTHROUGH_RUNNING; @@ -18,7 +38,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,20 +47,68 @@ 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 cm handle but non existing xpath'() { + given: 'an ongoing cm subscription with the following details' + def datastoreType = PASSTHROUGH_RUNNING + def cmHandleId = 'ch-1' + def existingXpath = '/x/y' + assert cmNotificationSubscriptionPersistenceService.isOngoingCmNotificationSubscription(datastoreType,cmHandleId,existingXpath) + and: 'a non existing cm subscription with same datastore name and cm handle but different xpath' + def nonExistingXpath = '/x2/y2' + assert !cmNotificationSubscriptionPersistenceService.isOngoingCmNotificationSubscription(datastoreType,cmHandleId,nonExistingXpath) + when: 'a new cm notification subscription is made for the existing cm handle and non existing xpath' + cmNotificationSubscriptionPersistenceService.addCmNotificationSubscription(datastoreType,cmHandleId, nonExistingXpath, + 'subId-2') + then: 'there is an ongoing cm subscription for that CM handle and xpath' + assert cmNotificationSubscriptionPersistenceService.isOngoingCmNotificationSubscription(datastoreType,cmHandleId,nonExistingXpath) + and: 'only one subscription id is related to now ongoing cm subscription' + assert cmNotificationSubscriptionPersistenceService. + getOngoingCmNotificationSubscriptionIds(datastoreType,cmHandleId,nonExistingXpath).size() == 1 + } + + def 'Adding a cm notification subscription to the already existing cm handle and xpath'() { + 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, - 'subId-2') + cmNotificationSubscriptionPersistenceService.addCmNotificationSubscription(datastoreType,cmHandleId,xpath, + 'subId-3') 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") + assert subscriptionIds.contains("subId-1") && subscriptionIds.contains("subId-3") } + + 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-3') + 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) + } + }