Include a cm-handle-state at the top level 31/142031/4
authoregernug <gerard.nugent@est.tech>
Wed, 10 Sep 2025 12:36:13 +0000 (13:36 +0100)
committeregernug <gerard.nugent@est.tech>
Mon, 22 Sep 2025 09:23:08 +0000 (10:23 +0100)
- Added cm-handle-state to YangModelCmHandle
- Amended tests to include new property

Issue-ID: CPS-2922

Change-Id: I82333eb69b4b5d77a76cb15868d7e7e6865de9e2
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 25b6575..74543e6 100644 (file)
@@ -152,6 +152,9 @@ components:
         dataProducerIdentifier:
           type: string
           example: "my-data-producer-identifier"
+        cmHandleStatus:
+          type: string
+          example: "READY"
     #Module upgrade schema
     UpgradedCmHandles:
       required:
@@ -279,6 +282,9 @@ components:
         dataProducerIdentifier:
           type: string
           example: my-data-producer-identifier
+        cmHandleStatus:
+          type: string
+          example: "READY"
     CmHandleCompositeState:
       type: object
       properties:
index 000d96f..8d58946 100644 (file)
@@ -59,6 +59,7 @@ public class RestOutputCmHandleMapper {
         restOutputCmHandle.setModuleSetTag(ncmpServiceCmHandle.getModuleSetTag());
         restOutputCmHandle.setAlternateId(ncmpServiceCmHandle.getAlternateId());
         restOutputCmHandle.setDataProducerIdentifier(ncmpServiceCmHandle.getDataProducerIdentifier());
+        restOutputCmHandle.setCmHandleStatus(ncmpServiceCmHandle.getCmHandleStatus());
         return restOutputCmHandle;
     }
 }
index 50e2fd4..b467e0c 100644 (file)
@@ -48,6 +48,7 @@ class RestOutputCmHandleMapperSpec extends Specification {
             assert result.publicCmHandleProperties[0].containsKey('public property key')
             assert result.alternateId == 'alt-1'
             assert result.cmHandle == 'ch-1'
+            assert result.cmHandleStatus == 'REPORTED STATE'
         where:
             scenario                        | includeAdditionalProperties || trustLevel
             'without additional properties' | false                       || null
@@ -59,6 +60,6 @@ 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'))
+                alternateId: 'alt-1', compositeState: new CompositeState(cmHandleState: 'ADVISED'), cmHandleStatus: 'REPORTED STATE')
     }
 }
index 5c928c1..09ed1c3 100644 (file)
@@ -73,4 +73,8 @@ public class NcmpServiceCmHandle {
 
     @JsonSetter(nulls = Nulls.AS_EMPTY)
     private String dataProducerIdentifier;
+
+    @JsonSetter(nulls = Nulls.AS_EMPTY)
+    private String cmHandleStatus;
+
 }
index 63e0882..3615592 100644 (file)
@@ -407,7 +407,8 @@ public class CmHandleRegistrationService {
             ncmpServiceCmHandle,
             ncmpServiceCmHandle.getModuleSetTag(),
             ncmpServiceCmHandle.getAlternateId(),
-            ncmpServiceCmHandle.getDataProducerIdentifier());
+            ncmpServiceCmHandle.getDataProducerIdentifier(),
+            ncmpServiceCmHandle.getCmHandleStatus());
     }
 
     void removeAlternateIdsFromCache(final Collection<YangModelCmHandle> yangModelCmHandles) {
index 18e2ef9..fc62c69 100644 (file)
@@ -77,6 +77,9 @@ public class YangModelCmHandle {
     @JsonProperty("public-properties")
     private List<Property> publicProperties;
 
+    @JsonProperty("cm-handle-state")
+    private String cmHandleStatus;
+
     /**
      * Creates a deep copy of Yang Model Cm Handle.
      *
@@ -98,6 +101,7 @@ public class YangModelCmHandle {
         copy.moduleSetTag = original.getModuleSetTag();
         copy.alternateId = original.getAlternateId();
         copy.dataProducerIdentifier = original.getDataProducerIdentifier();
+        copy.cmHandleStatus = original.getCmHandleStatus();
         return copy;
     }
 
@@ -111,6 +115,7 @@ public class YangModelCmHandle {
      * @param moduleSetTag moduleSetTag
      * @param alternateId alternateId
      * @param dataProducerIdentifier dataProducerIdentifier
+     * @param cmHandleStatus cm handle status
      * @return instance of yangModelCmHandle
      */
     public static YangModelCmHandle toYangModelCmHandle(final String dmiServiceName,
@@ -119,7 +124,8 @@ public class YangModelCmHandle {
                                                         final NcmpServiceCmHandle ncmpServiceCmHandle,
                                                         final String moduleSetTag,
                                                         final String alternateId,
-                                                        final String dataProducerIdentifier) {
+                                                        final String dataProducerIdentifier,
+                                                        final String cmHandleStatus) {
         final YangModelCmHandle yangModelCmHandle = new YangModelCmHandle();
         yangModelCmHandle.setId(ncmpServiceCmHandle.getCmHandleId());
         yangModelCmHandle.setDmiServiceName(dmiServiceName);
@@ -132,6 +138,7 @@ public class YangModelCmHandle {
             asYangModelCmHandleProperties(ncmpServiceCmHandle.getAdditionalProperties()));
         yangModelCmHandle.setPublicProperties(asYangModelCmHandleProperties(ncmpServiceCmHandle.getPublicProperties()));
         yangModelCmHandle.setCompositeState(ncmpServiceCmHandle.getCompositeState());
+        yangModelCmHandle.setCmHandleStatus(cmHandleStatus);
         return yangModelCmHandle;
     }
 
index 8d7ac9f..ce65f58 100644 (file)
@@ -59,8 +59,10 @@ public class YangDataConverter {
         ncmpServiceCmHandle.setModuleSetTag(yangModelCmHandle.getModuleSetTag());
         ncmpServiceCmHandle.setAlternateId(yangModelCmHandle.getAlternateId());
         ncmpServiceCmHandle.setDataProducerIdentifier(yangModelCmHandle.getDataProducerIdentifier());
+        ncmpServiceCmHandle.setCmHandleStatus(yangModelCmHandle.getCmHandleStatus());
         setAdditionalProperties(additionalProperties, ncmpServiceCmHandle);
         setPublicProperties(publicProperties, ncmpServiceCmHandle);
+
         return ncmpServiceCmHandle;
     }
 
@@ -88,13 +90,14 @@ public class YangDataConverter {
         ncmpServiceCmHandle.setCmHandleId(cmHandleId);
         populateCmHandleDetails(cmHandleDataNode, ncmpServiceCmHandle);
         return YangModelCmHandle.toYangModelCmHandle(
-                (String) cmHandleDataNode.getLeaves().get("dmi-service-name"),
-                (String) cmHandleDataNode.getLeaves().get("dmi-data-service-name"),
-                (String) cmHandleDataNode.getLeaves().get("dmi-model-service-name"),
+                safeGetLeafValue(cmHandleDataNode, "dmi-service-name"),
+                safeGetLeafValue(cmHandleDataNode, "dmi-data-service-name"),
+                safeGetLeafValue(cmHandleDataNode, "dmi-model-service-name"),
                 ncmpServiceCmHandle,
-                (String) cmHandleDataNode.getLeaves().get("module-set-tag"),
-                (String) cmHandleDataNode.getLeaves().get("alternate-id"),
-                (String) cmHandleDataNode.getLeaves().get("data-producer-identifier")
+                safeGetLeafValue(cmHandleDataNode, "module-set-tag"),
+                safeGetLeafValue(cmHandleDataNode, "alternate-id"),
+                safeGetLeafValue(cmHandleDataNode, "data-producer-identifier"),
+                safeGetLeafValue(cmHandleDataNode, "cm-handle-state")
         );
     }
 
@@ -153,4 +156,12 @@ public class YangDataConverter {
                                             final NcmpServiceCmHandle ncmpServiceCmHandle) {
         ncmpServiceCmHandle.setPublicProperties(toPropertiesMap(publicProperties));
     }
+
+
+    private static String safeGetLeafValue(final DataNode node, final String leafName) {
+        final Object value = node.getLeaves().get(leafName);
+        return value == null ? null : value.toString();
+
+    }
+
 }
index 5dd8ca0..f9b6a32 100644 (file)
@@ -47,7 +47,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')
+            def objectUnderTest = YangModelCmHandle.toYangModelCmHandle('', '', '', ncmpServiceCmHandle,'my-module-set-tag', 'my-alternate-id', 'my-data-producer-identifier', 'ADVISED')
         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'
@@ -63,12 +63,14 @@ class YangModelCmHandleSpec extends Specification {
         and: 'the composite state matches the composite state of the ncmpServiceCmHandle'
             objectUnderTest.getCompositeState().cmHandleState == CmHandleState.LOCKED
             objectUnderTest.getCompositeState() == ncmpServiceCmHandle.getCompositeState()
+        and: 'the cm-handle-state is correct'
+            assert objectUnderTest.cmHandleStatus == 'ADVISED'
     }
 
     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 b4837f7..8659718 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 02fe9c8..7a77fe0 100644 (file)
@@ -318,6 +318,7 @@ components:
           dataProducerIdentifier: my-data-producer-identifier
           publicCmHandleProperties:
             key: my-property
+          cmHandleStatus: READY
           cmHandleProperties:
             key: my-property
           moduleSetTag: my-module-set-tag
@@ -327,6 +328,7 @@ components:
           dataProducerIdentifier: my-data-producer-identifier
           publicCmHandleProperties:
             key: my-property
+          cmHandleStatus: READY
           cmHandleProperties:
             key: my-property
           moduleSetTag: my-module-set-tag
@@ -337,6 +339,7 @@ components:
           dataProducerIdentifier: my-data-producer-identifier
           publicCmHandleProperties:
             key: my-property
+          cmHandleStatus: READY
           cmHandleProperties:
             key: my-property
           moduleSetTag: my-module-set-tag
@@ -346,6 +349,7 @@ components:
           dataProducerIdentifier: my-data-producer-identifier
           publicCmHandleProperties:
             key: my-property
+          cmHandleStatus: READY
           cmHandleProperties:
             key: my-property
           moduleSetTag: my-module-set-tag
@@ -402,6 +406,7 @@ components:
         dataProducerIdentifier: my-data-producer-identifier
         publicCmHandleProperties:
           key: my-property
+        cmHandleStatus: READY
         cmHandleProperties:
           key: my-property
         moduleSetTag: my-module-set-tag
@@ -435,6 +440,9 @@ components:
         dataProducerIdentifier:
           example: my-data-producer-identifier
           type: string
+        cmHandleStatus:
+          example: READY
+          type: string
       required:
       - cmHandle
       type: object
@@ -616,6 +624,7 @@ components:
         publicCmHandleProperties:
         - key: 3gpp Type
         - key: 3gpp Type
+        cmHandleStatus: READY
         cmHandleProperties:
           key: 3gpp Type
         state:
@@ -666,6 +675,9 @@ components:
         dataProducerIdentifier:
           example: my-data-producer-identifier
           type: string
+        cmHandleStatus:
+          example: READY
+          type: string
       title: CM handle Details
       type: object
     CmHandleCompositeState:
index 0e5cd57..5b0b0d6 100644 (file)
@@ -1937,6 +1937,7 @@ components:
         publicCmHandleProperties:
         - key: 3gpp Type
         - key: 3gpp Type
+        cmHandleStatus: READY
         cmHandleProperties:
           key: 3gpp Type
         state:
@@ -1987,6 +1988,9 @@ components:
         dataProducerIdentifier:
           example: my-data-producer-identifier
           type: string
+        cmHandleStatus:
+          example: READY
+          type: string
       title: CM handle Details
       type: object
     CmHandleCompositeState: