aboutsummaryrefslogtreecommitdiffstats
path: root/ms/blueprintsprocessor/functions/resource-resolution/src
diff options
context:
space:
mode:
Diffstat (limited to 'ms/blueprintsprocessor/functions/resource-resolution/src')
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceAssignmentRuntimeService.kt4
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionConstants.kt1
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceSourceProperties.kt2
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/DatabaseResourceAssignmentProcessor.kt14
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/DefaultResourceResolutionProcessor.kt6
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/InputResourceResolutionProcessor.kt6
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/RestResourceResolutionProcessor.kt15
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/utils/ResourceAssignmentUtils.kt59
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/utils/ResourceAssignmentUtilsTest.kt29
9 files changed, 118 insertions, 18 deletions
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceAssignmentRuntimeService.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceAssignmentRuntimeService.kt
index a65ec585b..8087f7e3f 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceAssignmentRuntimeService.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceAssignmentRuntimeService.kt
@@ -23,6 +23,10 @@ class ResourceAssignmentRuntimeService(private var id: String, private var blueP
resourceStore[key] = value
}
+ fun getResolutionStore(): MutableMap<String, JsonNode> {
+ return resourceStore.mapValues { e -> e.value.deepCopy() as JsonNode }.toMutableMap()
+ }
+
fun getResolutionStore(key: String): JsonNode {
return resourceStore[key]
?: throw BluePrintProcessorException("failed to get execution property ($key)")
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionConstants.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionConstants.kt
index 8f6069160..b934940b1 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionConstants.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionConstants.kt
@@ -30,4 +30,5 @@ object ResourceResolutionConstants {
const val RESOURCE_RESOLUTION_INPUT_RESOURCE_ID = "resource-id"
const val RESOURCE_RESOLUTION_INPUT_RESOURCE_TYPE = "resource-type"
const val RESOURCE_RESOLUTION_INPUT_RESOLUTION_SUMMARY = "resolution-summary"
+ const val METADATA_TRANSFORM_TEMPLATE = "transform-template"
}
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceSourceProperties.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceSourceProperties.kt
index 636e81dda..7a7edc92b 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceSourceProperties.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceSourceProperties.kt
@@ -51,6 +51,8 @@ open class RestResourceSource : ResourceSourceProperties() {
lateinit var verb: String
@get:JsonProperty("payload")
var payload: String? = null
+ @get:JsonProperty("resolved-payload")
+ var resolvedPayload: String? = null
lateinit var type: String
@get:JsonProperty("endpoint-selector")
var endpointSelector: String? = null
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/DatabaseResourceAssignmentProcessor.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/DatabaseResourceAssignmentProcessor.kt
index 0bfd7e4e2..2640b5b85 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/DatabaseResourceAssignmentProcessor.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/DatabaseResourceAssignmentProcessor.kt
@@ -23,10 +23,12 @@ import org.onap.ccsdk.cds.blueprintsprocessor.db.PrimaryDBLibGenericService
import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.DatabaseResourceSource
import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.ResourceResolutionConstants.PREFIX_RESOURCE_RESOLUTION_PROCESSOR
import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.utils.ResourceAssignmentUtils
+import org.onap.ccsdk.cds.blueprintsprocessor.services.execution.ExecutionServiceDomains
import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintProcessorException
-import org.onap.ccsdk.cds.controllerblueprints.core.checkNotEmpty
import org.onap.ccsdk.cds.controllerblueprints.core.isNotEmpty
+import org.onap.ccsdk.cds.controllerblueprints.core.checkNotEmpty
import org.onap.ccsdk.cds.controllerblueprints.core.nullToEmpty
+import org.onap.ccsdk.cds.controllerblueprints.core.updateErrorMessage
import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils
import org.onap.ccsdk.cds.controllerblueprints.resource.dict.KeyIdentifier
import org.onap.ccsdk.cds.controllerblueprints.resource.dict.ResourceAssignment
@@ -64,6 +66,10 @@ open class DatabaseResourceAssignmentProcessor(
}
// Check the value has populated for mandatory case
ResourceAssignmentUtils.assertTemplateKeyValueNotNull(resourceAssignment)
+ } catch (e: BluePrintProcessorException) {
+ val errorMsg = "Failed to process Database resource resolution in template key ($resourceAssignment) assignments."
+ throw e.updateErrorMessage(ExecutionServiceDomains.RESOURCE_RESOLUTION, errorMsg,
+ "Wrong resource definition or DB resolution failed.")
} catch (e: Exception) {
ResourceAssignmentUtils.setFailedResourceDataValue(resourceAssignment, e.message)
throw BluePrintProcessorException("Failed in template key ($resourceAssignment) assignments with: ${e.message}", e)
@@ -101,7 +107,7 @@ open class DatabaseResourceAssignmentProcessor(
"DatabaseResource ($dSource) dictionary information: " +
"Query:($sql), input-key-mapping:($inputKeyMapping), output-key-mapping:(${sourceProperties.outputKeyMapping})"
)
- val jdbcTemplate = blueprintDBLibService(sourceProperties)
+ val jdbcTemplate = blueprintDBLibService(sourceProperties, dSource)
val rows = jdbcTemplate.query(sql, populateNamedParameter(inputKeyMapping))
if (rows.isNullOrEmpty()) {
@@ -111,12 +117,12 @@ open class DatabaseResourceAssignmentProcessor(
}
}
- private fun blueprintDBLibService(sourceProperties: DatabaseResourceSource): BluePrintDBLibGenericService {
+ private fun blueprintDBLibService(sourceProperties: DatabaseResourceSource, selector: String): BluePrintDBLibGenericService {
return if (isNotEmpty(sourceProperties.endpointSelector)) {
val dbPropertiesJson = raRuntimeService.resolveDSLExpression(sourceProperties.endpointSelector!!)
bluePrintDBLibPropertyService.JdbcTemplate(dbPropertiesJson)
} else {
- primaryDBLibGenericService
+ bluePrintDBLibPropertyService.JdbcTemplate(selector)
}
}
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/DefaultResourceResolutionProcessor.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/DefaultResourceResolutionProcessor.kt
index 7705c1102..2921cb6fb 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/DefaultResourceResolutionProcessor.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/DefaultResourceResolutionProcessor.kt
@@ -19,7 +19,9 @@ package org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.pro
import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.ResourceResolutionConstants.PREFIX_RESOURCE_RESOLUTION_PROCESSOR
import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.utils.ResourceAssignmentUtils
+import org.onap.ccsdk.cds.blueprintsprocessor.services.execution.ExecutionServiceDomains
import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintProcessorException
+import org.onap.ccsdk.cds.controllerblueprints.core.updateErrorMessage
import org.onap.ccsdk.cds.controllerblueprints.resource.dict.ResourceAssignment
import org.slf4j.LoggerFactory
import org.springframework.beans.factory.config.ConfigurableBeanFactory
@@ -49,6 +51,10 @@ open class DefaultResourceResolutionProcessor : ResourceAssignmentProcessor() {
}
// Check the value has populated for mandatory case
ResourceAssignmentUtils.assertTemplateKeyValueNotNull(resourceAssignment)
+ } catch (e: BluePrintProcessorException) {
+ val errorMsg = "Failed to process default resource resolution in template key ($resourceAssignment) assignments."
+ throw e.updateErrorMessage(ExecutionServiceDomains.RESOURCE_RESOLUTION, errorMsg,
+ "Wrong default value was set.")
} catch (e: Exception) {
ResourceAssignmentUtils.setFailedResourceDataValue(resourceAssignment, e.message)
throw BluePrintProcessorException("Failed in template key ($resourceAssignment) assignments with: ${e.message}", e)
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/InputResourceResolutionProcessor.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/InputResourceResolutionProcessor.kt
index f04a787db..d078a2d70 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/InputResourceResolutionProcessor.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/InputResourceResolutionProcessor.kt
@@ -20,8 +20,10 @@ package org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.pro
import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.DatabaseResourceSource
import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.ResourceResolutionConstants.PREFIX_RESOURCE_RESOLUTION_PROCESSOR
import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.utils.ResourceAssignmentUtils
+import org.onap.ccsdk.cds.blueprintsprocessor.services.execution.ExecutionServiceDomains
import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintProcessorException
import org.onap.ccsdk.cds.controllerblueprints.core.isNotEmpty
+import org.onap.ccsdk.cds.controllerblueprints.core.updateErrorMessage
import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils
import org.onap.ccsdk.cds.controllerblueprints.resource.dict.ResourceAssignment
import org.springframework.beans.factory.config.ConfigurableBeanFactory
@@ -48,6 +50,10 @@ open class InputResourceResolutionProcessor : ResourceAssignmentProcessor() {
}
// Check the value has populated for mandatory case
ResourceAssignmentUtils.assertTemplateKeyValueNotNull(resourceAssignment)
+ } catch (e: BluePrintProcessorException) {
+ val errorMsg = "Failed to process input resource resolution in template key ($resourceAssignment) assignments."
+ throw e.updateErrorMessage(ExecutionServiceDomains.RESOURCE_RESOLUTION, errorMsg,
+ "Wrong input value was set.")
} catch (e: Exception) {
ResourceAssignmentUtils.setFailedResourceDataValue(resourceAssignment, e.message)
throw BluePrintProcessorException("Failed in template key ($resourceAssignment) assignments with : (${e.message})", e)
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/RestResourceResolutionProcessor.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/RestResourceResolutionProcessor.kt
index 5d9226876..7596d7d8c 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/RestResourceResolutionProcessor.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/RestResourceResolutionProcessor.kt
@@ -1,6 +1,6 @@
/*
- * Copyright © 2018 IBM.
- * Modifications Copyright © 2017-2019 AT&T, Bell Canada
+ * Copyright © 2018 - 2020 IBM.
+ * Modifications Copyright © 2017-2020 AT&T, Bell Canada
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,10 +22,12 @@ import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.Rest
import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.utils.ResourceAssignmentUtils
import org.onap.ccsdk.cds.blueprintsprocessor.rest.service.BluePrintRestLibPropertyService
import org.onap.ccsdk.cds.blueprintsprocessor.rest.service.BlueprintWebClientService
+import org.onap.ccsdk.cds.blueprintsprocessor.services.execution.ExecutionServiceDomains
import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintProcessorException
-import org.onap.ccsdk.cds.controllerblueprints.core.checkNotEmpty
import org.onap.ccsdk.cds.controllerblueprints.core.isNotEmpty
+import org.onap.ccsdk.cds.controllerblueprints.core.checkNotEmpty
import org.onap.ccsdk.cds.controllerblueprints.core.nullToEmpty
+import org.onap.ccsdk.cds.controllerblueprints.core.updateErrorMessage
import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils
import org.onap.ccsdk.cds.controllerblueprints.resource.dict.KeyIdentifier
import org.onap.ccsdk.cds.controllerblueprints.resource.dict.ResourceAssignment
@@ -76,8 +78,7 @@ open class RestResourceResolutionProcessor(private val blueprintRestLibPropertyS
checkNotNull(sourceProperties.inputKeyMapping) { "failed to get input-key-mappings for $dName under $dSource properties" }
val resolvedInputKeyMapping = resolveInputKeyMappingVariables(inputKeyMapping).toMutableMap()
- sourceProperties.inputKeyMapping
- ?.mapValues { raRuntimeService.getDictionaryStore(it.value) }
+ inputKeyMapping?.mapValues { raRuntimeService.getDictionaryStore(it.value) }
?.map { KeyIdentifier(it.key, it.value) }
?.let { resourceAssignment.keyIdentifiers.addAll(it) }
@@ -114,6 +115,10 @@ open class RestResourceResolutionProcessor(private val blueprintRestLibPropertyS
}
// Check the value has populated for mandatory case
ResourceAssignmentUtils.assertTemplateKeyValueNotNull(resourceAssignment)
+ } catch (e: BluePrintProcessorException) {
+ val errorMsg = "Failed to process REST resource resolution in template key ($resourceAssignment) assignments."
+ throw e.updateErrorMessage(ExecutionServiceDomains.RESOURCE_RESOLUTION, errorMsg,
+ "Wrong resource definition or resolution failed.")
} catch (e: Exception) {
ResourceAssignmentUtils.setFailedResourceDataValue(resourceAssignment, e.message)
throw BluePrintProcessorException("Failed in template key ($resourceAssignment) assignments with: ${e.message}", e)
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 7bb757b8e..497b26803 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
@@ -39,6 +39,7 @@ import org.onap.ccsdk.cds.controllerblueprints.core.normalizedFile
import org.onap.ccsdk.cds.controllerblueprints.core.nullToEmpty
import org.onap.ccsdk.cds.controllerblueprints.core.rootFieldsToMap
import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintRuntimeService
+import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintVelocityTemplateService
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
@@ -127,6 +128,32 @@ class ResourceAssignmentUtils {
raRuntimeService.putResolutionStore(resourceAssignment.name, value)
raRuntimeService.putDictionaryStore(resourceAssignment.dictionaryName!!, value)
resourceAssignment.property!!.value = value
+
+ val metadata = resourceAssignment.property?.metadata
+ metadata?.get(ResourceResolutionConstants.METADATA_TRANSFORM_TEMPLATE)
+ ?.let { if (it.contains("$")) it else null }
+ ?.let { template ->
+ val resolutionStore = raRuntimeService.getResolutionStore()
+ .mapValues { e -> e.value.asText() } as MutableMap<String, Any>
+ val newValue: JsonNode
+ try {
+ newValue = BluePrintVelocityTemplateService
+ .generateContent(template, null, true, resolutionStore)
+ .also { if (hasLogProtect(metadata))
+ logger.info("Transformed value: $resourceAssignment.name")
+ else
+ logger.info("Transformed value: $value -> $it") }
+ .let { v -> v.asJsonType() }
+ } catch (e: Exception) {
+ throw BluePrintProcessorException(
+ "transform-template failed: $template", e)
+ }
+ with(resourceAssignment) {
+ raRuntimeService.putResolutionStore(this.name, newValue)
+ raRuntimeService.putDictionaryStore(this.dictionaryName!!, newValue)
+ this.property!!.value = newValue
+ }
+ }
}
fun setFailedResourceDataValue(resourceAssignment: ResourceAssignment, message: String?) {
@@ -203,18 +230,40 @@ class ResourceAssignmentUtils {
resourceAssignments: List<ResourceAssignment>,
resourceDefinitions: Map<String, ResourceDefinition>
): String {
+ val emptyTextNode = TextNode.valueOf("")
val resolutionSummaryList = resourceAssignments.map {
val definition = resourceDefinitions[it.name]
- val payload = definition?.sources?.get(it.dictionarySource)
+ val description = definition?.property?.description ?: ""
+ val value = it.property?.value
+ ?.let { v -> if (v.isNullOrMissing()) emptyTextNode else v }
+ ?: emptyTextNode
+
+ var payload: JsonNode = definition?.sources?.get(it.dictionarySource)
?.properties?.get("resolved-payload")
+ ?.let { p -> if (p.isNullOrMissing()) emptyTextNode else p }
+ ?: emptyTextNode
+
val metadata = definition?.property?.metadata
?.map { e -> DictionaryMetadataEntry(e.key, e.value) }
?.toMutableList() ?: mutableListOf()
- val description = definition?.property?.description
+
+ val keyIdentifiers: MutableList<KeyIdentifier> = it.keyIdentifiers.map { k ->
+ if (k.value.isNullOrMissing()) KeyIdentifier(k.name, emptyTextNode) else k
+ }.toMutableList()
+
ResolutionSummary(
- it.name, it.property?.value, it.property?.required, it.property?.type,
- it.keyIdentifiers, description, metadata, it.dictionaryName,
- it.dictionarySource, payload, it.status, it.message
+ it.name,
+ value,
+ it.property?.required ?: false,
+ it.property?.type ?: "",
+ keyIdentifiers,
+ description,
+ metadata,
+ it.dictionaryName ?: "",
+ it.dictionarySource ?: "",
+ payload,
+ it.status ?: "",
+ it.message ?: ""
)
}
// Wrapper needed for integration with SDNC
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 9df8fb7d7..7746b5c41 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
@@ -29,6 +29,7 @@ import kotlinx.coroutines.runBlocking
import org.junit.Before
import org.junit.Test
import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.ResourceAssignmentRuntimeService
+import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.ResourceResolutionConstants.METADATA_TRANSFORM_TEMPLATE
import org.onap.ccsdk.cds.controllerblueprints.core.asJsonPrimitive
import org.onap.ccsdk.cds.controllerblueprints.core.asJsonType
import org.onap.ccsdk.cds.controllerblueprints.core.data.DataType
@@ -180,8 +181,8 @@ class ResourceAssignmentUtilsTest {
"resolution-summary":[
{
"name":"pnf-id",
- "value":null,
- "required":null,
+ "value":"",
+ "required":false,
"type":"string",
"key-identifiers":[],
"dictionary-description":"pnf-id",
@@ -191,8 +192,8 @@ class ResourceAssignmentUtilsTest {
"dictionary-name":"pnf-id",
"dictionary-source":"input",
"request-payload":{"mock":true},
- "status":null,
- "message":null
+ "status":"",
+ "message":""
}
]
}
@@ -333,6 +334,26 @@ class ResourceAssignmentUtilsTest {
)
}
+ @Test
+ fun `transform resolved value with inline template`() {
+ resourceAssignmentRuntimeService.putResolutionStore("vnf_name", "abc-vnf".asJsonType())
+ resourceAssignment = ResourceAssignment()
+ resourceAssignment.name = "int_pktgen_private_net_id"
+ resourceAssignment.property = PropertyDefinition()
+ resourceAssignment.property!!.type = "string"
+ val value = "".asJsonType()
+
+ // Enable transform template
+ resourceAssignment.property!!.metadata =
+ mutableMapOf(METADATA_TRANSFORM_TEMPLATE to "\${vnf_name}_private2")
+
+ ResourceAssignmentUtils
+ .setResourceDataValue(resourceAssignment, resourceAssignmentRuntimeService, value)
+
+ assertEquals("abc-vnf_private2",
+ resourceAssignment.property!!.value!!.asText())
+ }
+
private fun initInputMapAndExpectedValuesForPrimitiveType() {
inputMapToTestPrimitiveTypeWithValue = "1.2.3.1".asJsonType()
val keyValue = mutableMapOf<String, String>()