From 33ffcd9a60f464ca2c4a55f9aac0cb35d7aeaa88 Mon Sep 17 00:00:00 2001 From: mpriyank Date: Mon, 12 Feb 2024 16:16:36 +0000 Subject: Update cm-data-subscriptions model - rename leaf-list subscribers to subscriptionIds - code using the same also updated - not creating a new version of model as nobody is using it at the moment Issue-ID: CPS-2088 Change-Id: I43d679047bdfc665b56f262757acc4bbaba2733f Signed-off-by: mpriyank --- ...ficationSubscriptionPersistenceServiceImpl.java | 5 ++- .../ncmp/init/CmDataSubscriptionModelLoader.java | 2 +- .../models/cm-data-subscriptions@2023-11-13.yang | 49 ---------------------- .../models/cm-data-subscriptions@2024-02-12.yang | 49 ++++++++++++++++++++++ ...onSubscriptionPersistenceServiceImplSpec.groovy | 6 +-- .../cps/ncmp/init/AbstractModelLoaderSpec.groovy | 6 +-- .../init/CmDataSubscriptionModelLoaderSpec.groovy | 2 +- 7 files changed, 60 insertions(+), 59 deletions(-) delete mode 100644 cps-ncmp-service/src/main/resources/models/cm-data-subscriptions@2023-11-13.yang create mode 100644 cps-ncmp-service/src/main/resources/models/cm-data-subscriptions@2024-02-12.yang (limited to 'cps-ncmp-service') diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/cmsubscription/service/CmNotificationSubscriptionPersistenceServiceImpl.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/cmsubscription/service/CmNotificationSubscriptionPersistenceServiceImpl.java index ca9adb36b2..63f12ad623 100644 --- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/cmsubscription/service/CmNotificationSubscriptionPersistenceServiceImpl.java +++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/cmsubscription/service/CmNotificationSubscriptionPersistenceServiceImpl.java @@ -37,7 +37,8 @@ import org.springframework.stereotype.Service; public class CmNotificationSubscriptionPersistenceServiceImpl implements CmNotificationSubscriptionPersistenceService { private static final String IS_ONGOING_CM_SUBSCRIPTION_CPS_PATH_QUERY = """ - /datastores/datastore[@name='%s']/cm-handles/cm-handle[@id='%s']/filters/filter[@xpath='%s']"""; + /datastores/datastore[@name='%s']/cm-handles/cm-handle[@id='%s']/filters/filter[@xpath='%s'] + """.trim(); private final CpsQueryService cpsQueryService; @@ -60,7 +61,7 @@ public class CmNotificationSubscriptionPersistenceServiceImpl implements CmNotif if (existingNodes.isEmpty()) { return Collections.emptyList(); } - return (List) existingNodes.iterator().next().getLeaves().get("subscribers"); + return (List) existingNodes.iterator().next().getLeaves().get("subscriptionIds"); } private static String escapeQuotesByDoublingThem(final String inputXpath) { diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/init/CmDataSubscriptionModelLoader.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/init/CmDataSubscriptionModelLoader.java index c0b1f34d49..7cee87a2a0 100644 --- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/init/CmDataSubscriptionModelLoader.java +++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/init/CmDataSubscriptionModelLoader.java @@ -39,7 +39,7 @@ import org.springframework.stereotype.Service; @Service public class CmDataSubscriptionModelLoader extends AbstractModelLoader { - private static final String MODEL_FILENAME = "cm-data-subscriptions@2023-11-13.yang"; + private static final String MODEL_FILENAME = "cm-data-subscriptions@2024-02-12.yang"; private static final String SCHEMASET_NAME = "cm-data-subscriptions"; private static final String ANCHOR_NAME = "cm-data-subscriptions"; private static final String REGISTRY_DATANODE_NAME = "datastores"; diff --git a/cps-ncmp-service/src/main/resources/models/cm-data-subscriptions@2023-11-13.yang b/cps-ncmp-service/src/main/resources/models/cm-data-subscriptions@2023-11-13.yang deleted file mode 100644 index de675b117c..0000000000 --- a/cps-ncmp-service/src/main/resources/models/cm-data-subscriptions@2023-11-13.yang +++ /dev/null @@ -1,49 +0,0 @@ -module cm-data-subscriptions { - yang-version 1.1; - namespace "org:onap:cps:ncmp"; - - prefix cmds; - - revision "2023-11-13" { - description - "First release of cm data (notification) subscriptions model"; - } - - container datastores { - - list datastore { - key "name"; - - leaf name { - type string; - } - - container cm-handles { - - list cm-handle { - key "id"; - - leaf id { - type string; - } - - container filters { - - list filter { - key "xpath"; - - leaf xpath { - type string; - } - - leaf-list subscribers { - type string; - } - - } - } - } - } - } - } -} diff --git a/cps-ncmp-service/src/main/resources/models/cm-data-subscriptions@2024-02-12.yang b/cps-ncmp-service/src/main/resources/models/cm-data-subscriptions@2024-02-12.yang new file mode 100644 index 0000000000..e9d9658eb1 --- /dev/null +++ b/cps-ncmp-service/src/main/resources/models/cm-data-subscriptions@2024-02-12.yang @@ -0,0 +1,49 @@ +module cm-data-subscriptions { + yang-version 1.1; + namespace "org:onap:cps:ncmp"; + + prefix cmds; + + revision "2024-02-12" { + description + "First release of cm data (notification) subscriptions model"; + } + + container datastores { + + list datastore { + key "name"; + + leaf name { + type string; + } + + container cm-handles { + + list cm-handle { + key "id"; + + leaf id { + type string; + } + + container filters { + + list filter { + key "xpath"; + + leaf xpath { + type string; + } + + leaf-list subscriptionIds { + type string; + } + + } + } + } + } + } + } +} diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/cmsubscription/service/CmNotificationSubscriptionPersistenceServiceImplSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/cmsubscription/service/CmNotificationSubscriptionPersistenceServiceImplSpec.groovy index f6103ef3ba..e951c31094 100644 --- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/cmsubscription/service/CmNotificationSubscriptionPersistenceServiceImplSpec.groovy +++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/cmsubscription/service/CmNotificationSubscriptionPersistenceServiceImplSpec.groovy @@ -44,8 +44,8 @@ class CmNotificationSubscriptionPersistenceServiceImplSpec extends Specification then: 'we get expected response' assert response == isOngoingCmSubscription where: 'following scenarios are used' - scenario | dataNode || isOngoingCmSubscription - 'valid datanodes present' | [new DataNode(xpath: '/cps/path', leaves: ['subscribers': ['sub-1', 'sub-2']])] || true - 'no datanodes present' | [] || false + scenario | dataNode || isOngoingCmSubscription + 'valid datanodes present' | [new DataNode(xpath: '/cps/path', leaves: ['subscriptionIds': ['sub-1', 'sub-2']])] || true + 'no datanodes present' | [] || false } } diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/init/AbstractModelLoaderSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/init/AbstractModelLoaderSpec.groovy index a9f24667f8..f122b57634 100644 --- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/init/AbstractModelLoaderSpec.groovy +++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/init/AbstractModelLoaderSpec.groovy @@ -51,7 +51,7 @@ class AbstractModelLoaderSpec extends Specification { def loggingListAppender void setup() { - yangResourceToContentMap = objectUnderTest.createYangResourcesToContentMap('cm-data-subscriptions@2023-11-13.yang') + yangResourceToContentMap = objectUnderTest.createYangResourcesToContentMap('cm-data-subscriptions@2024-02-12.yang') logger.setLevel(Level.DEBUG) loggingListAppender = new ListAppender() logger.addAppender(loggingListAppender) @@ -91,7 +91,7 @@ class AbstractModelLoaderSpec extends Specification { def 'Create schema set.'() { when: 'creating a schema set' - objectUnderTest.createSchemaSet('some dataspace','new name','cm-data-subscriptions@2023-11-13.yang') + objectUnderTest.createSchemaSet('some dataspace','new name','cm-data-subscriptions@2024-02-12.yang') then: 'the operation is delegated to the admin service' 1 * mockCpsModuleService.createSchemaSet('some dataspace','new name',_) } @@ -100,7 +100,7 @@ class AbstractModelLoaderSpec extends Specification { given: 'the module service throws an already defined exception' mockCpsModuleService.createSchemaSet(*_) >> { throw AlreadyDefinedException.forSchemaSet('name','context',null) } when: 'attempt to create a schema set' - objectUnderTest.createSchemaSet('some dataspace','new name','cm-data-subscriptions@2023-11-13.yang') + objectUnderTest.createSchemaSet('some dataspace','new name','cm-data-subscriptions@2024-02-12.yang') then: 'the exception is ignored i.e. no exception thrown up' noExceptionThrown() and: 'the exception message is logged' diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/init/CmDataSubscriptionModelLoaderSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/init/CmDataSubscriptionModelLoaderSpec.groovy index 0e95e123e3..bde9961c2f 100644 --- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/init/CmDataSubscriptionModelLoaderSpec.groovy +++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/init/CmDataSubscriptionModelLoaderSpec.groovy @@ -53,7 +53,7 @@ class CmDataSubscriptionModelLoaderSpec extends Specification { def loggingListAppender void setup() { - expectedYangResourcesToContentMap = objectUnderTest.createYangResourcesToContentMap('cm-data-subscriptions@2023-11-13.yang') + expectedYangResourcesToContentMap = objectUnderTest.createYangResourcesToContentMap('cm-data-subscriptions@2024-02-12.yang') logger.setLevel(Level.DEBUG) loggingListAppender = new ListAppender() logger.addAppender(loggingListAppender) -- cgit 1.2.3-korg