diff options
Diffstat (limited to 'ms/blueprintsprocessor/functions')
3 files changed, 40 insertions, 19 deletions
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/utils/ResourceAssignmentUtils.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/utils/ResourceAssignmentUtils.kt index 6922192c6..7bb757b8e 100644 --- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/utils/ResourceAssignmentUtils.kt +++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/utils/ResourceAssignmentUtils.kt @@ -42,6 +42,7 @@ import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintRuntimeServ import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonReactorUtils import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils import org.onap.ccsdk.cds.controllerblueprints.core.utils.PropertyDefinitionUtils.Companion.hasLogProtect +import org.onap.ccsdk.cds.controllerblueprints.resource.dict.DictionaryMetadataEntry import org.onap.ccsdk.cds.controllerblueprints.resource.dict.KeyIdentifier import org.onap.ccsdk.cds.controllerblueprints.resource.dict.ResolutionSummary import org.onap.ccsdk.cds.controllerblueprints.resource.dict.ResourceAssignment @@ -203,15 +204,22 @@ class ResourceAssignmentUtils { resourceDefinitions: Map<String, ResourceDefinition> ): String { val resolutionSummaryList = resourceAssignments.map { - val payload = resourceDefinitions[it.name] - ?.sources?.get(it.dictionarySource)?.properties?.get("resolved-payload") + val definition = resourceDefinitions[it.name] + val payload = definition?.sources?.get(it.dictionarySource) + ?.properties?.get("resolved-payload") + val metadata = definition?.property?.metadata + ?.map { e -> DictionaryMetadataEntry(e.key, e.value) } + ?.toMutableList() ?: mutableListOf() + val description = definition?.property?.description ResolutionSummary( - it.name, it.property?.value, it.property?.required, - it.property?.type, it.keyIdentifiers, it.dictionaryName, - payload, it.dictionarySource, it.status, it.message + it.name, it.property?.value, it.property?.required, it.property?.type, + it.keyIdentifiers, description, metadata, it.dictionaryName, + it.dictionarySource, payload, it.status, it.message ) } - return JacksonUtils.getJson(resolutionSummaryList, includeNull = true) + // Wrapper needed for integration with SDNC + val data = mapOf("resolution-summary" to resolutionSummaryList) + return JacksonUtils.getJson(data, includeNull = true) } private fun useDefaultValueIfNull( diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionServiceTest.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionServiceTest.kt index 0a12540d4..d5c43184e 100644 --- a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionServiceTest.kt +++ b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionServiceTest.kt @@ -256,7 +256,8 @@ class ResourceResolutionServiceTest { props ) }.let { - val list = JacksonUtils.getListFromJson(it, ResolutionSummary::class.java) + val summaries = JacksonUtils.jsonNode(it)["resolution-summary"] + val list = JacksonUtils.getListFromJsonNode(summaries, ResolutionSummary::class.java) assertEquals(list.size, 3) } } 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 da3b9c23b..9df8fb7d7 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 @@ -167,23 +167,35 @@ class ResourceAssignmentUtilsTest { properties = mutableMapOf("resolved-payload" to JacksonUtils.jsonNode("{\"mock\": true}")) } resourceDefinition.sources = mutableMapOf("input" to nodeTemplate) + resourceDefinition.property = PropertyDefinition().apply { + this.description = "pnf-id" + this.metadata = mutableMapOf("aai-path" to "//path/in/aai") + } val result = ResourceAssignmentUtils.generateResolutionSummaryData( listOf(resourceAssignment), mapOf("pnf-id" to resourceDefinition)) assertEquals(""" - [{ - "name":"pnf-id", - "value":null, - "required":null, - "type":"string", - "key-identifiers":[], - "dictionary-name":"pnf-id", - "request-payload":{"mock":true}, - "dictionary-source":"input", - "status":null, - "message":null - }] + { + "resolution-summary":[ + { + "name":"pnf-id", + "value":null, + "required":null, + "type":"string", + "key-identifiers":[], + "dictionary-description":"pnf-id", + "dictionary-metadata":[ + {"name":"aai-path","value":"//path/in/aai"} + ], + "dictionary-name":"pnf-id", + "dictionary-source":"input", + "request-payload":{"mock":true}, + "status":null, + "message":null + } + ] + } """.replace("\n|\\s".toRegex(), ""), result) } |