Include a dmi-properties value at the top level 21/142121/1
authoregernug <gerard.nugent@est.tech>
Thu, 25 Sep 2025 14:42:50 +0000 (15:42 +0100)
committeregernug <gerard.nugent@est.tech>
Thu, 25 Sep 2025 14:42:50 +0000 (15:42 +0100)
- Added dmi-properties to YangModelCmHandle
- Amended tests to include new property

Issue-ID: CPS-2987

Change-Id: Ib1b8bc99389afff55d4ab93f2a435fb86769e43e
Signed-off-by: egernug <gerard.nugent@est.tech>
cps-ncmp-rest/docs/openapi/components.yaml
cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/util/RestOutputCmHandleMapper.java
cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/util/RestOutputCmHandleMapperSpec.groovy
cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/models/NcmpServiceCmHandle.java
cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/inventory/CmHandleRegistrationService.java
cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/inventory/models/YangModelCmHandle.java
cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/utils/YangDataConverter.java
cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/inventory/models/YangModelCmHandleSpec.groovy
cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/inventory/sync/ModuleSyncServiceSpec.groovy
docs/api/swagger/ncmp/openapi-inventory.yaml
docs/api/swagger/ncmp/openapi.yaml

index 74543e6..002dca1 100644 (file)
@@ -155,6 +155,9 @@ components:
         cmHandleStatus:
           type: string
           example: "READY"
+        dmiProperties:
+          type: string
+          example: my-dmi-property
     #Module upgrade schema
     UpgradedCmHandles:
       required:
@@ -285,6 +288,9 @@ components:
         cmHandleStatus:
           type: string
           example: "READY"
+        dmiProperties:
+          type: string
+          example: my-dmi-property
     CmHandleCompositeState:
       type: object
       properties:
index 8d58946..d035c48 100644 (file)
@@ -60,6 +60,7 @@ public class RestOutputCmHandleMapper {
         restOutputCmHandle.setAlternateId(ncmpServiceCmHandle.getAlternateId());
         restOutputCmHandle.setDataProducerIdentifier(ncmpServiceCmHandle.getDataProducerIdentifier());
         restOutputCmHandle.setCmHandleStatus(ncmpServiceCmHandle.getCmHandleStatus());
+        restOutputCmHandle.setDmiProperties(ncmpServiceCmHandle.getDmiProperties());
         return restOutputCmHandle;
     }
 }
index b467e0c..8f46513 100644 (file)
@@ -49,6 +49,7 @@ class RestOutputCmHandleMapperSpec extends Specification {
             assert result.alternateId == 'alt-1'
             assert result.cmHandle == 'ch-1'
             assert result.cmHandleStatus == 'REPORTED STATE'
+            assert result.dmiProperties == 'dmi property'
         where:
             scenario                        | includeAdditionalProperties || trustLevel
             'without additional properties' | false                       || null
@@ -60,6 +61,7 @@ class RestOutputCmHandleMapperSpec extends Specification {
         return new NcmpServiceCmHandle(cmHandleId: 'ch-1', additionalProperties: ['additional property key': 'some value'],
                 currentTrustLevel: trustLevel,
                 publicProperties: ['public property key': 'public property value'],
-                alternateId: 'alt-1', compositeState: new CompositeState(cmHandleState: 'ADVISED'), cmHandleStatus: 'REPORTED STATE')
+                alternateId: 'alt-1', compositeState: new CompositeState(cmHandleState: 'ADVISED'), cmHandleStatus: 'REPORTED STATE',
+                dmiProperties: 'dmi property')
     }
 }
index 09ed1c3..2f571f1 100644 (file)
@@ -77,4 +77,7 @@ public class NcmpServiceCmHandle {
     @JsonSetter(nulls = Nulls.AS_EMPTY)
     private String cmHandleStatus;
 
+    @JsonSetter(nulls = Nulls.AS_EMPTY)
+    private String dmiProperties;
+
 }
index 3615592..f6f751e 100644 (file)
@@ -408,7 +408,8 @@ public class CmHandleRegistrationService {
             ncmpServiceCmHandle.getModuleSetTag(),
             ncmpServiceCmHandle.getAlternateId(),
             ncmpServiceCmHandle.getDataProducerIdentifier(),
-            ncmpServiceCmHandle.getCmHandleStatus());
+            ncmpServiceCmHandle.getCmHandleStatus(),
+            ncmpServiceCmHandle.getDmiProperties());
     }
 
     void removeAlternateIdsFromCache(final Collection<YangModelCmHandle> yangModelCmHandles) {
index fc62c69..40009bd 100644 (file)
@@ -80,6 +80,9 @@ public class YangModelCmHandle {
     @JsonProperty("cm-handle-state")
     private String cmHandleStatus;
 
+    @JsonProperty("dmi-properties")
+    private String dmiProperties;
+
     /**
      * Creates a deep copy of Yang Model Cm Handle.
      *
@@ -102,6 +105,7 @@ public class YangModelCmHandle {
         copy.alternateId = original.getAlternateId();
         copy.dataProducerIdentifier = original.getDataProducerIdentifier();
         copy.cmHandleStatus = original.getCmHandleStatus();
+        copy.dmiProperties = original.getDmiProperties();
         return copy;
     }
 
@@ -116,6 +120,7 @@ public class YangModelCmHandle {
      * @param alternateId alternateId
      * @param dataProducerIdentifier dataProducerIdentifier
      * @param cmHandleStatus cm handle status
+     * @param dmiProperties dmi properties
      * @return instance of yangModelCmHandle
      */
     public static YangModelCmHandle toYangModelCmHandle(final String dmiServiceName,
@@ -125,7 +130,8 @@ public class YangModelCmHandle {
                                                         final String moduleSetTag,
                                                         final String alternateId,
                                                         final String dataProducerIdentifier,
-                                                        final String cmHandleStatus) {
+                                                        final String cmHandleStatus,
+                                                        final String dmiProperties) {
         final YangModelCmHandle yangModelCmHandle = new YangModelCmHandle();
         yangModelCmHandle.setId(ncmpServiceCmHandle.getCmHandleId());
         yangModelCmHandle.setDmiServiceName(dmiServiceName);
@@ -139,6 +145,8 @@ public class YangModelCmHandle {
         yangModelCmHandle.setPublicProperties(asYangModelCmHandleProperties(ncmpServiceCmHandle.getPublicProperties()));
         yangModelCmHandle.setCompositeState(ncmpServiceCmHandle.getCompositeState());
         yangModelCmHandle.setCmHandleStatus(cmHandleStatus);
+        yangModelCmHandle.setDmiProperties(dmiProperties);
+
         return yangModelCmHandle;
     }
 
index ce65f58..12b223a 100644 (file)
@@ -60,6 +60,7 @@ public class YangDataConverter {
         ncmpServiceCmHandle.setAlternateId(yangModelCmHandle.getAlternateId());
         ncmpServiceCmHandle.setDataProducerIdentifier(yangModelCmHandle.getDataProducerIdentifier());
         ncmpServiceCmHandle.setCmHandleStatus(yangModelCmHandle.getCmHandleStatus());
+        ncmpServiceCmHandle.setDmiProperties(yangModelCmHandle.getDmiProperties());
         setAdditionalProperties(additionalProperties, ncmpServiceCmHandle);
         setPublicProperties(publicProperties, ncmpServiceCmHandle);
 
@@ -97,7 +98,8 @@ public class YangDataConverter {
                 safeGetLeafValue(cmHandleDataNode, "module-set-tag"),
                 safeGetLeafValue(cmHandleDataNode, "alternate-id"),
                 safeGetLeafValue(cmHandleDataNode, "data-producer-identifier"),
-                safeGetLeafValue(cmHandleDataNode, "cm-handle-state")
+                safeGetLeafValue(cmHandleDataNode, "cm-handle-state"),
+                safeGetLeafValue(cmHandleDataNode, "dmi-properties")
         );
     }
 
@@ -140,6 +142,7 @@ public class YangDataConverter {
         ncmpServiceCmHandle.setAdditionalProperties(additionalProperties);
         ncmpServiceCmHandle.setPublicProperties(publicProperties);
         ncmpServiceCmHandle.setCompositeState(compositeState);
+        ncmpServiceCmHandle.setDmiProperties(ncmpServiceCmHandle.getDmiProperties());
     }
 
     private static void addProperty(final DataNode propertyDataNode, final Map<String, String> propertiesAsMap) {
index f9b6a32..c1fe4f6 100644 (file)
@@ -39,6 +39,7 @@ class YangModelCmHandleSpec extends Specification {
             ncmpServiceCmHandle.cmHandleId = 'cm-handle-id01'
             ncmpServiceCmHandle.additionalProperties = [myAdditionalProperty:'value1']
             ncmpServiceCmHandle.publicProperties = [myPublicProperty:'value2']
+            ncmpServiceCmHandle.dmiProperties = [myDmiProperty:'value3']
         and: 'with a composite state'
             def compositeState = new CompositeStateBuilder()
                 .withCmHandleState(CmHandleState.LOCKED)
@@ -47,7 +48,7 @@ class YangModelCmHandleSpec extends Specification {
                 .withOperationalDataStores(DataStoreSyncState.SYNCHRONIZED, 'some-sync-time').build()
             ncmpServiceCmHandle.setCompositeState(compositeState)
         when: 'it is converted to a yang model cm handle'
-            def objectUnderTest = YangModelCmHandle.toYangModelCmHandle('', '', '', ncmpServiceCmHandle,'my-module-set-tag', 'my-alternate-id', 'my-data-producer-identifier', 'ADVISED')
+            def objectUnderTest = YangModelCmHandle.toYangModelCmHandle('', '', '', ncmpServiceCmHandle,'my-module-set-tag', 'my-alternate-id', 'my-data-producer-identifier', 'ADVISED', 'my-dmi-property')
         then: 'the result has the right size'
             assert objectUnderTest.additionalProperties.size() == 1
         and: 'the result has the correct values for module set tag, alternate ID, and data producer identifier'
@@ -65,12 +66,14 @@ class YangModelCmHandleSpec extends Specification {
             objectUnderTest.getCompositeState() == ncmpServiceCmHandle.getCompositeState()
         and: 'the cm-handle-state is correct'
             assert objectUnderTest.cmHandleStatus == 'ADVISED'
+        and: 'the dmi-properties are correct'
+            assert objectUnderTest.dmiProperties == 'my-dmi-property'
     }
 
     def 'Resolve DMI service name: #scenario and #requiredService service require.'() {
         given: 'a yang model cm handle'
             def objectUnderTest = YangModelCmHandle.toYangModelCmHandle(dmiServiceName, dmiDataServiceName,
-                    dmiModelServiceName, new NcmpServiceCmHandle(cmHandleId: 'cm-handle-id-1'),'', '', '', '')
+                    dmiModelServiceName, new NcmpServiceCmHandle(cmHandleId: 'cm-handle-id-1'),'', '', '', '', '')
         expect:
             assert objectUnderTest.resolveDmiServiceName(requiredService) == expectedService
         where:
index 8659718..af2c7b7 100644 (file)
@@ -139,7 +139,7 @@ class ModuleSyncServiceSpec extends Specification {
             ncmpServiceCmHandle.setCompositeState(new CompositeStateBuilder().withLockReason(MODULE_UPGRADE, '').build())
             def dmiServiceName = 'some service name'
             ncmpServiceCmHandle.cmHandleId = 'upgraded-ch'
-            def yangModelCmHandle = YangModelCmHandle.toYangModelCmHandle(dmiServiceName, '', '', ncmpServiceCmHandle,'', '', '', '')
+            def yangModelCmHandle = YangModelCmHandle.toYangModelCmHandle(dmiServiceName, '', '', ncmpServiceCmHandle,'', '', '', '', '')
         and: 'DMI operations returns some module references for upgraded cm handle'
             def moduleReferences =  [ new ModuleReference('module1','1') ]
             mockDmiModelOperations.getModuleReferences(yangModelCmHandle, NO_MODULE_SET_TAG) >> moduleReferences
@@ -159,7 +159,7 @@ class ModuleSyncServiceSpec extends Specification {
             def ncmpServiceCmHandle = new NcmpServiceCmHandle()
             ncmpServiceCmHandle.setCompositeState(new CompositeStateBuilder().withLockReason(MODULE_UPGRADE, 'Upgrade to ModuleSetTag: ' + tagTo).build())
             ncmpServiceCmHandle.setCmHandleId('cmHandleId-1')
-            def yangModelCmHandle = YangModelCmHandle.toYangModelCmHandle('some service name', '', '', ncmpServiceCmHandle, tagFrom, '', '', '')
+            def yangModelCmHandle = YangModelCmHandle.toYangModelCmHandle('some service name', '', '', ncmpServiceCmHandle, tagFrom, '', '', '', '')
             mockCmHandleQueries.cmHandleHasState('cmHandleId-1', CmHandleState.READY) >> true
         and: 'the module tag (schemaset) exists is #schemaExists'
             mockCpsModuleService.schemaSetExists(NFP_OPERATIONAL_DATASTORE_DATASPACE_NAME, tagTo) >> schemaExists
@@ -186,7 +186,7 @@ class ModuleSyncServiceSpec extends Specification {
         def ncmpServiceCmHandle = new NcmpServiceCmHandle()
         ncmpServiceCmHandle.setCompositeState(new CompositeStateBuilder().withCmHandleState(CmHandleState.ADVISED).build())
         ncmpServiceCmHandle.cmHandleId = 'ch-1'
-        return YangModelCmHandle.toYangModelCmHandle('some service name', '', '', ncmpServiceCmHandle, moduleSetTag, '', '', '')
+        return YangModelCmHandle.toYangModelCmHandle('some service name', '', '', ncmpServiceCmHandle, moduleSetTag, '', '', '', '')
     }
 
 }
index 7a77fe0..61f6667 100644 (file)
@@ -323,6 +323,7 @@ components:
             key: my-property
           moduleSetTag: my-module-set-tag
           trustLevel: COMPLETE
+          dmiProperties: my-dmi-property
         - cmHandle: my-cm-handle
           alternateId: "Subnetwork=Europe,ManagedElement=X123"
           dataProducerIdentifier: my-data-producer-identifier
@@ -333,6 +334,7 @@ components:
             key: my-property
           moduleSetTag: my-module-set-tag
           trustLevel: COMPLETE
+          dmiProperties: my-dmi-property
         createdCmHandles:
         - cmHandle: my-cm-handle
           alternateId: "Subnetwork=Europe,ManagedElement=X123"
@@ -344,6 +346,7 @@ components:
             key: my-property
           moduleSetTag: my-module-set-tag
           trustLevel: COMPLETE
+          dmiProperties: my-dmi-property
         - cmHandle: my-cm-handle
           alternateId: "Subnetwork=Europe,ManagedElement=X123"
           dataProducerIdentifier: my-data-producer-identifier
@@ -354,6 +357,7 @@ components:
             key: my-property
           moduleSetTag: my-module-set-tag
           trustLevel: COMPLETE
+          dmiProperties: my-dmi-property
         dmiPlugin: my-dmi-plugin
         dmiModelPlugin: my-dmi-model-plugin
         upgradedCmHandles:
@@ -411,6 +415,7 @@ components:
           key: my-property
         moduleSetTag: my-module-set-tag
         trustLevel: COMPLETE
+        dmiProperties: my-dmi-property
       properties:
         cmHandle:
           example: my-cm-handle
@@ -443,6 +448,9 @@ components:
         cmHandleStatus:
           example: READY
           type: string
+        dmiProperties:
+          example: my-dmi-property
+          type: string
       required:
       - cmHandle
       type: object
@@ -643,6 +651,7 @@ components:
           lastUpdateTime: 2022-12-31T20:30:40.000+0000
         trustLevel: COMPLETE
         moduleSetTag: my-module-set-tag
+        dmiProperties: my-dmi-property
       properties:
         cmHandle:
           example: my-cm-handle1
@@ -678,6 +687,9 @@ components:
         cmHandleStatus:
           example: READY
           type: string
+        dmiProperties:
+          example: my-dmi-property
+          type: string
       title: CM handle Details
       type: object
     CmHandleCompositeState:
index 5b0b0d6..9d7d979 100644 (file)
@@ -1956,6 +1956,7 @@ components:
           lastUpdateTime: 2022-12-31T20:30:40.000+0000
         trustLevel: COMPLETE
         moduleSetTag: my-module-set-tag
+        dmiProperties: my-dmi-property
       properties:
         cmHandle:
           example: my-cm-handle1
@@ -1991,6 +1992,9 @@ components:
         cmHandleStatus:
           example: READY
           type: string
+        dmiProperties:
+          example: my-dmi-property
+          type: string
       title: CM handle Details
       type: object
     CmHandleCompositeState: