From 1591ba7289f34c1c44881c169e91c3a6ceda9531 Mon Sep 17 00:00:00 2001 From: Jozsef Csongvai Date: Mon, 25 May 2020 11:23:21 -0400 Subject: Fix sub-attribute parsing for accessing resolved values Added assignment-map attribute to ResourceResolutionComponent. This attribute will hold a json object with the resolved values for each artifact-prefix. It will enable accessing any resolved value, using get_attribute with JsonPath. Issue-ID: CCSDK-2389 Signed-off-by: Jozsef Csongvai Change-Id: I3441569d9766fbd79703d2f224de448edd56dbb2 --- .../resolution/utils/ResourceAssignmentUtilsTest.kt | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'ms/blueprintsprocessor/functions/resource-resolution/src/test') diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/utils/ResourceAssignmentUtilsTest.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/utils/ResourceAssignmentUtilsTest.kt index b4befc26d..6734613fc 100644 --- a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/utils/ResourceAssignmentUtilsTest.kt +++ b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/utils/ResourceAssignmentUtilsTest.kt @@ -22,6 +22,7 @@ package org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.utils import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.node.ObjectNode import com.fasterxml.jackson.databind.node.TextNode import io.mockk.every import io.mockk.spyk @@ -167,7 +168,7 @@ class ResourceAssignmentUtilsTest { } @Test - fun generate() { + fun generateResolutionSummaryDataTest() { val resourceAssignment = createResourceAssignmentForTest(null) val resourceDefinition = ResourceDefinition() val nodeTemplate = NodeTemplate().apply { @@ -206,6 +207,20 @@ class ResourceAssignmentUtilsTest { """.replace("\n|\\s".toRegex(), ""), result) } + @Test + fun generateAssignmentMapTest() { + val artifactPrefix = "vdns" + val resourceAssignments = mutableListOf( + createResourceAssignmentForTest("abc-123", "vnf-id"), + createResourceAssignmentForTest(null, "vf-module-name") + ) + + val result: ObjectNode = ResourceAssignmentUtils.generateAssignmentMap(artifactPrefix, resourceAssignments) + + assertEquals("abc-123", result["vdns"]["vnf-id"].textValue()) + assertEquals(JacksonUtils.getJsonNode(null), result["vdns"]["vf-module-name"]) + } + private fun createResourceAssignmentForTest(resourceValue: String?, resourceName: String = "pnf-id"): ResourceAssignment { val valueForTest = if (resourceValue == null) null else TextNode(resourceValue) val resourceAssignmentForTest = ResourceAssignment().apply { -- cgit 1.2.3-korg