allow null type for primitives 47/94147/3
authorOleg Mitsura <oleg.mitsura@amdocs.com>
Thu, 22 Aug 2019 19:05:01 +0000 (15:05 -0400)
committerOleg Mitsura <oleg.mitsura@amdocs.com>
Tue, 27 Aug 2019 16:50:53 +0000 (12:50 -0400)
(to be consistent with validPrimitiveTypes()
in BluePrintTypes)
TODO: refactor that as well.
This should fix the issue with missing values
in output-type-mapping breaking execution.

Issue-Id: CCSDK-1614

Signed-off-by: Oleg Mitsura <oleg.mitsura@amdocs.com>
Change-Id: Ia209a3bfcdc5fc2ef1179bd46669be2d57426749

ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/JacksonUtils.kt

index 73dff93..1f13453 100644 (file)
@@ -243,7 +243,8 @@ class JacksonUtils {
                 BluePrintConstants.DATA_TYPE_FLOAT,
                 BluePrintConstants.DATA_TYPE_DOUBLE,
                 BluePrintConstants.DATA_TYPE_TIMESTAMP,
-                BluePrintConstants.DATA_TYPE_STRING ->
+                BluePrintConstants.DATA_TYPE_STRING,
+                BluePrintConstants.DATA_TYPE_NULL ->
                     objectNode.set(key, value)
                 else -> throw BluePrintException("populatePrimitiveValues expected only primitive values! Received: ($value)")
             }
@@ -256,7 +257,9 @@ class JacksonUtils {
                 BluePrintConstants.DATA_TYPE_FLOAT,
                 BluePrintConstants.DATA_TYPE_DOUBLE,
                 BluePrintConstants.DATA_TYPE_TIMESTAMP,
-                BluePrintConstants.DATA_TYPE_STRING -> arrayNode.add(value)
+                BluePrintConstants.DATA_TYPE_STRING,
+                BluePrintConstants.DATA_TYPE_NULL ->
+                    arrayNode.add(value)
                 else -> throw BluePrintException("populatePrimitiveValues expected only primitive values! Received: ($value)")
             }
         }
@@ -284,7 +287,7 @@ class JacksonUtils {
             }
         }
 
-        fun populateJsonNodeValues(key: String, nodeValue: JsonNode, type: String, objectNode: ObjectNode) {
+        fun populateJsonNodeValues(key: String, nodeValue: JsonNode?, type: String, objectNode: ObjectNode) {
             if (nodeValue == null || nodeValue is NullNode) {
                 objectNode.set(key, nodeValue)
             } else if (BluePrintTypes.validPrimitiveTypes().contains(type)) {