aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--components/core/pom.xml6
-rw-r--r--components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/data/BluePrintModel.kt2
-rw-r--r--components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintContext.kt2
-rw-r--r--components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtils.kt364
-rw-r--r--components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintWorkflowValidatorImpl.kt28
-rw-r--r--components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeServiceTest.kt15
-rw-r--r--components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintValidatorServiceImplTest.kt72
-rw-r--r--components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/data_types.json12
-rw-r--r--components/parent/pom.xml11
-rw-r--r--components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDefinitionTest.java8
-rw-r--r--components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionValidationServiceTest.java2
-rw-r--r--components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/BulkResourceSequencingUtilsTest.java2
-rw-r--r--components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceDictionaryUtilsTest.java2
-rw-r--r--ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/utils/PythonExecutorUtils.kt5
-rw-r--r--ms/blueprintsprocessor/functions/python-executor/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/utils/PythonExecutorUtilsTest.kt2
-rw-r--r--ms/blueprintsprocessor/functions/python-executor/src/test/resources/requests/sample-activate-request.json31
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceAssignmentRuntimeService.kt58
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/InputResourceAssignmentProcessor.kt17
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/utils/ResourceResolutionUtils.kt127
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionServiceTest.kt9
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/payload/requests/sample-resourceresolution-request.json5
-rw-r--r--ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/SchemaGeneratorService.java2
-rw-r--r--ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/JpaJsonNodeConverter.java4
-rw-r--r--ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/JpaResourceDefinitionConverter.java4
-rw-r--r--ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/validator/ServiceTemplateValidator.java6
-rw-r--r--ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/ModelTypeServiceTest.java4
-rw-r--r--ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/ModelTypeReactRepositoryTest.java4
-rw-r--r--ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/ResourceDictionaryReactRepositoryTest.java2
-rw-r--r--ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ModelTypeRestTest.java4
29 files changed, 562 insertions, 248 deletions
diff --git a/components/core/pom.xml b/components/core/pom.xml
index 8b6c524d..631ee007 100644
--- a/components/core/pom.xml
+++ b/components/core/pom.xml
@@ -52,11 +52,17 @@
<groupId>org.yaml</groupId>
<artifactId>snakeyaml</artifactId>
</dependency>
+ <!--Testing dependencies-->
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-test-junit</artifactId>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>io.mockk</groupId>
+ <artifactId>mockk</artifactId>
+ <scope>test</scope>
+ </dependency>
</dependencies>
</project>
diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/data/BluePrintModel.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/data/BluePrintModel.kt
index 9767b2e1..663c1fe6 100644
--- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/data/BluePrintModel.kt
+++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/data/BluePrintModel.kt
@@ -502,7 +502,7 @@ class InterfaceAssignment {
A Node Template specifies the occurrence of a manageable software component as part of an application’s topology model which is defined in a TOSCA Service Template. A Node template is an instance of a specified Node Type and can provide customized properties, constraints or operations which override the defaults provided by its Node Type and its implementations.
*/
-class NodeTemplate {
+open class NodeTemplate {
@get:JsonIgnore
var id: String? = null
var description: String? = null
diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintContext.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintContext.kt
index bc1f4b43..1a6d096d 100644
--- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintContext.kt
+++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintContext.kt
@@ -148,7 +148,7 @@ class BluePrintContext(val serviceTemplate: ServiceTemplate) {
val nodeTemplates: MutableMap<String, NodeTemplate>? = serviceTemplate.topologyTemplate?.nodeTemplates
fun nodeTemplateByName(name: String): NodeTemplate =
- nodeTemplates?.get(name) ?: throw BluePrintException("could't get node template for the name($name) ")
+ nodeTemplates?.get(name) ?: throw BluePrintException("could't get node template for the name($name)")
fun nodeTemplateForNodeType(name: String): MutableMap<String, NodeTemplate>? {
return nodeTemplates?.filterValues { nodeTemplate -> nodeTemplate.type == name }?.toMutableMap()
diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtils.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtils.kt
index 01874455..58a82079 100644
--- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtils.kt
+++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtils.kt
@@ -14,7 +14,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.onap.ccsdk.apps.controllerblueprints.core.utils
import com.att.eelf.configuration.EELFLogger
@@ -22,6 +21,9 @@ import com.att.eelf.configuration.EELFManager
import com.fasterxml.jackson.annotation.JsonInclude
import com.fasterxml.jackson.core.type.TypeReference
import com.fasterxml.jackson.databind.JsonNode
+import com.fasterxml.jackson.databind.node.ArrayNode
+import com.fasterxml.jackson.databind.node.NullNode
+import com.fasterxml.jackson.databind.node.ObjectNode
import com.fasterxml.jackson.databind.SerializationFeature
import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
import kotlinx.coroutines.Dispatchers
@@ -40,241 +42,209 @@ import java.nio.charset.Charset
*
* @author Brinda Santh
*/
-object JacksonUtils {
- private val log: EELFLogger = EELFManager.getInstance().getLogger(this::class.toString())
-
- inline fun <reified T : Any> readValue(content: String): T =
- jacksonObjectMapper().readValue(content, T::class.java)
+class JacksonUtils {
+ companion object {
+ private val log: EELFLogger = EELFManager.getInstance().getLogger(this::class.toString())
+ inline fun <reified T : Any> readValue(content: String): T =
+ jacksonObjectMapper().readValue(content, T::class.java)
+
+ fun <T> readValue(content: String, valueType: Class<T>): T? {
+ return jacksonObjectMapper().readValue(content, valueType)
+ }
- @JvmStatic
- fun <T> readValue(content: String, valueType: Class<T>): T? {
- return jacksonObjectMapper().readValue(content, valueType)
- }
+ fun <T> readValue(node: JsonNode, valueType: Class<T>): T? {
+ return jacksonObjectMapper().treeToValue(node, valueType)
+ }
- @JvmStatic
- fun <T> readValue(node: JsonNode, valueType: Class<T>): T? {
- return jacksonObjectMapper().treeToValue(node, valueType)
- }
+ fun getContent(fileName: String): String = runBlocking {
+ async {
+ try {
+ File(fileName).readText(Charsets.UTF_8)
+ } catch (e: Exception) {
+ throw BluePrintException("couldn't get file ($fileName) content : ${e.message}")
+ }
+ }.await()
+ }
- @JvmStatic
- fun getContent(fileName: String): String = runBlocking {
- async {
- try {
- File(fileName).readText(Charsets.UTF_8)
- } catch (e: Exception) {
- throw BluePrintException("couldn't get file ($fileName) content : ${e.message}")
+ fun getClassPathFileContent(fileName: String): String {
+ return runBlocking {
+ withContext(Dispatchers.Default) {
+ IOUtils.toString(JacksonUtils::class.java.classLoader
+ .getResourceAsStream(fileName), Charset.defaultCharset())
+ }
}
- }.await()
- }
+ }
- @JvmStatic
- fun getClassPathFileContent(fileName: String): String {
- return runBlocking {
- withContext(Dispatchers.Default) {
- IOUtils.toString(JacksonUtils::class.java.classLoader
- .getResourceAsStream(fileName), Charset.defaultCharset())
- }
+ fun <T> readValueFromFile(fileName: String, valueType: Class<T>): T? {
+ val content: String = getContent(fileName)
+ return readValue(content, valueType)
}
- }
- @JvmStatic
- fun <T> readValueFromFile(fileName: String, valueType: Class<T>): T? {
- val content: String = getContent(fileName)
- return readValue(content, valueType)
- }
+ fun <T> readValueFromClassPathFile(fileName: String, valueType: Class<T>): T? {
+ val content: String = getClassPathFileContent(fileName)
+ return readValue(content, valueType)
+ }
- @JvmStatic
- fun <T> readValueFromClassPathFile(fileName: String, valueType: Class<T>): T? {
- val content: String = getClassPathFileContent(fileName)
- return readValue(content, valueType)
- }
+ fun jsonNodeFromObject(from: kotlin.Any): JsonNode {
+ return jacksonObjectMapper().convertValue(from, JsonNode::class.java)
+ }
- @JvmStatic
- fun jsonNodeFromObject(from: kotlin.Any): JsonNode = jacksonObjectMapper().convertValue(from, JsonNode::class.java)
+ fun jsonNodeFromClassPathFile(fileName: String): JsonNode {
+ val content: String = getClassPathFileContent(fileName)
+ return jsonNode(content)
+ }
- @JvmStatic
- fun jsonNodeFromClassPathFile(fileName: String): JsonNode {
- val content: String = getClassPathFileContent(fileName)
- return jsonNode(content)
- }
+ fun jsonNodeFromFile(fileName: String): JsonNode {
+ val content: String = getContent(fileName)
+ return jsonNode(content)
+ }
- @JvmStatic
- fun jsonNodeFromFile(fileName: String): JsonNode {
- val content: String = getContent(fileName)
- return jsonNode(content)
- }
+ fun jsonNode(content: String): JsonNode {
+ return jacksonObjectMapper().readTree(content)
+ }
- @JvmStatic
- fun jsonNode(content: String): JsonNode {
- return jacksonObjectMapper().readTree(content)
- }
+ fun getJson(any: kotlin.Any): String {
+ return getJson(any, false)
+ }
- @JvmStatic
- fun getJson(any: kotlin.Any): String {
- return getJson(any, false)
- }
+ fun getWrappedJson(wrapper: String, any: kotlin.Any, pretty: Boolean = false): String {
+ val wrapperMap = hashMapOf<String, Any>()
+ wrapperMap[wrapper] = any
+ return getJson(wrapperMap, pretty)
+ }
- @JvmStatic
- fun getWrappedJson(wrapper: String, any: kotlin.Any, pretty: Boolean = false): String {
- val wrapperMap = hashMapOf<String, Any>()
- wrapperMap[wrapper] = any
- return getJson(wrapperMap, pretty)
- }
+ fun getJson(any: kotlin.Any, pretty: Boolean = false): String {
+ val objectMapper = jacksonObjectMapper()
+ objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL)
+ if (pretty) {
+ objectMapper.enable(SerializationFeature.INDENT_OUTPUT)
+ }
+ return objectMapper.writeValueAsString(any)
+ }
- @JvmStatic
- fun getJson(any: kotlin.Any, pretty: Boolean = false): String {
- val objectMapper = jacksonObjectMapper()
- objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL)
- if (pretty) {
- objectMapper.enable(SerializationFeature.INDENT_OUTPUT)
+ fun getJsonNode(any: kotlin.Any?, pretty: Boolean = false): JsonNode {
+ val objectMapper = jacksonObjectMapper()
+ objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL)
+ if (pretty) {
+ objectMapper.enable(SerializationFeature.INDENT_OUTPUT)
+ }
+ return objectMapper.valueToTree(any)
}
- return objectMapper.writeValueAsString(any)
- }
- @JvmStatic
- fun <T> getListFromJsonNode(node: JsonNode, valueType: Class<T>): List<T>? {
- return getListFromJson(node.toString(), valueType)
- }
+ fun <T> getListFromJsonNode(node: JsonNode, valueType: Class<T>): List<T>? {
+ return getListFromJson(node.toString(), valueType)
+ }
- @JvmStatic
- fun <T> getListFromJson(content: String, valueType: Class<T>): List<T>? {
- val objectMapper = jacksonObjectMapper()
- val javaType = objectMapper.typeFactory.constructCollectionType(List::class.java, valueType)
- return objectMapper.readValue<List<T>>(content, javaType)
- }
+ fun <T> getListFromJson(content: String, valueType: Class<T>): List<T>? {
+ val objectMapper = jacksonObjectMapper()
+ val javaType = objectMapper.typeFactory.constructCollectionType(List::class.java, valueType)
+ return objectMapper.readValue<List<T>>(content, javaType)
+ }
- @JvmStatic
- fun <T> getListFromFile(fileName: String, valueType: Class<T>): List<T>? {
- val content: String = getContent(fileName)
- return getListFromJson(content, valueType)
- }
+ fun <T> getListFromFile(fileName: String, valueType: Class<T>): List<T>? {
+ val content: String = getContent(fileName)
+ return getListFromJson(content, valueType)
+ }
- @JvmStatic
- fun <T> getListFromClassPathFile(fileName: String, valueType: Class<T>): List<T>? {
- val content: String = getClassPathFileContent(fileName)
- return getListFromJson(content, valueType)
- }
+ fun <T> getListFromClassPathFile(fileName: String, valueType: Class<T>): List<T>? {
+ val content: String = getClassPathFileContent(fileName)
+ return getListFromJson(content, valueType)
+ }
- @JvmStatic
- fun <T> getMapFromJson(content: String, valueType: Class<T>): MutableMap<String, T>? {
- val objectMapper = jacksonObjectMapper()
- val typeRef = object : TypeReference<MutableMap<String, T>>() {}
- return objectMapper.readValue(content, typeRef)
- }
+ fun <T> getMapFromJson(content: String, valueType: Class<T>): MutableMap<String, T>? {
+ val objectMapper = jacksonObjectMapper()
+ val typeRef = object : TypeReference<MutableMap<String, T>>() {}
+ return objectMapper.readValue(content, typeRef)
+ }
- @JvmStatic
- fun <T> getMapFromFile(fileName: String, valueType: Class<T>): MutableMap<String, T>? {
- val content: String = getContent(fileName)
- return getMapFromJson(content, valueType)
- }
+ fun <T> getMapFromFile(fileName: String, valueType: Class<T>): MutableMap<String, T>? {
+ val content: String = getContent(fileName)
+ return getMapFromJson(content, valueType)
+ }
- @JvmStatic
- fun checkJsonNodeValueOfType(type: String, jsonNode: JsonNode): Boolean {
- if (BluePrintTypes.validPrimitiveTypes().contains(type)) {
- return checkJsonNodeValueOfPrimitiveType(type, jsonNode)
- } else if (BluePrintTypes.validCollectionTypes().contains(type)) {
- return checkJsonNodeValueOfCollectionType(type, jsonNode)
+ fun checkJsonNodeValueOfType(type: String, jsonNode: JsonNode): Boolean {
+ if (BluePrintTypes.validPrimitiveTypes().contains(type)) {
+ return checkJsonNodeValueOfPrimitiveType(type, jsonNode)
+ } else if (BluePrintTypes.validCollectionTypes().contains(type)) {
+ return checkJsonNodeValueOfCollectionType(type, jsonNode)
+ }
+ return false
}
- return false
- }
- @JvmStatic
- fun checkJsonNodeValueOfPrimitiveType(primitiveType: String, jsonNode: JsonNode): Boolean {
- when (primitiveType) {
- BluePrintConstants.DATA_TYPE_STRING -> return jsonNode.isTextual
- BluePrintConstants.DATA_TYPE_BOOLEAN -> return jsonNode.isBoolean
- BluePrintConstants.DATA_TYPE_INTEGER -> return jsonNode.isInt
- BluePrintConstants.DATA_TYPE_FLOAT -> return jsonNode.isDouble
- BluePrintConstants.DATA_TYPE_TIMESTAMP -> return jsonNode.isTextual
- else -> return false
+ fun checkJsonNodeValueOfPrimitiveType(primitiveType: String, jsonNode: JsonNode): Boolean {
+ when (primitiveType) {
+ BluePrintConstants.DATA_TYPE_STRING -> return jsonNode.isTextual
+ BluePrintConstants.DATA_TYPE_BOOLEAN -> return jsonNode.isBoolean
+ BluePrintConstants.DATA_TYPE_INTEGER -> return jsonNode.isInt
+ BluePrintConstants.DATA_TYPE_FLOAT -> return jsonNode.isDouble
+ BluePrintConstants.DATA_TYPE_TIMESTAMP -> return jsonNode.isTextual
+ else -> return false
+ }
}
- }
- @JvmStatic
- fun checkJsonNodeValueOfCollectionType(type: String, jsonNode: JsonNode): Boolean {
- when (type) {
- BluePrintConstants.DATA_TYPE_LIST -> return jsonNode.isArray
- BluePrintConstants.DATA_TYPE_MAP -> return jsonNode.isContainerNode
- else -> return false
+ fun checkJsonNodeValueOfCollectionType(type: String, jsonNode: JsonNode): Boolean {
+ when (type) {
+ BluePrintConstants.DATA_TYPE_LIST -> return jsonNode.isArray
+ BluePrintConstants.DATA_TYPE_MAP -> return jsonNode.isContainerNode
+ else -> return false
+ }
}
- }
-/*
- @JvmStatic
- fun populatePrimitiveValues(key: String, value: Any, primitiveType: String, objectNode: ObjectNode) {
- if (BluePrintConstants.DATA_TYPE_BOOLEAN == primitiveType) {
- objectNode.put(key, value as Boolean)
- } else if (BluePrintConstants.DATA_TYPE_INTEGER == primitiveType) {
- objectNode.put(key, value as Int)
- } else if (BluePrintConstants.DATA_TYPE_FLOAT == primitiveType) {
- objectNode.put(key, value as Float)
- } else if (BluePrintConstants.DATA_TYPE_TIMESTAMP == primitiveType) {
- objectNode.put(key, value as String)
- } else {
- objectNode.put(key, value as String)
+ fun populatePrimitiveValues(key: String, value: Any, primitiveType: String, objectNode: ObjectNode) {
+ when (primitiveType) {
+ BluePrintConstants.DATA_TYPE_BOOLEAN -> objectNode.put(key, value as Boolean)
+ BluePrintConstants.DATA_TYPE_INTEGER -> objectNode.put(key, value as Int)
+ BluePrintConstants.DATA_TYPE_FLOAT -> objectNode.put(key, value as Float)
+ BluePrintConstants.DATA_TYPE_TIMESTAMP -> objectNode.put(key, value as String)
+ else -> objectNode.put(key, value as String)
+ }
}
- }
- @JvmStatic
- fun populatePrimitiveValues(value: Any, primitiveType: String, objectNode: ArrayNode) {
- if (BluePrintConstants.DATA_TYPE_BOOLEAN == primitiveType) {
- objectNode.add(value as Boolean)
- } else if (BluePrintConstants.DATA_TYPE_INTEGER == primitiveType) {
- objectNode.add(value as Int)
- } else if (BluePrintConstants.DATA_TYPE_FLOAT == primitiveType) {
- objectNode.add(value as Float)
- } else if (BluePrintConstants.DATA_TYPE_TIMESTAMP == primitiveType) {
- objectNode.add(value as String)
- } else {
- objectNode.add(value as String)
+ fun populatePrimitiveValues(value: Any, primitiveType: String, arrayNode: ArrayNode) {
+ when (primitiveType) {
+ BluePrintConstants.DATA_TYPE_BOOLEAN -> arrayNode.add(value as Boolean)
+ BluePrintConstants.DATA_TYPE_INTEGER -> arrayNode.add(value as Int)
+ BluePrintConstants.DATA_TYPE_FLOAT -> arrayNode.add(value as Float)
+ BluePrintConstants.DATA_TYPE_TIMESTAMP -> arrayNode.add(value as String)
+ else -> arrayNode.add(value as String)
+ }
}
- }
- @JvmStatic
- fun populatePrimitiveDefaultValues(key: String, primitiveType: String, objectNode: ObjectNode) {
- if (BluePrintConstants.DATA_TYPE_BOOLEAN == primitiveType) {
- objectNode.put(key, false)
- } else if (BluePrintConstants.DATA_TYPE_INTEGER == primitiveType) {
- objectNode.put(key, 0)
- } else if (BluePrintConstants.DATA_TYPE_FLOAT == primitiveType) {
- objectNode.put(key, 0.0)
- } else {
- objectNode.put(key, "")
+ fun populatePrimitiveDefaultValues(key: String, primitiveType: String, objectNode: ObjectNode) {
+ when (primitiveType) {
+ BluePrintConstants.DATA_TYPE_BOOLEAN -> objectNode.put(key, false)
+ BluePrintConstants.DATA_TYPE_INTEGER -> objectNode.put(key, 0)
+ BluePrintConstants.DATA_TYPE_FLOAT -> objectNode.put(key, 0.0)
+ else -> objectNode.put(key, "")
+ }
}
- }
- @JvmStatic
- fun populatePrimitiveDefaultValuesForArrayNode(primitiveType: String, arrayNode: ArrayNode) {
- if (BluePrintConstants.DATA_TYPE_BOOLEAN == primitiveType) {
- arrayNode.add(false)
- } else if (BluePrintConstants.DATA_TYPE_INTEGER == primitiveType) {
- arrayNode.add(0)
- } else if (BluePrintConstants.DATA_TYPE_FLOAT == primitiveType) {
- arrayNode.add(0.0)
- } else {
- arrayNode.add("")
+ fun populatePrimitiveDefaultValuesForArrayNode(primitiveType: String, arrayNode: ArrayNode) {
+ when (primitiveType) {
+ BluePrintConstants.DATA_TYPE_BOOLEAN -> arrayNode.add(false)
+ BluePrintConstants.DATA_TYPE_INTEGER -> arrayNode.add(0)
+ BluePrintConstants.DATA_TYPE_FLOAT -> arrayNode.add(0.0)
+ else -> arrayNode.add("")
+ }
}
- }
- @JvmStatic
- 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)) {
- if (BluePrintConstants.DATA_TYPE_BOOLEAN == type) {
- objectNode.put(key, nodeValue.asBoolean())
- } else if (BluePrintConstants.DATA_TYPE_INTEGER == type) {
- objectNode.put(key, nodeValue.asInt())
- } else if (BluePrintConstants.DATA_TYPE_FLOAT == type) {
- objectNode.put(key, nodeValue.floatValue())
- } else if (BluePrintConstants.DATA_TYPE_TIMESTAMP == type) {
- objectNode.put(key, nodeValue.asText())
+ 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)) {
+ populatePrimitiveValues(key, nodeValue, type, objectNode)
} else {
- objectNode.put(key, nodeValue.asText())
+ objectNode.set(key, nodeValue)
+ }
+ }
+
+ fun convertPrimitiveResourceValue(type: String, value: String): JsonNode? {
+ when (type) {
+ BluePrintConstants.DATA_TYPE_BOOLEAN -> return JacksonUtils.getJsonNode(value as Boolean)
+ BluePrintConstants.DATA_TYPE_INTEGER -> return JacksonUtils.getJsonNode(value as Int)
+ BluePrintConstants.DATA_TYPE_FLOAT -> return JacksonUtils.getJsonNode(value as Float)
+ else -> return JacksonUtils.getJsonNode(value)
}
- } else {
- objectNode.set(key, nodeValue)
}
}
- */
} \ No newline at end of file
diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintWorkflowValidatorImpl.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintWorkflowValidatorImpl.kt
index 1a138c3a..f55449ef 100644
--- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintWorkflowValidatorImpl.kt
+++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintWorkflowValidatorImpl.kt
@@ -19,7 +19,10 @@ package org.onap.ccsdk.apps.controllerblueprints.core.validation
import com.att.eelf.configuration.EELFLogger
import com.att.eelf.configuration.EELFManager
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException
+import org.onap.ccsdk.apps.controllerblueprints.core.data.NodeTemplate
import org.onap.ccsdk.apps.controllerblueprints.core.data.Workflow
+import org.onap.ccsdk.apps.controllerblueprints.core.format
import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintTypeValidatorService
import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintWorkflowValidator
import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService
@@ -42,14 +45,35 @@ open class BluePrintWorkflowValidatorImpl(private val bluePrintTypeValidatorServ
// Step Validation Start
paths.add("steps")
- workflow.steps?.forEach { stepName, _ ->
+ workflow.steps?.forEach { stepName, step ->
paths.add(stepName)
paths.joinToString(BluePrintConstants.PATH_DIVIDER)
- // TODO("Step Validation")
+
+ // Validate target
+ step.target?.let {
+ try {
+ val nodeTemplate = bluePrintRuntimeService.bluePrintContext().nodeTemplateByName(it)
+
+ val nodeTypeDerivedFrom = bluePrintRuntimeService.bluePrintContext().nodeTemplateNodeType(it).derivedFrom
+
+ check(nodeTypeDerivedFrom == BluePrintConstants.MODEL_TYPE_NODE_DG) {
+ "NodeType(${nodeTemplate.type}) derived from is '$nodeTypeDerivedFrom', Expected is " +
+ "'${BluePrintConstants.MODEL_TYPE_NODE_DG}'"
+ }
+ } catch (e: Exception) {
+ bluePrintRuntimeService.getBluePrintError()
+ .addError("Failed to validate Workflow($workflowName)'s step($stepName)'s " +
+ "definition", paths.joinToString(BluePrintConstants.PATH_DIVIDER), e.message!!)
+ }
+ }
paths.removeAt(paths.lastIndex)
}
paths.removeAt(paths.lastIndex)
// Step Validation Ends
paths.removeAt(paths.lastIndex)
+
+ workflow.inputs?.let {
+ bluePrintTypeValidatorService.validatePropertyDefinitions(bluePrintRuntimeService, workflow.inputs!!)
+ }
}
} \ No newline at end of file
diff --git a/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeServiceTest.kt b/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeServiceTest.kt
index 1dfb89a5..c01b14b3 100644
--- a/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeServiceTest.kt
+++ b/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeServiceTest.kt
@@ -26,8 +26,7 @@ import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants
import org.onap.ccsdk.apps.controllerblueprints.core.asJsonPrimitive
import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintMetadataUtils
import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintRuntimeUtils
-import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils.jsonNodeFromFile
-import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils.jsonNodeFromObject
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils
import kotlin.test.assertEquals
import kotlin.test.assertNotNull
@@ -47,7 +46,7 @@ class BluePrintRuntimeServiceTest {
val inputDataPath = "src/test/resources/data/default-context.json"
- val inputNode: JsonNode = jsonNodeFromFile(inputDataPath)
+ val inputNode: JsonNode = JacksonUtils.jsonNodeFromFile(inputDataPath)
bluePrintRuntimeService.assignInputs(inputNode)
val propContext: MutableMap<String, JsonNode> = bluePrintRuntimeService.resolveNodeTemplateProperties("activate-process")
@@ -82,9 +81,9 @@ class BluePrintRuntimeServiceTest {
"ResourceAssignmentComponent", "process")
assertNotNull(inContext, "Failed to populate interface input property values")
- assertEquals(inContext["action-name"], jsonNodeFromObject("sample-action"), "Failed to populate parameter action-name")
- assertEquals(inContext["request-id"], jsonNodeFromObject("12345"), "Failed to populate parameter action-name")
- }
+ assertEquals(inContext["action-name"], JacksonUtils.jsonNodeFromObject("sample-action"), "Failed to populate parameter action-name")
+ assertEquals(inContext["request-id"], JacksonUtils.jsonNodeFromObject("12345"), "Failed to populate parameter action-name")
+ }
@Test
fun testResolveNodeTemplateInterfaceOperationOutputs() {
@@ -113,9 +112,9 @@ class BluePrintRuntimeServiceTest {
val bluePrintRuntimeService = getBluePrintRuntimeService()
bluePrintRuntimeService.setNodeTemplateAttributeValue("resource-assignment-ra-component", "context1",
- jsonNodeFromObject("context1-value"))
+ JacksonUtils.jsonNodeFromObject("context1-value"))
bluePrintRuntimeService.setNodeTemplateAttributeValue("resource-assignment-ra-component", "context2",
- jsonNodeFromObject("context2-value"))
+ JacksonUtils.jsonNodeFromObject("context2-value"))
val keys = listOf("context1", "context2")
diff --git a/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintValidatorServiceImplTest.kt b/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintValidatorServiceImplTest.kt
index c98f2ac3..344b0cca 100644
--- a/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintValidatorServiceImplTest.kt
+++ b/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintValidatorServiceImplTest.kt
@@ -16,28 +16,86 @@
package org.onap.ccsdk.apps.controllerblueprints.core.validation
+import io.mockk.every
+import io.mockk.mockk
+import org.junit.Ignore
import org.junit.Test
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintError
+import org.onap.ccsdk.apps.controllerblueprints.core.data.NodeTemplate
+import org.onap.ccsdk.apps.controllerblueprints.core.data.NodeType
+import org.onap.ccsdk.apps.controllerblueprints.core.data.Step
+import org.onap.ccsdk.apps.controllerblueprints.core.data.Workflow
import org.onap.ccsdk.apps.controllerblueprints.core.mock.MockBluePrintTypeValidatorService
+import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintContext
+import org.onap.ccsdk.apps.controllerblueprints.core.service.DefaultBluePrintRuntimeService
import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintMetadataUtils
+import kotlin.test.assertEquals
import kotlin.test.assertTrue
class BluePrintValidatorServiceImplTest {
- val blueprintBasePath: String = ("./../model-catalog/blueprint-model/starter-blueprint/baseconfiguration")
-
+ private val blueprintBasePath: String = ("./../model-catalog/blueprint-model/starter-blueprint/baseconfiguration")
+ private val bluePrintRuntime = BluePrintMetadataUtils.getBluePrintRuntime("1234", blueprintBasePath)
+ private val mockBluePrintTypeValidatorService = MockBluePrintTypeValidatorService()
+ private val defaultBluePrintValidatorService = BluePrintValidatorServiceImpl(mockBluePrintTypeValidatorService)
+ private val workflowValidator = BluePrintWorkflowValidatorImpl(mockBluePrintTypeValidatorService)
@Test
fun testValidateOfType() {
- val bluePrintRuntime = BluePrintMetadataUtils.getBluePrintRuntime("1234", blueprintBasePath)
+ val valid = defaultBluePrintValidatorService.validateBluePrints(bluePrintRuntime)
+ assertTrue(valid, "failed in blueprint Validation")
+ }
+
+ @Test
+ fun testValidateWorkflowFailToFoundNodeTemplate() {
+ val workflowName = "resource-assignment"
- val mockBluePrintTypeValidatorService = MockBluePrintTypeValidatorService()
+ val step = Step()
+ step.target = "TestCaseFailNoNodeTemplate"
+ val workflow = Workflow()
+ workflow.steps = mutableMapOf("test" to step)
+ workflowValidator.validate(bluePrintRuntime, workflowName, workflow)
- val defaultBluePrintValidatorService = BluePrintValidatorServiceImpl(mockBluePrintTypeValidatorService)
+ assertEquals(1, bluePrintRuntime.getBluePrintError().errors.size)
+ assertEquals("Failed to validate Workflow(resource-assignment)'s step(test)'s definition : resource-assignment/steps/test : could't get node template for the name(TestCaseFailNoNodeTemplate)", bluePrintRuntime.getBluePrintError().errors[0])
+ }
- val valid = defaultBluePrintValidatorService.validateBluePrints(bluePrintRuntime)
+ @Test
+ fun testValidateWorkflowFailNodeTemplateNotDgGeneric() {
+ val workflowName = "resource-assignment"
+ val nodeTemplateName = "resource-assignment-process"
- assertTrue(valid, "failed in blueprint Validation")
+ val nodeTemplate = mockk<NodeTemplate>()
+ every { nodeTemplate.type } returns "TestNodeType"
+ val nodeType = mockk<NodeType>()
+ every { nodeType.derivedFrom } returns "tosca.nodes.TEST"
+
+ val blueprintContext = mockk<BluePrintContext>()
+ every { blueprintContext.nodeTemplateByName(nodeTemplateName) } returns nodeTemplate
+ every { blueprintContext.nodeTemplateNodeType(nodeTemplateName) } returns nodeType
+
+ val bluePrintRuntime = mockk<DefaultBluePrintRuntimeService>("1234")
+
+ every { bluePrintRuntime.getBluePrintError() } returns BluePrintError()
+ every { bluePrintRuntime.bluePrintContext() } returns blueprintContext
+
+ val step = Step()
+ step.target = nodeTemplateName
+ val workflow = Workflow()
+ workflow.steps = mutableMapOf("test" to step)
+ workflowValidator.validate(bluePrintRuntime, workflowName, workflow)
+
+ assertEquals(1, bluePrintRuntime.getBluePrintError().errors.size)
+ assertEquals("Failed to validate Workflow(resource-assignment)'s step(test)'s definition : resource-assignment/steps/test : NodeType(TestNodeType) derived from is 'tosca.nodes.TEST', Expected is 'tosca.nodes.DG'", bluePrintRuntime.getBluePrintError().errors[0])
}
+
+ @Test
+ fun testValidateWorkflowSuccess() {
+ val workflowName = "resource-assignment"
+ workflowValidator.validate(bluePrintRuntime, workflowName, bluePrintRuntime.bluePrintContext().workflowByName(workflowName))
+ }
+
}
diff --git a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/data_types.json b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/data_types.json
index 7d850f20..6d771cd6 100644
--- a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/data_types.json
+++ b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/data_types.json
@@ -28,6 +28,14 @@
"required": true,
"type": "string"
},
+ "service-instance-id": {
+ "required": true,
+ "type": "string"
+ },
+ "vnf-id": {
+ "required": true,
+ "type": "string"
+ },
"action-name": {
"required": true,
"type": "string"
@@ -39,6 +47,10 @@
"hostname": {
"required": true,
"type": "string"
+ },
+ "vnf_name": {
+ "required": true,
+ "type": "string"
}
},
"derived_from": "tosca.datatypes.Dynamic"
diff --git a/components/parent/pom.xml b/components/parent/pom.xml
index 1c49aed3..71e2bec0 100644
--- a/components/parent/pom.xml
+++ b/components/parent/pom.xml
@@ -16,7 +16,8 @@
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.onap.ccsdk.apps</groupId>
@@ -40,7 +41,7 @@
<springfox.swagger2.version>2.9.2</springfox.swagger2.version>
<h2database.version>1.4.197</h2database.version>
<onap.logger.slf4j>1.2.2</onap.logger.slf4j>
- <powermock.version>1.7.4</powermock.version>
+ <mockk.version>1.9</mockk.version>
</properties>
<dependencyManagement>
<dependencies>
@@ -189,9 +190,9 @@
<!-- Testing Dependencies -->
<dependency>
- <groupId>org.powermock</groupId>
- <artifactId>powermock-api-mockito2</artifactId>
- <version>${powermock.version}</version>
+ <groupId>io.mockk</groupId>
+ <artifactId>mockk</artifactId>
+ <version>${mockk.version}</version>
<scope>test</scope>
</dependency>
<dependency>
diff --git a/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDefinitionTest.java b/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDefinitionTest.java
index fde80005..cb39200f 100644
--- a/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDefinitionTest.java
+++ b/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDefinitionTest.java
@@ -31,7 +31,7 @@ public class ResourceDefinitionTest {
public void testDictionaryDefinitionInputSource(){
String fileName = basePath + "/input-source.json";
- ResourceDefinition resourceDefinition = JacksonUtils.readValueFromFile(fileName, ResourceDefinition.class);
+ ResourceDefinition resourceDefinition = JacksonUtils.Companion.readValueFromFile(fileName, ResourceDefinition.class);
Assert.assertNotNull("Failed to populate dictionaryDefinition for input type", resourceDefinition);
}
@@ -39,7 +39,7 @@ public class ResourceDefinitionTest {
public void testDictionaryDefinitionDefaultSource(){
String fileName = basePath + "/default-source.json";
- ResourceDefinition resourceDefinition = JacksonUtils.readValueFromFile(fileName, ResourceDefinition.class);
+ ResourceDefinition resourceDefinition = JacksonUtils.Companion.readValueFromFile(fileName, ResourceDefinition.class);
Assert.assertNotNull("Failed to populate dictionaryDefinition for default type", resourceDefinition);
}
@@ -47,14 +47,14 @@ public class ResourceDefinitionTest {
public void testDictionaryDefinitionDBSource(){
String fileName = basePath + "/db-source.json";
- ResourceDefinition resourceDefinition = JacksonUtils.readValueFromFile(fileName, ResourceDefinition.class);
+ ResourceDefinition resourceDefinition = JacksonUtils.Companion.readValueFromFile(fileName, ResourceDefinition.class);
Assert.assertNotNull("Failed to populate dictionaryDefinition for db type", resourceDefinition);
}
@Test
public void testDictionaryDefinitionMDSALSource(){
String fileName = basePath + "/mdsal-source.json";
- ResourceDefinition resourceDefinition = JacksonUtils.readValueFromFile(fileName, ResourceDefinition.class);
+ ResourceDefinition resourceDefinition = JacksonUtils.Companion.readValueFromFile(fileName, ResourceDefinition.class);
Assert.assertNotNull("Failed to populate dictionaryDefinition for mdsal type", resourceDefinition);
}
}
diff --git a/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionValidationServiceTest.java b/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionValidationServiceTest.java
index 2b68585f..f5c3567f 100644
--- a/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionValidationServiceTest.java
+++ b/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionValidationServiceTest.java
@@ -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 =
diff --git a/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/BulkResourceSequencingUtilsTest.java b/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/BulkResourceSequencingUtilsTest.java
index c7444dba..a2c2310b 100644
--- a/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/BulkResourceSequencingUtilsTest.java
+++ b/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/BulkResourceSequencingUtilsTest.java
@@ -30,7 +30,7 @@ public class BulkResourceSequencingUtilsTest {
@Test
public void testProcess(){
- List<ResourceAssignment> assignments = JacksonUtils.getListFromClassPathFile("validation/success.json", ResourceAssignment.class);
+ List<ResourceAssignment> assignments = JacksonUtils.Companion.getListFromClassPathFile("validation/success.json", ResourceAssignment.class);
Assert.assertNotNull("failed to get ResourceAssignment from validation/success.json ", assignments);
BulkResourceSequencingUtils.process(assignments);
}
diff --git a/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceDictionaryUtilsTest.java b/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceDictionaryUtilsTest.java
index 13bf8195..fa241380 100644
--- a/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceDictionaryUtilsTest.java
+++ b/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceDictionaryUtilsTest.java
@@ -86,7 +86,7 @@ public class ResourceDictionaryUtilsTest {
@Test
public void testAssignInputs() {
- JsonNode data = JacksonUtils.jsonNodeFromClassPathFile("data/resource-assignment-input.json");
+ JsonNode data = JacksonUtils.Companion.jsonNodeFromClassPathFile("data/resource-assignment-input.json");
Map<String, Object> context = new HashMap<>();
ResourceDictionaryUtils.assignInputs(data, context);
String path = BluePrintConstants.PATH_INPUTS.concat(BluePrintConstants.PATH_DIVIDER).concat("mapValue");
diff --git a/ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/utils/PythonExecutorUtils.kt b/ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/utils/PythonExecutorUtils.kt
index 66c919d4..341ede58 100644
--- a/ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/utils/PythonExecutorUtils.kt
+++ b/ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/utils/PythonExecutorUtils.kt
@@ -20,6 +20,7 @@ import org.onap.ccsdk.apps.blueprintsprocessor.services.execution.AbstractCompon
import org.python.core.PyObject
import org.python.util.PythonInterpreter
import org.slf4j.LoggerFactory
+import java.io.File
import java.util.*
class PythonExecutorUtils {
@@ -61,9 +62,9 @@ class PythonExecutorUtils {
sb.append(System.getProperty("java.class.path"))
for (p in pythonPath) {
- sb.append(":").append(p)
+ sb.append(File.pathSeparator).append(p)
}
- log.debug("Paths : $sb")
+ log.debug("Python Paths : $sb")
props["python.import.site"] = "true"
props.setProperty("python.path", sb.toString())
diff --git a/ms/blueprintsprocessor/functions/python-executor/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/utils/PythonExecutorUtilsTest.kt b/ms/blueprintsprocessor/functions/python-executor/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/utils/PythonExecutorUtilsTest.kt
index 431c6b82..c4fd5467 100644
--- a/ms/blueprintsprocessor/functions/python-executor/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/utils/PythonExecutorUtilsTest.kt
+++ b/ms/blueprintsprocessor/functions/python-executor/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/utils/PythonExecutorUtilsTest.kt
@@ -30,7 +30,7 @@ class PythonExecutorUtilsTest {
@Test
fun testGetPythonComponent() {
- val pythonPath: MutableList<String> = arrayListOf()
+ val pythonPath: MutableList<String> = mutableListOf()
pythonPath.add("./../../../../components/scripts/python/ccsdk_blueprints")
val properties: MutableMap<String, Any> = hashMapOf()
diff --git a/ms/blueprintsprocessor/functions/python-executor/src/test/resources/requests/sample-activate-request.json b/ms/blueprintsprocessor/functions/python-executor/src/test/resources/requests/sample-activate-request.json
new file mode 100644
index 00000000..7142f045
--- /dev/null
+++ b/ms/blueprintsprocessor/functions/python-executor/src/test/resources/requests/sample-activate-request.json
@@ -0,0 +1,31 @@
+{
+ "actionIdentifiers": {
+ "actionName": "activate",
+ "blueprintName": "baseconfiguration",
+ "blueprintVersion": "1.0.0",
+ "mode": "sync"
+ },
+ "commonHeader": {
+ "flags": {
+ "force": true,
+ "ttl": 3600
+ },
+ "originatorId": "sdnc",
+ "requestId": "123456-1000",
+ "subRequestId": "sub-123456-1000",
+ "timestamp": "2012-04-23T18:25:43.511Z"
+ },
+ "payload": {
+ "resource-assignment-request": {
+ "resource-assignment-properties": {
+ "request-id": "1234",
+ "service-instance-id": "siid_1234",
+ "vnf-id": "vnf_1234",
+ "action-name": "assign-activate",
+ "scope-type": "vnf-type",
+ "hostname": "localhost",
+ "vnf_name": "temp_vnf"
+ }
+ }
+ }
+}
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceAssignmentRuntimeService.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceAssignmentRuntimeService.kt
new file mode 100644
index 00000000..9d6f4a6b
--- /dev/null
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceAssignmentRuntimeService.kt
@@ -0,0 +1,58 @@
+package org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution
+
+import com.fasterxml.jackson.databind.JsonNode
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException
+import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintContext
+import org.onap.ccsdk.apps.controllerblueprints.core.service.DefaultBluePrintRuntimeService
+
+class ResourceAssignmentRuntimeService(private var id: String, private var bluePrintContext: BluePrintContext)
+ : DefaultBluePrintRuntimeService(id, bluePrintContext){
+
+ private var resourceResolutionStore: MutableMap<String, JsonNode> = hashMapOf()
+
+ override fun getExecutionContext(): MutableMap<String, JsonNode> {
+ return resourceResolutionStore
+ }
+
+ @Suppress("UNCHECKED_CAST")
+ override fun setExecutionContext(executionContext: MutableMap<String, JsonNode>) {
+ this.resourceResolutionStore = executionContext
+ }
+
+ override fun put(key: String, value: JsonNode) {
+ resourceResolutionStore[key] = value
+ }
+
+ override fun get(key: String): JsonNode {
+ return resourceResolutionStore[key] ?: throw BluePrintProcessorException("failed to get execution property($key)")
+ }
+
+ override fun check(key: String): Boolean {
+ return resourceResolutionStore.containsKey(key)
+ }
+
+ override fun cleanRuntime() {
+ resourceResolutionStore.clear()
+ }
+
+ private fun getJsonNode(key: String): JsonNode {
+ return get(key)
+ }
+
+ override fun getAsString(key: String): String? {
+ return get(key).asText()
+ }
+
+ override fun getAsBoolean(key: String): Boolean? {
+ return get(key).asBoolean()
+ }
+
+ override fun getAsInt(key: String): Int? {
+ return get(key).asInt()
+ }
+
+ override fun getAsDouble(key: String): Double? {
+ return get(key).asDouble()
+ }
+
+}
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/InputResourceAssignmentProcessor.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/InputResourceAssignmentProcessor.kt
index 9d476008..ccf3aee1 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/InputResourceAssignmentProcessor.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/InputResourceAssignmentProcessor.kt
@@ -17,8 +17,11 @@
package org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.processor
+import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.utils.ResourceResolutionUtils
+import org.onap.ccsdk.apps.controllerblueprints.core.*
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment
import org.springframework.stereotype.Service
+import com.fasterxml.jackson.databind.node.NullNode
/**
* InputResourceAssignmentProcessor
@@ -33,6 +36,20 @@ open class InputResourceAssignmentProcessor : ResourceAssignmentProcessor() {
}
override fun process(executionRequest: ResourceAssignment) {
+ try {
+ if (checkNotEmpty(executionRequest.name)) {
+ val value = bluePrintRuntimeService!!.getInputValue(executionRequest.name)
+ // if value is null don't call setResourceDataValue to populate the value
+ if (value != null && value !is NullNode) {
+ ResourceResolutionUtils.setResourceDataValue(executionRequest, value)
+ }
+ }
+ // Check the value has populated for mandatory case
+ ResourceResolutionUtils.assertTemplateKeyValueNotNull(executionRequest)
+ } catch (e: Exception) {
+ ResourceResolutionUtils.setFailedResourceDataValue(executionRequest, e.message)
+ throw BluePrintProcessorException("Failed in template key ($executionRequest) assignments with : (${e.message})", e)
+ }
}
override fun recover(runtimeException: RuntimeException, executionRequest: ResourceAssignment) {
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/utils/ResourceResolutionUtils.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/utils/ResourceResolutionUtils.kt
index 6bcd21ba..7c590883 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/utils/ResourceResolutionUtils.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/utils/ResourceResolutionUtils.kt
@@ -16,17 +16,142 @@
package org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.utils
+import java.util.Date
+import org.apache.commons.lang3.StringUtils
+import com.att.eelf.configuration.EELFLogger
+import com.att.eelf.configuration.EELFManager
import com.fasterxml.jackson.databind.JsonNode
-import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException
+import com.fasterxml.jackson.databind.ObjectMapper
+import com.fasterxml.jackson.databind.node.NullNode
+import com.fasterxml.jackson.databind.node.ObjectNode
+import org.onap.ccsdk.apps.controllerblueprints.core.*
import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment
class ResourceResolutionUtils {
companion object {
+ private val logger: EELFLogger = EELFManager.getInstance().getLogger(ResourceResolutionUtils::class.toString())
+
+ @Synchronized
+ @Throws(BluePrintProcessorException::class)
+ fun setResourceDataValue(resourceAssignment: ResourceAssignment, value: Any?) {
+
+ val resourceProp = checkNotNull(resourceAssignment.property) { "Failed in setting resource value for resource mapping $resourceAssignment" }
+ checkNotEmptyNThrow(resourceAssignment.name, "Failed in setting resource value for resource mapping $resourceAssignment")
+
+ if (checkNotEmpty(resourceAssignment.dictionaryName)) {
+ resourceAssignment.dictionaryName = resourceAssignment.name
+ logger.warn("Missing dictionary key, setting with template key (${resourceAssignment.name}) as dictionary key (${resourceAssignment.dictionaryName})")
+ }
+
+ try {
+ if (checkNotEmpty(resourceProp.type)) {
+ val convertedValue = convertResourceValue(resourceProp.type, value)
+ logger.info("Setting Resource Value ($convertedValue) for Resource Name (${resourceAssignment.dictionaryName}) of type (${resourceProp.type})")
+ resourceProp.value = convertedValue
+ resourceAssignment.updatedDate = Date()
+ resourceAssignment.updatedBy = BluePrintConstants.USER_SYSTEM
+ resourceAssignment.status = BluePrintConstants.STATUS_SUCCESS
+ }
+ } catch (e: Exception) {
+ throw BluePrintProcessorException("Failed in setting value for template key (%s) and " +
+ "dictionary key (${resourceAssignment.name}) of type (${resourceProp.type}) with error message (${e.message})", e)
+ }
+ }
+
+ private fun convertResourceValue(type: String, value: Any?): JsonNode? {
+ var convertedValue: JsonNode?
+
+ if (value == null || value is NullNode) {
+ logger.info("Returning {} value from convertResourceValue", value)
+ return null
+ } else if (BluePrintTypes.validPrimitiveTypes().contains(type) && value is String) {
+ convertedValue = JacksonUtils.convertPrimitiveResourceValue(type, value)
+ } else {
+ // Case where Resource is non-primitive type
+ if (value is String) {
+ convertedValue = JacksonUtils.jsonNode(value)
+ } else {
+ convertedValue = JacksonUtils.getJsonNode(value)
+ }
+ }
+ return convertedValue
+ }
+
+ @Synchronized
+ fun setFailedResourceDataValue(resourceAssignment: ResourceAssignment, message: String?) {
+ if (checkNotEmpty(resourceAssignment.name)) {
+ resourceAssignment.updatedDate = Date()
+ resourceAssignment.updatedBy = BluePrintConstants.USER_SYSTEM
+ resourceAssignment.status = BluePrintConstants.STATUS_FAILURE
+ resourceAssignment.message = message
+ }
+ }
+
+ @Synchronized
+ @Throws(BluePrintProcessorException::class)
+ fun assertTemplateKeyValueNotNull(resourceAssignment: ResourceAssignment) {
+ val resourceProp = checkNotNull(resourceAssignment.property) { "Failed to populate mandatory resource resource mapping $resourceAssignment" }
+ if (resourceProp.required != null && resourceProp.required!! && (resourceProp.value == null || resourceProp.value !is NullNode)) {
+ logger.error("failed to populate mandatory resource mapping ($resourceAssignment)")
+ throw BluePrintProcessorException("failed to populate mandatory resource mapping ($resourceAssignment)")
+ }
+ }
+
+ @Synchronized
+ @Throws(BluePrintProcessorException::class)
+ fun generateResourceDataForAssignments(assignments: List<ResourceAssignment>): String {
+ var result = "{}"
+ try {
+ val mapper = ObjectMapper()
+ val root = mapper.readTree(result)
+
+ assignments.forEach {
+ if (checkNotEmpty(it.name) && it.property != null) {
+
+ val type = it.property?.type
+ val value = it.property?.value
+ logger.info("Generating Resource name ({}), type ({}), value ({})", it.name, type,
+ value)
+ if (value == null) {
+ (root as ObjectNode).set(it.name, null)
+ } else if (value is JsonNode) {
+ (root as ObjectNode).put(it.name, value as JsonNode)
+ } else if (BluePrintConstants.DATA_TYPE_STRING.equals(type, ignoreCase = true)) {
+ (root as ObjectNode).put(it.name, value as String)
+ } else if (BluePrintConstants.DATA_TYPE_BOOLEAN.equals(type, ignoreCase = true)) {
+ (root as ObjectNode).put(it.name, value as Boolean)
+ } else if (BluePrintConstants.DATA_TYPE_INTEGER.equals(type, ignoreCase = true)) {
+ (root as ObjectNode).put(it.name, value as Int)
+ } else if (BluePrintConstants.DATA_TYPE_FLOAT.equals(type, ignoreCase = true)) {
+ (root as ObjectNode).put(it.name, value as Float)
+ } else if (BluePrintConstants.DATA_TYPE_TIMESTAMP.equals(type, ignoreCase = true)) {
+ (root as ObjectNode).put(it.name, value as String)
+ } else {
+ val jsonNode = JacksonUtils.getJsonNode(value)
+ if (jsonNode != null) {
+ (root as ObjectNode).put(it.name, jsonNode)
+ } else {
+ (root as ObjectNode).set(it.name, null)
+ }
+ }
+ }
+ }
+ result = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(root)
+ logger.info("Generated Resource Param Data ({})", result)
+ } catch (e: Exception) {
+ throw BluePrintProcessorException("kapil is failing with $e.message", e)
+ }
+
+ return result
+ }
+
fun <T> transformResourceSource(properties: MutableMap<String, JsonNode>, classType: Class<T>): T {
val content = JacksonUtils.getJson(properties)
return JacksonUtils.readValue(content, classType)
?: throw BluePrintProcessorException("failed to transform content($content) to type($classType)")
}
+
}
} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionServiceTest.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionServiceTest.kt
index 7f41ba12..46ccb974 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionServiceTest.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionServiceTest.kt
@@ -19,8 +19,11 @@ package org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution
import org.junit.Assert
import org.junit.Test
import org.junit.runner.RunWith
+import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceInput
+import org.onap.ccsdk.apps.blueprintsprocessor.core.utils.PayloadUtils
import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.processor.*
import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintMetadataUtils
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils
import org.slf4j.LoggerFactory
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.test.context.ContextConfiguration
@@ -62,6 +65,12 @@ class ResourceResolutionServiceTest {
val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime("1234",
"./../../../../components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration")
+ val executionServiceInput = JacksonUtils.readValueFromClassPathFile("payload/requests/sample-resourceresolution-request.json",
+ ExecutionServiceInput::class.java)!!
+
+ // Prepare Inputs
+ PayloadUtils.prepareInputsFromWorkflowPayload(bluePrintRuntimeService, executionServiceInput.payload, "resource-assignment")
+
resourceResolutionService.resolveResources(bluePrintRuntimeService, "resource-assignment", "baseconfig")
}
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/payload/requests/sample-resourceresolution-request.json b/ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/payload/requests/sample-resourceresolution-request.json
index 7889a7e4..c4fe4eab 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/payload/requests/sample-resourceresolution-request.json
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/payload/requests/sample-resourceresolution-request.json
@@ -19,9 +19,12 @@
"resource-assignment-request": {
"resource-assignment-properties": {
"request-id": "1234",
+ "service-instance-id": "siid_1234",
+ "vnf-id": "vnf_1234",
"action-name": "assign-activate",
"scope-type": "vnf-type",
- "hostname": "localhost"
+ "hostname": "localhost",
+ "vnf_name": "temp_vnf"
}
}
}
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/SchemaGeneratorService.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/SchemaGeneratorService.java
index 89af9e9a..3a1535ac 100644
--- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/SchemaGeneratorService.java
+++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/SchemaGeneratorService.java
@@ -59,7 +59,7 @@ public class SchemaGeneratorService {
*/
public String generateSchema(String serviceTemplateContent) throws BluePrintException {
if (StringUtils.isNotBlank(serviceTemplateContent)) {
- ServiceTemplate serviceTemplate = JacksonUtils.readValue(serviceTemplateContent,
+ ServiceTemplate serviceTemplate = JacksonUtils.Companion.readValue(serviceTemplateContent,
ServiceTemplate.class);
return generateSchema(serviceTemplate);
} else {
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/JpaJsonNodeConverter.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/JpaJsonNodeConverter.java
index 23d3a977..074483a7 100644
--- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/JpaJsonNodeConverter.java
+++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/JpaJsonNodeConverter.java
@@ -30,11 +30,11 @@ public class JpaJsonNodeConverter implements
@Override
public String convertToDatabaseColumn(JsonNode node) {
- return JacksonUtils.getJson(node, true);
+ return JacksonUtils.Companion.getJson(node, true);
}
@Override
public JsonNode convertToEntityAttribute(String dbData) {
- return JacksonUtils.jsonNode(dbData);
+ return JacksonUtils.Companion.jsonNode(dbData);
}
} \ No newline at end of file
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/JpaResourceDefinitionConverter.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/JpaResourceDefinitionConverter.java
index 18672f1c..e28cdcd5 100644
--- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/JpaResourceDefinitionConverter.java
+++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/JpaResourceDefinitionConverter.java
@@ -29,11 +29,11 @@ public class JpaResourceDefinitionConverter implements
AttributeConverter<ResourceDefinition, String> {
@Override
public String convertToDatabaseColumn(ResourceDefinition resourceDefinition) {
- return JacksonUtils.getJson(resourceDefinition);
+ return JacksonUtils.Companion.getJson(resourceDefinition);
}
@Override
public ResourceDefinition convertToEntityAttribute(String content) {
- return JacksonUtils.readValue(content, ResourceDefinition.class);
+ return JacksonUtils.Companion.readValue(content, ResourceDefinition.class);
}
}
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/validator/ServiceTemplateValidator.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/validator/ServiceTemplateValidator.java
index 6d02544e..5d15e087 100644
--- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/validator/ServiceTemplateValidator.java
+++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/validator/ServiceTemplateValidator.java
@@ -58,7 +58,7 @@ public class ServiceTemplateValidator extends BluePrintValidatorDefaultService {
public boolean validateServiceTemplate(String serviceTemplateContent) throws BluePrintException {
if (StringUtils.isNotBlank(serviceTemplateContent)) {
ServiceTemplate serviceTemplate =
- JacksonUtils.readValue(serviceTemplateContent, ServiceTemplate.class);
+ JacksonUtils.Companion.readValue(serviceTemplateContent, ServiceTemplate.class);
return validateServiceTemplate(serviceTemplate);
} else {
throw new BluePrintException(
@@ -131,11 +131,11 @@ public class ServiceTemplateValidator extends BluePrintValidatorDefaultService {
Object mappingObject =
capabilityAssignment.getProperties().get(ConfigModelConstant.CAPABILITY_PROPERTY_MAPPING);
if (mappingObject != null) {
- String mappingContent = JacksonUtils.getJson(mappingObject);
+ String mappingContent = JacksonUtils.Companion.getJson(mappingObject);
Preconditions.checkArgument(StringUtils.isNotBlank(mappingContent),
String.format("Failed to get capability mapping property (%s) ", ConfigModelConstant.CAPABILITY_PROPERTY_MAPPING));
- resourceAssignment = JacksonUtils.getListFromJson(mappingContent, ResourceAssignment.class);
+ resourceAssignment = JacksonUtils.Companion.getListFromJson(mappingContent, ResourceAssignment.class);
Preconditions.checkNotNull(resourceAssignment,
String.format("Failed to get resource assignment info from the content (%s) ", mappingContent));
diff --git a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/ModelTypeServiceTest.java b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/ModelTypeServiceTest.java
index 412e9606..42c6365a 100644
--- a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/ModelTypeServiceTest.java
+++ b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/ModelTypeServiceTest.java
@@ -56,12 +56,12 @@ public class ModelTypeServiceTest {
public void test01SaveModelType() throws Exception {
log.info("**************** test01SaveModelType ********************");
- String content = JacksonUtils.getClassPathFileContent("model_type/data_type/datatype-property.json");
+ String content = JacksonUtils.Companion.getClassPathFileContent("model_type/data_type/datatype-property.json");
ModelType modelType = new ModelType();
modelType.setDefinitionType(BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE);
modelType.setDerivedFrom(BluePrintConstants.MODEL_TYPE_DATATYPES_ROOT);
modelType.setDescription("Definition for Sample Datatype ");
- modelType.setDefinition(JacksonUtils.jsonNode(content));
+ modelType.setDefinition(JacksonUtils.Companion.jsonNode(content));
modelType.setModelName(modelName);
modelType.setVersion("1.0.0");
modelType.setTags("test-datatype ," + BluePrintConstants.MODEL_TYPE_DATATYPES_ROOT + ","
diff --git a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/ModelTypeReactRepositoryTest.java b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/ModelTypeReactRepositoryTest.java
index 7549b780..739ce51b 100644
--- a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/ModelTypeReactRepositoryTest.java
+++ b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/ModelTypeReactRepositoryTest.java
@@ -54,12 +54,12 @@ public class ModelTypeReactRepositoryTest {
@Test
@Commit
public void test01Save() {
- String content = JacksonUtils.getClassPathFileContent("model_type/data_type/datatype-property.json");
+ String content = JacksonUtils.Companion.getClassPathFileContent("model_type/data_type/datatype-property.json");
ModelType modelType = new ModelType();
modelType.setDefinitionType(BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE);
modelType.setDerivedFrom(BluePrintConstants.MODEL_TYPE_DATATYPES_ROOT);
modelType.setDescription("Definition for Sample Datatype ");
- modelType.setDefinition(JacksonUtils.jsonNode(content));
+ modelType.setDefinition(JacksonUtils.Companion.jsonNode(content));
modelType.setModelName(modelName);
modelType.setVersion("1.0.0");
modelType.setTags("test-datatype ," + BluePrintConstants.MODEL_TYPE_DATATYPES_ROOT + ","
diff --git a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/ResourceDictionaryReactRepositoryTest.java b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/ResourceDictionaryReactRepositoryTest.java
index 2a636831..fb11c39f 100644
--- a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/ResourceDictionaryReactRepositoryTest.java
+++ b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/ResourceDictionaryReactRepositoryTest.java
@@ -55,7 +55,7 @@ public class ResourceDictionaryReactRepositoryTest {
@Test
@Commit
public void test01Save() {
- ResourceDefinition resourceDefinition = JacksonUtils.readValueFromFile("./../../../../components/model-catalog/resource-dictionary/starter-dictionary/sample-db-source.json", ResourceDefinition.class);
+ ResourceDefinition resourceDefinition = JacksonUtils.Companion.readValueFromFile("./../../../../components/model-catalog/resource-dictionary/starter-dictionary/sample-db-source.json", ResourceDefinition.class);
Assert.assertNotNull("Failed to get resourceDefinition from content", resourceDefinition);
resourceDefinition.setName(sourceName);
diff --git a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ModelTypeRestTest.java b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ModelTypeRestTest.java
index bf5db340..64c87e06 100644
--- a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ModelTypeRestTest.java
+++ b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ModelTypeRestTest.java
@@ -53,12 +53,12 @@ public class ModelTypeRestTest {
public void test01SaveModelType() throws Exception {
log.info("**************** test01SaveModelType ********************");
- String content = JacksonUtils.getClassPathFileContent("model_type/data_type/datatype-property.json");
+ String content = JacksonUtils.Companion.getClassPathFileContent("model_type/data_type/datatype-property.json");
ModelType modelType = new ModelType();
modelType.setDefinitionType(BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE);
modelType.setDerivedFrom(BluePrintConstants.MODEL_TYPE_DATATYPES_ROOT);
modelType.setDescription("Definition for Sample Datatype ");
- modelType.setDefinition(JacksonUtils.jsonNode(content));
+ modelType.setDefinition(JacksonUtils.Companion.jsonNode(content));
modelType.setModelName(modelName);
modelType.setVersion("1.0.0");
modelType.setTags("test-datatype ," + BluePrintConstants.MODEL_TYPE_DATATYPES_ROOT + ","