aboutsummaryrefslogtreecommitdiffstats
path: root/ms/blueprintsprocessor/modules/blueprints/blueprint-core
diff options
context:
space:
mode:
authorJozsef Csongvai <jozsef.csongvai@bell.ca>2020-05-28 13:57:06 -0400
committerKAPIL SINGAL <ks220y@att.com>2020-06-09 14:19:14 +0000
commit8a3d5215f2424bbea855ac1b86dfefb98f349496 (patch)
treed32c53b0936e73c7336e514964b3492b150d945d /ms/blueprintsprocessor/modules/blueprints/blueprint-core
parent7999215bcb96bfca2111014c47c9e8766936b254 (diff)
Add ResourceResolutionResult to ResourceResolutionService
In order to ensure consistent behavior for assignment-map, supporting occurences and multiple artifact-prefixes, ResourceResolutionService needs to return assignment-map alongside generated template content. Issue-ID: CCSDK-2389 Signed-off-by: Jozsef Csongvai <jozsef.csongvai@bell.ca> Change-Id: I54c1991d23d65217f3492b08a2170a6d41b6482d
Diffstat (limited to 'ms/blueprintsprocessor/modules/blueprints/blueprint-core')
-rw-r--r--ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintExpressionService.kt4
-rw-r--r--ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintExpressionServiceTest.kt4
-rw-r--r--ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintRuntimeServiceTest.kt41
3 files changed, 45 insertions, 4 deletions
diff --git a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintExpressionService.kt b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintExpressionService.kt
index 6a3c64650..b6c432b4d 100644
--- a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintExpressionService.kt
+++ b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintExpressionService.kt
@@ -130,7 +130,7 @@ object BluePrintExpressionService {
val propertyPaths: List<String> = arrayNode.filterIndexed { index, _ ->
index >= 3
}.map { it.textValue() }
- subProperty = propertyPaths.joinToString("/")
+ subProperty = propertyPaths.joinToString(".")
}
}
@@ -170,7 +170,7 @@ object BluePrintExpressionService {
val propertyPaths: List<String> = arrayNode.filterIndexed { index, _ ->
index >= 3
}.map { it.textValue() }
- subAttributeName = propertyPaths.joinToString("/")
+ subAttributeName = propertyPaths.joinToString(".")
}
}
return AttributeExpression(
diff --git a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintExpressionServiceTest.kt b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintExpressionServiceTest.kt
index f8cad990d..4f645270d 100644
--- a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintExpressionServiceTest.kt
+++ b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintExpressionServiceTest.kt
@@ -60,7 +60,7 @@ class BluePrintExpressionServiceTest {
assertEquals("SELF", expressionData1.propertyExpression?.modelableEntityName, " Failed to get expected modelableEntityName")
assertEquals("property-name", expressionData1.propertyExpression?.propertyName, " Failed to get expected propertyName")
assertEquals(
- "resource/name",
+ "resource.name",
expressionData1.propertyExpression?.subPropertyName,
" Failed to populate nested subPropertyName expression data"
)
@@ -84,7 +84,7 @@ class BluePrintExpressionServiceTest {
assertEquals("SELF", expressionData1.attributeExpression?.modelableEntityName, " Failed to get expected modelableEntityName")
assertEquals("attribute-name", expressionData1.attributeExpression?.attributeName, " Failed to get expected attributeName")
assertEquals(
- "resource/name",
+ "resource.name",
expressionData1.attributeExpression?.subAttributeName,
" Failed to populate nested subAttributeName expression data"
)
diff --git a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintRuntimeServiceTest.kt b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintRuntimeServiceTest.kt
index 871f8af08..79979b949 100644
--- a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintRuntimeServiceTest.kt
+++ b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintRuntimeServiceTest.kt
@@ -23,6 +23,7 @@ import org.junit.Test
import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants
import org.onap.ccsdk.cds.controllerblueprints.core.TestConstants
import org.onap.ccsdk.cds.controllerblueprints.core.asJsonPrimitive
+import org.onap.ccsdk.cds.controllerblueprints.core.data.PropertyDefinition
import org.onap.ccsdk.cds.controllerblueprints.core.normalizedPathName
import org.onap.ccsdk.cds.controllerblueprints.core.utils.BluePrintMetadataUtils
import org.onap.ccsdk.cds.controllerblueprints.core.utils.BluePrintRuntimeUtils
@@ -234,6 +235,46 @@ class BluePrintRuntimeServiceTest {
assertNotNull(resolvedJsonNode, "Failed to populate workflow output property values")
}
+ @Test
+ fun `test resolvePropertyDefinitions using sub attributes`() {
+ val bluePrintRuntimeService = getBluePrintRuntimeService()
+
+ bluePrintRuntimeService.setNodeTemplateAttributeValue(
+ "resource-assignment", "assignment-map",
+ JacksonUtils.jsonNode("""
+ {
+ "a-prefix":{
+ "an-object":{
+ "a-key":123
+ }
+ }
+ }
+ """.trimIndent())
+ )
+
+ val propertyDefinitions = mutableMapOf<String, PropertyDefinition>(
+ "resolution" to PropertyDefinition().apply {
+ this.type = "json"
+ this.value = JacksonUtils.jsonNode("""
+ {
+ "get_attribute":[
+ "resource-assignment",
+ "",
+ "assignment-map",
+ "a-prefix",
+ "an-object",
+ "a-key"
+ ]
+ }
+ """.trimIndent())
+ }
+ )
+
+ val result = bluePrintRuntimeService.resolvePropertyDefinitions("workflow", "WORKFLOW", propertyDefinitions)
+
+ assertEquals("123", result["resolution"]!!.asText())
+ }
+
private fun getBluePrintRuntimeService(): BluePrintRuntimeService<MutableMap<String, JsonNode>> {
val blueprintBasePath = normalizedPathName(TestConstants.PATH_TEST_BLUEPRINTS_BASECONFIG)
val blueprintRuntime = BluePrintMetadataUtils.bluePrintRuntime("1234", blueprintBasePath)