1 package org.onap.cps.integration.functional
3 import static org.onap.cps.ncmp.api.impl.operations.DatastoreType.PASSTHROUGH_RUNNING;
4 import org.onap.cps.integration.base.CpsIntegrationSpecBase;
5 import org.onap.cps.ncmp.api.impl.events.cmsubscription.service.CmNotificationSubscriptionPersistenceService;
6 import org.springframework.beans.factory.annotation.Autowired;
8 class NcmpCmNotificationSubscriptionSpec extends CpsIntegrationSpecBase {
11 CmNotificationSubscriptionPersistenceService cmNotificationSubscriptionPersistenceService;
13 def 'Adding a new cm notification subscription'() {
14 given: 'there is no ongoing cm subscription for the following'
15 def datastoreType = PASSTHROUGH_RUNNING
16 def cmHandleId = 'ch-1'
18 assert cmNotificationSubscriptionPersistenceService.
19 getOngoingCmNotificationSubscriptionIds(datastoreType,cmHandleId,xpath).size() == 0
20 when: 'we add a new cm notification subscription'
21 cmNotificationSubscriptionPersistenceService.addOrUpdateCmNotificationSubscription(datastoreType,cmHandleId,xpath,
23 then: 'there is an ongoing cm subscription for that CM handle and xpath'
24 assert cmNotificationSubscriptionPersistenceService.isOngoingCmNotificationSubscription(datastoreType,cmHandleId,xpath)
25 and: 'only one subscription id is related to now ongoing cm subscription'
26 assert cmNotificationSubscriptionPersistenceService.
27 getOngoingCmNotificationSubscriptionIds(datastoreType,cmHandleId,xpath).size() == 1
30 def 'Adding a cm notification subscription to an already existing'() {
31 given: 'an ongoing cm subscription'
32 def datastoreType = PASSTHROUGH_RUNNING
33 def cmHandleId = 'ch-1'
35 cmNotificationSubscriptionPersistenceService.addOrUpdateCmNotificationSubscription(datastoreType,cmHandleId,xpath,
37 when: 'a new cm notification subscription is made for the SAME CM handle and xpath'
38 cmNotificationSubscriptionPersistenceService.addOrUpdateCmNotificationSubscription(datastoreType,cmHandleId,xpath,
40 then: 'it is added to the ongoing list of subscription ids'
41 def subscriptionIds = cmNotificationSubscriptionPersistenceService.getOngoingCmNotificationSubscriptionIds(datastoreType,cmHandleId,xpath)
42 assert subscriptionIds.size() == 2
43 and: 'both subscription ids exists for the CM handle and xpath'
44 assert subscriptionIds.contains("subId-1") && subscriptionIds.contains("subId-2")