aboutsummaryrefslogtreecommitdiffstats
path: root/ms/controllerblueprints/modules/core
diff options
context:
space:
mode:
authorMuthuramalingam, Brinda Santh(bs2796) <bs2796@att.com>2018-08-31 19:52:48 +0000
committerMuthuramalingam, Brinda Santh(bs2796) <bs2796@att.com>2018-08-31 19:52:48 +0000
commit62cc10e56d33d0399f810c556470f3ad39361ae7 (patch)
tree87c6406d90e71b86e44bf1cefa81683a03b53005 /ms/controllerblueprints/modules/core
parent8fa6853463959ccc7a2215b0f43d4822a2f630b6 (diff)
Controller Blueprints Microservice
Add resource assignment enhancer, resource definition repo functions and code improvements. Change-Id: I751bf8149a36f80c20d48b86344cd6bd3054ed21 Issue-ID: CCSDK-431 Signed-off-by: Muthuramalingam, Brinda Santh(bs2796) <bs2796@att.com>
Diffstat (limited to 'ms/controllerblueprints/modules/core')
-rw-r--r--ms/controllerblueprints/modules/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintConstants.kt2
-rw-r--r--ms/controllerblueprints/modules/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintEnhancerService.kt37
-rw-r--r--ms/controllerblueprints/modules/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRepoService.kt32
-rw-r--r--ms/controllerblueprints/modules/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonReactorUtils.kt108
-rw-r--r--ms/controllerblueprints/modules/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtils.kt58
-rw-r--r--ms/controllerblueprints/modules/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRepoFileServiceTest.kt10
-rw-r--r--ms/controllerblueprints/modules/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonReactorUtilsTest.kt51
7 files changed, 228 insertions, 70 deletions
diff --git a/ms/controllerblueprints/modules/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintConstants.kt b/ms/controllerblueprints/modules/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintConstants.kt
index 85f1579e..2e3edb65 100644
--- a/ms/controllerblueprints/modules/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintConstants.kt
+++ b/ms/controllerblueprints/modules/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintConstants.kt
@@ -54,6 +54,8 @@ object BluePrintConstants {
const val PATH_ATTRIBUTES: String = "attributes"
const val PATH_ARTIFACTS: String = "artifacts"
+ const val MODEL_DIR_MODEL_TYPE: String = "model_type"
+
const val MODEL_DEFINITION_TYPE_NODE_TYPE: String = "node_type"
const val MODEL_DEFINITION_TYPE_ARTIFACT_TYPE: String = "artifact_type"
const val MODEL_DEFINITION_TYPE_CAPABILITY_TYPE: String = "capability_type"
diff --git a/ms/controllerblueprints/modules/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintEnhancerService.kt b/ms/controllerblueprints/modules/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintEnhancerService.kt
index c90d6597..f38c317e 100644
--- a/ms/controllerblueprints/modules/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintEnhancerService.kt
+++ b/ms/controllerblueprints/modules/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintEnhancerService.kt
@@ -23,6 +23,7 @@ import org.onap.ccsdk.apps.controllerblueprints.core.data.*
import org.onap.ccsdk.apps.controllerblueprints.core.format
import com.att.eelf.configuration.EELFLogger
import com.att.eelf.configuration.EELFManager
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonReactorUtils
import java.io.Serializable
/**
@@ -35,14 +36,23 @@ interface BluePrintEnhancerService : Serializable {
@Throws(BluePrintException::class)
fun enhance(content: String): ServiceTemplate
- @Throws(BluePrintException::class)
- fun enhance(serviceTemplate: ServiceTemplate): ServiceTemplate
-
/**
* Read Blueprint from CSAR structure Directory
*/
@Throws(BluePrintException::class)
fun enhance(fileName: String, basePath: String): ServiceTemplate
+
+ @Throws(BluePrintException::class)
+ fun enhance(serviceTemplate: ServiceTemplate): ServiceTemplate
+
+ @Throws(BluePrintException::class)
+ fun enrichNodeTemplate(nodeTemplateName: String, nodeTemplate: NodeTemplate)
+
+ @Throws(BluePrintException::class)
+ fun enrichNodeType(nodeTypeName: String, nodeType: NodeType)
+
+ @Throws(BluePrintException::class)
+ fun enrichPropertyDefinition(propertyName: String, propertyDefinition: PropertyDefinition)
}
open class BluePrintEnhancerDefaultService(val bluePrintRepoService: BluePrintRepoService) : BluePrintEnhancerService {
@@ -51,20 +61,25 @@ open class BluePrintEnhancerDefaultService(val bluePrintRepoService: BluePrintRe
lateinit var serviceTemplate: ServiceTemplate
+ @Throws(BluePrintException::class)
override fun enhance(content: String): ServiceTemplate {
- TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
+ return JacksonReactorUtils.readValueFromFile(content, ServiceTemplate::class.java).map { serviceTemplate ->
+ enhance(serviceTemplate!!)
+ }.block()!!
}
+ @Throws(BluePrintException::class)
override fun enhance(fileName: String, basePath: String): ServiceTemplate {
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
}
+ @Throws(BluePrintException::class)
override fun enhance(serviceTemplate: ServiceTemplate): ServiceTemplate {
this.serviceTemplate = serviceTemplate
initialCleanUp()
enrichTopologyTemplate(serviceTemplate)
- // log.info("Enriched Blueprint :\n {}", JacksonUtils.getJson(serviceTemplate, true))
+ // log.info("Enriched Blueprint :\n {}", JacksonUtils.getJson(serviceTemplate, true))
return this.serviceTemplate
}
@@ -79,6 +94,7 @@ open class BluePrintEnhancerDefaultService(val bluePrintRepoService: BluePrintRe
}
+ @Throws(BluePrintException::class)
open fun enrichTopologyTemplate(serviceTemplate: ServiceTemplate) {
serviceTemplate.topologyTemplate?.let { topologyTemplate ->
enrichTopologyTemplateInputs(topologyTemplate)
@@ -86,6 +102,7 @@ open class BluePrintEnhancerDefaultService(val bluePrintRepoService: BluePrintRe
}
}
+ @Throws(BluePrintException::class)
open fun enrichTopologyTemplateInputs(topologyTemplate: TopologyTemplate) {
topologyTemplate.inputs?.let { inputs ->
enrichPropertyDefinitions(inputs)
@@ -99,7 +116,7 @@ open class BluePrintEnhancerDefaultService(val bluePrintRepoService: BluePrintRe
}
@Throws(BluePrintException::class)
- open fun enrichNodeTemplate(nodeTemplateName: String, nodeTemplate: NodeTemplate) {
+ override fun enrichNodeTemplate(nodeTemplateName: String, nodeTemplate: NodeTemplate) {
val nodeTypeName = nodeTemplate.type
// Get NodeType from Repo and Update Service Template
val nodeType = populateNodeType(nodeTypeName)
@@ -111,7 +128,8 @@ open class BluePrintEnhancerDefaultService(val bluePrintRepoService: BluePrintRe
enrichNodeTemplateArtifactDefinition(nodeTemplateName, nodeTemplate)
}
- open fun enrichNodeType(nodeTypeName: String, nodeType: NodeType) {
+ @Throws(BluePrintException::class)
+ override fun enrichNodeType(nodeTypeName: String, nodeType: NodeType) {
// NodeType Property Definitions
enrichNodeTypeProperties(nodeTypeName, nodeType)
@@ -132,7 +150,7 @@ open class BluePrintEnhancerDefaultService(val bluePrintRepoService: BluePrintRe
open fun enrichNodeTypeRequirements(nodeTypeName: String, nodeType: NodeType) {
- nodeType.requirements?.forEach { requirementDefinitionName, requirementDefinition ->
+ nodeType.requirements?.forEach { _, requirementDefinition ->
// Populate Requirement Node
requirementDefinition.node?.let { requirementNodeTypeName ->
// Get Requirement NodeType from Repo and Update Service Template
@@ -187,7 +205,8 @@ open class BluePrintEnhancerDefaultService(val bluePrintRepoService: BluePrintRe
}
}
- open fun enrichPropertyDefinition(propertyName: String, propertyDefinition: PropertyDefinition) {
+ @Throws(BluePrintException::class)
+ override fun enrichPropertyDefinition(propertyName: String, propertyDefinition: PropertyDefinition) {
val propertyType = propertyDefinition.type
if (BluePrintTypes.validPrimitiveTypes().contains(propertyType)) {
diff --git a/ms/controllerblueprints/modules/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRepoService.kt b/ms/controllerblueprints/modules/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRepoService.kt
index 8d2557cd..e1d1eac7 100644
--- a/ms/controllerblueprints/modules/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRepoService.kt
+++ b/ms/controllerblueprints/modules/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRepoService.kt
@@ -17,15 +17,12 @@
package org.onap.ccsdk.apps.controllerblueprints.core.service
-import com.google.common.base.Preconditions
-import org.apache.commons.io.FileUtils
-import org.apache.commons.lang3.StringUtils
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException
import org.onap.ccsdk.apps.controllerblueprints.core.data.*
-import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils
import com.att.eelf.configuration.EELFLogger
import com.att.eelf.configuration.EELFManager
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonReactorUtils
import reactor.core.publisher.Mono
import java.io.File
import java.io.Serializable
@@ -57,15 +54,15 @@ interface BluePrintRepoService : Serializable {
}
-class BluePrintRepoFileService(val basePath: String) : BluePrintRepoService {
+open class BluePrintRepoFileService(modelTypePath: String) : BluePrintRepoService {
- private val log: EELFLogger = EELFManager.getInstance().getLogger(this::class.toString())
+ private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintRepoFileService::class.toString())
- private val dataTypePath = basePath.plus(BluePrintConstants.PATH_DIVIDER).plus(BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE)
- private val nodeTypePath = basePath.plus(BluePrintConstants.PATH_DIVIDER).plus(BluePrintConstants.MODEL_DEFINITION_TYPE_NODE_TYPE)
- private val artifactTypePath = basePath.plus(BluePrintConstants.PATH_DIVIDER).plus(BluePrintConstants.MODEL_DEFINITION_TYPE_ARTIFACT_TYPE)
- private val capabilityTypePath = basePath.plus(BluePrintConstants.PATH_DIVIDER).plus(BluePrintConstants.MODEL_DEFINITION_TYPE_CAPABILITY_TYPE)
- private val relationshipTypePath = basePath.plus(BluePrintConstants.PATH_DIVIDER).plus(BluePrintConstants.MODEL_DEFINITION_TYPE_RELATIONSHIP_TYPE)
+ private val dataTypePath = modelTypePath.plus(BluePrintConstants.PATH_DIVIDER).plus(BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE)
+ private val nodeTypePath = modelTypePath.plus(BluePrintConstants.PATH_DIVIDER).plus(BluePrintConstants.MODEL_DEFINITION_TYPE_NODE_TYPE)
+ private val artifactTypePath = modelTypePath.plus(BluePrintConstants.PATH_DIVIDER).plus(BluePrintConstants.MODEL_DEFINITION_TYPE_ARTIFACT_TYPE)
+ private val capabilityTypePath = modelTypePath.plus(BluePrintConstants.PATH_DIVIDER).plus(BluePrintConstants.MODEL_DEFINITION_TYPE_CAPABILITY_TYPE)
+ private val relationshipTypePath = modelTypePath.plus(BluePrintConstants.PATH_DIVIDER).plus(BluePrintConstants.MODEL_DEFINITION_TYPE_RELATIONSHIP_TYPE)
private val extension = ".json"
override fun getDataType(dataTypeName: String): Mono<DataType>? {
@@ -98,17 +95,6 @@ class BluePrintRepoFileService(val basePath: String) : BluePrintRepoService {
}
private fun <T> getModelType(fileName: String, valueType: Class<T>): Mono<T> {
- return getFileContent(fileName).map { content ->
- Preconditions.checkArgument(StringUtils.isNotBlank(content),
- String.format("Failed to get model content for file (%s)", fileName))
-
- JacksonUtils.readValue(content, valueType)
- ?: throw BluePrintException(String.format("Failed to get model file from content for file (%s)", fileName))
-
- }
- }
-
- private fun getFileContent(fileName: String): Mono<String> {
- return Mono.just(FileUtils.readFileToString(File(fileName), Charset.defaultCharset()))
+ return JacksonReactorUtils.readValueFromFile(fileName, valueType)
}
} \ No newline at end of file
diff --git a/ms/controllerblueprints/modules/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonReactorUtils.kt b/ms/controllerblueprints/modules/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonReactorUtils.kt
new file mode 100644
index 00000000..0ed90170
--- /dev/null
+++ b/ms/controllerblueprints/modules/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonReactorUtils.kt
@@ -0,0 +1,108 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * 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
+import com.att.eelf.configuration.EELFManager
+import com.fasterxml.jackson.databind.JsonNode
+import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
+import reactor.core.publisher.Mono
+import reactor.core.publisher.toMono
+
+object JacksonReactorUtils {
+ private val log: EELFLogger = EELFManager.getInstance().getLogger(this::class.toString())
+
+ @JvmStatic
+ fun getContent(fileName: String): Mono<String> {
+ return JacksonUtils.getContent(fileName).toMono()
+ }
+
+ @JvmStatic
+ fun getClassPathFileContent(fileName: String): Mono<String> {
+ return JacksonUtils.getClassPathFileContent(fileName).toMono()
+ }
+
+ @JvmStatic
+ fun <T> readValue(content: String, valueType: Class<T>): Mono<T> {
+ return Mono.just(jacksonObjectMapper().readValue(content, valueType))
+ }
+
+ @JvmStatic
+ fun jsonNode(content: String): Mono<JsonNode> {
+ return Mono.just(jacksonObjectMapper().readTree(content))
+ }
+
+ @JvmStatic
+ fun getJson(any: kotlin.Any, pretty: Boolean = false): Mono<String> {
+ return Mono.just(JacksonUtils.getJson(any, pretty))
+ }
+
+ @JvmStatic
+ fun <T> getListFromJson(content: String, valueType: Class<T>): Mono<List<T>> {
+ val objectMapper = jacksonObjectMapper()
+ val javaType = objectMapper.typeFactory.constructCollectionType(List::class.java, valueType)
+ return objectMapper.readValue<List<T>>(content, javaType).toMono()
+ }
+
+ @JvmStatic
+ fun <T> readValueFromFile(fileName: String, valueType: Class<T>): Mono<T> {
+ return getContent(fileName)
+ .flatMap { content ->
+ readValue(content, valueType)
+ }
+ }
+
+ @JvmStatic
+ fun <T> readValueFromClassPathFile(fileName: String, valueType: Class<T>): Mono<T> {
+ return getClassPathFileContent(fileName)
+ .flatMap { content ->
+ readValue(content, valueType)
+ }
+ }
+
+ @JvmStatic
+ fun jsonNodeFromFile(fileName: String): Mono<JsonNode> {
+ return getContent(fileName)
+ .flatMap { content ->
+ jsonNode(content)
+ }
+ }
+
+ @JvmStatic
+ fun jsonNodeFromClassPathFile(fileName: String): Mono<JsonNode> {
+ return getClassPathFileContent(fileName)
+ .flatMap { content ->
+ jsonNode(content)
+ }
+ }
+
+ @JvmStatic
+ fun <T> getListFromFile(fileName: String, valueType: Class<T>): Mono<List<T>> {
+ return getContent(fileName)
+ .flatMap { content ->
+ getListFromJson(content, valueType)
+ }
+ }
+
+ @JvmStatic
+ fun <T> getListFromClassPathFile(fileName: String, valueType: Class<T>): Mono<List<T>> {
+ return getClassPathFileContent(fileName)
+ .flatMap { content ->
+ getListFromJson(content, valueType)
+ }
+ }
+} \ No newline at end of file
diff --git a/ms/controllerblueprints/modules/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtils.kt b/ms/controllerblueprints/modules/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtils.kt
index 7e72744c..5075e726 100644
--- a/ms/controllerblueprints/modules/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtils.kt
+++ b/ms/controllerblueprints/modules/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtils.kt
@@ -23,9 +23,6 @@ import com.fasterxml.jackson.annotation.JsonInclude
import com.fasterxml.jackson.core.type.TypeReference
import com.fasterxml.jackson.databind.JsonNode
import com.fasterxml.jackson.databind.SerializationFeature
-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.module.kotlin.jacksonObjectMapper
import org.apache.commons.io.FileUtils
import org.apache.commons.io.IOUtils
@@ -53,6 +50,17 @@ object JacksonUtils {
}
@JvmStatic
+ fun getContent(fileName: String): String {
+ return File(fileName).readText(Charsets.UTF_8)
+ }
+
+ @JvmStatic
+ fun getClassPathFileContent(fileName: String): String {
+ return IOUtils.toString(JacksonUtils::class.java.classLoader
+ .getResourceAsStream(fileName), Charset.defaultCharset())
+ }
+
+ @JvmStatic
fun <T> readValueFromFile(fileName: String, valueType: Class<T>): T? {
val content: String = FileUtils.readFileToString(File(fileName), Charset.defaultCharset())
?: throw BluePrintException(format("Failed to read json file : {}", fileName))
@@ -61,8 +69,7 @@ object JacksonUtils {
@JvmStatic
fun <T> readValueFromClassPathFile(fileName: String, valueType: Class<T>): T? {
- val content: String = IOUtils.toString(JacksonUtils::class.java.classLoader.getResourceAsStream(fileName), Charset.defaultCharset())
- ?: throw BluePrintException(String.format("Failed to read json file : %s", fileName))
+ val content: String = getClassPathFileContent(fileName)
return readValue(content, valueType)
}
@@ -71,8 +78,7 @@ object JacksonUtils {
@JvmStatic
fun jsonNodeFromClassPathFile(fileName: String): JsonNode {
- val content: String = IOUtils.toString(JacksonUtils::class.java.classLoader.getResourceAsStream(fileName), Charset.defaultCharset())
- ?: throw BluePrintException(String.format("Failed to read json file : %s", fileName))
+ val content: String = getClassPathFileContent(fileName)
return jsonNode(content)
}
@@ -119,8 +125,7 @@ object JacksonUtils {
@JvmStatic
fun <T> getListFromClassPathFile(fileName: String, valueType: Class<T>): List<T>? {
- val content: String = IOUtils.toString(JacksonUtils::class.java.classLoader.getResourceAsStream(fileName), Charset.defaultCharset())
- ?: throw BluePrintException(String.format("Failed to read json file : %s", fileName))
+ val content: String = getClassPathFileContent(fileName)
return getListFromJson(content, valueType)
}
@@ -144,39 +149,25 @@ object JacksonUtils {
@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
+ 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
+ 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) {
@@ -253,4 +244,5 @@ object JacksonUtils {
objectNode.set(key, nodeValue)
}
}
+ */
} \ No newline at end of file
diff --git a/ms/controllerblueprints/modules/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRepoFileServiceTest.kt b/ms/controllerblueprints/modules/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRepoFileServiceTest.kt
index 081f4fe3..88aea919 100644
--- a/ms/controllerblueprints/modules/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRepoFileServiceTest.kt
+++ b/ms/controllerblueprints/modules/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRepoFileServiceTest.kt
@@ -28,30 +28,30 @@ import kotlin.test.assertNotNull
*/
class BluePrintRepoFileServiceTest {
- val basePath = "load/model_type"
+ private val basePath = "load/model_type"
private val bluePrintEnhancerRepoFileService = BluePrintRepoFileService(basePath)
@Test
fun testGetDataType() {
- val dataType = bluePrintEnhancerRepoFileService.getDataType("dt-v4-aggregate")
+ val dataType = bluePrintEnhancerRepoFileService.getDataType("dt-v4-aggregate")?.block()
assertNotNull(dataType, "Failed to get DataType from repo")
}
@Test
fun testGetNodeType() {
- val nodeType = bluePrintEnhancerRepoFileService.getNodeType("component-resource-assignment")
+ val nodeType = bluePrintEnhancerRepoFileService.getNodeType("component-resource-assignment")?.block()
assertNotNull(nodeType, "Failed to get NodeType from repo")
}
@Test
fun testGetArtifactType() {
- val nodeType = bluePrintEnhancerRepoFileService.getArtifactType("artifact-template-velocity")
+ val nodeType = bluePrintEnhancerRepoFileService.getArtifactType("artifact-template-velocity")?.block()
assertNotNull(nodeType, "Failed to get ArtifactType from repo")
}
@Test(expected = FileNotFoundException::class)
fun testModelNotFound() {
- val dataType = bluePrintEnhancerRepoFileService.getDataType("dt-not-found")
+ val dataType = bluePrintEnhancerRepoFileService.getDataType("dt-not-found")?.block()
assertNotNull(dataType, "Failed to get DataType from repo")
}
} \ No newline at end of file
diff --git a/ms/controllerblueprints/modules/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonReactorUtilsTest.kt b/ms/controllerblueprints/modules/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonReactorUtilsTest.kt
new file mode 100644
index 00000000..d13caa52
--- /dev/null
+++ b/ms/controllerblueprints/modules/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonReactorUtilsTest.kt
@@ -0,0 +1,51 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * 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
+import com.att.eelf.configuration.EELFManager
+import org.junit.Test
+import org.onap.ccsdk.apps.controllerblueprints.core.data.ServiceTemplate
+import java.io.FileNotFoundException
+import kotlin.test.assertEquals
+import kotlin.test.assertNotNull
+
+class JacksonReactorUtilsTest {
+ private val log: EELFLogger = EELFManager.getInstance().getLogger(this::class.toString())
+ @Test
+ fun testReadValues() {
+
+ val serviceTemplate = JacksonReactorUtils.readValueFromFile("load/blueprints/baseconfiguration/Definitions/activation-blueprint.json",
+ ServiceTemplate::class.java).block()
+
+ assertNotNull(serviceTemplate, "Failed to simple transform Service Template")
+ assertEquals(true, serviceTemplate is ServiceTemplate, "failed to get Service Template instance")
+
+ val jsonContent = JacksonReactorUtils.getJson(serviceTemplate!!, true).block()
+ assertNotNull(jsonContent, "Failed to get json content")
+
+ val jsonNode = JacksonReactorUtils.jsonNodeFromFile("load/blueprints/baseconfiguration/Definitions/activation-blueprint.json")
+ .block()
+ assertNotNull(jsonContent, "Failed to get json Node")
+ }
+
+ @Test(expected = FileNotFoundException::class)
+ fun testReadValuesFailure() {
+ JacksonReactorUtils.jsonNodeFromFile("load/blueprints/not-found.json")
+ .block()
+ }
+} \ No newline at end of file