aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/operations/YangModelCmHandleRetriever.java6
-rw-r--r--cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/operations/YangModelCmHandleRetrieverSpec.groovy12
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
+ }
}