1 package org.onap.cps.integration.functional
3 import spock.lang.Ignore
5 import static org.onap.cps.ncmp.api.impl.operations.DatastoreType.PASSTHROUGH_RUNNING;
6 import org.onap.cps.integration.base.CpsIntegrationSpecBase;
7 import org.onap.cps.ncmp.api.impl.events.cmsubscription.service.CmNotificationSubscriptionPersistenceService;
8 import org.springframework.beans.factory.annotation.Autowired;
11 class NcmpCmNotificationSubscriptionSpec extends CpsIntegrationSpecBase {
14 CmNotificationSubscriptionPersistenceService cmNotificationSubscriptionPersistenceService;
16 def 'Adding a new cm notification subscription'() {
17 given: 'there is no ongoing cm subscription for the following'
18 def datastoreType = PASSTHROUGH_RUNNING
19 def cmHandleId = 'ch-1'
21 assert cmNotificationSubscriptionPersistenceService.
22 getOngoingCmNotificationSubscriptionIds(datastoreType,cmHandleId,xpath).size() == 0
23 when: 'we add a new cm notification subscription'
24 cmNotificationSubscriptionPersistenceService.addCmNotificationSubscription(datastoreType,cmHandleId,xpath,
26 then: 'there is an ongoing cm subscription for that CM handle and xpath'
27 assert cmNotificationSubscriptionPersistenceService.isOngoingCmNotificationSubscription(datastoreType,cmHandleId,xpath)
28 and: 'only one subscription id is related to now ongoing cm subscription'
29 assert cmNotificationSubscriptionPersistenceService.
30 getOngoingCmNotificationSubscriptionIds(datastoreType,cmHandleId,xpath).size() == 1
33 def 'Adding a cm notification subscription to the already existing'() {
34 given: 'an ongoing cm subscription with the following details'
35 def datastoreType = PASSTHROUGH_RUNNING
36 def cmHandleId = 'ch-1'
38 when: 'a new cm notification subscription is made for the SAME CM handle and xpath'
39 cmNotificationSubscriptionPersistenceService.addCmNotificationSubscription(datastoreType,cmHandleId,xpath,
41 then: 'it is added to the ongoing list of subscription ids'
42 def subscriptionIds = cmNotificationSubscriptionPersistenceService.getOngoingCmNotificationSubscriptionIds(datastoreType,cmHandleId,xpath)
43 assert subscriptionIds.size() == 2
44 and: 'both subscription ids exists for the CM handle and xpath'
45 assert subscriptionIds.contains("subId-1") && subscriptionIds.contains("subId-2")
48 def 'Removing cm notification subscriber among other subscribers'() {
49 given: 'an ongoing cm subscription with the following details'
50 def datastoreType = PASSTHROUGH_RUNNING
51 def cmHandleId = 'ch-1'
53 and: 'the number of subscribers is as follows'
54 def originalNumberOfSubscribers =
55 cmNotificationSubscriptionPersistenceService.getOngoingCmNotificationSubscriptionIds(datastoreType,cmHandleId,xpath).size()
56 when: 'a subscriber is removed'
57 cmNotificationSubscriptionPersistenceService.removeCmNotificationSubscription(datastoreType,cmHandleId,xpath,'subId-2')
58 then: 'the number of subscribers is reduced by 1'
59 def updatedNumberOfSubscribers =
60 cmNotificationSubscriptionPersistenceService.getOngoingCmNotificationSubscriptionIds(datastoreType,cmHandleId,xpath).size()
61 assert updatedNumberOfSubscribers == originalNumberOfSubscribers-1
64 def 'Removing the LAST cm notification subscriber for a given cm handle, datastore and xpath'() {
65 given: 'an ongoing cm subscription with the following details'
66 def datastoreType = PASSTHROUGH_RUNNING
67 def cmHandleId = 'ch-1'
69 and: 'there is only one subscriber'
70 assert cmNotificationSubscriptionPersistenceService
71 .getOngoingCmNotificationSubscriptionIds(datastoreType,cmHandleId,xpath).size() == 1
72 when: 'only subscriber is removed'
73 cmNotificationSubscriptionPersistenceService.removeCmNotificationSubscription(datastoreType,cmHandleId,xpath,'subId-1')
74 then: 'there are no longer any subscriptions for the cm handle, datastore and xpath'
75 assert !cmNotificationSubscriptionPersistenceService.isOngoingCmNotificationSubscription(datastoreType, cmHandleId, xpath)