Resource Resoulution Service
authorSingal, Kapil (ks220y) <ks220y@att.com>
Thu, 10 Jan 2019 17:50:06 +0000 (12:50 -0500)
committerSingal, Kapil (ks220y) <ks220y@att.com>
Fri, 11 Jan 2019 15:08:58 +0000 (10:08 -0500)
Implement Input Resource Resolution Processor Service along with Resource Resolution Utilities

Change-Id: Ibb4899e415f4b79cd6cd1b190b0f4969b09c3fe4
Issue-ID: CCSDK-936
Signed-off-by: Singal, Kapil (ks220y) <ks220y@att.com>
components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtils.kt
components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeServiceTest.kt
components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/data_types.json
components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDefinitionTest.java
components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionValidationServiceTest.java
components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/BulkResourceSequencingUtilsTest.java
components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceDictionaryUtilsTest.java

index 0187445..58a8207 100644 (file)
@@ -14,7 +14,6 @@
  * See the License for the specific language governing permissions and\r
  * limitations under the License.\r
  */\r
-\r
 package org.onap.ccsdk.apps.controllerblueprints.core.utils\r
 \r
 import com.att.eelf.configuration.EELFLogger\r
@@ -22,6 +21,9 @@ import com.att.eelf.configuration.EELFManager
 import com.fasterxml.jackson.annotation.JsonInclude\r
 import com.fasterxml.jackson.core.type.TypeReference\r
 import com.fasterxml.jackson.databind.JsonNode\r
+import com.fasterxml.jackson.databind.node.ArrayNode\r
+import com.fasterxml.jackson.databind.node.NullNode\r
+import com.fasterxml.jackson.databind.node.ObjectNode\r
 import com.fasterxml.jackson.databind.SerializationFeature\r
 import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper\r
 import kotlinx.coroutines.Dispatchers\r
@@ -40,241 +42,209 @@ import java.nio.charset.Charset
  *\r
  * @author Brinda Santh\r
  */\r
-object JacksonUtils {\r
-    private val log: EELFLogger = EELFManager.getInstance().getLogger(this::class.toString())\r
-\r
-    inline fun <reified T : Any> readValue(content: String): T =\r
-            jacksonObjectMapper().readValue(content, T::class.java)\r
+class JacksonUtils {\r
+    companion object {\r
+        private val log: EELFLogger = EELFManager.getInstance().getLogger(this::class.toString())\r
+        inline fun <reified T : Any> readValue(content: String): T =\r
+                jacksonObjectMapper().readValue(content, T::class.java)\r
+\r
+        fun <T> readValue(content: String, valueType: Class<T>): T? {\r
+            return jacksonObjectMapper().readValue(content, valueType)\r
+        }\r
 \r
-    @JvmStatic\r
-    fun <T> readValue(content: String, valueType: Class<T>): T? {\r
-        return jacksonObjectMapper().readValue(content, valueType)\r
-    }\r
+        fun <T> readValue(node: JsonNode, valueType: Class<T>): T? {\r
+            return jacksonObjectMapper().treeToValue(node, valueType)\r
+        }\r
 \r
-    @JvmStatic\r
-    fun <T> readValue(node: JsonNode, valueType: Class<T>): T? {\r
-        return jacksonObjectMapper().treeToValue(node, valueType)\r
-    }\r
+        fun getContent(fileName: String): String = runBlocking {\r
+            async {\r
+                try {\r
+                    File(fileName).readText(Charsets.UTF_8)\r
+                } catch (e: Exception) {\r
+                    throw BluePrintException("couldn't get file ($fileName) content : ${e.message}")\r
+                }\r
+            }.await()\r
+        }\r
 \r
-    @JvmStatic\r
-    fun getContent(fileName: String): String = runBlocking {\r
-        async {\r
-            try {\r
-                File(fileName).readText(Charsets.UTF_8)\r
-            } catch (e: Exception) {\r
-                throw BluePrintException("couldn't get file ($fileName) content : ${e.message}")\r
+        fun getClassPathFileContent(fileName: String): String {\r
+            return runBlocking {\r
+                withContext(Dispatchers.Default) {\r
+                    IOUtils.toString(JacksonUtils::class.java.classLoader\r
+                            .getResourceAsStream(fileName), Charset.defaultCharset())\r
+                }\r
             }\r
-        }.await()\r
-    }\r
+        }\r
 \r
-    @JvmStatic\r
-    fun getClassPathFileContent(fileName: String): String {\r
-        return runBlocking {\r
-            withContext(Dispatchers.Default) {\r
-                IOUtils.toString(JacksonUtils::class.java.classLoader\r
-                        .getResourceAsStream(fileName), Charset.defaultCharset())\r
-            }\r
+        fun <T> readValueFromFile(fileName: String, valueType: Class<T>): T? {\r
+            val content: String = getContent(fileName)\r
+            return readValue(content, valueType)\r
         }\r
-    }\r
 \r
-    @JvmStatic\r
-    fun <T> readValueFromFile(fileName: String, valueType: Class<T>): T? {\r
-        val content: String = getContent(fileName)\r
-        return readValue(content, valueType)\r
-    }\r
+        fun <T> readValueFromClassPathFile(fileName: String, valueType: Class<T>): T? {\r
+            val content: String = getClassPathFileContent(fileName)\r
+            return readValue(content, valueType)\r
+        }\r
 \r
-    @JvmStatic\r
-    fun <T> readValueFromClassPathFile(fileName: String, valueType: Class<T>): T? {\r
-        val content: String = getClassPathFileContent(fileName)\r
-        return readValue(content, valueType)\r
-    }\r
+        fun jsonNodeFromObject(from: kotlin.Any): JsonNode {\r
+            return jacksonObjectMapper().convertValue(from, JsonNode::class.java)\r
+        }\r
 \r
-    @JvmStatic\r
-    fun jsonNodeFromObject(from: kotlin.Any): JsonNode = jacksonObjectMapper().convertValue(from, JsonNode::class.java)\r
+        fun jsonNodeFromClassPathFile(fileName: String): JsonNode {\r
+            val content: String = getClassPathFileContent(fileName)\r
+            return jsonNode(content)\r
+        }\r
 \r
-    @JvmStatic\r
-    fun jsonNodeFromClassPathFile(fileName: String): JsonNode {\r
-        val content: String = getClassPathFileContent(fileName)\r
-        return jsonNode(content)\r
-    }\r
+        fun jsonNodeFromFile(fileName: String): JsonNode {\r
+            val content: String = getContent(fileName)\r
+            return jsonNode(content)\r
+        }\r
 \r
-    @JvmStatic\r
-    fun jsonNodeFromFile(fileName: String): JsonNode {\r
-        val content: String = getContent(fileName)\r
-        return jsonNode(content)\r
-    }\r
+        fun jsonNode(content: String): JsonNode {\r
+            return jacksonObjectMapper().readTree(content)\r
+        }\r
 \r
-    @JvmStatic\r
-    fun jsonNode(content: String): JsonNode {\r
-        return jacksonObjectMapper().readTree(content)\r
-    }\r
+        fun getJson(any: kotlin.Any): String {\r
+            return getJson(any, false)\r
+        }\r
 \r
-    @JvmStatic\r
-    fun getJson(any: kotlin.Any): String {\r
-        return getJson(any, false)\r
-    }\r
+        fun getWrappedJson(wrapper: String, any: kotlin.Any, pretty: Boolean = false): String {\r
+            val wrapperMap = hashMapOf<String, Any>()\r
+            wrapperMap[wrapper] = any\r
+            return getJson(wrapperMap, pretty)\r
+        }\r
 \r
-    @JvmStatic\r
-    fun getWrappedJson(wrapper: String, any: kotlin.Any, pretty: Boolean = false): String {\r
-        val wrapperMap = hashMapOf<String, Any>()\r
-        wrapperMap[wrapper] = any\r
-        return getJson(wrapperMap, pretty)\r
-    }\r
+        fun getJson(any: kotlin.Any, pretty: Boolean = false): String {\r
+            val objectMapper = jacksonObjectMapper()\r
+            objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL)\r
+            if (pretty) {\r
+                objectMapper.enable(SerializationFeature.INDENT_OUTPUT)\r
+            }\r
+            return objectMapper.writeValueAsString(any)\r
+        }\r
 \r
-    @JvmStatic\r
-    fun getJson(any: kotlin.Any, pretty: Boolean = false): String {\r
-        val objectMapper = jacksonObjectMapper()\r
-        objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL)\r
-        if (pretty) {\r
-            objectMapper.enable(SerializationFeature.INDENT_OUTPUT)\r
+        fun getJsonNode(any: kotlin.Any?, pretty: Boolean = false): JsonNode {\r
+            val objectMapper = jacksonObjectMapper()\r
+            objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL)\r
+            if (pretty) {\r
+                objectMapper.enable(SerializationFeature.INDENT_OUTPUT)\r
+            }\r
+            return objectMapper.valueToTree(any)\r
         }\r
-        return objectMapper.writeValueAsString(any)\r
-    }\r
 \r
-    @JvmStatic\r
-    fun <T> getListFromJsonNode(node: JsonNode, valueType: Class<T>): List<T>? {\r
-        return getListFromJson(node.toString(), valueType)\r
-    }\r
+        fun <T> getListFromJsonNode(node: JsonNode, valueType: Class<T>): List<T>? {\r
+            return getListFromJson(node.toString(), valueType)\r
+        }\r
 \r
-    @JvmStatic\r
-    fun <T> getListFromJson(content: String, valueType: Class<T>): List<T>? {\r
-        val objectMapper = jacksonObjectMapper()\r
-        val javaType = objectMapper.typeFactory.constructCollectionType(List::class.java, valueType)\r
-        return objectMapper.readValue<List<T>>(content, javaType)\r
-    }\r
+        fun <T> getListFromJson(content: String, valueType: Class<T>): List<T>? {\r
+            val objectMapper = jacksonObjectMapper()\r
+            val javaType = objectMapper.typeFactory.constructCollectionType(List::class.java, valueType)\r
+            return objectMapper.readValue<List<T>>(content, javaType)\r
+        }\r
 \r
-    @JvmStatic\r
-    fun <T> getListFromFile(fileName: String, valueType: Class<T>): List<T>? {\r
-        val content: String = getContent(fileName)\r
-        return getListFromJson(content, valueType)\r
-    }\r
+        fun <T> getListFromFile(fileName: String, valueType: Class<T>): List<T>? {\r
+            val content: String = getContent(fileName)\r
+            return getListFromJson(content, valueType)\r
+        }\r
 \r
-    @JvmStatic\r
-    fun <T> getListFromClassPathFile(fileName: String, valueType: Class<T>): List<T>? {\r
-        val content: String = getClassPathFileContent(fileName)\r
-        return getListFromJson(content, valueType)\r
-    }\r
+        fun <T> getListFromClassPathFile(fileName: String, valueType: Class<T>): List<T>? {\r
+            val content: String = getClassPathFileContent(fileName)\r
+            return getListFromJson(content, valueType)\r
+        }\r
 \r
-    @JvmStatic\r
-    fun <T> getMapFromJson(content: String, valueType: Class<T>): MutableMap<String, T>? {\r
-        val objectMapper = jacksonObjectMapper()\r
-        val typeRef = object : TypeReference<MutableMap<String, T>>() {}\r
-        return objectMapper.readValue(content, typeRef)\r
-    }\r
+        fun <T> getMapFromJson(content: String, valueType: Class<T>): MutableMap<String, T>? {\r
+            val objectMapper = jacksonObjectMapper()\r
+            val typeRef = object : TypeReference<MutableMap<String, T>>() {}\r
+            return objectMapper.readValue(content, typeRef)\r
+        }\r
 \r
-    @JvmStatic\r
-    fun <T> getMapFromFile(fileName: String, valueType: Class<T>): MutableMap<String, T>? {\r
-        val content: String = getContent(fileName)\r
-        return getMapFromJson(content, valueType)\r
-    }\r
+        fun <T> getMapFromFile(fileName: String, valueType: Class<T>): MutableMap<String, T>? {\r
+            val content: String = getContent(fileName)\r
+            return getMapFromJson(content, valueType)\r
+        }\r
 \r
-    @JvmStatic\r
-    fun checkJsonNodeValueOfType(type: String, jsonNode: JsonNode): Boolean {\r
-        if (BluePrintTypes.validPrimitiveTypes().contains(type)) {\r
-            return checkJsonNodeValueOfPrimitiveType(type, jsonNode)\r
-        } else if (BluePrintTypes.validCollectionTypes().contains(type)) {\r
-            return checkJsonNodeValueOfCollectionType(type, jsonNode)\r
+        fun checkJsonNodeValueOfType(type: String, jsonNode: JsonNode): Boolean {\r
+            if (BluePrintTypes.validPrimitiveTypes().contains(type)) {\r
+                return checkJsonNodeValueOfPrimitiveType(type, jsonNode)\r
+            } else if (BluePrintTypes.validCollectionTypes().contains(type)) {\r
+                return checkJsonNodeValueOfCollectionType(type, jsonNode)\r
+            }\r
+            return false\r
         }\r
-        return false\r
-    }\r
 \r
-    @JvmStatic\r
-    fun checkJsonNodeValueOfPrimitiveType(primitiveType: String, jsonNode: JsonNode): Boolean {\r
-        when (primitiveType) {\r
-            BluePrintConstants.DATA_TYPE_STRING -> return jsonNode.isTextual\r
-            BluePrintConstants.DATA_TYPE_BOOLEAN -> return jsonNode.isBoolean\r
-            BluePrintConstants.DATA_TYPE_INTEGER -> return jsonNode.isInt\r
-            BluePrintConstants.DATA_TYPE_FLOAT -> return jsonNode.isDouble\r
-            BluePrintConstants.DATA_TYPE_TIMESTAMP -> return jsonNode.isTextual\r
-            else -> return false\r
+        fun checkJsonNodeValueOfPrimitiveType(primitiveType: String, jsonNode: JsonNode): Boolean {\r
+            when (primitiveType) {\r
+                BluePrintConstants.DATA_TYPE_STRING -> return jsonNode.isTextual\r
+                BluePrintConstants.DATA_TYPE_BOOLEAN -> return jsonNode.isBoolean\r
+                BluePrintConstants.DATA_TYPE_INTEGER -> return jsonNode.isInt\r
+                BluePrintConstants.DATA_TYPE_FLOAT -> return jsonNode.isDouble\r
+                BluePrintConstants.DATA_TYPE_TIMESTAMP -> return jsonNode.isTextual\r
+                else -> return false\r
+            }\r
         }\r
-    }\r
 \r
-    @JvmStatic\r
-    fun checkJsonNodeValueOfCollectionType(type: String, jsonNode: JsonNode): Boolean {\r
-        when (type) {\r
-            BluePrintConstants.DATA_TYPE_LIST -> return jsonNode.isArray\r
-            BluePrintConstants.DATA_TYPE_MAP -> return jsonNode.isContainerNode\r
-            else -> return false\r
+        fun checkJsonNodeValueOfCollectionType(type: String, jsonNode: JsonNode): Boolean {\r
+            when (type) {\r
+                BluePrintConstants.DATA_TYPE_LIST -> return jsonNode.isArray\r
+                BluePrintConstants.DATA_TYPE_MAP -> return jsonNode.isContainerNode\r
+                else -> return false\r
+            }\r
         }\r
 \r
-    }\r
-/*\r
-    @JvmStatic\r
-    fun populatePrimitiveValues(key: String, value: Any, primitiveType: String, objectNode: ObjectNode) {\r
-        if (BluePrintConstants.DATA_TYPE_BOOLEAN == primitiveType) {\r
-            objectNode.put(key, value as Boolean)\r
-        } else if (BluePrintConstants.DATA_TYPE_INTEGER == primitiveType) {\r
-            objectNode.put(key, value as Int)\r
-        } else if (BluePrintConstants.DATA_TYPE_FLOAT == primitiveType) {\r
-            objectNode.put(key, value as Float)\r
-        } else if (BluePrintConstants.DATA_TYPE_TIMESTAMP == primitiveType) {\r
-            objectNode.put(key, value as String)\r
-        } else {\r
-            objectNode.put(key, value as String)\r
+        fun populatePrimitiveValues(key: String, value: Any, primitiveType: String, objectNode: ObjectNode) {\r
+            when (primitiveType) {\r
+                BluePrintConstants.DATA_TYPE_BOOLEAN -> objectNode.put(key, value as Boolean)\r
+                BluePrintConstants.DATA_TYPE_INTEGER -> objectNode.put(key, value as Int)\r
+                BluePrintConstants.DATA_TYPE_FLOAT -> objectNode.put(key, value as Float)\r
+                BluePrintConstants.DATA_TYPE_TIMESTAMP -> objectNode.put(key, value as String)\r
+                else -> objectNode.put(key, value as String)\r
+            }\r
         }\r
-    }\r
 \r
-    @JvmStatic\r
-    fun populatePrimitiveValues(value: Any, primitiveType: String, objectNode: ArrayNode) {\r
-        if (BluePrintConstants.DATA_TYPE_BOOLEAN == primitiveType) {\r
-            objectNode.add(value as Boolean)\r
-        } else if (BluePrintConstants.DATA_TYPE_INTEGER == primitiveType) {\r
-            objectNode.add(value as Int)\r
-        } else if (BluePrintConstants.DATA_TYPE_FLOAT == primitiveType) {\r
-            objectNode.add(value as Float)\r
-        } else if (BluePrintConstants.DATA_TYPE_TIMESTAMP == primitiveType) {\r
-            objectNode.add(value as String)\r
-        } else {\r
-            objectNode.add(value as String)\r
+        fun populatePrimitiveValues(value: Any, primitiveType: String, arrayNode: ArrayNode) {\r
+            when (primitiveType) {\r
+                BluePrintConstants.DATA_TYPE_BOOLEAN -> arrayNode.add(value as Boolean)\r
+                BluePrintConstants.DATA_TYPE_INTEGER -> arrayNode.add(value as Int)\r
+                BluePrintConstants.DATA_TYPE_FLOAT -> arrayNode.add(value as Float)\r
+                BluePrintConstants.DATA_TYPE_TIMESTAMP -> arrayNode.add(value as String)\r
+                else -> arrayNode.add(value as String)\r
+            }\r
         }\r
-    }\r
 \r
-    @JvmStatic\r
-    fun populatePrimitiveDefaultValues(key: String, primitiveType: String, objectNode: ObjectNode) {\r
-        if (BluePrintConstants.DATA_TYPE_BOOLEAN == primitiveType) {\r
-            objectNode.put(key, false)\r
-        } else if (BluePrintConstants.DATA_TYPE_INTEGER == primitiveType) {\r
-            objectNode.put(key, 0)\r
-        } else if (BluePrintConstants.DATA_TYPE_FLOAT == primitiveType) {\r
-            objectNode.put(key, 0.0)\r
-        } else {\r
-            objectNode.put(key, "")\r
+        fun populatePrimitiveDefaultValues(key: String, primitiveType: String, objectNode: ObjectNode) {\r
+            when (primitiveType) {\r
+                BluePrintConstants.DATA_TYPE_BOOLEAN -> objectNode.put(key, false)\r
+                BluePrintConstants.DATA_TYPE_INTEGER -> objectNode.put(key, 0)\r
+                BluePrintConstants.DATA_TYPE_FLOAT -> objectNode.put(key, 0.0)\r
+                else -> objectNode.put(key, "")\r
+            }\r
         }\r
-    }\r
 \r
-    @JvmStatic\r
-    fun populatePrimitiveDefaultValuesForArrayNode(primitiveType: String, arrayNode: ArrayNode) {\r
-        if (BluePrintConstants.DATA_TYPE_BOOLEAN == primitiveType) {\r
-            arrayNode.add(false)\r
-        } else if (BluePrintConstants.DATA_TYPE_INTEGER == primitiveType) {\r
-            arrayNode.add(0)\r
-        } else if (BluePrintConstants.DATA_TYPE_FLOAT == primitiveType) {\r
-            arrayNode.add(0.0)\r
-        } else {\r
-            arrayNode.add("")\r
+        fun populatePrimitiveDefaultValuesForArrayNode(primitiveType: String, arrayNode: ArrayNode) {\r
+            when (primitiveType) {\r
+                BluePrintConstants.DATA_TYPE_BOOLEAN -> arrayNode.add(false)\r
+                BluePrintConstants.DATA_TYPE_INTEGER -> arrayNode.add(0)\r
+                BluePrintConstants.DATA_TYPE_FLOAT -> arrayNode.add(0.0)\r
+                else -> arrayNode.add("")\r
+            }\r
         }\r
-    }\r
 \r
-    @JvmStatic\r
-    fun populateJsonNodeValues(key: String, nodeValue: JsonNode?, type: String, objectNode: ObjectNode) {\r
-        if (nodeValue == null || nodeValue is NullNode) {\r
-            objectNode.set(key, nodeValue)\r
-        } else if (BluePrintTypes.validPrimitiveTypes().contains(type)) {\r
-            if (BluePrintConstants.DATA_TYPE_BOOLEAN == type) {\r
-                objectNode.put(key, nodeValue.asBoolean())\r
-            } else if (BluePrintConstants.DATA_TYPE_INTEGER == type) {\r
-                objectNode.put(key, nodeValue.asInt())\r
-            } else if (BluePrintConstants.DATA_TYPE_FLOAT == type) {\r
-                objectNode.put(key, nodeValue.floatValue())\r
-            } else if (BluePrintConstants.DATA_TYPE_TIMESTAMP == type) {\r
-                objectNode.put(key, nodeValue.asText())\r
+        fun populateJsonNodeValues(key: String, nodeValue: JsonNode?, type: String, objectNode: ObjectNode) {\r
+            if (nodeValue == null || nodeValue is NullNode) {\r
+                objectNode.set(key, nodeValue)\r
+            } else if (BluePrintTypes.validPrimitiveTypes().contains(type)) {\r
+                populatePrimitiveValues(key, nodeValue, type, objectNode)\r
             } else {\r
-                objectNode.put(key, nodeValue.asText())\r
+                objectNode.set(key, nodeValue)\r
+            }\r
+        }\r
+\r
+        fun convertPrimitiveResourceValue(type: String, value: String): JsonNode? {\r
+            when (type) {\r
+                BluePrintConstants.DATA_TYPE_BOOLEAN -> return JacksonUtils.getJsonNode(value as Boolean)\r
+                BluePrintConstants.DATA_TYPE_INTEGER -> return JacksonUtils.getJsonNode(value as Int)\r
+                BluePrintConstants.DATA_TYPE_FLOAT -> return JacksonUtils.getJsonNode(value as Float)\r
+                else -> return JacksonUtils.getJsonNode(value)\r
             }\r
-        } else {\r
-            objectNode.set(key, nodeValue)\r
         }\r
     }\r
-    */\r
 }
\ No newline at end of file
index 1dfb89a..c01b14b 100644 (file)
@@ -26,8 +26,7 @@ import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants
 import org.onap.ccsdk.apps.controllerblueprints.core.asJsonPrimitive\r
 import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintMetadataUtils\r
 import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintRuntimeUtils\r
-import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils.jsonNodeFromFile\r
-import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils.jsonNodeFromObject\r
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils\r
 import kotlin.test.assertEquals\r
 import kotlin.test.assertNotNull\r
 \r
@@ -47,7 +46,7 @@ class BluePrintRuntimeServiceTest {
 \r
         val inputDataPath = "src/test/resources/data/default-context.json"\r
 \r
-        val inputNode: JsonNode = jsonNodeFromFile(inputDataPath)\r
+        val inputNode: JsonNode = JacksonUtils.jsonNodeFromFile(inputDataPath)\r
         bluePrintRuntimeService.assignInputs(inputNode)\r
 \r
         val propContext: MutableMap<String, JsonNode> = bluePrintRuntimeService.resolveNodeTemplateProperties("activate-process")\r
@@ -82,9 +81,9 @@ class BluePrintRuntimeServiceTest {
                 "ResourceAssignmentComponent", "process")\r
 \r
         assertNotNull(inContext, "Failed to populate interface input property values")\r
-        assertEquals(inContext["action-name"], jsonNodeFromObject("sample-action"), "Failed to populate parameter action-name")\r
-        assertEquals(inContext["request-id"], jsonNodeFromObject("12345"), "Failed to populate parameter action-name")\r
-    }\r
+        assertEquals(inContext["action-name"], JacksonUtils.jsonNodeFromObject("sample-action"), "Failed to populate parameter action-name")\r
+        assertEquals(inContext["request-id"], JacksonUtils.jsonNodeFromObject("12345"), "Failed to populate parameter action-name")\r
+      }\r
 \r
     @Test\r
     fun testResolveNodeTemplateInterfaceOperationOutputs() {\r
@@ -113,9 +112,9 @@ class BluePrintRuntimeServiceTest {
         val bluePrintRuntimeService = getBluePrintRuntimeService()\r
 \r
         bluePrintRuntimeService.setNodeTemplateAttributeValue("resource-assignment-ra-component", "context1",\r
-                jsonNodeFromObject("context1-value"))\r
+                JacksonUtils.jsonNodeFromObject("context1-value"))\r
         bluePrintRuntimeService.setNodeTemplateAttributeValue("resource-assignment-ra-component", "context2",\r
-                jsonNodeFromObject("context2-value"))\r
+                JacksonUtils.jsonNodeFromObject("context2-value"))\r
 \r
         val keys = listOf("context1", "context2")\r
 \r
index 7d850f2..6d771cd 100644 (file)
           "required": true,
           "type": "string"
         },
+        "service-instance-id": {
+          "required": true,
+          "type": "string"
+        },
+        "vnf-id": {
+          "required": true,
+          "type": "string"
+        },
         "action-name": {
           "required": true,
           "type": "string"
         "hostname": {
           "required": true,
           "type": "string"
+        },
+        "vnf_name": {
+          "required": true,
+          "type": "string"
         }
       },
       "derived_from": "tosca.datatypes.Dynamic"
index fde8000..cb39200 100644 (file)
@@ -31,7 +31,7 @@ public class ResourceDefinitionTest {
     public void testDictionaryDefinitionInputSource(){\r
 \r
         String fileName = basePath + "/input-source.json";\r
-        ResourceDefinition resourceDefinition = JacksonUtils.readValueFromFile(fileName, ResourceDefinition.class);\r
+        ResourceDefinition resourceDefinition = JacksonUtils.Companion.readValueFromFile(fileName, ResourceDefinition.class);\r
         Assert.assertNotNull("Failed to populate dictionaryDefinition for input type", resourceDefinition);\r
     }\r
 \r
@@ -39,7 +39,7 @@ public class ResourceDefinitionTest {
     public void testDictionaryDefinitionDefaultSource(){\r
 \r
         String fileName = basePath + "/default-source.json";\r
-        ResourceDefinition resourceDefinition = JacksonUtils.readValueFromFile(fileName, ResourceDefinition.class);\r
+        ResourceDefinition resourceDefinition = JacksonUtils.Companion.readValueFromFile(fileName, ResourceDefinition.class);\r
         Assert.assertNotNull("Failed to populate dictionaryDefinition for default type", resourceDefinition);\r
     }\r
 \r
@@ -47,14 +47,14 @@ public class ResourceDefinitionTest {
     public void testDictionaryDefinitionDBSource(){\r
 \r
         String fileName = basePath + "/db-source.json";\r
-        ResourceDefinition resourceDefinition = JacksonUtils.readValueFromFile(fileName, ResourceDefinition.class);\r
+        ResourceDefinition resourceDefinition = JacksonUtils.Companion.readValueFromFile(fileName, ResourceDefinition.class);\r
         Assert.assertNotNull("Failed to populate dictionaryDefinition for db type", resourceDefinition);\r
     }\r
 \r
     @Test\r
     public void testDictionaryDefinitionMDSALSource(){\r
         String fileName = basePath + "/mdsal-source.json";\r
-        ResourceDefinition resourceDefinition = JacksonUtils.readValueFromFile(fileName, ResourceDefinition.class);\r
+        ResourceDefinition resourceDefinition = JacksonUtils.Companion.readValueFromFile(fileName, ResourceDefinition.class);\r
         Assert.assertNotNull("Failed to populate dictionaryDefinition for mdsal type", resourceDefinition);\r
     }\r
 }\r
index 2b68585..f5c3567 100644 (file)
@@ -45,7 +45,7 @@ public class ResourceDefinitionValidationServiceTest {
 
     private void testValidate(String fileName) throws Exception {
 
-        ResourceDefinition resourceDefinition = JacksonUtils.readValueFromFile(fileName, ResourceDefinition.class);
+        ResourceDefinition resourceDefinition = JacksonUtils.Companion.readValueFromFile(fileName, ResourceDefinition.class);
         Assert.assertNotNull("Failed to populate dictionaryDefinition for  type", resourceDefinition);
 
         ResourceDefinitionValidationService resourceDictionaryValidationService =
index c7444db..a2c2310 100644 (file)
@@ -30,7 +30,7 @@ public class BulkResourceSequencingUtilsTest {
 \r
     @Test\r
     public void testProcess(){\r
-        List<ResourceAssignment> assignments = JacksonUtils.getListFromClassPathFile("validation/success.json", ResourceAssignment.class);\r
+        List<ResourceAssignment> assignments = JacksonUtils.Companion.getListFromClassPathFile("validation/success.json", ResourceAssignment.class);\r
         Assert.assertNotNull("failed to get ResourceAssignment from validation/success.json ", assignments);\r
         BulkResourceSequencingUtils.process(assignments);\r
     }\r
index 13bf819..fa24138 100644 (file)
@@ -86,7 +86,7 @@ public class ResourceDictionaryUtilsTest {
 \r
     @Test\r
     public void testAssignInputs() {\r
-        JsonNode data = JacksonUtils.jsonNodeFromClassPathFile("data/resource-assignment-input.json");\r
+        JsonNode data = JacksonUtils.Companion.jsonNodeFromClassPathFile("data/resource-assignment-input.json");\r
         Map<String, Object> context = new HashMap<>();\r
         ResourceDictionaryUtils.assignInputs(data, context);\r
         String path = BluePrintConstants.PATH_INPUTS.concat(BluePrintConstants.PATH_DIVIDER).concat("mapValue");\r