aboutsummaryrefslogtreecommitdiffstats
path: root/ms/controllerblueprints/modules/blueprint-core/src/test
diff options
context:
space:
mode:
authorMuthuramalingam, Brinda Santh <brindasanth@in.ibm.com>2019-02-20 11:34:23 -0500
committerMuthuramalingam, Brinda Santh <brindasanth@in.ibm.com>2019-02-22 18:02:51 -0500
commit39800c759802dd011b8ca0d9508c37df6772d869 (patch)
tree2aca67047fca354af201cbfcbba78e0183ca3e49 /ms/controllerblueprints/modules/blueprint-core/src/test
parent5ce12a24482427f09cfdfc580fb4b59a6d86f5c2 (diff)
Add dsl model definition
Change-Id: Ic2332e32d142f231cc8a3a25e2528cde455da827 Issue-ID: CCSDK-1095 Signed-off-by: Muthuramalingam, Brinda Santh <brindasanth@in.ibm.com> Signed-off-by: Balazinski <bartosz.balazinski@ibm.com>
Diffstat (limited to 'ms/controllerblueprints/modules/blueprint-core/src/test')
-rw-r--r--ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintExpressionServiceTest.kt50
-rw-r--r--ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeServiceTest.kt14
-rw-r--r--ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintMetadataUtilsTest.kt24
-rw-r--r--ms/controllerblueprints/modules/blueprint-core/src/test/resources/environments/Environments/environment1.properties2
-rw-r--r--ms/controllerblueprints/modules/blueprint-core/src/test/resources/environments/Environments/environment2.properties2
5 files changed, 70 insertions, 22 deletions
diff --git a/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintExpressionServiceTest.kt b/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintExpressionServiceTest.kt
index d68892fc..58910055 100644
--- a/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintExpressionServiceTest.kt
+++ b/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintExpressionServiceTest.kt
@@ -1,5 +1,6 @@
/*
* 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.
@@ -19,9 +20,11 @@ package org.onap.ccsdk.apps.controllerblueprints.core.service
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
+
/**
*
*
@@ -30,8 +33,8 @@ 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")
@@ -40,49 +43,49 @@ class BluePrintExpressionServiceTest {
@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")
@@ -95,8 +98,8 @@ class BluePrintExpressionServiceTest {
@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")
@@ -104,8 +107,8 @@ class BluePrintExpressionServiceTest {
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")
@@ -114,4 +117,15 @@ class BluePrintExpressionServiceTest {
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
diff --git a/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeServiceTest.kt b/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeServiceTest.kt
index 92e9247a..c0bfd0f5 100644
--- a/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeServiceTest.kt
+++ b/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeServiceTest.kt
@@ -24,6 +24,7 @@ import com.fasterxml.jackson.databind.node.NullNode
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
@@ -139,6 +140,19 @@ class BluePrintRuntimeServiceTest {
}
+ @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)
diff --git a/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintMetadataUtilsTest.kt b/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintMetadataUtilsTest.kt
index 599bb3be..366ce4a8 100644
--- a/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintMetadataUtilsTest.kt
+++ b/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintMetadataUtilsTest.kt
@@ -20,16 +20,18 @@ package org.onap.ccsdk.apps.controllerblueprints.core.utils
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")
@@ -38,4 +40,18 @@ class BluePrintMetadataUtilsTest {
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
diff --git a/ms/controllerblueprints/modules/blueprint-core/src/test/resources/environments/Environments/environment1.properties b/ms/controllerblueprints/modules/blueprint-core/src/test/resources/environments/Environments/environment1.properties
new file mode 100644
index 00000000..d735087b
--- /dev/null
+++ b/ms/controllerblueprints/modules/blueprint-core/src/test/resources/environments/Environments/environment1.properties
@@ -0,0 +1,2 @@
+blueprintsprocessor.database.alt1.username=username1
+blueprintsprocessor.database.alt1.password=password1 \ No newline at end of file
diff --git a/ms/controllerblueprints/modules/blueprint-core/src/test/resources/environments/Environments/environment2.properties b/ms/controllerblueprints/modules/blueprint-core/src/test/resources/environments/Environments/environment2.properties
new file mode 100644
index 00000000..5530a8f8
--- /dev/null
+++ b/ms/controllerblueprints/modules/blueprint-core/src/test/resources/environments/Environments/environment2.properties
@@ -0,0 +1,2 @@
+blueprintsprocessor.database.alt2.username=username2
+blueprintsprocessor.database.alt2.password=password2 \ No newline at end of file