From 8a3d5215f2424bbea855ac1b86dfefb98f349496 Mon Sep 17 00:00:00 2001 From: Jozsef Csongvai Date: Thu, 28 May 2020 13:57:06 -0400 Subject: 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 Change-Id: I54c1991d23d65217f3492b08a2170a6d41b6482d --- .../core/service/BluePrintExpressionServiceTest.kt | 4 +-- .../core/service/BluePrintRuntimeServiceTest.kt | 41 ++++++++++++++++++++++ 2 files changed, 43 insertions(+), 2 deletions(-) (limited to 'ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/test') 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( + "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> { val blueprintBasePath = normalizedPathName(TestConstants.PATH_TEST_BLUEPRINTS_BASECONFIG) val blueprintRuntime = BluePrintMetadataUtils.bluePrintRuntime("1234", blueprintBasePath) -- cgit 1.2.3-korg