URI is not absolute when service name is not set 15/129315/1
authorDylanB95EST <dylan.byrne@est.tech>
Thu, 19 May 2022 10:00:18 +0000 (11:00 +0100)
committerDylanB95EST <dylan.byrne@est.tech>
Thu, 19 May 2022 10:00:22 +0000 (11:00 +0100)
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>
cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/operations/YangModelCmHandleRetriever.java
cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/operations/YangModelCmHandleRetrieverSpec.groovy

index b1ac91d..5063e82 100644 (file)
@@ -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
         );
     }
index beea1fa..5ecc8b0 100644 (file)
@@ -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
+    }
 }