diff options
author | DylanB95EST <dylan.byrne@est.tech> | 2022-05-19 11:00:18 +0100 |
---|---|---|
committer | DylanB95EST <dylan.byrne@est.tech> | 2022-05-19 11:00:22 +0100 |
commit | ef62391fb034f599f92b113e27f90f7cedc1a5c0 (patch) | |
tree | 50ebed8c15fdd2088fdb39582f512ab5f0f10132 | |
parent | 324eb16687756f1850ffa484f652e117878cf33f (diff) |
URI is not absolute when service name is not set
BUG - URI is not absolute exception when dmi-service-name
is not set in the database, due to null String
Has now been set to null value
Issue-ID: CPS-1043
Change-Id: If48c34d8caee302a1849555755960dccfd26ab7a
Signed-off-by: DylanB95EST <dylan.byrne@est.tech>
2 files changed, 15 insertions, 3 deletions
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/operations/YangModelCmHandleRetriever.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/operations/YangModelCmHandleRetriever.java index b1ac91d7a3..5063e8298a 100644 --- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/operations/YangModelCmHandleRetriever.java +++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/operations/YangModelCmHandleRetriever.java @@ -55,9 +55,9 @@ public class YangModelCmHandleRetriever { ncmpServiceCmHandle.setCmHandleId(cmHandleId); populateCmHandleProperties(cmHandleDataNode, ncmpServiceCmHandle); return YangModelCmHandle.toYangModelCmHandle( - String.valueOf(cmHandleDataNode.getLeaves().get("dmi-service-name")), - String.valueOf(cmHandleDataNode.getLeaves().get("dmi-data-service-name")), - String.valueOf(cmHandleDataNode.getLeaves().get("dmi-model-service-name")), + (String) cmHandleDataNode.getLeaves().get("dmi-service-name"), + (String) cmHandleDataNode.getLeaves().get("dmi-data-service-name"), + (String) cmHandleDataNode.getLeaves().get("dmi-model-service-name"), ncmpServiceCmHandle ); } diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/operations/YangModelCmHandleRetrieverSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/operations/YangModelCmHandleRetrieverSpec.groovy index beea1faada..5ecc8b0da3 100644 --- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/operations/YangModelCmHandleRetrieverSpec.groovy +++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/operations/YangModelCmHandleRetrieverSpec.groovy @@ -79,4 +79,16 @@ class YangModelCmHandleRetrieverSpec extends Specification { and: 'the result is not returned' result == null } + + def "Handling missing service names as null CPS-1043."() { + given: 'the cps data service returns a data node from the DMI registry with empty child and leaf attributes' + def dataNode = new DataNode(childDataNodes:[], leaves: [:]) + mockCpsDataService.getDataNode('NCMP-Admin', 'ncmp-dmi-registry', xpath, INCLUDE_ALL_DESCENDANTS) >> dataNode + when: 'retrieving the yang modelled cm handle' + def result = objectUnderTest.getYangModelCmHandle(cmHandleId) + then: 'the service names ae returned as null' + result.dmiServiceName == null + result.dmiDataServiceName == null + result.dmiModelServiceName == null + } } |