From: egernug Date: Wed, 10 Sep 2025 12:36:13 +0000 (+0100) Subject: Include a cm-handle-state at the top level X-Git-Tag: 3.7.1~8^2 X-Git-Url: https://gerrit.onap.org/r/gitweb?a=commitdiff_plain;h=eca0db664d935b22c065f681f8eb53e0d191f4f5;p=cps.git Include a cm-handle-state at the top level - Added cm-handle-state to YangModelCmHandle - Amended tests to include new property Issue-ID: CPS-2922 Change-Id: I82333eb69b4b5d77a76cb15868d7e7e6865de9e2 Signed-off-by: egernug --- diff --git a/cps-ncmp-rest/docs/openapi/components.yaml b/cps-ncmp-rest/docs/openapi/components.yaml index 25b65750be..74543e698e 100644 --- a/cps-ncmp-rest/docs/openapi/components.yaml +++ b/cps-ncmp-rest/docs/openapi/components.yaml @@ -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: diff --git a/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/util/RestOutputCmHandleMapper.java b/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/util/RestOutputCmHandleMapper.java index 000d96fc67..8d58946f56 100644 --- a/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/util/RestOutputCmHandleMapper.java +++ b/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/util/RestOutputCmHandleMapper.java @@ -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; } } diff --git a/cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/util/RestOutputCmHandleMapperSpec.groovy b/cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/util/RestOutputCmHandleMapperSpec.groovy index 50e2fd4f49..b467e0c2e0 100644 --- a/cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/util/RestOutputCmHandleMapperSpec.groovy +++ b/cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/util/RestOutputCmHandleMapperSpec.groovy @@ -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') } } diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/models/NcmpServiceCmHandle.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/models/NcmpServiceCmHandle.java index 5c928c15f3..09ed1c3453 100644 --- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/models/NcmpServiceCmHandle.java +++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/models/NcmpServiceCmHandle.java @@ -73,4 +73,8 @@ public class NcmpServiceCmHandle { @JsonSetter(nulls = Nulls.AS_EMPTY) private String dataProducerIdentifier; + + @JsonSetter(nulls = Nulls.AS_EMPTY) + private String cmHandleStatus; + } diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/inventory/CmHandleRegistrationService.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/inventory/CmHandleRegistrationService.java index 63e0882aa3..361559290e 100644 --- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/inventory/CmHandleRegistrationService.java +++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/inventory/CmHandleRegistrationService.java @@ -407,7 +407,8 @@ public class CmHandleRegistrationService { ncmpServiceCmHandle, ncmpServiceCmHandle.getModuleSetTag(), ncmpServiceCmHandle.getAlternateId(), - ncmpServiceCmHandle.getDataProducerIdentifier()); + ncmpServiceCmHandle.getDataProducerIdentifier(), + ncmpServiceCmHandle.getCmHandleStatus()); } void removeAlternateIdsFromCache(final Collection yangModelCmHandles) { diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/inventory/models/YangModelCmHandle.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/inventory/models/YangModelCmHandle.java index 18e2ef9fde..fc62c6931e 100644 --- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/inventory/models/YangModelCmHandle.java +++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/inventory/models/YangModelCmHandle.java @@ -77,6 +77,9 @@ public class YangModelCmHandle { @JsonProperty("public-properties") private List 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; } diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/utils/YangDataConverter.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/utils/YangDataConverter.java index 8d7ac9f9a6..ce65f588c4 100644 --- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/utils/YangDataConverter.java +++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/utils/YangDataConverter.java @@ -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(); + + } + } diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/inventory/models/YangModelCmHandleSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/inventory/models/YangModelCmHandleSpec.groovy index 5dd8ca0471..f9b6a32de0 100644 --- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/inventory/models/YangModelCmHandleSpec.groovy +++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/inventory/models/YangModelCmHandleSpec.groovy @@ -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: diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/inventory/sync/ModuleSyncServiceSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/inventory/sync/ModuleSyncServiceSpec.groovy index b4837f7bab..8659718ff9 100644 --- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/inventory/sync/ModuleSyncServiceSpec.groovy +++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/inventory/sync/ModuleSyncServiceSpec.groovy @@ -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, '', '', '') } } diff --git a/docs/api/swagger/ncmp/openapi-inventory.yaml b/docs/api/swagger/ncmp/openapi-inventory.yaml index 02fe9c8fce..7a77fe091f 100644 --- a/docs/api/swagger/ncmp/openapi-inventory.yaml +++ b/docs/api/swagger/ncmp/openapi-inventory.yaml @@ -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: diff --git a/docs/api/swagger/ncmp/openapi.yaml b/docs/api/swagger/ncmp/openapi.yaml index 0e5cd576c2..5b0b0d6493 100644 --- a/docs/api/swagger/ncmp/openapi.yaml +++ b/docs/api/swagger/ncmp/openapi.yaml @@ -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: