const val MODEL_TYPE_CAPABILITY_TYPE_SSH = "tosca.capabilities.Ssh"
const val MODEL_TYPE_CAPABILITY_TYPE_SFTP = "tosca.capabilities.Sftp"
+ const val EXPRESSION_DSL_REFERENCE: String = "*"
const val EXPRESSION_GET_INPUT: String = "get_input"
const val EXPRESSION_GET_ATTRIBUTE: String = "get_attribute"
const val EXPRESSION_GET_ARTIFACT: String = "get_artifact"
BluePrintConstants.MODEL_TYPE_NODE_DG,
BluePrintConstants.MODEL_TYPE_NODE_COMPONENT,
BluePrintConstants.MODEL_TYPE_NODE_VNF,
- BluePrintConstants.MODEL_TYPE_NODE_ARTIFACT,
BluePrintConstants.MODEL_TYPE_NODE_RESOURCE_SOURCE,
BluePrintConstants.MODEL_TYPE_NODES_COMPONENT_JAVA,
BluePrintConstants.MODEL_TYPE_NODES_COMPONENT_BUNDLE,
BluePrintConstants.MODEL_TYPE_DATA_TYPE_DYNAMIC
)
- @Deprecated("This has to move to Relationship Types Model Drive")
@JvmStatic
val validRelationShipDerivedFroms: MutableList<String> = arrayListOf(
BluePrintConstants.MODEL_TYPE_RELATIONSHIPS_ROOT,
BluePrintConstants.MODEL_TYPE_RELATIONSHIPS_ROUTES_TO
)
- @Deprecated("This has to move to Capability Types Model Drive")
@JvmStatic
val validCapabilityTypes: MutableList<String> = arrayListOf(
BluePrintConstants.MODEL_TYPE_CAPABILITIES_ROOT,
@JvmStatic
fun validCommands(): List<String> {
- return listOf(BluePrintConstants.EXPRESSION_GET_INPUT,
+ return listOf(BluePrintConstants.EXPRESSION_DSL_REFERENCE,
+ BluePrintConstants.EXPRESSION_GET_INPUT,
BluePrintConstants.EXPRESSION_GET_ATTRIBUTE,
BluePrintConstants.EXPRESSION_GET_PROPERTY,
BluePrintConstants.EXPRESSION_GET_ARTIFACT,
package org.onap.ccsdk.apps.controllerblueprints.core
import com.fasterxml.jackson.databind.JsonNode
-import com.fasterxml.jackson.databind.node.BooleanNode
-import com.fasterxml.jackson.databind.node.DoubleNode
-import com.fasterxml.jackson.databind.node.IntNode
-import com.fasterxml.jackson.databind.node.TextNode
+import com.fasterxml.jackson.databind.node.*
import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils
import org.slf4j.helpers.MessageFormatter
import java.io.File
}
}
+/**
+ * Convert Json to map of json node, the root fields will be map keys
+ */
+fun JsonNode.rootFieldsToMap(): MutableMap<String, JsonNode> {
+ if (this is ObjectNode) {
+ val propertyMap: MutableMap<String, JsonNode> = hashMapOf()
+ this.fields().forEach {
+ propertyMap[it.key] = it.value
+ }
+ return propertyMap
+ } else {
+ throw BluePrintException("json node should be Object Node Type")
+ }
+}
+
+
fun MutableMap<String, JsonNode>.putJsonElement(key: String, value: Any) {
when (value) {
is JsonNode ->
/*
* Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+@file:Suppress("unused")
package org.onap.ccsdk.apps.controllerblueprints.core.data
var isExpression: Boolean = false,
var valueNode: JsonNode,
var expressionNode: ObjectNode? = null,
+ var dslExpression: DSLExpression? = null,
var inputExpression: InputExpression? = null,
var propertyExpression: PropertyExpression? = null,
var attributeExpression: AttributeExpression? = null,
val propertyName: String
)
+data class DSLExpression(
+ val propertyName: String
+)
+
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+@file:Suppress("unused")
package org.onap.ccsdk.apps.controllerblueprints.core.data
A TOSCA Service Template (YAML) document contains element definitions of building blocks for cloud application, or complete models of cloud applications. This section describes the top-level structural elements (TOSCA keynames) along with their grammars, which are allowed to appear in a TOSCA Service Template document.
*/
-@JsonPropertyOrder(value = ["toscaDefinitionsVersion", "description", "metadata", "imports", "topologyTemplate"])
+@JsonPropertyOrder(value = ["toscaDefinitionsVersion", "description", "metadata", "imports", "dsl_definitions",
+ "topologyTemplate"])
class ServiceTemplate : Cloneable {
@get:JsonIgnore
var id: String? = null
var metadata: MutableMap<String, String>? = null
var description: String? = null
@get:JsonProperty("dsl_definitions")
- var dslDefinitions: MutableMap<String, Any>? = null
+ var dslDefinitions: MutableMap<String, JsonNode>? = null
var repositories: MutableMap<String, RepositoryDefinition>? = null
var imports: MutableList<ImportDefinition>? = null
@get:JsonProperty("artifact_types")
/*
* Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
val imports: List<ImportDefinition>? = serviceTemplate.imports
+ val dslDefinitions = serviceTemplate.dslDefinitions
+
val metadata: MutableMap<String, String>? = serviceTemplate.metadata
val dataTypes: MutableMap<String, DataType>? = serviceTemplate.dataTypes
?: throw BluePrintException("could't get first callOperation for WorkFlow($workFlowName) ")
}
+ // DSL
+ fun dslPropertiesByName(name: String): JsonNode = dslDefinitions?.get(name)
+ ?: throw BluePrintException("could't get policy type for the dsl($name)")
+
// Data Type
fun dataTypeByName(name: String): DataType? = dataTypes?.get(name)
/*
* Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
import com.fasterxml.jackson.databind.JsonNode
import com.fasterxml.jackson.databind.node.ArrayNode
import com.fasterxml.jackson.databind.node.ObjectNode
+import com.fasterxml.jackson.databind.node.TextNode
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintTypes
object BluePrintExpressionService {
val log: EELFLogger = EELFManager.getInstance().getLogger(this::class.toString())
+ @JvmStatic
+ fun checkContainsExpression(propertyAssignmentNode: JsonNode): Boolean {
+ val json = propertyAssignmentNode.toString()
+ // FIXME("Check if any Optimisation needed")
+ return (json.contains(BluePrintConstants.EXPRESSION_GET_INPUT)
+ || json.contains(BluePrintConstants.EXPRESSION_GET_ATTRIBUTE)
+ || json.contains(BluePrintConstants.EXPRESSION_GET_PROPERTY))
+
+ }
+
@JvmStatic
fun getExpressionData(propertyAssignmentNode: JsonNode): ExpressionData {
log.trace("Assignment Data/Expression : {}", propertyAssignmentNode)
val expressionData = ExpressionData(valueNode = propertyAssignmentNode)
if (propertyAssignmentNode is ObjectNode) {
-
val commands: Set<String> = propertyAssignmentNode.fieldNames().asSequence().toList().intersect(BluePrintTypes.validCommands())
if (commands.isNotEmpty()) {
expressionData.isExpression = true
}
}
}
+ } else if (propertyAssignmentNode is TextNode
+ && propertyAssignmentNode.textValue().startsWith(BluePrintConstants.EXPRESSION_DSL_REFERENCE)) {
+ expressionData.isExpression = true
+ expressionData.command = BluePrintConstants.EXPRESSION_DSL_REFERENCE
+ expressionData.dslExpression = populateDSLExpression(propertyAssignmentNode)
}
return expressionData
}
+ @JvmStatic
+ fun populateDSLExpression(jsonNode: TextNode): DSLExpression {
+ return DSLExpression(propertyName = jsonNode.textValue()
+ .removePrefix(BluePrintConstants.EXPRESSION_DSL_REFERENCE))
+ }
+
@JvmStatic
fun populateInputExpression(jsonNode: JsonNode): InputExpression {
return InputExpression(propertyName = jsonNode.first().textValue())
import com.fasterxml.jackson.databind.node.NullNode
import com.fasterxml.jackson.databind.node.ObjectNode
import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
-import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants
-import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintError
-import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException
+import org.onap.ccsdk.apps.controllerblueprints.core.*
import org.onap.ccsdk.apps.controllerblueprints.core.data.ArtifactDefinition
import org.onap.ccsdk.apps.controllerblueprints.core.data.NodeTemplate
import org.onap.ccsdk.apps.controllerblueprints.core.data.PropertyDefinition
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintMetadataUtils
import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils
+import java.io.File
interface BluePrintRuntimeService<T> {
fun setBluePrintError(bluePrintError: BluePrintError)
+ fun loadEnvironments(fileName: String)
+
fun resolveNodeTemplatePropertyAssignments(nodeTemplateName: String,
propertyDefinitions: MutableMap<String, PropertyDefinition>,
propertyAssignments: MutableMap<String, JsonNode>): MutableMap<String, JsonNode>
fun resolveNodeTemplateArtifactDefinition(nodeTemplateName: String, artifactName: String): ArtifactDefinition
+ fun resolveDSLExpression(dslPropertyName: String): JsonNode
+
fun setInputValue(propertyName: String, propertyDefinition: PropertyDefinition, value: JsonNode)
fun setWorkflowInputValue(workflowName: String, propertyName: String, propertyDefinition: PropertyDefinition, value: JsonNode)
private var bluePrintError = BluePrintError()
+ init {
+ /**
+ * Load Default Environments Properties
+ */
+ val absoluteEnvFilePath = bluePrintContext.rootPath.plus(File.separator)
+ .plus(BluePrintConstants.TOSCA_ENVIRONMENTS_DIR)
+ loadEnvironments(absoluteEnvFilePath)
+
+ }
+
override fun id(): String {
return id
}
this.bluePrintError = bluePrintError
}
+ override fun loadEnvironments(fileName: String) {
+ BluePrintMetadataUtils.environmentFileProperties(fileName).forEach { key, value ->
+ setNodeTemplateAttributeValue("ENV", key.toString(), value.toString().asJsonPrimitive())
+ }
+ }
+
/**
* Resolve any property assignments for the node
*/
}
+ /**
+ * Read the DSL Property reference, If there is any expression, then resolve those expression and return as Json
+ * Type
+ */
+ override fun resolveDSLExpression(dslPropertyName: String): JsonNode {
+ val propertyAssignments = bluePrintContext.dslPropertiesByName(dslPropertyName)
+ return if (BluePrintExpressionService.checkContainsExpression(propertyAssignments)
+ && propertyAssignments is ObjectNode) {
+
+ val rootKeyMap = propertyAssignments.rootFieldsToMap()
+ val propertyAssignmentValue: MutableMap<String, JsonNode> = hashMapOf()
+ rootKeyMap.forEach { propertyName, propertyValue ->
+ val propertyAssignmentExpression = PropertyAssignmentService(this)
+ propertyAssignmentValue[propertyName] = propertyAssignmentExpression
+ .resolveAssignmentExpression("DSL", propertyName, propertyValue)
+ }
+ propertyAssignmentValue.asJsonNode()
+ } else {
+ propertyAssignments
+ }
+ }
+
override fun setInputValue(propertyName: String, propertyDefinition: PropertyDefinition, value: JsonNode) {
val path = StringBuilder(BluePrintConstants.PATH_INPUTS)
.append(BluePrintConstants.PATH_DIVIDER).append(propertyName).toString()
BluePrintConstants.EXPRESSION_GET_ARTIFACT -> {
valueNode = resolveArtifactExpression(nodeTemplateName, expressionData.artifactExpression!!)
}
+ BluePrintConstants.EXPRESSION_DSL_REFERENCE -> {
+ valueNode = bluePrintRuntimeService.resolveDSLExpression(expressionData.dslExpression!!.propertyName)
+ }
BluePrintConstants.EXPRESSION_GET_NODE_OF_TYPE -> {
}
/*
* Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
import org.onap.ccsdk.apps.controllerblueprints.core.service.DefaultBluePrintRuntimeService
import java.io.File
import java.nio.charset.Charset
+import java.util.*
class BluePrintMetadataUtils {
companion object {
return toscaMetaDataFromMetaFile(toscaMetaPath).entityDefinitions
}
+ fun bluePrintEnvProperties(basePath: String): Properties {
+ val blueprintsEnvFilePath = basePath.plus(File.separator)
+ .plus(BluePrintConstants.TOSCA_ENVIRONMENTS_DIR)
+ return environmentFileProperties(blueprintsEnvFilePath)
+ }
+
+ fun environmentFileProperties(pathName: String): Properties {
+ val properties = Properties()
+ val envDir = File(pathName)
+ // Verify if the environment directory exists
+ if (envDir.exists() && envDir.isDirectory) {
+ //Find all available environment files
+ envDir.listFiles()
+ .filter { it.name.endsWith(".properties") }
+ .forEach {
+ properties.load(it.inputStream())
+ }
+ }
+ return properties
+ }
+
fun toscaMetaDataFromMetaFile(metaFilePath: String): ToscaMetaData {
val toscaMetaData = ToscaMetaData()
val lines: MutableList<String> = FileUtils.readLines(File(metaFilePath), Charset.defaultCharset())
/*
* Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
import com.fasterxml.jackson.databind.JsonNode
import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
import org.junit.Test
+import org.onap.ccsdk.apps.controllerblueprints.core.asJsonPrimitive
import org.onap.ccsdk.apps.controllerblueprints.core.data.ExpressionData
import kotlin.test.assertEquals
import kotlin.test.assertNotNull
+
/**
*
*
class BluePrintExpressionServiceTest {
@Test
fun testInputExpression() {
- val node : JsonNode = jacksonObjectMapper().readTree("{ \"get_input\" : \"input-name\" }")
- val expressionData : ExpressionData = BluePrintExpressionService.getExpressionData(node)
+ val node: JsonNode = jacksonObjectMapper().readTree("{ \"get_input\" : \"input-name\" }")
+ val expressionData: ExpressionData = BluePrintExpressionService.getExpressionData(node)
assertNotNull(expressionData, " Failed to populate expression data")
assertEquals(expressionData.isExpression, true, "Failed to identify as expression")
assertNotNull(expressionData.inputExpression, " Failed to populate input expression data")
@Test
fun testPropertyExpression() {
- val node : JsonNode = jacksonObjectMapper().readTree("{ \"get_property\" : [\"SELF\", \"property-name\"] }")
- val expressionData : ExpressionData = BluePrintExpressionService.getExpressionData(node)
+ val node: JsonNode = jacksonObjectMapper().readTree("{ \"get_property\" : [\"SELF\", \"property-name\"] }")
+ val expressionData: ExpressionData = BluePrintExpressionService.getExpressionData(node)
assertNotNull(expressionData, " Failed to populate expression data")
assertEquals(expressionData.isExpression, true, "Failed to identify as expression")
assertNotNull(expressionData.propertyExpression, " Failed to populate property expression data")
assertEquals("SELF", expressionData.propertyExpression?.modelableEntityName, " Failed to get expected modelableEntityName")
assertEquals("property-name", expressionData.propertyExpression?.propertyName, " Failed to get expected propertyName")
- val node1 : JsonNode = jacksonObjectMapper().readTree("{ \"get_property\" : [\"SELF\", \"\",\"property-name\", \"resource\", \"name\"] }")
- val expressionData1 : ExpressionData = BluePrintExpressionService.getExpressionData(node1)
+ val node1: JsonNode = jacksonObjectMapper().readTree("{ \"get_property\" : [\"SELF\", \"\",\"property-name\", \"resource\", \"name\"] }")
+ val expressionData1: ExpressionData = BluePrintExpressionService.getExpressionData(node1)
assertNotNull(expressionData1, " Failed to populate expression data")
assertEquals(expressionData1.isExpression, true, "Failed to identify as nested property expression")
assertNotNull(expressionData1.propertyExpression, " Failed to populate nested property expression data")
assertEquals("SELF", expressionData1.propertyExpression?.modelableEntityName, " Failed to get expected modelableEntityName")
assertEquals("property-name", expressionData1.propertyExpression?.propertyName, " Failed to get expected propertyName")
- assertEquals("resource/name",expressionData1.propertyExpression?.subPropertyName, " Failed to populate nested subPropertyName expression data")
+ assertEquals("resource/name", expressionData1.propertyExpression?.subPropertyName, " Failed to populate nested subPropertyName expression data")
}
@Test
fun testAttributeExpression() {
- val node : JsonNode = jacksonObjectMapper().readTree("{ \"get_attribute\" : [\"SELF\", \"resource\"] }")
- val expressionData : ExpressionData = BluePrintExpressionService.getExpressionData(node)
+ val node: JsonNode = jacksonObjectMapper().readTree("{ \"get_attribute\" : [\"SELF\", \"resource\"] }")
+ val expressionData: ExpressionData = BluePrintExpressionService.getExpressionData(node)
assertNotNull(expressionData, " Failed to populate expression data")
assertEquals(expressionData.isExpression, true, "Failed to identify as expression")
assertNotNull(expressionData.attributeExpression, " Failed to populate attribute expression data")
assertEquals("SELF", expressionData.attributeExpression?.modelableEntityName, " Failed to get expected modelableEntityName")
assertEquals("resource", expressionData.attributeExpression?.attributeName, " Failed to get expected attributeName")
- val node1 : JsonNode = jacksonObjectMapper().readTree("{ \"get_attribute\" : [\"SELF\", \"\",\"attribute-name\", \"resource\", \"name\"] }")
- val expressionData1 : ExpressionData = BluePrintExpressionService.getExpressionData(node1)
+ val node1: JsonNode = jacksonObjectMapper().readTree("{ \"get_attribute\" : [\"SELF\", \"\",\"attribute-name\", \"resource\", \"name\"] }")
+ val expressionData1: ExpressionData = BluePrintExpressionService.getExpressionData(node1)
assertNotNull(expressionData1, " Failed to populate expression data")
assertEquals(expressionData1.isExpression, true, "Failed to identify as expression")
assertNotNull(expressionData1.attributeExpression, " Failed to populate attribute expression data")
assertEquals("SELF", expressionData1.attributeExpression?.modelableEntityName, " Failed to get expected modelableEntityName")
assertEquals("attribute-name", expressionData1.attributeExpression?.attributeName, " Failed to get expected attributeName")
- assertEquals("resource/name",expressionData1.attributeExpression?.subAttributeName, " Failed to populate nested subAttributeName expression data")
+ assertEquals("resource/name", expressionData1.attributeExpression?.subAttributeName, " Failed to populate nested subAttributeName expression data")
}
@Test
fun testOutputOperationExpression() {
- val node : JsonNode = jacksonObjectMapper().readTree("{ \"get_operation_output\": [\"SELF\", \"interface-name\", \"operation-name\", \"output-property-name\"] }")
- val expressionData : ExpressionData = BluePrintExpressionService.getExpressionData(node)
+ val node: JsonNode = jacksonObjectMapper().readTree("{ \"get_operation_output\": [\"SELF\", \"interface-name\", \"operation-name\", \"output-property-name\"] }")
+ val expressionData: ExpressionData = BluePrintExpressionService.getExpressionData(node)
assertNotNull(expressionData, " Failed to populate expression data")
assertEquals(expressionData.isExpression, true, "Failed to identify as expression")
assertNotNull(expressionData.operationOutputExpression, " Failed to populate output expression data")
@Test
fun testArtifactExpression() {
- val node : JsonNode = jacksonObjectMapper().readTree("{ \"get_artifact\" : [\"SELF\", \"artifact-template\"] }")
- val expressionData : ExpressionData = BluePrintExpressionService.getExpressionData(node)
+ val node: JsonNode = jacksonObjectMapper().readTree("{ \"get_artifact\" : [\"SELF\", \"artifact-template\"] }")
+ val expressionData: ExpressionData = BluePrintExpressionService.getExpressionData(node)
assertNotNull(expressionData, " Failed to populate expression data")
assertEquals(expressionData.isExpression, true, "Failed to identify as expression")
assertNotNull(expressionData.artifactExpression, " Failed to populate Artifact expression data")
assertEquals("artifact-template", expressionData.artifactExpression?.artifactName, " Failed to get expected artifactName")
- val node1 : JsonNode = jacksonObjectMapper().readTree("{ \"get_artifact\" : [\"SELF\", \"artifact-template\", \"location\", true] }")
- val expressionData1 : ExpressionData = BluePrintExpressionService.getExpressionData(node1)
+ val node1: JsonNode = jacksonObjectMapper().readTree("{ \"get_artifact\" : [\"SELF\", \"artifact-template\", \"location\", true] }")
+ val expressionData1: ExpressionData = BluePrintExpressionService.getExpressionData(node1)
assertNotNull(expressionData1, " Failed to populate expression data")
assertEquals(expressionData1.isExpression, true, "Failed to identify as expression")
assertNotNull(expressionData1.artifactExpression, " Failed to populate Artifact expression data")
assertEquals("location", expressionData1.artifactExpression?.location, " Failed to get expected location")
assertEquals(true, expressionData1.artifactExpression?.remove, " Failed to get expected remove")
}
+
+ @Test
+ fun testDSLExpression() {
+ val node: JsonNode = "*dynamic-rest-source".asJsonPrimitive()
+ val expressionData: ExpressionData = BluePrintExpressionService.getExpressionData(node)
+ assertNotNull(expressionData, " Failed to populate expression data")
+ assertEquals(expressionData.isExpression, true, "Failed to identify as expression")
+ assertNotNull(expressionData.dslExpression, " Failed to populate dsl expression data")
+ assertEquals("dynamic-rest-source", expressionData.dslExpression!!.propertyName,
+ " Failed to populate dsl property name")
+ }
}
\ No newline at end of file
import org.junit.Test
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants
import org.onap.ccsdk.apps.controllerblueprints.core.asJsonPrimitive
+import org.onap.ccsdk.apps.controllerblueprints.core.data.PropertyDefinition
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
}
+ @Test
+ fun `test Resolve DSL Properties`() {
+ log.info("************************ resolveDSLExpression **********************")
+
+ val bluePrintRuntimeService = getBluePrintRuntimeService()
+
+ bluePrintRuntimeService.setInputValue("rest-user-name", PropertyDefinition(), "sample-username"
+ .asJsonPrimitive())
+
+ val resolvedJsonNode: JsonNode = bluePrintRuntimeService.resolveDSLExpression("dynamic-rest-source")
+ assertNotNull(resolvedJsonNode, "Failed to populate dsl property values")
+ }
+
private fun getBluePrintRuntimeService(): BluePrintRuntimeService<MutableMap<String, JsonNode>> {
val blueprintBasePath: String = ("./../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration")
val blueprintRuntime = BluePrintMetadataUtils.getBluePrintRuntime("1234", blueprintBasePath)
import org.junit.Test
import org.onap.ccsdk.apps.controllerblueprints.core.data.ToscaMetaData
+import kotlin.test.assertEquals
import kotlin.test.assertNotNull
+import kotlin.test.assertNull
class BluePrintMetadataUtilsTest {
-
+
@Test
- fun testToscaMetaData(){
+ fun testToscaMetaData() {
- val basePath : String = "./../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration"
+ val basePath: String = "./../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration"
- val toscaMetaData : ToscaMetaData = BluePrintMetadataUtils.toscaMetaData(basePath)
+ val toscaMetaData: ToscaMetaData = BluePrintMetadataUtils.toscaMetaData(basePath)
assertNotNull(toscaMetaData, "Missing Tosca Definition Object")
assertNotNull(toscaMetaData.toscaMetaFileVersion, "Missing Tosca Metadata Version")
assertNotNull(toscaMetaData.csarVersion, "Missing CSAR version")
assertNotNull(toscaMetaData.templateTags, "Missing Template Tags")
}
+
+ @Test
+ fun environmentDataTest() {
+ val environmentPath = "./src/test/resources/environments"
+
+ val properties = BluePrintMetadataUtils.bluePrintEnvProperties(environmentPath)
+
+ assertNotNull(properties, "Could not read the properties")
+ assertEquals(properties.getProperty("blueprintsprocessor.database.alt1.username"), "username1", "failed 1")
+ assertEquals(properties.getProperty("blueprintsprocessor.database.alt1.password"), "password1", "failed 2")
+ assertEquals(properties.getProperty("blueprintsprocessor.database.alt2.username"), "username2", "failed 3")
+ assertEquals(properties.getProperty("blueprintsprocessor.database.alt2.password"), "password2", "failed 4")
+ assertNull(properties.getProperty("blueprintsprocessor.database.alt3.password"), "failed 5")
+ }
}
\ No newline at end of file
--- /dev/null
+blueprintsprocessor.database.alt1.username=username1
+blueprintsprocessor.database.alt1.password=password1
\ No newline at end of file
--- /dev/null
+blueprintsprocessor.database.alt2.username=username2
+blueprintsprocessor.database.alt2.password=password2
\ No newline at end of file