aboutsummaryrefslogtreecommitdiffstats
path: root/ms/blueprintsprocessor/functions/resource-resolution/src
diff options
context:
space:
mode:
authorSingal, Kapil (ks220y) <ks220y@att.com>2019-11-22 18:06:08 -0500
committerKAPIL SINGAL <ks220y@att.com>2019-11-26 21:32:38 +0000
commit341db21b2ac0a14a1ed2b8bf7930914dda054bfe (patch)
tree113bba965b06cfe3a8af3a0a527d1a41c9faf0f9 /ms/blueprintsprocessor/functions/resource-resolution/src
parentd274e5fc552cf9ae25500f504f0434981cf3accf (diff)
Formatting Code base with ktlint
No Business logic change, just the code format. Competible with IntelliJ: https://github.com/pinterest/ktlint#option-3 To format run: mvn process-sources -P format Issue-ID: CCSDK-1947 Signed-off-by: Singal, Kapil (ks220y) <ks220y@att.com> Change-Id: Ic9e9209fb7023d77f434693ad5a01229f8d09331
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.kt9
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceDefinitionDSL.kt73
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponent.kt45
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponentDSL.kt133
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionConfiguration.kt2
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionConstants.kt24
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionExtensions.kt19
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionService.kt351
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceSourceDSL.kt244
-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/db/ResourceResolution.kt29
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/ResourceResolutionDBService.kt101
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/ResourceResolutionRepository.kt40
-rwxr-xr-xms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/TemplateResolution.kt23
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/TemplateResolutionRepository.kt12
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/TemplateResolutionService.kt107
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/CapabilityResourceResolutionProcessor.kt7
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/DatabaseResourceAssignmentProcessor.kt22
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/DefaultResourceResolutionProcessor.kt3
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/InputResourceResolutionProcessor.kt31
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/ResourceAssignmentProcessor.kt37
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/RestResourceResolutionProcessor.kt13
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/utils/ResourceAssignmentUtils.kt73
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/utils/ResourceDefinitionUtils.kt17
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/scripts/SimpleRAProcessor.kt (renamed from ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/scripts/InternalRAProcessor.cba.kt)0
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceDefinitionDSLTest.kt26
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponentDSLTest.kt12
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponentTest.kt44
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionServiceTest.kt190
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceSourceDSLTest.kt24
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/ResourceResolutionDBServiceTest.kt47
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/TemplateResolutionServiceTest.kt35
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/mock/MockBluePrintRestLibPropertyService.kt (renamed from ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/mock/MockBlueprintResLibPropertyService.kt)6
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/mock/MockBlueprintWebClientService.kt44
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/mock/MockDatabaseConfiguration.kt6
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/mock/MockRestResourceResolutionProcessor.kt25
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/CapabilityResourceResolutionProcessorTest.kt8
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/DatabaseResourceResolutionProcessorTest.kt19
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/DefaultResourceResolutionProcessorTest.kt5
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/InputResourceResolutionProcessorTest.kt5
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/RestResourceResolutionProcessorTest.kt24
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/utils/ResourceAssignmentUtilsTest.kt144
42 files changed, 1307 insertions, 774 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 3a3750acb..a65ec585b 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
@@ -5,8 +5,8 @@ import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintProcessorException
import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintContext
import org.onap.ccsdk.cds.controllerblueprints.core.service.DefaultBluePrintRuntimeService
-class ResourceAssignmentRuntimeService(private var id: String, private var bluePrintContext: BluePrintContext)
- : DefaultBluePrintRuntimeService(id, bluePrintContext) {
+class ResourceAssignmentRuntimeService(private var id: String, private var bluePrintContext: BluePrintContext) :
+ DefaultBluePrintRuntimeService(id, bluePrintContext) {
private lateinit var resolutionId: String
private var resourceStore: MutableMap<String, JsonNode> = hashMapOf()
@@ -25,7 +25,7 @@ class ResourceAssignmentRuntimeService(private var id: String, private var blueP
fun getResolutionStore(key: String): JsonNode {
return resourceStore[key]
- ?: throw BluePrintProcessorException("failed to get execution property ($key)")
+ ?: throw BluePrintProcessorException("failed to get execution property ($key)")
}
fun checkResolutionStore(key: String): Boolean {
@@ -58,7 +58,7 @@ class ResourceAssignmentRuntimeService(private var id: String, private var blueP
fun getDictionaryStore(key: String): JsonNode {
return resourceStore["dictionary-$key"]
- ?: throw BluePrintProcessorException("failed to get execution property (dictionary-$key)")
+ ?: throw BluePrintProcessorException("failed to get execution property (dictionary-$key)")
}
fun checkDictionaryStore(key: String): Boolean {
@@ -84,5 +84,4 @@ class ResourceAssignmentRuntimeService(private var id: String, private var blueP
fun getDoubleFromDictionaryStore(key: String): Double? {
return getResolutionStore("dictionary-$key").asDouble()
}
-
}
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceDefinitionDSL.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceDefinitionDSL.kt
index 141bad619..7c6ba603b 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceDefinitionDSL.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceDefinitionDSL.kt
@@ -24,32 +24,42 @@ import org.onap.ccsdk.cds.controllerblueprints.resource.dict.ResourceAssignment
import org.onap.ccsdk.cds.controllerblueprints.resource.dict.ResourceDefinition
/** Resource Definition DSL **/
-fun BluePrintTypes.resourceDefinitions(block: ResourceDefinitionsBuilder.() -> Unit)
- : MutableMap<String, ResourceDefinition> {
+fun BluePrintTypes.resourceDefinitions(block: ResourceDefinitionsBuilder.() -> Unit):
+ MutableMap<String, ResourceDefinition> {
return ResourceDefinitionsBuilder().apply(block).build()
}
-fun BluePrintTypes.resourceDefinition(name: String, description: String,
- block: ResourceDefinitionBuilder.() -> Unit): ResourceDefinition {
+fun BluePrintTypes.resourceDefinition(
+ name: String,
+ description: String,
+ block: ResourceDefinitionBuilder.() -> Unit
+): ResourceDefinition {
return ResourceDefinitionBuilder(name, description).apply(block).build()
}
/** Resource Mapping DSL **/
-fun BluePrintTypes.resourceAssignments(block: ResourceAssignmentsBuilder.() -> Unit)
- : MutableMap<String, ResourceAssignment> {
+fun BluePrintTypes.resourceAssignments(block: ResourceAssignmentsBuilder.() -> Unit):
+ MutableMap<String, ResourceAssignment> {
return ResourceAssignmentsBuilder().apply(block).build()
}
-fun BluePrintTypes.resourceAssignment(name: String, dictionaryName: String, dictionarySource: String,
- block: ResourceAssignmentBuilder.() -> Unit): ResourceAssignment {
+fun BluePrintTypes.resourceAssignment(
+ name: String,
+ dictionaryName: String,
+ dictionarySource: String,
+ block: ResourceAssignmentBuilder.() -> Unit
+): ResourceAssignment {
return ResourceAssignmentBuilder(name, dictionaryName, dictionarySource).apply(block).build()
}
class ResourceDefinitionsBuilder() {
private val resourceDefinitions: MutableMap<String, ResourceDefinition> = hashMapOf()
- fun resourceDefinition(name: String, description: String,
- block: ResourceDefinitionBuilder.() -> Unit) {
+ fun resourceDefinition(
+ name: String,
+ description: String,
+ block: ResourceDefinitionBuilder.() -> Unit
+ ) {
val resourceDefinition = ResourceDefinitionBuilder(name, description).apply(block).build()
resourceDefinitions[resourceDefinition.name] = resourceDefinition
}
@@ -82,8 +92,11 @@ class ResourceDefinitionBuilder(private val name: String, private val descriptio
resourceDefinition.property = PropertyDefinitionBuilder(name, type, required, description).build()
}
- fun property(type: String, required: Boolean,
- block: PropertyDefinitionBuilder.() -> Unit) {
+ fun property(
+ type: String,
+ required: Boolean,
+ block: PropertyDefinitionBuilder.() -> Unit
+ ) {
resourceDefinition.property = PropertyDefinitionBuilder(name, type, required, description).apply(block).build()
}
@@ -136,8 +149,12 @@ class ResourceDefinitionSourcesBuilder {
class ResourceAssignmentsBuilder() {
private val resourceAssignments: MutableMap<String, ResourceAssignment> = hashMapOf()
- fun resourceAssignment(name: String, dictionaryName: String, dictionarySource: String,
- block: ResourceAssignmentBuilder.() -> Unit) {
+ fun resourceAssignment(
+ name: String,
+ dictionaryName: String,
+ dictionarySource: String,
+ block: ResourceAssignmentBuilder.() -> Unit
+ ) {
val resourceAssignment = ResourceAssignmentBuilder(name, dictionaryName, dictionarySource).apply(block).build()
resourceAssignments[resourceAssignment.name] = resourceAssignment
}
@@ -151,8 +168,12 @@ class ResourceAssignmentsBuilder() {
}
}
-class ResourceAssignmentBuilder(private val name: String, private val dictionaryName: String,
- private val dictionarySource: String) {
+class ResourceAssignmentBuilder(
+ private val name: String,
+ private val dictionaryName: String,
+ private val dictionarySource: String
+) {
+
private val resourceAssignment = ResourceAssignment()
fun inputParameter(inputParameter: Boolean) {
@@ -163,8 +184,12 @@ class ResourceAssignmentBuilder(private val name: String, private val dictionary
resourceAssignment.property = PropertyDefinitionBuilder(name, type, required, description).build()
}
- fun property(type: String, required: Boolean, description: String? = "",
- block: PropertyDefinitionBuilder.() -> Unit) {
+ fun property(
+ type: String,
+ required: Boolean,
+ description: String? = "",
+ block: PropertyDefinitionBuilder.() -> Unit
+ ) {
resourceAssignment.property = PropertyDefinitionBuilder(name, type, required, description).apply(block).build()
}
@@ -174,27 +199,27 @@ class ResourceAssignmentBuilder(private val name: String, private val dictionary
fun sourceInput(block: SourceInputNodeTemplateBuilder.() -> Unit) {
resourceAssignment.dictionarySourceDefinition = SourceInputNodeTemplateBuilder(dictionarySource, "")
- .apply(block).build()
+ .apply(block).build()
}
fun sourceDefault(block: SourceDefaultNodeTemplateBuilder.() -> Unit) {
resourceAssignment.dictionarySourceDefinition = SourceDefaultNodeTemplateBuilder(dictionarySource, "")
- .apply(block).build()
+ .apply(block).build()
}
fun sourceDb(block: SourceDbNodeTemplateBuilder.() -> Unit) {
resourceAssignment.dictionarySourceDefinition = SourceDbNodeTemplateBuilder(dictionarySource, "")
- .apply(block).build()
+ .apply(block).build()
}
fun sourceRest(block: SourceRestNodeTemplateBuilder.() -> Unit) {
resourceAssignment.dictionarySourceDefinition = SourceRestNodeTemplateBuilder(dictionarySource, "")
- .apply(block).build()
+ .apply(block).build()
}
fun sourceCapability(block: SourceCapabilityNodeTemplateBuilder.() -> Unit) {
resourceAssignment.dictionarySourceDefinition = SourceCapabilityNodeTemplateBuilder(dictionarySource, "")
- .apply(block).build()
+ .apply(block).build()
}
fun dependencies(dependencies: MutableList<String>) {
@@ -207,4 +232,4 @@ class ResourceAssignmentBuilder(private val name: String, private val dictionary
resourceAssignment.dictionarySource = dictionarySource
return resourceAssignment
}
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponent.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponent.kt
index 0521919aa..293f29cfc 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponent.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponent.kt
@@ -32,8 +32,9 @@ import org.springframework.stereotype.Component
@Component("component-resource-resolution")
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
open class ResourceResolutionComponent(private val resourceResolutionService: ResourceResolutionService) :
- AbstractComponentFunction() {
- companion object{
+ AbstractComponentFunction() {
+
+ companion object {
const val INPUT_REQUEST_ID = "request-id"
const val INPUT_RESOURCE_ID = "resource-id"
const val INPUT_ACTION_NAME = "action-name"
@@ -54,11 +55,14 @@ open class ResourceResolutionComponent(private val resourceResolutionService: Re
override suspend fun processNB(executionRequest: ExecutionServiceInput) {
val occurrence = getOptionalOperationInput(ResourceResolutionConstants.RESOURCE_RESOLUTION_INPUT_OCCURRENCE)?.asInt() ?: 1
- val resolutionKey = getOptionalOperationInput(ResourceResolutionConstants.RESOURCE_RESOLUTION_INPUT_RESOLUTION_KEY)?.returnNullIfMissing()?.textValue() ?: ""
+ val resolutionKey =
+ getOptionalOperationInput(ResourceResolutionConstants.RESOURCE_RESOLUTION_INPUT_RESOLUTION_KEY)?.returnNullIfMissing()?.textValue() ?: ""
val storeResult = getOptionalOperationInput(ResourceResolutionConstants.RESOURCE_RESOLUTION_INPUT_STORE_RESULT)?.asBoolean() ?: false
- val resourceId = getOptionalOperationInput(ResourceResolutionConstants.RESOURCE_RESOLUTION_INPUT_RESOURCE_ID)?.returnNullIfMissing()?.textValue() ?: ""
+ val resourceId =
+ getOptionalOperationInput(ResourceResolutionConstants.RESOURCE_RESOLUTION_INPUT_RESOURCE_ID)?.returnNullIfMissing()?.textValue() ?: ""
- val resourceType = getOptionalOperationInput(ResourceResolutionConstants.RESOURCE_RESOLUTION_INPUT_RESOURCE_TYPE)?.returnNullIfMissing()?.textValue() ?: ""
+ val resourceType =
+ getOptionalOperationInput(ResourceResolutionConstants.RESOURCE_RESOLUTION_INPUT_RESOURCE_TYPE)?.returnNullIfMissing()?.textValue() ?: ""
val properties: MutableMap<String, Any> = mutableMapOf()
properties[ResourceResolutionConstants.RESOURCE_RESOLUTION_INPUT_STORE_RESULT] = storeResult
@@ -69,8 +73,10 @@ open class ResourceResolutionComponent(private val resourceResolutionService: Re
val jsonResponse = JsonNodeFactory.instance.objectNode()
// Initialize Output Attribute to empty JSON
- bluePrintRuntimeService.setNodeTemplateAttributeValue(nodeTemplateName,
- ResourceResolutionConstants.OUTPUT_ASSIGNMENT_PARAMS, jsonResponse)
+ bluePrintRuntimeService.setNodeTemplateAttributeValue(
+ nodeTemplateName,
+ ResourceResolutionConstants.OUTPUT_ASSIGNMENT_PARAMS, jsonResponse
+ )
// validate inputs if we need to store the resource and template resolution.
if (storeResult) {
@@ -79,8 +85,10 @@ open class ResourceResolutionComponent(private val resourceResolutionService: Re
} else if ((resourceType.isNotEmpty() && resourceId.isEmpty()) || (resourceType.isEmpty() && resourceId.isNotEmpty())) {
throw BluePrintProcessorException("Can't proceed with the resolution: both resource-id and resource-type should be provided, one of them is missing.")
} else if (resourceType.isEmpty() && resourceId.isEmpty() && resolutionKey.isEmpty()) {
- throw BluePrintProcessorException("Can't proceed with the resolution: can't persist resolution without a correlation key. " +
- "Either provide a resolution-key OR combination of resource-id and resource-type OR set `storeResult` to false.")
+ throw BluePrintProcessorException(
+ "Can't proceed with the resolution: can't persist resolution without a correlation key. " +
+ "Either provide a resolution-key OR combination of resource-id and resource-type OR set `storeResult` to false."
+ )
}
}
@@ -90,10 +98,12 @@ open class ResourceResolutionComponent(private val resourceResolutionService: Re
for (j in 1..occurrence) {
properties[ResourceResolutionConstants.RESOURCE_RESOLUTION_INPUT_OCCURRENCE] = j
- val response = resourceResolutionService.resolveResources(bluePrintRuntimeService,
- nodeTemplateName,
- artifactPrefixNames,
- properties)
+ val response = resourceResolutionService.resolveResources(
+ bluePrintRuntimeService,
+ nodeTemplateName,
+ artifactPrefixNames,
+ properties
+ )
// provide indexed result in output if we have multiple resolution
if (occurrence != 1) {
@@ -101,15 +111,16 @@ open class ResourceResolutionComponent(private val resourceResolutionService: Re
} else {
jsonResponse.setAll(response.asObjectNode())
}
-
}
// Set Output Attributes with resolved value
- bluePrintRuntimeService.setNodeTemplateAttributeValue(nodeTemplateName,
- ResourceResolutionConstants.OUTPUT_ASSIGNMENT_PARAMS, jsonResponse)
+ bluePrintRuntimeService.setNodeTemplateAttributeValue(
+ nodeTemplateName,
+ ResourceResolutionConstants.OUTPUT_ASSIGNMENT_PARAMS, jsonResponse
+ )
}
override suspend fun recoverNB(runtimeException: RuntimeException, executionRequest: ExecutionServiceInput) {
bluePrintRuntimeService.getBluePrintError().addError(runtimeException.message!!)
}
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponentDSL.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponentDSL.kt
index 40ea47e33..25338c6ca 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponentDSL.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponentDSL.kt
@@ -17,81 +17,118 @@
package org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution
import com.fasterxml.jackson.databind.JsonNode
-import org.onap.ccsdk.cds.controllerblueprints.core.*
+import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants
+import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintTypes
+import org.onap.ccsdk.cds.controllerblueprints.core.asJsonPrimitive
+import org.onap.ccsdk.cds.controllerblueprints.core.asJsonString
+import org.onap.ccsdk.cds.controllerblueprints.core.asJsonType
import org.onap.ccsdk.cds.controllerblueprints.core.data.NodeTemplate
import org.onap.ccsdk.cds.controllerblueprints.core.data.NodeType
import org.onap.ccsdk.cds.controllerblueprints.core.dsl.AbstractNodeTemplateOperationImplBuilder
import org.onap.ccsdk.cds.controllerblueprints.core.dsl.PropertiesAssignmentBuilder
import org.onap.ccsdk.cds.controllerblueprints.core.dsl.nodeType
+import org.onap.ccsdk.cds.controllerblueprints.core.jsonAsJsonType
/** Component Extensions **/
fun BluePrintTypes.nodeTypeComponentResourceResolution(): NodeType {
- return nodeType(id = "component-resource-resolution", version = BluePrintConstants.DEFAULT_VERSION_NUMBER,
- derivedFrom = BluePrintConstants.MODEL_TYPE_NODE_COMPONENT,
- description = "Resource Assignment Component") {
-
- attribute(ResourceResolutionComponent.ATTRIBUTE_ASSIGNMENT_PARAM, BluePrintConstants.DATA_TYPE_STRING,
- true)
- attribute(ResourceResolutionComponent.ATTRIBUTE_STATUS, BluePrintConstants.DATA_TYPE_STRING,
- true)
+ return nodeType(
+ id = "component-resource-resolution", version = BluePrintConstants.DEFAULT_VERSION_NUMBER,
+ derivedFrom = BluePrintConstants.MODEL_TYPE_NODE_COMPONENT,
+ description = "Resource Assignment Component"
+ ) {
+
+ attribute(
+ ResourceResolutionComponent.ATTRIBUTE_ASSIGNMENT_PARAM, BluePrintConstants.DATA_TYPE_STRING,
+ true
+ )
+ attribute(
+ ResourceResolutionComponent.ATTRIBUTE_STATUS, BluePrintConstants.DATA_TYPE_STRING,
+ true
+ )
operation("ResourceResolutionComponent", "ResourceResolutionComponent Operation") {
inputs {
- property(ResourceResolutionComponent.INPUT_REQUEST_ID, BluePrintConstants.DATA_TYPE_STRING,
- true, "Request Id, Unique Id for the request.")
-
- property(ResourceResolutionComponent.INPUT_RESOURCE_ID, BluePrintConstants.DATA_TYPE_STRING,
- false, "Resource Id.")
-
- property(ResourceResolutionComponent.INPUT_ACTION_NAME, BluePrintConstants.DATA_TYPE_STRING,
- false, "Action Name of the process")
-
- property(ResourceResolutionComponent.INPUT_DYNAMIC_PROPERTIES, BluePrintConstants.DATA_TYPE_JSON,
- false, "Dynamic Json Content or DSL Json reference.")
-
- property(ResourceResolutionComponent.INPUT_RESOLUTION_KEY, BluePrintConstants.DATA_TYPE_STRING,
- false, "Key for service instance related correlation.")
-
- property(ResourceResolutionComponent.INPUT_OCCURRENCE, BluePrintConstants.DATA_TYPE_INTEGER,
- false, "Number of time to perform the resolution.") {
+ property(
+ ResourceResolutionComponent.INPUT_REQUEST_ID, BluePrintConstants.DATA_TYPE_STRING,
+ true, "Request Id, Unique Id for the request."
+ )
+
+ property(
+ ResourceResolutionComponent.INPUT_RESOURCE_ID, BluePrintConstants.DATA_TYPE_STRING,
+ false, "Resource Id."
+ )
+
+ property(
+ ResourceResolutionComponent.INPUT_ACTION_NAME, BluePrintConstants.DATA_TYPE_STRING,
+ false, "Action Name of the process"
+ )
+
+ property(
+ ResourceResolutionComponent.INPUT_DYNAMIC_PROPERTIES, BluePrintConstants.DATA_TYPE_JSON,
+ false, "Dynamic Json Content or DSL Json reference."
+ )
+
+ property(
+ ResourceResolutionComponent.INPUT_RESOLUTION_KEY, BluePrintConstants.DATA_TYPE_STRING,
+ false, "Key for service instance related correlation."
+ )
+
+ property(
+ ResourceResolutionComponent.INPUT_OCCURRENCE, BluePrintConstants.DATA_TYPE_INTEGER,
+ false, "Number of time to perform the resolution."
+ ) {
defaultValue(1)
}
- property(ResourceResolutionComponent.INPUT_STORE_RESULT, BluePrintConstants.DATA_TYPE_BOOLEAN,
- false, "Whether or not to store the output.")
+ property(
+ ResourceResolutionComponent.INPUT_STORE_RESULT, BluePrintConstants.DATA_TYPE_BOOLEAN,
+ false, "Whether or not to store the output."
+ )
- property(ResourceResolutionComponent.INPUT_RESOURCE_TYPE, BluePrintConstants.DATA_TYPE_STRING,
- false, "Request type.")
+ property(
+ ResourceResolutionComponent.INPUT_RESOURCE_TYPE, BluePrintConstants.DATA_TYPE_STRING,
+ false, "Request type."
+ )
- property(ResourceResolutionComponent.INPUT_ARTIFACT_PREFIX_NAMES, BluePrintConstants.DATA_TYPE_LIST,
- true, "Template , Resource Assignment Artifact Prefix names") {
+ property(
+ ResourceResolutionComponent.INPUT_ARTIFACT_PREFIX_NAMES, BluePrintConstants.DATA_TYPE_LIST,
+ true, "Template , Resource Assignment Artifact Prefix names"
+ ) {
entrySchema(BluePrintConstants.DATA_TYPE_STRING)
}
}
outputs {
- property(ResourceResolutionComponent.OUTPUT_RESOURCE_ASSIGNMENT_PARAMS, BluePrintConstants.DATA_TYPE_STRING,
- true, "Output Response")
- property(ResourceResolutionComponent.OUTPUT_STATUS, BluePrintConstants.DATA_TYPE_STRING,
- true, "Status of the Component Execution ( success or failure )")
+ property(
+ ResourceResolutionComponent.OUTPUT_RESOURCE_ASSIGNMENT_PARAMS, BluePrintConstants.DATA_TYPE_STRING,
+ true, "Output Response"
+ )
+ property(
+ ResourceResolutionComponent.OUTPUT_STATUS, BluePrintConstants.DATA_TYPE_STRING,
+ true, "Status of the Component Execution ( success or failure )"
+ )
}
}
}
}
/** Component Builder */
-fun BluePrintTypes.nodeTemplateComponentResourceResolution(id: String,
- description: String,
- block: ComponentResourceResolutionNodeTemplateBuilder.() -> Unit)
- : NodeTemplate {
+fun BluePrintTypes.nodeTemplateComponentResourceResolution(
+ id: String,
+ description: String,
+ block: ComponentResourceResolutionNodeTemplateBuilder.() -> Unit
+):
+ NodeTemplate {
return ComponentResourceResolutionNodeTemplateBuilder(id, description).apply(block).build()
}
class ComponentResourceResolutionNodeTemplateBuilder(id: String, description: String) :
- AbstractNodeTemplateOperationImplBuilder<PropertiesAssignmentBuilder,
- ComponentResourceResolutionNodeTemplateBuilder.InputsBuilder,
- ComponentResourceResolutionNodeTemplateBuilder.OutputsBuilder>(id, "component-script-executor",
- "ComponentResourceResolution",
- description) {
+ AbstractNodeTemplateOperationImplBuilder<PropertiesAssignmentBuilder,
+ ComponentResourceResolutionNodeTemplateBuilder.InputsBuilder,
+ ComponentResourceResolutionNodeTemplateBuilder.OutputsBuilder>(
+ id, "component-script-executor",
+ "ComponentResourceResolution",
+ description
+ ) {
class InputsBuilder : PropertiesAssignmentBuilder() {
@@ -146,7 +183,7 @@ class ComponentResourceResolutionNodeTemplateBuilder(id: String, description: St
fun artifactPrefixNames(artifactPrefixNames: String) = artifactPrefixNames(artifactPrefixNames.jsonAsJsonType())
fun artifactPrefixNames(artifactPrefixNameList: List<String>) =
- artifactPrefixNames(artifactPrefixNameList.asJsonString())
+ artifactPrefixNames(artifactPrefixNameList.asJsonString())
fun artifactPrefixNames(artifactPrefixNames: JsonNode) {
property(ResourceResolutionComponent.INPUT_ARTIFACT_PREFIX_NAMES, artifactPrefixNames)
@@ -162,10 +199,10 @@ class ComponentResourceResolutionNodeTemplateBuilder(id: String, description: St
}
fun resourceAssignmentParams(resourceAssignmentParams: String) =
- resourceAssignmentParams(resourceAssignmentParams.asJsonType())
+ resourceAssignmentParams(resourceAssignmentParams.asJsonType())
fun resourceAssignmentParams(resourceAssignmentParams: JsonNode) {
property(ResourceResolutionComponent.OUTPUT_RESOURCE_ASSIGNMENT_PARAMS, resourceAssignmentParams)
}
}
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionConfiguration.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionConfiguration.kt
index 13ff0a73f..219040e6b 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionConfiguration.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionConfiguration.kt
@@ -22,5 +22,3 @@ import org.springframework.context.annotation.Configuration
@Configuration
@ComponentScan
open class ResourceResolutionConfiguration
-
-
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 537074383..0726d2871 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
@@ -19,15 +19,15 @@ package org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution
object ResourceResolutionConstants {
- const val SERVICE_RESOURCE_RESOLUTION = "resource-resolution-service"
- const val PREFIX_RESOURCE_RESOLUTION_PROCESSOR = "rr-processor-"
- const val INPUT_ARTIFACT_PREFIX_NAMES = "artifact-prefix-names"
- const val OUTPUT_ASSIGNMENT_PARAMS = "assignment-params"
- const val FILE_NAME_RESOURCE_DEFINITION_TYPES = "resources_definition_types.json"
- const val RESOURCE_RESOLUTION_INPUT_RESOLUTION_KEY = "resolution-key"
- const val RESOURCE_RESOLUTION_INPUT_STORE_RESULT = "store-result"
- const val RESOURCE_RESOLUTION_INPUT_OCCURRENCE = "occurrence"
- const val RESOURCE_RESOLUTION_INPUT_RESOURCE_ID = "resource-id"
- const val RESOURCE_RESOLUTION_INPUT_RESOURCE_TYPE = "resource-type"
- const val RESOURCE_RESOLUTION_LOG_PROTECTED_METADATA = "log-protect"
-} \ No newline at end of file
+ const val SERVICE_RESOURCE_RESOLUTION = "resource-resolution-service"
+ const val PREFIX_RESOURCE_RESOLUTION_PROCESSOR = "rr-processor-"
+ const val INPUT_ARTIFACT_PREFIX_NAMES = "artifact-prefix-names"
+ const val OUTPUT_ASSIGNMENT_PARAMS = "assignment-params"
+ const val FILE_NAME_RESOURCE_DEFINITION_TYPES = "resources_definition_types.json"
+ const val RESOURCE_RESOLUTION_INPUT_RESOLUTION_KEY = "resolution-key"
+ const val RESOURCE_RESOLUTION_INPUT_STORE_RESULT = "store-result"
+ const val RESOURCE_RESOLUTION_INPUT_OCCURRENCE = "occurrence"
+ const val RESOURCE_RESOLUTION_INPUT_RESOURCE_ID = "resource-id"
+ const val RESOURCE_RESOLUTION_INPUT_RESOURCE_TYPE = "resource-type"
+ const val RESOURCE_RESOLUTION_LOG_PROTECTED_METADATA = "log-protect"
+}
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionExtensions.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionExtensions.kt
index ab01b15b7..53ce65d0b 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionExtensions.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionExtensions.kt
@@ -20,18 +20,18 @@ import kotlinx.coroutines.runBlocking
import org.onap.ccsdk.cds.blueprintsprocessor.services.execution.AbstractComponentFunction
import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintDependencyService
-
/**
* Register the Resolution module exposed dependency
*/
fun BluePrintDependencyService.resourceResolutionService(): ResourceResolutionService =
- instance(ResourceResolutionConstants.SERVICE_RESOURCE_RESOLUTION)
-
+ instance(ResourceResolutionConstants.SERVICE_RESOURCE_RESOLUTION)
-suspend fun AbstractComponentFunction.storedContentFromResolvedArtifactNB(resolutionKey: String,
- artifactName: String): String {
+suspend fun AbstractComponentFunction.storedContentFromResolvedArtifactNB(
+ resolutionKey: String,
+ artifactName: String
+): String {
return BluePrintDependencyService.resourceResolutionService()
- .resolveFromDatabase(bluePrintRuntimeService, artifactName, resolutionKey)
+ .resolveFromDatabase(bluePrintRuntimeService, artifactName, resolutionKey)
}
/**
@@ -39,16 +39,15 @@ suspend fun AbstractComponentFunction.storedContentFromResolvedArtifactNB(resolu
*/
suspend fun AbstractComponentFunction.contentFromResolvedArtifactNB(artifactPrefix: String): String {
return BluePrintDependencyService.resourceResolutionService()
- .resolveResources(bluePrintRuntimeService, nodeTemplateName, artifactPrefix, mapOf())
+ .resolveResources(bluePrintRuntimeService, nodeTemplateName, artifactPrefix, mapOf())
}
-
/**
* Blocking Methods called from Jython Scripts
*/
-fun AbstractComponentFunction.storedContentFromResolvedArtifact(resolutionKey: String, artifactName: String)
- : String = runBlocking {
+fun AbstractComponentFunction.storedContentFromResolvedArtifact(resolutionKey: String, artifactName: String):
+ String = runBlocking {
storedContentFromResolvedArtifactNB(resolutionKey, artifactName)
}
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionService.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionService.kt
index 28e7d395a..14e60bc95 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionService.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionService.kt
@@ -27,7 +27,11 @@ import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.db.T
import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.processor.ResourceAssignmentProcessor
import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.utils.ResourceAssignmentUtils
import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.utils.ResourceDefinitionUtils.createResourceAssignments
-import org.onap.ccsdk.cds.controllerblueprints.core.*
+import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants
+import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintProcessorException
+import org.onap.ccsdk.cds.controllerblueprints.core.asJsonPrimitive
+import org.onap.ccsdk.cds.controllerblueprints.core.asJsonType
+import org.onap.ccsdk.cds.controllerblueprints.core.checkNotEmpty
import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintRuntimeService
import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintTemplateService
import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils
@@ -37,80 +41,109 @@ import org.onap.ccsdk.cds.controllerblueprints.resource.dict.utils.BulkResourceS
import org.slf4j.LoggerFactory
import org.springframework.context.ApplicationContext
import org.springframework.stereotype.Service
-import java.util.*
+import java.util.UUID
interface ResourceResolutionService {
fun registeredResourceSources(): List<String>
- suspend fun resolveFromDatabase(bluePrintRuntimeService: BluePrintRuntimeService<*>, artifactTemplate: String,
- resolutionKey: String): String
-
- suspend fun resolveResources(bluePrintRuntimeService: BluePrintRuntimeService<*>, nodeTemplateName: String,
- artifactNames: List<String>, properties: Map<String, Any>): MutableMap<String, String>
-
- suspend fun resolveResources(bluePrintRuntimeService: BluePrintRuntimeService<*>, nodeTemplateName: String,
- artifactPrefix: String, properties: Map<String, Any>): String
+ suspend fun resolveFromDatabase(
+ bluePrintRuntimeService: BluePrintRuntimeService<*>,
+ artifactTemplate: String,
+ resolutionKey: String
+ ): String
+
+ suspend fun resolveResources(
+ bluePrintRuntimeService: BluePrintRuntimeService<*>,
+ nodeTemplateName: String,
+ artifactNames: List<String>,
+ properties: Map<String, Any>
+ ): MutableMap<String, String>
+
+ suspend fun resolveResources(
+ bluePrintRuntimeService: BluePrintRuntimeService<*>,
+ nodeTemplateName: String,
+ artifactPrefix: String,
+ properties: Map<String, Any>
+ ): String
/** Resolve resources for all the sources defined in a particular resource Definition[resolveDefinition]
* with other [resourceDefinitions] dependencies for the sources [sources]
* Used to get the same resource values from multiple sources. **/
- suspend fun resolveResourceDefinition(blueprintRuntimeService: BluePrintRuntimeService<*>,
- resourceDefinitions: MutableMap<String, ResourceDefinition>,
- resolveDefinition: String, sources: List<String>)
- : MutableMap<String, JsonNode>
-
- suspend fun resolveResourceAssignments(blueprintRuntimeService: BluePrintRuntimeService<*>,
- resourceDefinitions: MutableMap<String, ResourceDefinition>,
- resourceAssignments: MutableList<ResourceAssignment>,
- artifactPrefix: String,
- properties: Map<String, Any>)
+ suspend fun resolveResourceDefinition(
+ blueprintRuntimeService: BluePrintRuntimeService<*>,
+ resourceDefinitions: MutableMap<String, ResourceDefinition>,
+ resolveDefinition: String,
+ sources: List<String>
+ ):
+ MutableMap<String, JsonNode>
+
+ suspend fun resolveResourceAssignments(
+ blueprintRuntimeService: BluePrintRuntimeService<*>,
+ resourceDefinitions: MutableMap<String, ResourceDefinition>,
+ resourceAssignments: MutableList<ResourceAssignment>,
+ artifactPrefix: String,
+ properties: Map<String, Any>
+ )
}
@Service(ResourceResolutionConstants.SERVICE_RESOURCE_RESOLUTION)
-open class ResourceResolutionServiceImpl(private var applicationContext: ApplicationContext,
- private var templateResolutionDBService: TemplateResolutionService,
- private var blueprintTemplateService: BluePrintTemplateService,
- private var resourceResolutionDBService: ResourceResolutionDBService) :
- ResourceResolutionService {
+open class ResourceResolutionServiceImpl(
+ private var applicationContext: ApplicationContext,
+ private var templateResolutionDBService: TemplateResolutionService,
+ private var blueprintTemplateService: BluePrintTemplateService,
+ private var resourceResolutionDBService: ResourceResolutionDBService
+) :
+ ResourceResolutionService {
private val log = LoggerFactory.getLogger(ResourceResolutionService::class.java)
override fun registeredResourceSources(): List<String> {
return applicationContext.getBeanNamesForType(ResourceAssignmentProcessor::class.java)
- .filter { it.startsWith(ResourceResolutionConstants.PREFIX_RESOURCE_RESOLUTION_PROCESSOR) }
- .map { it.substringAfter(ResourceResolutionConstants.PREFIX_RESOURCE_RESOLUTION_PROCESSOR) }
+ .filter { it.startsWith(ResourceResolutionConstants.PREFIX_RESOURCE_RESOLUTION_PROCESSOR) }
+ .map { it.substringAfter(ResourceResolutionConstants.PREFIX_RESOURCE_RESOLUTION_PROCESSOR) }
}
- override suspend fun resolveFromDatabase(bluePrintRuntimeService: BluePrintRuntimeService<*>,
- artifactTemplate: String,
- resolutionKey: String): String {
+ override suspend fun resolveFromDatabase(
+ bluePrintRuntimeService: BluePrintRuntimeService<*>,
+ artifactTemplate: String,
+ resolutionKey: String
+ ): String {
return templateResolutionDBService.findByResolutionKeyAndBlueprintNameAndBlueprintVersionAndArtifactName(
- bluePrintRuntimeService,
- artifactTemplate,
- resolutionKey)
+ bluePrintRuntimeService,
+ artifactTemplate,
+ resolutionKey
+ )
}
- override suspend fun resolveResources(bluePrintRuntimeService: BluePrintRuntimeService<*>, nodeTemplateName: String,
- artifactNames: List<String>,
- properties: Map<String, Any>): MutableMap<String, String> {
+ override suspend fun resolveResources(
+ bluePrintRuntimeService: BluePrintRuntimeService<*>,
+ nodeTemplateName: String,
+ artifactNames: List<String>,
+ properties: Map<String, Any>
+ ): MutableMap<String, String> {
val resourceAssignmentRuntimeService =
- ResourceAssignmentUtils.transformToRARuntimeService(bluePrintRuntimeService, artifactNames.toString())
+ ResourceAssignmentUtils.transformToRARuntimeService(bluePrintRuntimeService, artifactNames.toString())
val resolvedParams: MutableMap<String, String> = hashMapOf()
artifactNames.forEach { artifactName ->
- val resolvedContent = resolveResources(resourceAssignmentRuntimeService, nodeTemplateName,
- artifactName, properties)
+ val resolvedContent = resolveResources(
+ resourceAssignmentRuntimeService, nodeTemplateName,
+ artifactName, properties
+ )
resolvedParams[artifactName] = resolvedContent
}
return resolvedParams
}
-
- override suspend fun resolveResources(bluePrintRuntimeService: BluePrintRuntimeService<*>, nodeTemplateName: String,
- artifactPrefix: String, properties: Map<String, Any>): String {
+ override suspend fun resolveResources(
+ bluePrintRuntimeService: BluePrintRuntimeService<*>,
+ nodeTemplateName: String,
+ artifactPrefix: String,
+ properties: Map<String, Any>
+ ): String {
// Velocity Artifact Definition Name
val artifactTemplate = "$artifactPrefix-template"
@@ -121,39 +154,47 @@ open class ResourceResolutionServiceImpl(private var applicationContext: Applica
log.info("Resolving resource for template artifact($artifactTemplate) with resource assignment artifact($artifactMapping)")
val resourceAssignmentContent =
- bluePrintRuntimeService.resolveNodeTemplateArtifact(nodeTemplateName, artifactMapping)
+ bluePrintRuntimeService.resolveNodeTemplateArtifact(nodeTemplateName, artifactMapping)
val resourceAssignments: MutableList<ResourceAssignment> =
- JacksonUtils.getListFromJson(resourceAssignmentContent, ResourceAssignment::class.java)
- as? MutableList<ResourceAssignment>
- ?: throw BluePrintProcessorException("couldn't get Dictionary Definitions")
+ JacksonUtils.getListFromJson(resourceAssignmentContent, ResourceAssignment::class.java)
+ as? MutableList<ResourceAssignment>
+ ?: throw BluePrintProcessorException("couldn't get Dictionary Definitions")
if (isToStore(properties)) {
val existingResourceResolution = isNewResolution(bluePrintRuntimeService, properties, artifactPrefix)
if (existingResourceResolution.isNotEmpty()) {
- updateResourceAssignmentWithExisting(bluePrintRuntimeService as ResourceAssignmentRuntimeService,
- existingResourceResolution, resourceAssignments)
+ updateResourceAssignmentWithExisting(
+ bluePrintRuntimeService as ResourceAssignmentRuntimeService,
+ existingResourceResolution, resourceAssignments
+ )
}
}
// Get the Resource Dictionary Name
val resourceDefinitions: MutableMap<String, ResourceDefinition> = ResourceAssignmentUtils
- .resourceDefinitions(bluePrintRuntimeService.bluePrintContext().rootPath)
+ .resourceDefinitions(bluePrintRuntimeService.bluePrintContext().rootPath)
// Resolve resources
- resolveResourceAssignments(bluePrintRuntimeService,
- resourceDefinitions,
- resourceAssignments,
- artifactPrefix,
- properties)
+ resolveResourceAssignments(
+ bluePrintRuntimeService,
+ resourceDefinitions,
+ resourceAssignments,
+ artifactPrefix,
+ properties
+ )
val resolvedParamJsonContent =
- ResourceAssignmentUtils.generateResourceDataForAssignments(resourceAssignments.toList())
+ ResourceAssignmentUtils.generateResourceDataForAssignments(resourceAssignments.toList())
- resolvedContent = blueprintTemplateService.generateContent(bluePrintRuntimeService, nodeTemplateName,
- artifactTemplate, resolvedParamJsonContent, false,
- mutableMapOf(ResourceResolutionConstants.RESOURCE_RESOLUTION_INPUT_OCCURRENCE to
- properties[ResourceResolutionConstants.RESOURCE_RESOLUTION_INPUT_OCCURRENCE].asJsonPrimitive()))
+ resolvedContent = blueprintTemplateService.generateContent(
+ bluePrintRuntimeService, nodeTemplateName,
+ artifactTemplate, resolvedParamJsonContent, false,
+ mutableMapOf(
+ ResourceResolutionConstants.RESOURCE_RESOLUTION_INPUT_OCCURRENCE to
+ properties[ResourceResolutionConstants.RESOURCE_RESOLUTION_INPUT_OCCURRENCE].asJsonPrimitive()
+ )
+ )
if (isToStore(properties)) {
templateResolutionDBService.write(properties, resolvedContent, bluePrintRuntimeService, artifactPrefix)
@@ -163,16 +204,21 @@ open class ResourceResolutionServiceImpl(private var applicationContext: Applica
return resolvedContent
}
- override suspend fun resolveResourceDefinition(blueprintRuntimeService: BluePrintRuntimeService<*>,
- resourceDefinitions: MutableMap<String, ResourceDefinition>,
- resolveDefinition: String, sources: List<String>)
- : MutableMap<String, JsonNode> {
+ override suspend fun resolveResourceDefinition(
+ blueprintRuntimeService: BluePrintRuntimeService<*>,
+ resourceDefinitions: MutableMap<String, ResourceDefinition>,
+ resolveDefinition: String,
+ sources: List<String>
+ ):
+ MutableMap<String, JsonNode> {
// Populate Dummy Resource Assignments
val resourceAssignments = createResourceAssignments(resourceDefinitions, resolveDefinition, sources)
- resolveResourceAssignments(blueprintRuntimeService, resourceDefinitions, resourceAssignments,
- UUID.randomUUID().toString(), hashMapOf())
+ resolveResourceAssignments(
+ blueprintRuntimeService, resourceDefinitions, resourceAssignments,
+ UUID.randomUUID().toString(), hashMapOf()
+ )
// Get the data from Resource Assignments
return ResourceAssignmentUtils.generateResourceForAssignments(resourceAssignments)
@@ -183,11 +229,13 @@ open class ResourceResolutionServiceImpl(private var applicationContext: Applica
* name, then get the type of the Resource Definition, Get the instance for the Resource Type and process the
* request.
*/
- override suspend fun resolveResourceAssignments(blueprintRuntimeService: BluePrintRuntimeService<*>,
- resourceDefinitions: MutableMap<String, ResourceDefinition>,
- resourceAssignments: MutableList<ResourceAssignment>,
- artifactPrefix: String,
- properties: Map<String, Any>) {
+ override suspend fun resolveResourceAssignments(
+ blueprintRuntimeService: BluePrintRuntimeService<*>,
+ resourceDefinitions: MutableMap<String, ResourceDefinition>,
+ resourceAssignments: MutableList<ResourceAssignment>,
+ artifactPrefix: String,
+ properties: Map<String, Any>
+ ) {
val bulkSequenced = BulkResourceSequencingUtils.process(resourceAssignments)
@@ -204,56 +252,62 @@ open class ResourceResolutionServiceImpl(private var applicationContext: Applica
bulkSequenced.forEach { batchResourceAssignments ->
// Execute Non Dependent Assignments in parallel ( ie asynchronously )
val deferred = batchResourceAssignments
- .filter { it.name != "*" && it.name != "start" }
- .filter { it.status != BluePrintConstants.STATUS_SUCCESS }
- .map { resourceAssignment ->
- async {
- val dictionaryName = resourceAssignment.dictionaryName
- val dictionarySource = resourceAssignment.dictionarySource
-
- val processorName = processorName(dictionaryName!!, dictionarySource!!, resourceDefinitions)
-
- val resourceAssignmentProcessor =
- applicationContext.getBean(processorName) as? ResourceAssignmentProcessor
- ?: throw BluePrintProcessorException("failed to get resource processor ($processorName) " +
- "for resource assignment(${resourceAssignment.name})")
- try {
- // Set BluePrint Runtime Service
- resourceAssignmentProcessor.raRuntimeService = resourceAssignmentRuntimeService
- // Set Resource Dictionaries
- resourceAssignmentProcessor.resourceDictionaries = resourceDefinitions
- // Invoke Apply Method
- resourceAssignmentProcessor.applyNB(resourceAssignment)
-
- if (isToStore(properties)) {
- resourceResolutionDBService.write(properties,
- blueprintRuntimeService,
- artifactPrefix,
- resourceAssignment)
- log.info("Resource resolution saved into database successfully : (${resourceAssignment.name})")
- }
-
- // Set errors from RA
- blueprintRuntimeService.setBluePrintError(resourceAssignmentRuntimeService.getBluePrintError())
- } catch (e: RuntimeException) {
- log.error("Fail in processing ${resourceAssignment.name}", e)
- throw BluePrintProcessorException(e)
+ .filter { it.name != "*" && it.name != "start" }
+ .filter { it.status != BluePrintConstants.STATUS_SUCCESS }
+ .map { resourceAssignment ->
+ async {
+ val dictionaryName = resourceAssignment.dictionaryName
+ val dictionarySource = resourceAssignment.dictionarySource
+
+ val processorName = processorName(dictionaryName!!, dictionarySource!!, resourceDefinitions)
+
+ val resourceAssignmentProcessor =
+ applicationContext.getBean(processorName) as? ResourceAssignmentProcessor
+ ?: throw BluePrintProcessorException(
+ "failed to get resource processor ($processorName) " +
+ "for resource assignment(${resourceAssignment.name})"
+ )
+ try {
+ // Set BluePrint Runtime Service
+ resourceAssignmentProcessor.raRuntimeService = resourceAssignmentRuntimeService
+ // Set Resource Dictionaries
+ resourceAssignmentProcessor.resourceDictionaries = resourceDefinitions
+ // Invoke Apply Method
+ resourceAssignmentProcessor.applyNB(resourceAssignment)
+
+ if (isToStore(properties)) {
+ resourceResolutionDBService.write(
+ properties,
+ blueprintRuntimeService,
+ artifactPrefix,
+ resourceAssignment
+ )
+ log.info("Resource resolution saved into database successfully : (${resourceAssignment.name})")
}
+
+ // Set errors from RA
+ blueprintRuntimeService.setBluePrintError(resourceAssignmentRuntimeService.getBluePrintError())
+ } catch (e: RuntimeException) {
+ log.error("Fail in processing ${resourceAssignment.name}", e)
+ throw BluePrintProcessorException(e)
}
}
+ }
log.debug("Resolving (${deferred.size})resources parallel.")
deferred.awaitAll()
}
}
-
}
/**
* If the Source instance is "input", then it is not mandatory to have source Resource Definition, So it can
* derive the default input processor.
*/
- private fun processorName(dictionaryName: String, dictionarySource: String,
- resourceDefinitions: MutableMap<String, ResourceDefinition>): String {
+ private fun processorName(
+ dictionaryName: String,
+ dictionarySource: String,
+ resourceDefinitions: MutableMap<String, ResourceDefinition>
+ ): String {
val processorName: String = when (dictionarySource) {
"input" -> {
"${ResourceResolutionConstants.PREFIX_RESOURCE_RESOLUTION_PROCESSOR}source-input"
@@ -263,10 +317,10 @@ open class ResourceResolutionServiceImpl(private var applicationContext: Applica
}
else -> {
val resourceDefinition = resourceDefinitions[dictionaryName]
- ?: throw BluePrintProcessorException("couldn't get resource dictionary definition for $dictionaryName")
+ ?: throw BluePrintProcessorException("couldn't get resource dictionary definition for $dictionaryName")
val resourceSource = resourceDefinition.sources[dictionarySource]
- ?: throw BluePrintProcessorException("couldn't get resource definition $dictionaryName source($dictionarySource)")
+ ?: throw BluePrintProcessorException("couldn't get resource definition $dictionaryName source($dictionarySource)")
ResourceResolutionConstants.PREFIX_RESOURCE_RESOLUTION_PROCESSOR.plus(resourceSource.type)
}
@@ -276,19 +330,20 @@ open class ResourceResolutionServiceImpl(private var applicationContext: Applica
}
return processorName
-
}
// Check whether to store or not the resolution of resource and template
private fun isToStore(properties: Map<String, Any>): Boolean {
- return properties.containsKey(ResourceResolutionConstants.RESOURCE_RESOLUTION_INPUT_STORE_RESULT)
- && properties[ResourceResolutionConstants.RESOURCE_RESOLUTION_INPUT_STORE_RESULT] as Boolean
+ return properties.containsKey(ResourceResolutionConstants.RESOURCE_RESOLUTION_INPUT_STORE_RESULT) &&
+ properties[ResourceResolutionConstants.RESOURCE_RESOLUTION_INPUT_STORE_RESULT] as Boolean
}
// Check whether resolution already exist in the database for the specified resolution-key or resourceId/resourceType
- private suspend fun isNewResolution(bluePrintRuntimeService: BluePrintRuntimeService<*>,
- properties: Map<String, Any>,
- artifactPrefix: String): List<ResourceResolution> {
+ private suspend fun isNewResolution(
+ bluePrintRuntimeService: BluePrintRuntimeService<*>,
+ properties: Map<String, Any>,
+ artifactPrefix: String
+ ): List<ResourceResolution> {
val occurrence = properties[ResourceResolutionConstants.RESOURCE_RESOLUTION_INPUT_OCCURRENCE] as Int
val resolutionKey = properties[ResourceResolutionConstants.RESOURCE_RESOLUTION_INPUT_RESOLUTION_KEY] as String
val resourceId = properties[ResourceResolutionConstants.RESOURCE_RESOLUTION_INPUT_RESOURCE_ID] as String
@@ -296,28 +351,34 @@ open class ResourceResolutionServiceImpl(private var applicationContext: Applica
if (resolutionKey.isNotEmpty()) {
val existingResourceAssignments =
- resourceResolutionDBService.findByBlueprintNameAndBlueprintVersionAndArtifactNameAndResolutionKeyAndOccurrence(
- bluePrintRuntimeService,
- resolutionKey,
- occurrence,
- artifactPrefix)
+ resourceResolutionDBService.findByBlueprintNameAndBlueprintVersionAndArtifactNameAndResolutionKeyAndOccurrence(
+ bluePrintRuntimeService,
+ resolutionKey,
+ occurrence,
+ artifactPrefix
+ )
if (existingResourceAssignments.isNotEmpty()) {
- log.info("Resolution with resolutionKey=($resolutionKey) already exist - will resolve all resources not already resolved.",
- resolutionKey)
+ log.info(
+ "Resolution with resolutionKey=($resolutionKey) already exist - will resolve all resources not already resolved.",
+ resolutionKey
+ )
}
return existingResourceAssignments
} else if (resourceId.isNotEmpty() && resourceType.isNotEmpty()) {
val existingResourceAssignments =
- resourceResolutionDBService.findByBlueprintNameAndBlueprintVersionAndArtifactNameAndResourceIdAndResourceTypeAndOccurrence(
- bluePrintRuntimeService,
- resourceId,
- resourceType,
-
- occurrence,
- artifactPrefix)
+ resourceResolutionDBService.findByBlueprintNameAndBlueprintVersionAndArtifactNameAndResourceIdAndResourceTypeAndOccurrence(
+ bluePrintRuntimeService,
+ resourceId,
+ resourceType,
+
+ occurrence,
+ artifactPrefix
+ )
if (existingResourceAssignments.isNotEmpty()) {
- log.info("Resolution with resourceId=($resourceId) and resourceType=($resourceType) already exist - will resolve " +
- "all resources not already resolved.")
+ log.info(
+ "Resolution with resourceId=($resourceId) and resourceType=($resourceType) already exist - will resolve " +
+ "all resources not already resolved."
+ )
}
return existingResourceAssignments
}
@@ -325,9 +386,11 @@ open class ResourceResolutionServiceImpl(private var applicationContext: Applica
}
// Update the resource assignment list with the status of the resource that have already been resolved
- private fun updateResourceAssignmentWithExisting(raRuntimeService : ResourceAssignmentRuntimeService,
- resourceResolutionList: List<ResourceResolution>,
- resourceAssignmentList: MutableList<ResourceAssignment>) {
+ private fun updateResourceAssignmentWithExisting(
+ raRuntimeService: ResourceAssignmentRuntimeService,
+ resourceResolutionList: List<ResourceResolution>,
+ resourceAssignmentList: MutableList<ResourceAssignment>
+ ) {
resourceResolutionList.forEach { resourceResolution ->
if (resourceResolution.status == BluePrintConstants.STATUS_SUCCESS) {
resourceAssignmentList.forEach {
@@ -347,15 +410,19 @@ open class ResourceResolutionServiceImpl(private var applicationContext: Applica
// Comparision between what we have in the database vs what we have to assign.
private fun compareOne(resourceResolution: ResourceResolution, resourceAssignment: ResourceAssignment): Boolean {
- return (resourceResolution.name == resourceAssignment.name
- && resourceResolution.dictionaryName == resourceAssignment.dictionaryName
- && resourceResolution.dictionarySource == resourceAssignment.dictionarySource
- && resourceResolution.dictionaryVersion == resourceAssignment.version)
+ return (resourceResolution.name == resourceAssignment.name &&
+ resourceResolution.dictionaryName == resourceAssignment.dictionaryName &&
+ resourceResolution.dictionarySource == resourceAssignment.dictionarySource &&
+ resourceResolution.dictionaryVersion == resourceAssignment.version)
}
- private fun exposeOccurrencePropertyInResourceAssignments(raRuntimeService: ResourceAssignmentRuntimeService,
- properties: Map<String, Any>) {
- raRuntimeService.putResolutionStore(ResourceResolutionConstants.RESOURCE_RESOLUTION_INPUT_OCCURRENCE,
- properties[ResourceResolutionConstants.RESOURCE_RESOLUTION_INPUT_OCCURRENCE].asJsonPrimitive())
+ private fun exposeOccurrencePropertyInResourceAssignments(
+ raRuntimeService: ResourceAssignmentRuntimeService,
+ properties: Map<String, Any>
+ ) {
+ raRuntimeService.putResolutionStore(
+ ResourceResolutionConstants.RESOURCE_RESOLUTION_INPUT_OCCURRENCE,
+ properties[ResourceResolutionConstants.RESOURCE_RESOLUTION_INPUT_OCCURRENCE].asJsonPrimitive()
+ )
}
}
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceSourceDSL.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceSourceDSL.kt
index 182f3a178..d541fe60c 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceSourceDSL.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceSourceDSL.kt
@@ -18,7 +18,11 @@ package org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution
import com.fasterxml.jackson.databind.JsonNode
import org.onap.ccsdk.cds.blueprintsprocessor.services.execution.ComponentScriptExecutor
-import org.onap.ccsdk.cds.controllerblueprints.core.*
+import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants
+import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintTypes
+import org.onap.ccsdk.cds.controllerblueprints.core.asJsonPrimitive
+import org.onap.ccsdk.cds.controllerblueprints.core.asJsonString
+import org.onap.ccsdk.cds.controllerblueprints.core.asJsonType
import org.onap.ccsdk.cds.controllerblueprints.core.data.NodeTemplate
import org.onap.ccsdk.cds.controllerblueprints.core.data.NodeType
import org.onap.ccsdk.cds.controllerblueprints.core.dsl.AbstractNodeTemplatePropertyImplBuilder
@@ -27,149 +31,220 @@ import org.onap.ccsdk.cds.controllerblueprints.core.dsl.nodeType
import kotlin.reflect.KClass
fun BluePrintTypes.nodeTypeSourceInput(): NodeType {
- return nodeType(id = "source-input", version = BluePrintConstants.DEFAULT_VERSION_NUMBER,
- derivedFrom = BluePrintConstants.MODEL_TYPE_NODE_RESOURCE_SOURCE,
- description = "This is Input Resource Source Node Type") {}
+ return nodeType(
+ id = "source-input", version = BluePrintConstants.DEFAULT_VERSION_NUMBER,
+ derivedFrom = BluePrintConstants.MODEL_TYPE_NODE_RESOURCE_SOURCE,
+ description = "This is Input Resource Source Node Type"
+ ) {}
}
fun BluePrintTypes.nodeTypeSourceDefault(): NodeType {
- return nodeType(id = "source-default", version = BluePrintConstants.DEFAULT_VERSION_NUMBER,
- derivedFrom = BluePrintConstants.MODEL_TYPE_NODE_RESOURCE_SOURCE,
- description = "This is Default Resource Source Node Type") {}
+ return nodeType(
+ id = "source-default", version = BluePrintConstants.DEFAULT_VERSION_NUMBER,
+ derivedFrom = BluePrintConstants.MODEL_TYPE_NODE_RESOURCE_SOURCE,
+ description = "This is Default Resource Source Node Type"
+ ) {}
}
fun BluePrintTypes.nodeTypeSourceDb(): NodeType {
- return nodeType(id = "source-db", version = BluePrintConstants.DEFAULT_VERSION_NUMBER,
- derivedFrom = BluePrintConstants.MODEL_TYPE_NODE_RESOURCE_SOURCE,
- description = "This is Database Resource Source Node Type") {
- property("type", BluePrintConstants.DATA_TYPE_STRING,
- true, "") {
+ return nodeType(
+ id = "source-db", version = BluePrintConstants.DEFAULT_VERSION_NUMBER,
+ derivedFrom = BluePrintConstants.MODEL_TYPE_NODE_RESOURCE_SOURCE,
+ description = "This is Database Resource Source Node Type"
+ ) {
+ property(
+ "type", BluePrintConstants.DATA_TYPE_STRING,
+ true, ""
+ ) {
defaultValue("SQL".asJsonPrimitive())
constrain {
validValues(arrayListOf("SQL".asJsonPrimitive(), "PLSQL".asJsonPrimitive()))
}
}
- property("endpoint-selector", BluePrintConstants.DATA_TYPE_STRING,
- false, "")
- property("query", BluePrintConstants.DATA_TYPE_STRING,
- true, "")
- property("input-key-mapping", BluePrintConstants.DATA_TYPE_MAP,
- true, "") {
+ property(
+ "endpoint-selector", BluePrintConstants.DATA_TYPE_STRING,
+ false, ""
+ )
+ property(
+ "query", BluePrintConstants.DATA_TYPE_STRING,
+ true, ""
+ )
+ property(
+ "input-key-mapping", BluePrintConstants.DATA_TYPE_MAP,
+ true, ""
+ ) {
entrySchema(BluePrintConstants.DATA_TYPE_STRING)
}
- property("output-key-mapping", BluePrintConstants.DATA_TYPE_MAP,
- false, "") {
+ property(
+ "output-key-mapping", BluePrintConstants.DATA_TYPE_MAP,
+ false, ""
+ ) {
entrySchema(BluePrintConstants.DATA_TYPE_STRING)
}
- property("key-dependencies", BluePrintConstants.DATA_TYPE_LIST,
- true, "Resource Resolution dependency dictionary names.") {
+ property(
+ "key-dependencies", BluePrintConstants.DATA_TYPE_LIST,
+ true, "Resource Resolution dependency dictionary names."
+ ) {
entrySchema(BluePrintConstants.DATA_TYPE_STRING)
}
}
}
fun BluePrintTypes.nodeTypeSourceRest(): NodeType {
- return nodeType(id = "source-rest", version = BluePrintConstants.DEFAULT_VERSION_NUMBER,
- derivedFrom = BluePrintConstants.MODEL_TYPE_NODE_RESOURCE_SOURCE,
- description = "This is Rest Resource Source Node Type") {
- property("type", BluePrintConstants.DATA_TYPE_STRING,
- true, "") {
+ return nodeType(
+ id = "source-rest", version = BluePrintConstants.DEFAULT_VERSION_NUMBER,
+ derivedFrom = BluePrintConstants.MODEL_TYPE_NODE_RESOURCE_SOURCE,
+ description = "This is Rest Resource Source Node Type"
+ ) {
+ property(
+ "type", BluePrintConstants.DATA_TYPE_STRING,
+ true, ""
+ ) {
defaultValue("JSON".asJsonPrimitive())
constrain {
validValues(arrayListOf("JSON".asJsonPrimitive(), "XML".asJsonPrimitive()))
}
}
- property("verb", BluePrintConstants.DATA_TYPE_STRING,
- true, "") {
+ property(
+ "verb", BluePrintConstants.DATA_TYPE_STRING,
+ true, ""
+ ) {
defaultValue("GET".asJsonPrimitive())
constrain {
- validValues(arrayListOf("GET".asJsonPrimitive(), "POST".asJsonPrimitive(),
- "DELETE".asJsonPrimitive(), "PUT".asJsonPrimitive()))
+ validValues(
+ arrayListOf(
+ "GET".asJsonPrimitive(), "POST".asJsonPrimitive(),
+ "DELETE".asJsonPrimitive(), "PUT".asJsonPrimitive()
+ )
+ )
}
}
- property("payload", BluePrintConstants.DATA_TYPE_STRING,
- false, "") {
+ property(
+ "payload", BluePrintConstants.DATA_TYPE_STRING,
+ false, ""
+ ) {
defaultValue("".asJsonPrimitive())
}
- property("endpoint-selector", BluePrintConstants.DATA_TYPE_STRING,
- false, "")
- property("url-path", BluePrintConstants.DATA_TYPE_STRING,
- true, "")
- property("path", BluePrintConstants.DATA_TYPE_STRING,
- true, "")
- property("expression-type", BluePrintConstants.DATA_TYPE_STRING,
- false, "") {
+ property(
+ "endpoint-selector", BluePrintConstants.DATA_TYPE_STRING,
+ false, ""
+ )
+ property(
+ "url-path", BluePrintConstants.DATA_TYPE_STRING,
+ true, ""
+ )
+ property(
+ "path", BluePrintConstants.DATA_TYPE_STRING,
+ true, ""
+ )
+ property(
+ "expression-type", BluePrintConstants.DATA_TYPE_STRING,
+ false, ""
+ ) {
defaultValue("JSON_PATH".asJsonPrimitive())
constrain {
validValues(arrayListOf("JSON_PATH".asJsonPrimitive(), "JSON_POINTER".asJsonPrimitive()))
}
}
- property("input-key-mapping", BluePrintConstants.DATA_TYPE_MAP,
- true, "") {
+ property(
+ "input-key-mapping", BluePrintConstants.DATA_TYPE_MAP,
+ true, ""
+ ) {
entrySchema(BluePrintConstants.DATA_TYPE_STRING)
}
- property("output-key-mapping", BluePrintConstants.DATA_TYPE_MAP,
- false, "") {
+ property(
+ "output-key-mapping", BluePrintConstants.DATA_TYPE_MAP,
+ false, ""
+ ) {
entrySchema(BluePrintConstants.DATA_TYPE_STRING)
}
- property("key-dependencies", BluePrintConstants.DATA_TYPE_LIST,
- true, "Resource Resolution dependency dictionary names.") {
+ property(
+ "key-dependencies", BluePrintConstants.DATA_TYPE_LIST,
+ true, "Resource Resolution dependency dictionary names."
+ ) {
entrySchema(BluePrintConstants.DATA_TYPE_STRING)
}
}
}
fun BluePrintTypes.nodeTypeSourceCapability(): NodeType {
- return nodeType(id = "source-capability", version = BluePrintConstants.DEFAULT_VERSION_NUMBER,
- derivedFrom = BluePrintConstants.MODEL_TYPE_NODE_RESOURCE_SOURCE,
- description = "This is Component Resource Source Node Type") {
- property(ComponentScriptExecutor.INPUT_SCRIPT_TYPE, BluePrintConstants.DATA_TYPE_STRING,
- true, "Request Id, Unique Id for the request.") {
+ return nodeType(
+ id = "source-capability", version = BluePrintConstants.DEFAULT_VERSION_NUMBER,
+ derivedFrom = BluePrintConstants.MODEL_TYPE_NODE_RESOURCE_SOURCE,
+ description = "This is Component Resource Source Node Type"
+ ) {
+ property(
+ ComponentScriptExecutor.INPUT_SCRIPT_TYPE, BluePrintConstants.DATA_TYPE_STRING,
+ true, "Request Id, Unique Id for the request."
+ ) {
defaultValue(BluePrintConstants.SCRIPT_KOTLIN)
constrain {
- validValues(arrayListOf(BluePrintConstants.SCRIPT_KOTLIN.asJsonPrimitive(),
+ validValues(
+ arrayListOf(
+ BluePrintConstants.SCRIPT_KOTLIN.asJsonPrimitive(),
BluePrintConstants.SCRIPT_INTERNAL.asJsonPrimitive(),
- BluePrintConstants.SCRIPT_JYTHON.asJsonPrimitive()))
+ BluePrintConstants.SCRIPT_JYTHON.asJsonPrimitive()
+ )
+ )
}
}
- property(ComponentScriptExecutor.INPUT_SCRIPT_CLASS_REFERENCE, BluePrintConstants.DATA_TYPE_STRING,
- true, "Kotlin Script class name or jython script name.")
- property("key-dependencies", BluePrintConstants.DATA_TYPE_LIST,
- true, "Resource Resolution dependency dictionary names.") {
+ property(
+ ComponentScriptExecutor.INPUT_SCRIPT_CLASS_REFERENCE, BluePrintConstants.DATA_TYPE_STRING,
+ true, "Kotlin Script class name or jython script name."
+ )
+ property(
+ "key-dependencies", BluePrintConstants.DATA_TYPE_LIST,
+ true, "Resource Resolution dependency dictionary names."
+ ) {
entrySchema(BluePrintConstants.DATA_TYPE_STRING)
}
}
}
/** Node Template Source Input **/
-fun BluePrintTypes.nodeTemplateSourceInput(id: String, description: String,
- block: SourceInputNodeTemplateBuilder.() -> Unit): NodeTemplate {
+fun BluePrintTypes.nodeTemplateSourceInput(
+ id: String,
+ description: String,
+ block: SourceInputNodeTemplateBuilder.() -> Unit
+): NodeTemplate {
return SourceInputNodeTemplateBuilder(id, description).apply(block).build()
}
class SourceInputNodeTemplateBuilder(id: String, description: String) :
- AbstractNodeTemplatePropertyImplBuilder<PropertiesAssignmentBuilder>(id,
- "source-input", description)
+ AbstractNodeTemplatePropertyImplBuilder<PropertiesAssignmentBuilder>(
+ id,
+ "source-input", description
+ )
/** Node Template Source Default **/
-fun BluePrintTypes.nodeTemplateSourceDefault(id: String, description: String,
- block: SourceDefaultNodeTemplateBuilder.() -> Unit): NodeTemplate {
+fun BluePrintTypes.nodeTemplateSourceDefault(
+ id: String,
+ description: String,
+ block: SourceDefaultNodeTemplateBuilder.() -> Unit
+): NodeTemplate {
return SourceDefaultNodeTemplateBuilder(id, description).apply(block).build()
}
class SourceDefaultNodeTemplateBuilder(id: String, description: String) :
- AbstractNodeTemplatePropertyImplBuilder<PropertiesAssignmentBuilder>(id,
- "source-default", description)
+ AbstractNodeTemplatePropertyImplBuilder<PropertiesAssignmentBuilder>(
+ id,
+ "source-default", description
+ )
/** Node Template Source DB **/
-fun BluePrintTypes.nodeTemplateSourceDb(id: String, description: String,
- block: SourceDbNodeTemplateBuilder.() -> Unit): NodeTemplate {
+fun BluePrintTypes.nodeTemplateSourceDb(
+ id: String,
+ description: String,
+ block: SourceDbNodeTemplateBuilder.() -> Unit
+): NodeTemplate {
return SourceDbNodeTemplateBuilder(id, description).apply(block).build()
}
class SourceDbNodeTemplateBuilder(id: String, description: String) :
- AbstractNodeTemplatePropertyImplBuilder<SourceDbNodeTemplateBuilder.PropertiesBuilder>(id,
- "source-db", description) {
+ AbstractNodeTemplatePropertyImplBuilder<SourceDbNodeTemplateBuilder.PropertiesBuilder>(
+ id,
+ "source-db", description
+ ) {
class PropertiesBuilder : PropertiesAssignmentBuilder() {
fun type(type: String) = type(type.asJsonPrimitive())
@@ -221,16 +296,20 @@ class KeyMappingBuilder() {
}
}
-
/** Node Template Source Rest **/
-fun BluePrintTypes.nodeTemplateSourceRest(id: String, description: String,
- block: SourceRestNodeTemplateBuilder.() -> Unit): NodeTemplate {
+fun BluePrintTypes.nodeTemplateSourceRest(
+ id: String,
+ description: String,
+ block: SourceRestNodeTemplateBuilder.() -> Unit
+): NodeTemplate {
return SourceRestNodeTemplateBuilder(id, description).apply(block).build()
}
class SourceRestNodeTemplateBuilder(id: String, description: String) :
- AbstractNodeTemplatePropertyImplBuilder<SourceRestNodeTemplateBuilder.PropertiesBuilder>(id,
- "source-rest", description) {
+ AbstractNodeTemplatePropertyImplBuilder<SourceRestNodeTemplateBuilder.PropertiesBuilder>(
+ id,
+ "source-rest", description
+ ) {
class PropertiesBuilder : PropertiesAssignmentBuilder() {
fun type(type: String) = type(type.asJsonPrimitive())
@@ -296,14 +375,19 @@ class SourceRestNodeTemplateBuilder(id: String, description: String) :
}
/** Node Template Source Rest **/
-fun BluePrintTypes.nodeTemplateSourceCapability(id: String, description: String,
- block: SourceCapabilityNodeTemplateBuilder.() -> Unit): NodeTemplate {
+fun BluePrintTypes.nodeTemplateSourceCapability(
+ id: String,
+ description: String,
+ block: SourceCapabilityNodeTemplateBuilder.() -> Unit
+): NodeTemplate {
return SourceCapabilityNodeTemplateBuilder(id, description).apply(block).build()
}
class SourceCapabilityNodeTemplateBuilder(id: String, description: String) :
- AbstractNodeTemplatePropertyImplBuilder<SourceCapabilityNodeTemplateBuilder.PropertiesBuilder>(id,
- "source-capability", description) {
+ AbstractNodeTemplatePropertyImplBuilder<SourceCapabilityNodeTemplateBuilder.PropertiesBuilder>(
+ id,
+ "source-capability", description
+ ) {
class PropertiesBuilder : PropertiesAssignmentBuilder() {
fun type(type: String) = type(type.asJsonPrimitive())
@@ -330,4 +414,4 @@ class SourceCapabilityNodeTemplateBuilder(id: String, description: String) :
property("key-dependencies", keyDependencies)
}
}
-} \ No newline at end of file
+}
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 2a0e7a443..636e81dda 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
@@ -78,4 +78,4 @@ open class CapabilityResourceSource : ResourceSourceProperties() {
var instanceDependencies: List<String>? = null
@get:JsonProperty("key-dependencies")
lateinit var keyDependencies: MutableList<String>
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/ResourceResolution.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/ResourceResolution.kt
index 781cafd97..db023acfb 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/ResourceResolution.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/ResourceResolution.kt
@@ -22,8 +22,15 @@ import org.hibernate.annotations.Proxy
import org.springframework.data.annotation.LastModifiedDate
import org.springframework.data.jpa.domain.support.AuditingEntityListener
import java.io.Serializable
-import java.util.*
-import javax.persistence.*
+import java.util.Date
+import javax.persistence.Column
+import javax.persistence.Entity
+import javax.persistence.EntityListeners
+import javax.persistence.Id
+import javax.persistence.Lob
+import javax.persistence.Table
+import javax.persistence.Temporal
+import javax.persistence.TemporalType
@EntityListeners(AuditingEntityListener::class)
@Entity
@@ -56,8 +63,10 @@ class ResourceResolution : Serializable {
@Column(name = "status", nullable = false)
var status: String? = null
- @get:ApiModelProperty(value = "Resolution Key uniquely identifying the resolution of a given artifact within a CBA.",
- required = true)
+ @get:ApiModelProperty(
+ value = "Resolution Key uniquely identifying the resolution of a given artifact within a CBA.",
+ required = true
+ )
@Column(name = "resolution_key", nullable = false)
var resolutionKey: String? = null
@@ -69,8 +78,10 @@ class ResourceResolution : Serializable {
@Column(name = "resource_id", nullable = false)
var resourceId: String? = null
- @get:ApiModelProperty(value = "If resolution occurred multiple time, this field provides the index.",
- required = true)
+ @get:ApiModelProperty(
+ value = "If resolution occurred multiple time, this field provides the index.",
+ required = true
+ )
@Column(name = "occurrence", nullable = false)
var occurrence: Int = 0
@@ -78,8 +89,10 @@ class ResourceResolution : Serializable {
@Column(name = "dictionary_name", nullable = false)
var dictionaryName: String? = null
- @get:ApiModelProperty(value = "Source associated with the data dictionary used for the resolution.",
- required = true)
+ @get:ApiModelProperty(
+ value = "Source associated with the data dictionary used for the resolution.",
+ required = true
+ )
@Column(name = "dictionary_status", nullable = false)
var dictionarySource: String? = null
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/ResourceResolutionDBService.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/ResourceResolutionDBService.kt
index e5a13a630..f8bf7bd09 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/ResourceResolutionDBService.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/ResourceResolutionDBService.kt
@@ -26,7 +26,7 @@ import org.onap.ccsdk.cds.controllerblueprints.resource.dict.ResourceAssignment
import org.slf4j.LoggerFactory
import org.springframework.dao.EmptyResultDataAccessException
import org.springframework.stereotype.Service
-import java.util.*
+import java.util.UUID
@Service
class ResourceResolutionDBService(private val resourceResolutionRepository: ResourceResolutionRepository) {
@@ -34,8 +34,11 @@ class ResourceResolutionDBService(private val resourceResolutionRepository: Reso
private val log = LoggerFactory.getLogger(ResourceResolutionDBService::class.toString())
suspend fun findByBlueprintNameAndBlueprintVersionAndArtifactNameAndResolutionKeyAndOccurrence(
- bluePrintRuntimeService: BluePrintRuntimeService<*>, key: String,
- occurrence: Int, artifactPrefix: String): List<ResourceResolution> {
+ bluePrintRuntimeService: BluePrintRuntimeService<*>,
+ key: String,
+ occurrence: Int,
+ artifactPrefix: String
+ ): List<ResourceResolution> {
return try {
val metadata = bluePrintRuntimeService.bluePrintContext().metadata!!
@@ -47,16 +50,20 @@ class ResourceResolutionDBService(private val resourceResolutionRepository: Reso
blueprintVersion,
artifactPrefix,
key,
- occurrence)
+ occurrence
+ )
} catch (e: EmptyResultDataAccessException) {
emptyList()
}
}
suspend fun findByBlueprintNameAndBlueprintVersionAndArtifactNameAndResourceIdAndResourceTypeAndOccurrence(
- bluePrintRuntimeService: BluePrintRuntimeService<*>, resourceId: String,
- resourceType: String, occurrence: Int,
- artifactPrefix: String): List<ResourceResolution> {
+ bluePrintRuntimeService: BluePrintRuntimeService<*>,
+ resourceId: String,
+ resourceType: String,
+ occurrence: Int,
+ artifactPrefix: String
+ ): List<ResourceResolution> {
return try {
val metadata = bluePrintRuntimeService.bluePrintContext().metadata!!
@@ -70,55 +77,67 @@ class ResourceResolutionDBService(private val resourceResolutionRepository: Reso
artifactPrefix,
resourceId,
resourceType,
- occurrence)
+ occurrence
+ )
} catch (e: EmptyResultDataAccessException) {
emptyList()
}
}
- suspend fun readValue(blueprintName: String,
- blueprintVersion: String,
- artifactPrefix: String,
- resolutionKey: String,
- name: String): ResourceResolution = withContext(Dispatchers.IO) {
+ suspend fun readValue(
+ blueprintName: String,
+ blueprintVersion: String,
+ artifactPrefix: String,
+ resolutionKey: String,
+ name: String
+ ): ResourceResolution = withContext(Dispatchers.IO) {
resourceResolutionRepository.findByResolutionKeyAndBlueprintNameAndBlueprintVersionAndArtifactNameAndName(
resolutionKey,
blueprintName,
blueprintVersion,
artifactPrefix,
- name)
+ name
+ )
}
- suspend fun readWithResolutionKey(blueprintName: String,
- blueprintVersion: String,
- artifactPrefix: String,
- resolutionKey: String): List<ResourceResolution> = withContext(Dispatchers.IO) {
+ suspend fun readWithResolutionKey(
+ blueprintName: String,
+ blueprintVersion: String,
+ artifactPrefix: String,
+ resolutionKey: String
+ ): List<ResourceResolution> = withContext(Dispatchers.IO) {
resourceResolutionRepository.findByResolutionKeyAndBlueprintNameAndBlueprintVersionAndArtifactName(
resolutionKey,
blueprintName,
blueprintVersion,
- artifactPrefix)
+ artifactPrefix
+ )
}
- suspend fun readWithResourceIdAndResourceType(blueprintName: String,
- blueprintVersion: String,
- resourceId: String,
- resourceType: String): List<ResourceResolution> =
+ suspend fun readWithResourceIdAndResourceType(
+ blueprintName: String,
+ blueprintVersion: String,
+ resourceId: String,
+ resourceType: String
+ ): List<ResourceResolution> =
withContext(Dispatchers.IO) {
resourceResolutionRepository.findByBlueprintNameAndBlueprintVersionAndResourceIdAndResourceType(
blueprintName,
blueprintVersion,
resourceId,
- resourceType)
+ resourceType
+ )
}
- suspend fun write(properties: Map<String, Any>,
- bluePrintRuntimeService: BluePrintRuntimeService<*>,
- artifactPrefix: String,
- resourceAssignment: ResourceAssignment): ResourceResolution = withContext(Dispatchers.IO) {
+ suspend fun write(
+ properties: Map<String, Any>,
+ bluePrintRuntimeService: BluePrintRuntimeService<*>,
+ artifactPrefix: String,
+ resourceAssignment: ResourceAssignment
+ ): ResourceResolution = withContext(Dispatchers.IO) {
val metadata = bluePrintRuntimeService.bluePrintContext().metadata!!
@@ -130,24 +149,28 @@ class ResourceResolutionDBService(private val resourceResolutionRepository: Reso
val resourceType = properties[ResourceResolutionConstants.RESOURCE_RESOLUTION_INPUT_RESOURCE_TYPE] as String
val occurrence = properties[ResourceResolutionConstants.RESOURCE_RESOLUTION_INPUT_OCCURRENCE] as Int
- write(blueprintName,
+ write(
+ blueprintName,
blueprintVersion,
resolutionKey,
resourceId,
resourceType,
artifactPrefix,
resourceAssignment,
- occurrence)
+ occurrence
+ )
}
- suspend fun write(blueprintName: String,
- blueprintVersion: String,
- resolutionKey: String,
- resourceId: String,
- resourceType: String,
- artifactPrefix: String,
- resourceAssignment: ResourceAssignment,
- occurrence: Int = 0): ResourceResolution = withContext(Dispatchers.IO) {
+ suspend fun write(
+ blueprintName: String,
+ blueprintVersion: String,
+ resolutionKey: String,
+ resourceId: String,
+ resourceType: String,
+ artifactPrefix: String,
+ resourceAssignment: ResourceAssignment,
+ occurrence: Int = 0
+ ): ResourceResolution = withContext(Dispatchers.IO) {
val resourceResolution = ResourceResolution()
resourceResolution.id = UUID.randomUUID().toString()
@@ -175,4 +198,4 @@ class ResourceResolutionDBService(private val resourceResolutionRepository: Reso
throw BluePrintException("Failed to store resource resolution result.", ex)
}
}
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/ResourceResolutionRepository.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/ResourceResolutionRepository.kt
index 429041e14..155270cd9 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/ResourceResolutionRepository.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/ResourceResolutionRepository.kt
@@ -19,28 +19,35 @@ import org.springframework.data.jpa.repository.JpaRepository
interface ResourceResolutionRepository : JpaRepository<ResourceResolution, String> {
- fun findByResolutionKeyAndBlueprintNameAndBlueprintVersionAndArtifactNameAndName(key: String,
- blueprintName: String?,
- blueprintVersion: String?,
- artifactName: String,
- name: String): ResourceResolution
+ fun findByResolutionKeyAndBlueprintNameAndBlueprintVersionAndArtifactNameAndName(
+ key: String,
+ blueprintName: String?,
+ blueprintVersion: String?,
+ artifactName: String,
+ name: String
+ ): ResourceResolution
- fun findByResolutionKeyAndBlueprintNameAndBlueprintVersionAndArtifactName(resolutionKey: String,
- blueprintName: String,
- blueprintVersion: String,
- artifactPrefix: String): List<ResourceResolution>
+ fun findByResolutionKeyAndBlueprintNameAndBlueprintVersionAndArtifactName(
+ resolutionKey: String,
+ blueprintName: String,
+ blueprintVersion: String,
+ artifactPrefix: String
+ ): List<ResourceResolution>
- fun findByBlueprintNameAndBlueprintVersionAndResourceIdAndResourceType(blueprintName: String,
- blueprintVersion: String,
- resourceId: String,
- resourceType: String): List<ResourceResolution>
+ fun findByBlueprintNameAndBlueprintVersionAndResourceIdAndResourceType(
+ blueprintName: String,
+ blueprintVersion: String,
+ resourceId: String,
+ resourceType: String
+ ): List<ResourceResolution>
fun findByBlueprintNameAndBlueprintVersionAndArtifactNameAndResolutionKeyAndOccurrence(
blueprintName: String?,
blueprintVersion: String?,
artifactName: String,
resolutionKey: String,
- occurrence: Int): List<ResourceResolution>
+ occurrence: Int
+ ): List<ResourceResolution>
fun findByBlueprintNameAndBlueprintVersionAndArtifactNameAndResourceIdAndResourceTypeAndOccurrence(
blueprintName: String?,
@@ -48,5 +55,6 @@ interface ResourceResolutionRepository : JpaRepository<ResourceResolution, Strin
artifactName: String,
resourceId: String,
resourceType: String,
- occurrence: Int): List<ResourceResolution>
-} \ No newline at end of file
+ occurrence: Int
+ ): List<ResourceResolution>
+}
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/TemplateResolution.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/TemplateResolution.kt
index 9d5a3f5d5..8b235925b 100755
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/TemplateResolution.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/TemplateResolution.kt
@@ -22,8 +22,15 @@ import org.hibernate.annotations.Proxy
import org.springframework.data.annotation.LastModifiedDate
import org.springframework.data.jpa.domain.support.AuditingEntityListener
import java.io.Serializable
-import java.util.*
-import javax.persistence.*
+import java.util.Date
+import javax.persistence.Column
+import javax.persistence.Entity
+import javax.persistence.EntityListeners
+import javax.persistence.Id
+import javax.persistence.Lob
+import javax.persistence.Table
+import javax.persistence.Temporal
+import javax.persistence.TemporalType
@EntityListeners(AuditingEntityListener::class)
@Entity
@@ -48,8 +55,10 @@ class TemplateResolution : Serializable {
@Column(name = "result", nullable = false)
var result: String? = null
- @get:ApiModelProperty(value = "Resolution Key uniquely identifying the resolution of a given artifact within a CBA.",
- required = true)
+ @get:ApiModelProperty(
+ value = "Resolution Key uniquely identifying the resolution of a given artifact within a CBA.",
+ required = true
+ )
@Column(name = "resolution_key", nullable = false)
var resolutionKey: String? = null
@@ -61,8 +70,10 @@ class TemplateResolution : Serializable {
@Column(name = "resource_id", nullable = false)
var resourceId: String? = null
- @get:ApiModelProperty(value = "If resolution occurred multiple time, this field provides the index.",
- required = true)
+ @get:ApiModelProperty(
+ value = "If resolution occurred multiple time, this field provides the index.",
+ required = true
+ )
@Column(name = "occurrence", nullable = false)
var occurrence: Int = 1
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/TemplateResolutionRepository.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/TemplateResolutionRepository.kt
index 440663f25..610a3cfe3 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/TemplateResolutionRepository.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/TemplateResolutionRepository.kt
@@ -26,14 +26,16 @@ interface TemplateResolutionRepository : JpaRepository<TemplateResolution, Strin
blueprintName: String?,
blueprintVersion: String?,
artifactName: String,
- occurrence: Int): TemplateResolution ?
+ occurrence: Int
+ ): TemplateResolution?
fun findByResolutionKeyAndBlueprintNameAndBlueprintVersionAndArtifactNameAndOccurrence(
key: String,
blueprintName: String?,
blueprintVersion: String?,
artifactName: String,
- occurrence: Int): TemplateResolution ?
+ occurrence: Int
+ ): TemplateResolution?
@Transactional
fun deleteByResourceIdAndResourceTypeAndBlueprintNameAndBlueprintVersionAndArtifactNameAndOccurrence(
@@ -42,7 +44,8 @@ interface TemplateResolutionRepository : JpaRepository<TemplateResolution, Strin
blueprintName: String?,
blueprintVersion: String?,
artifactName: String,
- occurrence: Int)
+ occurrence: Int
+ )
@Transactional
fun deleteByResolutionKeyAndBlueprintNameAndBlueprintVersionAndArtifactNameAndOccurrence(
@@ -50,5 +53,6 @@ interface TemplateResolutionRepository : JpaRepository<TemplateResolution, Strin
blueprintName: String?,
blueprintVersion: String?,
artifactName: String,
- occurrence: Int)
+ occurrence: Int
+ )
}
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/TemplateResolutionService.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/TemplateResolutionService.kt
index c64605ef0..895bc993f 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/TemplateResolutionService.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/TemplateResolutionService.kt
@@ -25,7 +25,7 @@ import org.slf4j.LoggerFactory
import org.springframework.dao.DataIntegrityViolationException
import org.springframework.dao.EmptyResultDataAccessException
import org.springframework.stereotype.Service
-import java.util.*
+import java.util.UUID
@Service
class TemplateResolutionService(private val templateResolutionRepository: TemplateResolutionRepository) {
@@ -35,7 +35,8 @@ class TemplateResolutionService(private val templateResolutionRepository: Templa
suspend fun findByResolutionKeyAndBlueprintNameAndBlueprintVersionAndArtifactName(
bluePrintRuntimeService: BluePrintRuntimeService<*>,
artifactPrefix: String,
- resolutionKey: String): String =
+ resolutionKey: String
+ ): String =
withContext(Dispatchers.IO) {
val metadata = bluePrintRuntimeService.bluePrintContext().metadata!!
@@ -43,17 +44,21 @@ class TemplateResolutionService(private val templateResolutionRepository: Templa
val blueprintVersion = metadata[BluePrintConstants.METADATA_TEMPLATE_VERSION]!!
val blueprintName = metadata[BluePrintConstants.METADATA_TEMPLATE_NAME]!!
- findByResolutionKeyAndBlueprintNameAndBlueprintVersionAndArtifactName(blueprintName,
+ findByResolutionKeyAndBlueprintNameAndBlueprintVersionAndArtifactName(
+ blueprintName,
blueprintVersion,
artifactPrefix,
- resolutionKey)
+ resolutionKey
+ )
}
- suspend fun findByResolutionKeyAndBlueprintNameAndBlueprintVersionAndArtifactName(blueprintName: String,
- blueprintVersion: String,
- artifactPrefix: String,
- resolutionKey: String,
- occurrence: Int = 1): String =
+ suspend fun findByResolutionKeyAndBlueprintNameAndBlueprintVersionAndArtifactName(
+ blueprintName: String,
+ blueprintVersion: String,
+ artifactPrefix: String,
+ resolutionKey: String,
+ occurrence: Int = 1
+ ): String =
withContext(Dispatchers.IO) {
templateResolutionRepository.findByResolutionKeyAndBlueprintNameAndBlueprintVersionAndArtifactNameAndOccurrence(
@@ -61,15 +66,18 @@ class TemplateResolutionService(private val templateResolutionRepository: Templa
blueprintName,
blueprintVersion,
artifactPrefix,
- occurrence)?.result ?: throw EmptyResultDataAccessException(1)
+ occurrence
+ )?.result ?: throw EmptyResultDataAccessException(1)
}
- suspend fun findByResoureIdAndResourceTypeAndBlueprintNameAndBlueprintVersionAndArtifactName(blueprintName: String,
- blueprintVersion: String,
- artifactPrefix: String,
- resourceId: String,
- resourceType: String,
- occurrence: Int = 1): String =
+ suspend fun findByResoureIdAndResourceTypeAndBlueprintNameAndBlueprintVersionAndArtifactName(
+ blueprintName: String,
+ blueprintVersion: String,
+ artifactPrefix: String,
+ resourceId: String,
+ resourceType: String,
+ occurrence: Int = 1
+ ): String =
withContext(Dispatchers.IO) {
templateResolutionRepository.findByResourceIdAndResourceTypeAndBlueprintNameAndBlueprintVersionAndArtifactNameAndOccurrence(
@@ -78,12 +86,16 @@ class TemplateResolutionService(private val templateResolutionRepository: Templa
blueprintName,
blueprintVersion,
artifactPrefix,
- occurrence)?.result!!
+ occurrence
+ )?.result!!
}
- suspend fun write(properties: Map<String, Any>,
- result: String, bluePrintRuntimeService: BluePrintRuntimeService<*>,
- artifactPrefix: String): TemplateResolution = withContext(Dispatchers.IO) {
+ suspend fun write(
+ properties: Map<String, Any>,
+ result: String,
+ bluePrintRuntimeService: BluePrintRuntimeService<*>,
+ artifactPrefix: String
+ ): TemplateResolution = withContext(Dispatchers.IO) {
val metadata = bluePrintRuntimeService.bluePrintContext().metadata!!
@@ -93,19 +105,28 @@ class TemplateResolutionService(private val templateResolutionRepository: Templa
val resourceId = properties[ResourceResolutionConstants.RESOURCE_RESOLUTION_INPUT_RESOURCE_ID] as String
val resourceType = properties[ResourceResolutionConstants.RESOURCE_RESOLUTION_INPUT_RESOURCE_TYPE] as String
val occurrence = properties[ResourceResolutionConstants.RESOURCE_RESOLUTION_INPUT_OCCURRENCE] as Int
- write(blueprintName,
+ write(
+ blueprintName,
blueprintVersion,
artifactPrefix,
result,
occurrence,
resolutionKey,
resourceId,
- resourceType)
+ resourceType
+ )
}
- suspend fun write(blueprintName: String, blueprintVersion: String, artifactPrefix: String,
- template: String, occurrence: Int = 1, resolutionKey: String = "", resourceId: String = "",
- resourceType: String = ""): TemplateResolution =
+ suspend fun write(
+ blueprintName: String,
+ blueprintVersion: String,
+ artifactPrefix: String,
+ template: String,
+ occurrence: Int = 1,
+ resolutionKey: String = "",
+ resourceId: String = "",
+ resourceType: String = ""
+ ): TemplateResolution =
withContext(Dispatchers.IO) {
val resourceResolutionResult = TemplateResolution()
@@ -122,37 +143,49 @@ class TemplateResolutionService(private val templateResolutionRepository: Templa
// Overwrite template resolution-key of resourceId/resourceType already existant
if (resolutionKey.isNotEmpty()) {
templateResolutionRepository.findByResolutionKeyAndBlueprintNameAndBlueprintVersionAndArtifactNameAndOccurrence(
- resolutionKey, blueprintName, blueprintVersion, artifactPrefix, occurrence)?.let {
- log.info("Overwriting template resolution for blueprintName=($blueprintVersion), blueprintVersion=($blueprintName), " +
- "artifactName=($artifactPrefix) and resolutionKey=($resolutionKey)")
+ resolutionKey, blueprintName, blueprintVersion, artifactPrefix, occurrence
+ )?.let {
+ log.info(
+ "Overwriting template resolution for blueprintName=($blueprintVersion), blueprintVersion=($blueprintName), " +
+ "artifactName=($artifactPrefix) and resolutionKey=($resolutionKey)"
+ )
templateResolutionRepository.deleteByResolutionKeyAndBlueprintNameAndBlueprintVersionAndArtifactNameAndOccurrence(
resolutionKey,
blueprintName,
blueprintVersion,
artifactPrefix,
- occurrence)
+ occurrence
+ )
}
} else if (resourceId.isNotEmpty() && resourceType.isNotEmpty()) {
templateResolutionRepository.findByResourceIdAndResourceTypeAndBlueprintNameAndBlueprintVersionAndArtifactNameAndOccurrence(
- resourceId, resourceType, blueprintName, blueprintVersion, artifactPrefix, occurrence)?.let {
- log.info("Overwriting template resolution for blueprintName=($blueprintVersion), blueprintVersion=($blueprintName), " +
- "artifactName=($artifactPrefix), resourceId=($resourceId) and resourceType=($resourceType)")
+ resourceId, resourceType, blueprintName, blueprintVersion, artifactPrefix, occurrence
+ )?.let {
+ log.info(
+ "Overwriting template resolution for blueprintName=($blueprintVersion), blueprintVersion=($blueprintName), " +
+ "artifactName=($artifactPrefix), resourceId=($resourceId) and resourceType=($resourceType)"
+ )
templateResolutionRepository.deleteByResourceIdAndResourceTypeAndBlueprintNameAndBlueprintVersionAndArtifactNameAndOccurrence(
resourceId,
resourceType,
blueprintName,
blueprintVersion,
artifactPrefix,
- occurrence)
+ occurrence
+ )
}
}
try {
- log.info("Writing out template_resolution result: bpName: $blueprintName bpVer $blueprintVersion resKey:$resolutionKey" +
- " (resourceId: $resourceId resourceType: $resourceType) occurrence:$occurrence")
+ log.info(
+ "Writing out template_resolution result: bpName: $blueprintName bpVer $blueprintVersion resKey:$resolutionKey" +
+ " (resourceId: $resourceId resourceType: $resourceType) occurrence:$occurrence"
+ )
templateResolutionRepository.saveAndFlush(resourceResolutionResult)
} catch (ex: DataIntegrityViolationException) {
- log.error("Error writing out template_resolution result: bpName: $blueprintName bpVer $blueprintVersion resKey:$resolutionKey" +
- " (resourceId: $resourceId resourceType: $resourceType) occurrence:$occurrence error: {}", ex.message)
+ log.error(
+ "Error writing out template_resolution result: bpName: $blueprintName bpVer $blueprintVersion resKey:$resolutionKey" +
+ " (resourceId: $resourceId resourceType: $resourceType) occurrence:$occurrence error: {}", ex.message
+ )
throw BluePrintException("Failed to store resource api result.", ex)
}
}
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/CapabilityResourceResolutionProcessor.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/CapabilityResourceResolutionProcessor.kt
index 9867cd658..feef4c2fe 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/CapabilityResourceResolutionProcessor.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/CapabilityResourceResolutionProcessor.kt
@@ -90,8 +90,8 @@ open class CapabilityResourceResolutionProcessor(private var componentFunctionSc
ResourceAssignmentUtils.setFailedResourceDataValue(resourceAssignment, runtimeException.message)
}
- suspend fun scriptInstance(scriptType: String, scriptClassReference: String, instanceDependencies: List<String>)
- : ResourceAssignmentProcessor {
+ suspend fun scriptInstance(scriptType: String, scriptClassReference: String, instanceDependencies: List<String>):
+ ResourceAssignmentProcessor {
log.info(
"creating resource resolution of script type($scriptType), reference name($scriptClassReference) and" +
@@ -106,5 +106,4 @@ open class CapabilityResourceResolutionProcessor(private var componentFunctionSc
return scriptComponent
}
-
-} \ No newline at end of file
+}
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 0f5d91415..8ca0ab63f 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
@@ -18,7 +18,7 @@
package org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.processor
import org.onap.ccsdk.cds.blueprintsprocessor.db.BluePrintDBLibGenericService
-import org.onap.ccsdk.cds.blueprintsprocessor.db.primary.BluePrintDBLibPropertySevice
+import org.onap.ccsdk.cds.blueprintsprocessor.db.primary.BluePrintDBLibPropertyService
import org.onap.ccsdk.cds.blueprintsprocessor.db.primary.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
@@ -34,7 +34,7 @@ import org.slf4j.LoggerFactory
import org.springframework.beans.factory.config.ConfigurableBeanFactory
import org.springframework.context.annotation.Scope
import org.springframework.stereotype.Service
-import java.util.*
+import java.util.HashMap
/**
* DatabaseResourceAssignmentProcessor
@@ -44,7 +44,7 @@ import java.util.*
@Service("${PREFIX_RESOURCE_RESOLUTION_PROCESSOR}source-db")
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
open class DatabaseResourceAssignmentProcessor(
- private val bluePrintDBLibPropertySevice: BluePrintDBLibPropertySevice,
+ private val bluePrintDBLibPropertyService: BluePrintDBLibPropertyService,
private val primaryDBLibGenericService: PrimaryDBLibGenericService
) : ResourceAssignmentProcessor() {
@@ -91,8 +91,10 @@ open class DatabaseResourceAssignmentProcessor(
"failed to get input-key-mappings for $dName under $dSource properties"
}
- logger.info("DatabaseResource ($dSource) dictionary information: " +
- "Query:($sql), input-key-mapping:($inputKeyMapping), output-key-mapping:(${sourceProperties.outputKeyMapping})")
+ logger.info(
+ "DatabaseResource ($dSource) dictionary information: " +
+ "Query:($sql), input-key-mapping:($inputKeyMapping), output-key-mapping:(${sourceProperties.outputKeyMapping})"
+ )
val jdbcTemplate = blueprintDBLibService(sourceProperties)
val rows = jdbcTemplate.query(sql, populateNamedParameter(inputKeyMapping))
@@ -106,11 +108,10 @@ open class DatabaseResourceAssignmentProcessor(
private fun blueprintDBLibService(sourceProperties: DatabaseResourceSource): BluePrintDBLibGenericService {
return if (isNotEmpty(sourceProperties.endpointSelector)) {
val dbPropertiesJson = raRuntimeService.resolveDSLExpression(sourceProperties.endpointSelector!!)
- bluePrintDBLibPropertySevice.JdbcTemplate(dbPropertiesJson)
+ bluePrintDBLibPropertyService.JdbcTemplate(dbPropertiesJson)
} else {
primaryDBLibGenericService
}
-
}
@Throws(BluePrintProcessorException::class)
@@ -119,14 +120,13 @@ open class DatabaseResourceAssignmentProcessor(
checkNotEmpty(resourceAssignment.dictionaryName) {
"resource assignment dictionary name is not defined for template key (${resourceAssignment.name})"
}
- check(resourceAssignment.dictionarySource in getListOfDBSources())
- {
+ check(resourceAssignment.dictionarySource in getListOfDBSources()) {
"resource assignment source is not ${ResourceDictionaryConstants.PROCESSOR_DB} but it is ${resourceAssignment.dictionarySource}"
}
}
- //placeholder to get the list of DB sources.
- //TODO: This will be replaced with a DB
+ // placeholder to get the list of DB sources.
+ // TODO: This will be replaced with a DB
private fun getListOfDBSources(): Array<String> = arrayOf(ResourceDictionaryConstants.PROCESSOR_DB)
private fun populateNamedParameter(inputKeyMapping: Map<String, String>): Map<String, Any> {
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 9a83b0cc0..7705c1102 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
@@ -53,10 +53,9 @@ open class DefaultResourceResolutionProcessor : ResourceAssignmentProcessor() {
ResourceAssignmentUtils.setFailedResourceDataValue(resourceAssignment, e.message)
throw BluePrintProcessorException("Failed in template key ($resourceAssignment) assignments with: ${e.message}", e)
}
-
}
override suspend fun recoverNB(runtimeException: RuntimeException, resourceAssignment: ResourceAssignment) {
raRuntimeService.getBluePrintError().addError(runtimeException.message!!)
}
-} \ No newline at end of file
+}
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 a78e7872e..f04a787db 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
@@ -17,10 +17,12 @@
package org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.processor
+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.controllerblueprints.core.BluePrintProcessorException
import org.onap.ccsdk.cds.controllerblueprints.core.isNotEmpty
+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
import org.springframework.context.annotation.Scope
@@ -41,8 +43,8 @@ open class InputResourceResolutionProcessor : ResourceAssignmentProcessor() {
override suspend fun processNB(resourceAssignment: ResourceAssignment) {
try {
- if (isNotEmpty(resourceAssignment.name)) {
- setFromInput(resourceAssignment)
+ if (isNotEmpty(resourceAssignment.name) && !setFromInput(resourceAssignment)) {
+ setFromKeyDependencies(resourceAssignment)
}
// Check the value has populated for mandatory case
ResourceAssignmentUtils.assertTemplateKeyValueNotNull(resourceAssignment)
@@ -52,7 +54,30 @@ open class InputResourceResolutionProcessor : ResourceAssignmentProcessor() {
}
}
+ // usecase: where input data attribute doesn't match with resourceName, and needs an alternate mapping provided under key-dependencies.
+ private fun setFromKeyDependencies(resourceAssignment: ResourceAssignment) {
+ val dName = resourceAssignment.dictionaryName!!
+ val dSource = resourceAssignment.dictionarySource!!
+ val resourceDefinition = resourceDefinition(dName)
+
+ /** Check Resource Assignment has the source definitions, If not get from Resource Definition **/
+ val resourceSource = resourceAssignment.dictionarySourceDefinition
+ ?: resourceDefinition?.sources?.get(dSource)
+ ?: throw BluePrintProcessorException("couldn't get resource definition $dName source($dSource)")
+ val resourceSourceProperties = checkNotNull(resourceSource.properties) {
+ "failed to get source properties for $dName "
+ }
+ val sourceProperties =
+ JacksonUtils.getInstanceFromMap(resourceSourceProperties, DatabaseResourceSource::class.java)
+
+ val keyDependency = checkNotNull(sourceProperties.keyDependencies) {
+ "failed to get input-key-mappings for $dName under $dSource properties"
+ }
+ // keyDependency = service-instance.service-instance-id
+ setFromInputKeyDependencies(keyDependency, resourceAssignment); // New API which picks arrtibute from Input
+ }
+
override suspend fun recoverNB(runtimeException: RuntimeException, resourceAssignment: ResourceAssignment) {
raRuntimeService.getBluePrintError().addError(runtimeException.message!!)
}
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/ResourceAssignmentProcessor.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/ResourceAssignmentProcessor.kt
index e513170a8..454a899aa 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/ResourceAssignmentProcessor.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/ResourceAssignmentProcessor.kt
@@ -22,13 +22,17 @@ import com.fasterxml.jackson.databind.JsonNode
import org.apache.commons.collections.MapUtils
import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.ResourceAssignmentRuntimeService
import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.utils.ResourceAssignmentUtils
-import org.onap.ccsdk.cds.controllerblueprints.core.*
+import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants
+import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException
+import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintProcessorException
+import org.onap.ccsdk.cds.controllerblueprints.core.asJsonNode
import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BlueprintFunctionNode
+import org.onap.ccsdk.cds.controllerblueprints.core.isNullOrMissing
import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintVelocityTemplateService
import org.onap.ccsdk.cds.controllerblueprints.resource.dict.ResourceAssignment
import org.onap.ccsdk.cds.controllerblueprints.resource.dict.ResourceDefinition
import org.slf4j.LoggerFactory
-import java.util.*
+import java.util.HashMap
abstract class ResourceAssignmentProcessor : BlueprintFunctionNode<ResourceAssignment, Boolean> {
@@ -52,8 +56,10 @@ abstract class ResourceAssignmentProcessor : BlueprintFunctionNode<ResourceAssig
try {
val value = raRuntimeService.getInputValue(resourceAssignment.name)
if (!value.isNullOrMissing()) {
- log.debug("For Resource:(${resourceAssignment.name}) found value:({}) in input-data.",
- ResourceAssignmentUtils.getValueToLog(resourceAssignment.property?.metadata, value))
+ log.debug(
+ "For Resource:(${resourceAssignment.name}) found value:({}) in input-data.",
+ ResourceAssignmentUtils.getValueToLog(resourceAssignment.property?.metadata, value)
+ )
ResourceAssignmentUtils.setResourceDataValue(resourceAssignment, raRuntimeService, value)
return true
}
@@ -63,6 +69,25 @@ abstract class ResourceAssignmentProcessor : BlueprintFunctionNode<ResourceAssig
return false
}
+ open fun setFromInputKeyDependencies(keys: MutableList<String>, resourceAssignment: ResourceAssignment): Boolean {
+ try {
+ for (dependencyKey in keys) {
+ var value = raRuntimeService.getInputValue(dependencyKey)
+ if (!value.isNullOrMissing()) {
+ log.debug(
+ "For Resource:(${resourceAssignment.name}) found value:({}) in input-data under: ($dependencyKey).",
+ ResourceAssignmentUtils.getValueToLog(resourceAssignment.property?.metadata, value)
+ )
+ ResourceAssignmentUtils.setResourceDataValue(resourceAssignment, raRuntimeService, value)
+ return true
+ }
+ }
+ } catch (e: BluePrintProcessorException) {
+ // NoOp - couldn't find value from input
+ }
+ return false
+ }
+
open fun resourceDefinition(name: String): ResourceDefinition? {
return if (resourceDictionaries.containsKey(name)) resourceDictionaries[name] else null
}
@@ -83,7 +108,7 @@ abstract class ResourceAssignmentProcessor : BlueprintFunctionNode<ResourceAssig
if (valueToResolve.isEmpty() || !valueToResolve.contains("$")) {
return valueToResolve
}
- //TODO("Optimize to JSON Node directly without velocity").asJsonNode().toString()
+ // TODO("Optimize to JSON Node directly without velocity").asJsonNode().toString()
return BluePrintVelocityTemplateService.generateContent(valueToResolve, keyMapping.asJsonNode().toString())
}
@@ -171,4 +196,4 @@ abstract class ResourceAssignmentProcessor : BlueprintFunctionNode<ResourceAssig
fun addError(error: String) {
raRuntimeService.getBluePrintError().addError(error)
}
-} \ No newline at end of file
+}
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 e9aa2749a..2ff5c441e 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
@@ -81,8 +81,10 @@ open class RestResourceResolutionProcessor(private val blueprintRestLibPropertyS
resolveFromInputKeyMapping(checkNotNull(sourceProperties.urlPath), resolvedInputKeyMapping)
val verb = resolveFromInputKeyMapping(nullToEmpty(sourceProperties.verb), resolvedInputKeyMapping)
- logger.info("RestResource ($dSource) dictionary information: " +
- "URL:($urlPath), input-key-mapping:($inputKeyMapping), output-key-mapping:(${sourceProperties.outputKeyMapping})")
+ logger.info(
+ "RestResource ($dSource) dictionary information: " +
+ "URL:($urlPath), input-key-mapping:($inputKeyMapping), output-key-mapping:(${sourceProperties.outputKeyMapping})"
+ )
val requestHeaders = sourceProperties.headers
logger.info("$dSource dictionary information : ($urlPath), ($inputKeyMapping), (${sourceProperties.outputKeyMapping})")
// Get the Rest Client Service
@@ -125,8 +127,10 @@ open class RestResourceResolutionProcessor(private val blueprintRestLibPropertyS
@Throws(BluePrintProcessorException::class)
private fun populateResource(
- resourceAssignment: ResourceAssignment, sourceProperties: RestResourceSource,
- restResponse: String, path: String
+ resourceAssignment: ResourceAssignment,
+ sourceProperties: RestResourceSource,
+ restResponse: String,
+ path: String
) {
val dName = resourceAssignment.dictionaryName
val dSource = resourceAssignment.dictionarySource
@@ -168,5 +172,4 @@ open class RestResourceResolutionProcessor(private val blueprintRestLibPropertyS
override suspend fun recoverNB(runtimeException: RuntimeException, resourceAssignment: ResourceAssignment) {
raRuntimeService.getBluePrintError().addError(runtimeException.message!!)
}
-
}
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 688713469..b818cc2b1 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
@@ -25,14 +25,25 @@ import com.fasterxml.jackson.databind.node.ObjectNode
import com.fasterxml.jackson.databind.node.TextNode
import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.ResourceAssignmentRuntimeService
import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.ResourceResolutionConstants
-import org.onap.ccsdk.cds.controllerblueprints.core.*
+import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants
+import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintProcessorException
+import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintTypes
+import org.onap.ccsdk.cds.controllerblueprints.core.asJsonType
+import org.onap.ccsdk.cds.controllerblueprints.core.checkFileExists
+import org.onap.ccsdk.cds.controllerblueprints.core.checkNotEmpty
+import org.onap.ccsdk.cds.controllerblueprints.core.isComplexType
+import org.onap.ccsdk.cds.controllerblueprints.core.isNotEmpty
+import org.onap.ccsdk.cds.controllerblueprints.core.isNullOrMissing
+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.utils.JacksonReactorUtils
import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils
import org.onap.ccsdk.cds.controllerblueprints.resource.dict.ResourceAssignment
import org.onap.ccsdk.cds.controllerblueprints.resource.dict.ResourceDefinition
import org.slf4j.LoggerFactory
-import java.util.*
+import java.util.Date
class ResourceAssignmentUtils {
companion object {
@@ -51,7 +62,8 @@ class ResourceAssignmentUtils {
@Throws(BluePrintProcessorException::class)
fun setResourceDataValue(
resourceAssignment: ResourceAssignment,
- raRuntimeService: ResourceAssignmentRuntimeService, value: Any?
+ raRuntimeService: ResourceAssignmentRuntimeService,
+ value: Any?
) {
// TODO("See if Validation is needed in future with respect to conversion and Types")
return setResourceDataValue(resourceAssignment, raRuntimeService, value.asJsonType())
@@ -60,7 +72,8 @@ class ResourceAssignmentUtils {
@Throws(BluePrintProcessorException::class)
fun setResourceDataValue(
resourceAssignment: ResourceAssignment,
- raRuntimeService: ResourceAssignmentRuntimeService, value: JsonNode
+ raRuntimeService: ResourceAssignmentRuntimeService,
+ value: JsonNode
) {
val resourceProp = checkNotNull(resourceAssignment.property) {
"Failed in setting resource value for resource mapping $resourceAssignment"
@@ -102,7 +115,8 @@ class ResourceAssignmentUtils {
private fun setResourceValue(
resourceAssignment: ResourceAssignment,
- raRuntimeService: ResourceAssignmentRuntimeService, value: JsonNode
+ raRuntimeService: ResourceAssignmentRuntimeService,
+ value: JsonNode
) {
// TODO("See if Validation is needed wrt to type before storing")
raRuntimeService.putResolutionStore(resourceAssignment.name, value)
@@ -211,7 +225,8 @@ class ResourceAssignmentUtils {
@Throws(BluePrintProcessorException::class)
fun getPropertyType(
- raRuntimeService: ResourceAssignmentRuntimeService, dataTypeName: String,
+ raRuntimeService: ResourceAssignmentRuntimeService,
+ dataTypeName: String,
propertyName: String
): String {
lateinit var type: String
@@ -231,8 +246,10 @@ class ResourceAssignmentUtils {
@Throws(BluePrintProcessorException::class)
fun parseResponseNode(
- responseNode: JsonNode, resourceAssignment: ResourceAssignment,
- raRuntimeService: ResourceAssignmentRuntimeService, outputKeyMapping: MutableMap<String, String>
+ responseNode: JsonNode,
+ resourceAssignment: ResourceAssignment,
+ raRuntimeService: ResourceAssignmentRuntimeService,
+ outputKeyMapping: MutableMap<String, String>
): JsonNode {
val metadata = resourceAssignment.property!!.metadata
try {
@@ -297,7 +314,8 @@ class ResourceAssignmentUtils {
}
private fun parseResponseNodeForCollection(
- responseNode: JsonNode, resourceAssignment: ResourceAssignment,
+ responseNode: JsonNode,
+ resourceAssignment: ResourceAssignment,
raRuntimeService: ResourceAssignmentRuntimeService,
outputKeyMapping: MutableMap<String, String>
): JsonNode {
@@ -368,9 +386,11 @@ class ResourceAssignmentUtils {
}
private fun parseSingleElementOfArrayResponseNode(
- entrySchemaType: String, outputKeyMapping: MutableMap<String, String>,
+ entrySchemaType: String,
+ outputKeyMapping: MutableMap<String, String>,
raRuntimeService: ResourceAssignmentRuntimeService,
- responseNode: JsonNode, metadata: MutableMap<String, String>?
+ responseNode: JsonNode,
+ metadata: MutableMap<String, String>?
): ObjectNode {
val outputKeyMappingHasOnlyOneElement = checkIfOutputKeyMappingProvideOneElement(outputKeyMapping)
when (entrySchemaType) {
@@ -421,8 +441,10 @@ class ResourceAssignmentUtils {
}
private fun parseObjectResponseNode(
- entrySchemaType: String, outputKeyMapping: MutableMap<String, String>,
- responseArrayNode: MutableMap<String, JsonNode>, metadata: MutableMap<String, String>?
+ entrySchemaType: String,
+ outputKeyMapping: MutableMap<String, String>,
+ responseArrayNode: MutableMap<String, JsonNode>,
+ metadata: MutableMap<String, String>?
): ObjectNode {
val outputKeyMappingHasOnlyOneElement = checkIfOutputKeyMappingProvideOneElement(outputKeyMapping)
if (outputKeyMappingHasOnlyOneElement) {
@@ -437,8 +459,12 @@ class ResourceAssignmentUtils {
}
private fun parseSingleElementNodeWithOneOutputKeyMapping(
- responseSingleJsonNode: JsonNode, outputKeyMappingKey:
- String, outputKeyMappingValue: String, type: String, metadata: MutableMap<String, String>?
+ responseSingleJsonNode: JsonNode,
+ outputKeyMappingKey:
+ String,
+ outputKeyMappingValue: String,
+ type: String,
+ metadata: MutableMap<String, String>?
): ObjectNode {
val arrayChildNode = JacksonUtils.objectMapper.createObjectNode()
@@ -457,7 +483,8 @@ class ResourceAssignmentUtils {
private fun parseSingleElementNodeWithAllOutputKeyMapping(
responseSingleJsonNode: JsonNode,
outputKeyMapping: MutableMap<String, String>,
- type: String, metadata: MutableMap<String, String>?
+ type: String,
+ metadata: MutableMap<String, String>?
): ObjectNode {
val arrayChildNode = JacksonUtils.objectMapper.createObjectNode()
outputKeyMapping.map {
@@ -475,8 +502,10 @@ class ResourceAssignmentUtils {
private fun parseObjectResponseNodeWithOneOutputKeyMapping(
responseArrayNode: MutableMap<String, JsonNode>,
- outputKeyMappingKey: String, outputKeyMappingValue: String,
- type: String, metadata: MutableMap<String, String>?
+ outputKeyMappingKey: String,
+ outputKeyMappingValue: String,
+ type: String,
+ metadata: MutableMap<String, String>?
): ObjectNode {
val objectNode = JacksonUtils.objectMapper.createObjectNode()
val responseSingleJsonNode = responseArrayNode.filterKeys { key ->
@@ -494,7 +523,8 @@ class ResourceAssignmentUtils {
}
private fun parseResponseNodeForComplexType(
- responseNode: JsonNode, resourceAssignment: ResourceAssignment,
+ responseNode: JsonNode,
+ resourceAssignment: ResourceAssignment,
raRuntimeService: ResourceAssignmentRuntimeService,
outputKeyMapping: MutableMap<String, String>
): JsonNode {
@@ -536,7 +566,8 @@ class ResourceAssignmentUtils {
}
private fun checkOutputKeyMappingAllElementsInDataTypeProperties(
- dataTypeName: String, outputKeyMapping: MutableMap<String, String>,
+ dataTypeName: String,
+ outputKeyMapping: MutableMap<String, String>,
raRuntimeService: ResourceAssignmentRuntimeService
): Boolean {
val dataTypeProps = raRuntimeService.bluePrintContext().dataTypeByName(dataTypeName)?.properties
@@ -583,4 +614,4 @@ class ResourceAssignmentUtils {
return checkProtected
}
}
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/utils/ResourceDefinitionUtils.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/utils/ResourceDefinitionUtils.kt
index 15a8c6c80..d3641a850 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/utils/ResourceDefinitionUtils.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/utils/ResourceDefinitionUtils.kt
@@ -40,19 +40,22 @@ object ResourceDefinitionUtils {
}
/** Create a processing resource assignments for the resource definition */
- fun createResourceAssignments(resourceDefinitions: MutableMap<String, ResourceDefinition>,
- resolveDefinition: String, sources: List<String>)
- : MutableList<ResourceAssignment> {
+ fun createResourceAssignments(
+ resourceDefinitions: MutableMap<String, ResourceDefinition>,
+ resolveDefinition: String,
+ sources: List<String>
+ ):
+ MutableList<ResourceAssignment> {
/** Check if resolve definition is defined in the resource definition Map */
val resourceDefinition = resourceDefinitions[resolveDefinition]
- ?: throw BluePrintProcessorException("failed to get resolve definition($resolveDefinition)")
+ ?: throw BluePrintProcessorException("failed to get resolve definition($resolveDefinition)")
val resourceAssignments: MutableList<ResourceAssignment> = arrayListOf()
/** Get the dependency property fields for the the resource definition to resolve */
val definitionDependencies = definitionDependencies(resourceDefinition, sources)
definitionDependencies.forEach { definitionDependencyName ->
val definitionDependency = resourceDefinitions[definitionDependencyName]
- ?: throw BluePrintProcessorException("failed to get dependency definition($definitionDependencyName)")
+ ?: throw BluePrintProcessorException("failed to get dependency definition($definitionDependencyName)")
val resourceAssignment = ResourceAssignment().apply {
name = definitionDependency.name
@@ -73,7 +76,7 @@ object ResourceDefinitionUtils {
dictionarySourceDefinition = source
// Clone the PropertyDefinition, otherwise property value will be overridden
property = JacksonUtils
- .readValue(resourceDefinition.property.asJsonString(), PropertyDefinition::class.java)
+ .readValue(resourceDefinition.property.asJsonString(), PropertyDefinition::class.java)
val keyDependenciesExists = source.properties?.containsKey("key-dependencies") ?: false
if (keyDependenciesExists) {
dependencies = source.properties!!["key-dependencies"]!!.asListOfString().toMutableList()
@@ -85,4 +88,4 @@ object ResourceDefinitionUtils {
// Populate Resource Definition's dependencies as Input Resource Assignment
return resourceAssignments
}
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/scripts/InternalRAProcessor.cba.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/scripts/SimpleRAProcessor.kt
index 32f04e6a0..32f04e6a0 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/scripts/InternalRAProcessor.cba.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/scripts/SimpleRAProcessor.kt
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceDefinitionDSLTest.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceDefinitionDSLTest.kt
index f8f0e991e..7dcaab733 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceDefinitionDSLTest.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceDefinitionDSLTest.kt
@@ -25,8 +25,10 @@ class ResourceDefinitionDSLTest {
@Test
fun testResourceDefinitionDSL() {
- val testResourceDefinition = BluePrintTypes.resourceDefinition("service-instance-id",
- "VFW Service Instance Name") {
+ val testResourceDefinition = BluePrintTypes.resourceDefinition(
+ "service-instance-id",
+ "VFW Service Instance Name"
+ ) {
tags("service-instance-name, vfw, resources")
updatedBy("brindasanth@onap.com")
property("string", true)
@@ -74,7 +76,7 @@ class ResourceDefinitionDSLTest {
}
}
}
- //println(resourceDefinition.asJsonString(true))
+ // println(resourceDefinition.asJsonString(true))
assertNotNull(testResourceDefinition, "failed to generate testResourceDefinition")
val testResourceDefinitions = BluePrintTypes.resourceDefinitions {
@@ -86,26 +88,30 @@ class ResourceDefinitionDSLTest {
@Test
fun testResourceAssignment() {
- val testResourceAssignment = BluePrintTypes.resourceAssignment("instance-name",
- "service-instance-name", "odl-mdsal") {
+ val testResourceAssignment = BluePrintTypes.resourceAssignment(
+ "instance-name",
+ "service-instance-name", "odl-mdsal"
+ ) {
inputParameter(true)
property("string", true)
dependencies(arrayListOf("service-instance-id"))
}
- //println(resourceAssignment.asJsonString(true))
+ // println(resourceAssignment.asJsonString(true))
assertNotNull(testResourceAssignment, "failed to generate resourceAssignment")
val testResourceAssignments = BluePrintTypes.resourceAssignments {
resourceAssignment(testResourceAssignment)
- resourceAssignment("instance-name1",
- "service-instance-name", "odl-mdsal") {
+ resourceAssignment(
+ "instance-name1",
+ "service-instance-name", "odl-mdsal"
+ ) {
inputParameter(true)
property("string", true)
dependencies(arrayListOf("service-instance-id"))
}
}
- //println(testResourceAssignments.asJsonString(true))
+ // println(testResourceAssignments.asJsonString(true))
assertNotNull(testResourceAssignments, "failed to generate testResourceAssignments")
assertEquals(2, testResourceAssignments.size, "testResourceAssignments size doesn't match")
}
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponentDSLTest.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponentDSLTest.kt
index 671acff95..ae9b4208f 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponentDSLTest.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponentDSLTest.kt
@@ -26,7 +26,7 @@ class ResourceResolutionComponentDSLTest {
@Test
fun testNodeTypeComponentResourceResolution() {
val nodeType = BluePrintTypes.nodeTypeComponentResourceResolution()
- //println(nodeType.asJsonString(true))
+ // println(nodeType.asJsonString(true))
assertNotNull(nodeType, "failed to generate nodeTypeComponentResourceResolution")
}
@@ -42,11 +42,13 @@ class ResourceResolutionComponentDSLTest {
resourceType("vnf")
storeResult(false)
artifactPrefixNames(arrayListOf("template1", "template2"))
- dynamicProperties("""{
+ dynamicProperties(
+ """{
"prop1" : "1234",
"prop2" : true,
"prop3" : 23
- }""".trimIndent())
+ }""".trimIndent()
+ )
}
outputs {
resourceAssignmentParams(getAttribute("assignment-params"))
@@ -54,7 +56,7 @@ class ResourceResolutionComponentDSLTest {
}
}
}
- //println(nodeTemplate.asJsonString(true))
+ // println(nodeTemplate.asJsonString(true))
assertNotNull(nodeTemplate, "failed to generate nodeTemplateComponentResourceResolution")
}
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponentTest.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponentTest.kt
index b63fa6798..e1f708341 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponentTest.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponentTest.kt
@@ -50,7 +50,6 @@ class ResourceResolutionComponentTest {
private val executionRequest = ExecutionServiceInput()
-
@Before
fun setup() {
@@ -81,8 +80,10 @@ class ResourceResolutionComponentTest {
try {
resourceResolutionComponent.processNB(executionRequest)
} catch (e: BluePrintProcessorException) {
- assertEquals("Can't proceed with the resolution: either provide resolution-key OR combination of resource-id and resource-type.",
- e.message)
+ assertEquals(
+ "Can't proceed with the resolution: either provide resolution-key OR combination of resource-id and resource-type.",
+ e.message
+ )
return@runBlocking
}
fail()
@@ -98,8 +99,10 @@ class ResourceResolutionComponentTest {
try {
resourceResolutionComponent.processNB(executionRequest)
} catch (e: BluePrintProcessorException) {
- assertEquals("Can't proceed with the resolution: both resource-id and resource-type should be provided, one of them is missing.",
- e.message)
+ assertEquals(
+ "Can't proceed with the resolution: both resource-id and resource-type should be provided, one of them is missing.",
+ e.message
+ )
return@runBlocking
}
fail()
@@ -116,9 +119,11 @@ class ResourceResolutionComponentTest {
try {
resourceResolutionComponent.processNB(executionRequest)
} catch (e: BluePrintProcessorException) {
- assertEquals("Can't proceed with the resolution: can't persist resolution without a correlation key. " +
- "Either provide a resolution-key OR combination of resource-id and resource-type OR set `storeResult` to false.",
- e.message)
+ assertEquals(
+ "Can't proceed with the resolution: can't persist resolution without a correlation key. " +
+ "Either provide a resolution-key OR combination of resource-id and resource-type OR set `storeResult` to false.",
+ e.message
+ )
return@runBlocking
}
fail()
@@ -136,22 +141,23 @@ class ResourceResolutionComponentTest {
properties[ResourceResolutionConstants.RESOURCE_RESOLUTION_INPUT_OCCURRENCE] = occurrence
coEvery {
- resourceResolutionService.resolveResources(any(),
- any(),
- any<List<String>>(),
- any<MutableMap<String, Any>>())
+ resourceResolutionService.resolveResources(
+ any(),
+ any(),
+ any<List<String>>(),
+ any<MutableMap<String, Any>>()
+ )
} returns mutableMapOf()
-
runBlocking {
resourceResolutionComponent.processNB(executionRequest)
}
-// FIXME add verification
-// coVerify {
-// resourceResolutionService.resolveResources(eq(bluePrintRuntimeService),
-// eq(nodeTemplateName), eq(artifactNames), eq(properties))
-// }
+ // FIXME add verification
+ // coVerify {
+ // resourceResolutionService.resolveResources(eq(bluePrintRuntimeService),
+ // eq(nodeTemplateName), eq(artifactNames), eq(properties))
+ // }
}
@Test
@@ -165,4 +171,4 @@ class ResourceResolutionComponentTest {
assertEquals(1, blueprintError.errors.size)
}
}
-} \ No newline at end of file
+}
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 db453acf4..e46d457cd 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
@@ -30,7 +30,12 @@ import org.onap.ccsdk.cds.blueprintsprocessor.core.BluePrintPropertyConfiguratio
import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ExecutionServiceInput
import org.onap.ccsdk.cds.blueprintsprocessor.core.utils.PayloadUtils
import org.onap.ccsdk.cds.blueprintsprocessor.db.BluePrintDBLibConfiguration
-import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.processor.*
+import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.processor.CapabilityResourceResolutionProcessor
+import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.processor.DatabaseResourceAssignmentProcessor
+import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.processor.DefaultResourceResolutionProcessor
+import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.processor.InputResourceResolutionProcessor
+import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.processor.MockCapabilityScriptRA
+import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.processor.RestResourceResolutionProcessor
import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.utils.ResourceAssignmentUtils
import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants
import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintError
@@ -57,12 +62,14 @@ import kotlin.test.assertTrue
* @author Brinda Santh DATE : 8/15/2018
*/
@RunWith(SpringRunner::class)
-@ContextConfiguration(classes = [ResourceResolutionServiceImpl::class,
- InputResourceResolutionProcessor::class, DefaultResourceResolutionProcessor::class,
- DatabaseResourceAssignmentProcessor::class, RestResourceResolutionProcessor::class,
- CapabilityResourceResolutionProcessor::class,
- BluePrintPropertyConfiguration::class, BluePrintPropertiesService::class,
- BluePrintDBLibConfiguration::class, BluePrintLoadConfiguration::class])
+@ContextConfiguration(
+ classes = [ResourceResolutionServiceImpl::class,
+ InputResourceResolutionProcessor::class, DefaultResourceResolutionProcessor::class,
+ DatabaseResourceAssignmentProcessor::class, RestResourceResolutionProcessor::class,
+ CapabilityResourceResolutionProcessor::class,
+ BluePrintPropertyConfiguration::class, BluePrintPropertiesService::class,
+ BluePrintDBLibConfiguration::class, BluePrintLoadConfiguration::class]
+)
@TestPropertySource(locations = ["classpath:application-test.properties"])
@ComponentScan(basePackages = ["org.onap.ccsdk.cds.blueprintsprocessor", "org.onap.ccsdk.cds.controllerblueprints"])
@EnableAutoConfiguration
@@ -92,8 +99,14 @@ class ResourceResolutionServiceTest {
fun testRegisteredSource() {
val sources = resourceResolutionService.registeredResourceSources()
assertNotNull(sources, "failed to get registered sources")
- assertTrue(sources.containsAll(arrayListOf("source-input", "source-default", "source-db",
- "source-rest", "source-capability")), "failed to get registered sources : $sources")
+ assertTrue(
+ sources.containsAll(
+ arrayListOf(
+ "source-input", "source-default", "source-db",
+ "source-rest", "source-capability"
+ )
+ ), "failed to get registered sources : $sources"
+ )
}
@Test
@@ -103,29 +116,36 @@ class ResourceResolutionServiceTest {
Assert.assertNotNull("failed to create ResourceResolutionService", resourceResolutionService)
- val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime("1234",
- "./../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration")
+ val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime(
+ "1234",
+ "./../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration"
+ )
val executionServiceInput =
- JacksonUtils.readValueFromClassPathFile("payload/requests/sample-resourceresolution-request.json",
- ExecutionServiceInput::class.java)!!
-
+ JacksonUtils.readValueFromClassPathFile(
+ "payload/requests/sample-resourceresolution-request.json",
+ ExecutionServiceInput::class.java
+ )!!
val resourceAssignmentRuntimeService =
- ResourceAssignmentUtils.transformToRARuntimeService(bluePrintRuntimeService,
- "testResolveResource")
-
+ ResourceAssignmentUtils.transformToRARuntimeService(
+ bluePrintRuntimeService,
+ "testResolveResource"
+ )
// Prepare Inputs
- PayloadUtils.prepareInputsFromWorkflowPayload(bluePrintRuntimeService,
- executionServiceInput.payload,
- "resource-assignment")
-
- resourceResolutionService.resolveResources(resourceAssignmentRuntimeService,
- "resource-assignment",
- "baseconfig",
- props)
-
+ PayloadUtils.prepareInputsFromWorkflowPayload(
+ bluePrintRuntimeService,
+ executionServiceInput.payload,
+ "resource-assignment"
+ )
+
+ resourceResolutionService.resolveResources(
+ resourceAssignmentRuntimeService,
+ "resource-assignment",
+ "baseconfig",
+ props
+ )
}
}
@@ -135,26 +155,33 @@ class ResourceResolutionServiceTest {
runBlocking {
Assert.assertNotNull("failed to create ResourceResolutionService", resourceResolutionService)
- val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime("1234",
- "./../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration")
+ val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime(
+ "1234",
+ "./../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration"
+ )
val executionServiceInput =
- JacksonUtils.readValueFromClassPathFile("payload/requests/sample-resourceresolution-request.json",
- ExecutionServiceInput::class.java)!!
+ JacksonUtils.readValueFromClassPathFile(
+ "payload/requests/sample-resourceresolution-request.json",
+ ExecutionServiceInput::class.java
+ )!!
val artefactNames = listOf("baseconfig", "another")
// Prepare Inputs
- PayloadUtils.prepareInputsFromWorkflowPayload(bluePrintRuntimeService,
- executionServiceInput.payload,
- "resource-assignment")
-
- resourceResolutionService.resolveResources(bluePrintRuntimeService,
- "resource-assignment",
- artefactNames,
- props)
+ PayloadUtils.prepareInputsFromWorkflowPayload(
+ bluePrintRuntimeService,
+ executionServiceInput.payload,
+ "resource-assignment"
+ )
+
+ resourceResolutionService.resolveResources(
+ bluePrintRuntimeService,
+ "resource-assignment",
+ artefactNames,
+ props
+ )
}
-
}
@Test
@@ -163,32 +190,41 @@ class ResourceResolutionServiceTest {
runBlocking {
Assert.assertNotNull("failed to create ResourceResolutionService", resourceResolutionService)
- val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime("1234",
- "./../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration")
+ val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime(
+ "1234",
+ "./../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration"
+ )
val executionServiceInput =
- JacksonUtils.readValueFromClassPathFile("payload/requests/sample-resourceresolution-request.json",
- ExecutionServiceInput::class.java)!!
+ JacksonUtils.readValueFromClassPathFile(
+ "payload/requests/sample-resourceresolution-request.json",
+ ExecutionServiceInput::class.java
+ )!!
val resourceAssignmentRuntimeService =
- ResourceAssignmentUtils.transformToRARuntimeService(bluePrintRuntimeService,
- "testResolveResourcesWithMappingAndTemplate")
+ ResourceAssignmentUtils.transformToRARuntimeService(
+ bluePrintRuntimeService,
+ "testResolveResourcesWithMappingAndTemplate"
+ )
val artifactPrefix = "another"
// Prepare Inputs
- PayloadUtils.prepareInputsFromWorkflowPayload(bluePrintRuntimeService,
- executionServiceInput.payload,
- "resource-assignment")
-
- resourceResolutionService.resolveResources(resourceAssignmentRuntimeService,
- "resource-assignment",
- artifactPrefix,
- props)
+ PayloadUtils.prepareInputsFromWorkflowPayload(
+ bluePrintRuntimeService,
+ executionServiceInput.payload,
+ "resource-assignment"
+ )
+
+ resourceResolutionService.resolveResources(
+ resourceAssignmentRuntimeService,
+ "resource-assignment",
+ artifactPrefix,
+ props
+ )
}
}
-
@Test
fun testResolveResourcesWithResourceIdAndResourceType() {
@@ -197,28 +233,38 @@ class ResourceResolutionServiceTest {
runBlocking {
Assert.assertNotNull("failed to create ResourceResolutionService", resourceResolutionService)
- val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime("1234",
- "./../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration")
+ val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime(
+ "1234",
+ "./../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration"
+ )
val executionServiceInput =
- JacksonUtils.readValueFromClassPathFile("payload/requests/sample-resourceresolution-request.json",
- ExecutionServiceInput::class.java)!!
+ JacksonUtils.readValueFromClassPathFile(
+ "payload/requests/sample-resourceresolution-request.json",
+ ExecutionServiceInput::class.java
+ )!!
val resourceAssignmentRuntimeService =
- ResourceAssignmentUtils.transformToRARuntimeService(bluePrintRuntimeService,
- "testResolveResourcesWithMappingAndTemplate")
+ ResourceAssignmentUtils.transformToRARuntimeService(
+ bluePrintRuntimeService,
+ "testResolveResourcesWithMappingAndTemplate"
+ )
val artifactPrefix = "another"
// Prepare Inputs
- PayloadUtils.prepareInputsFromWorkflowPayload(bluePrintRuntimeService,
- executionServiceInput.payload,
- "resource-assignment")
-
- resourceResolutionService.resolveResources(resourceAssignmentRuntimeService,
- "resource-assignment",
- artifactPrefix,
- props)
+ PayloadUtils.prepareInputsFromWorkflowPayload(
+ bluePrintRuntimeService,
+ executionServiceInput.payload,
+ "resource-assignment"
+ )
+
+ resourceResolutionService.resolveResources(
+ resourceAssignmentRuntimeService,
+ "resource-assignment",
+ artifactPrefix,
+ props
+ )
}
}
@@ -259,7 +305,7 @@ class ResourceResolutionServiceTest {
val raRuntimeService = mockk<ResourceAssignmentRuntimeService>()
every { raRuntimeService.bluePrintContext() } returns mockk<BluePrintContext>()
every { raRuntimeService.getBluePrintError() } returns BluePrintError()
- every { raRuntimeService.setBluePrintError(any())} returns Unit
+ every { raRuntimeService.setBluePrintError(any()) } returns Unit
every { raRuntimeService.getInputValue("device-id") } returns "123456".asJsonPrimitive()
every { raRuntimeService.putResolutionStore(any(), any()) } returns Unit
@@ -271,8 +317,10 @@ class ResourceResolutionServiceTest {
val sources = arrayListOf<String>("sdno", "sdnc")
val resourceResolutionService = ResourceResolutionServiceImpl(applicationContext, mockk(), mockk(), mockk())
- val resolvedResources = resourceResolutionService.resolveResourceDefinition(raRuntimeService,
- resourceDefinitions, "port-speed", sources)
+ val resolvedResources = resourceResolutionService.resolveResourceDefinition(
+ raRuntimeService,
+ resourceDefinitions, "port-speed", sources
+ )
assertNotNull(resolvedResources, "failed to resolve the resources")
}
}
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceSourceDSLTest.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceSourceDSLTest.kt
index 2eb208566..2e9dc9e2a 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceSourceDSLTest.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceSourceDSLTest.kt
@@ -25,53 +25,51 @@ class ResourceSourceDSLTest {
@Test
fun testNodeTypeSourceInput() {
val nodeType = BluePrintTypes.nodeTypeSourceInput()
- //println(nodeType.asJsonString(true))
+ // println(nodeType.asJsonString(true))
assertNotNull(nodeType, "failed to generate nodeTypeSourceInput")
}
@Test
fun testNodeTypeSourceDefault() {
val nodeType = BluePrintTypes.nodeTypeSourceDefault()
- //println(nodeType.asJsonString(true))
+ // println(nodeType.asJsonString(true))
assertNotNull(nodeType, "failed to generate nodeTypeSourceDefault")
}
@Test
fun testNodeTypeSourceDb() {
val nodeType = BluePrintTypes.nodeTypeSourceDb()
- //println(nodeType.asJsonString(true))
+ // println(nodeType.asJsonString(true))
assertNotNull(nodeType, "failed to generate nodeTypeSourceDb")
}
@Test
fun testNodeTypeSourceRest() {
val nodeType = BluePrintTypes.nodeTypeSourceRest()
- //println(nodeType.asJsonString(true))
+ // println(nodeType.asJsonString(true))
assertNotNull(nodeType, "failed to generate nodeTypeSourceRest")
}
@Test
fun testNodeTypeSourceCapability() {
val nodeType = BluePrintTypes.nodeTypeSourceCapability()
- //println(nodeType.asJsonString(true))
+ // println(nodeType.asJsonString(true))
assertNotNull(nodeType, "failed to generate nodeTypeSourceCapability")
}
@Test
fun testNodeTemplateSourceInput() {
val nodeTemplate = BluePrintTypes.nodeTemplateSourceInput("InputSystem", "") {
-
}
- //println(nodeTemplate.asJsonString(true))
+ // println(nodeTemplate.asJsonString(true))
assertNotNull(nodeTemplate, "failed to generate nodeTemplateSourceInput")
}
@Test
fun testNodeTemplateSourceDefault() {
val nodeTemplate = BluePrintTypes.nodeTemplateSourceDefault("DefaultSystem", "") {
-
}
- //println(nodeTemplate.asJsonString(true))
+ // println(nodeTemplate.asJsonString(true))
assertNotNull(nodeTemplate, "failed to generate nodeTemplateSourceDefault")
}
@@ -91,7 +89,7 @@ class ResourceSourceDSLTest {
keyDependencies(arrayListOf("name"))
}
}
- //println(nodeTemplate.asJsonString(true))
+ // println(nodeTemplate.asJsonString(true))
assertNotNull(nodeTemplate, "failed to generate nodeTemplateSourceDb")
}
@@ -115,7 +113,7 @@ class ResourceSourceDSLTest {
keyDependencies(arrayListOf("name"))
}
}
- //println(nodeTemplate.asJsonString(true))
+ // println(nodeTemplate.asJsonString(true))
assertNotNull(nodeTemplate, "failed to generate nodeTemplateSourceRest")
}
@@ -128,7 +126,7 @@ class ResourceSourceDSLTest {
keyDependencies(arrayListOf("name"))
}
}
- //println(nodeTemplate.asJsonString(true))
+ // println(nodeTemplate.asJsonString(true))
assertNotNull(nodeTemplate, "failed to generate nodeTemplateSourceCapability")
}
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/ResourceResolutionDBServiceTest.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/ResourceResolutionDBServiceTest.kt
index dcf2e64a5..4f864a49c 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/ResourceResolutionDBServiceTest.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/ResourceResolutionDBServiceTest.kt
@@ -72,13 +72,15 @@ open class ResourceResolutionDBServiceTest {
val list = listOf(rr1, rr2)
every {
resourceResolutionRepository.findByBlueprintNameAndBlueprintVersionAndArtifactNameAndResolutionKeyAndOccurrence(
- any(), any(), any(), any(), any())
+ any(), any(), any(), any(), any()
+ )
} returns list
runBlocking {
val res =
resourceResolutionDBService.findByBlueprintNameAndBlueprintVersionAndArtifactNameAndResolutionKeyAndOccurrence(
- bluePrintRuntimeService, resolutionKey, occurrence, artifactPrefix)
+ bluePrintRuntimeService, resolutionKey, occurrence, artifactPrefix
+ )
assertEquals(2, res.size)
}
@@ -88,12 +90,14 @@ open class ResourceResolutionDBServiceTest {
fun findByBlueprintNameAndBlueprintVersionAndArtifactNameAndResolutionKeyAndOccurrenceTestException() {
every {
resourceResolutionRepository.findByBlueprintNameAndBlueprintVersionAndArtifactNameAndResolutionKeyAndOccurrence(
- any(), any(), any(), any(), any())
+ any(), any(), any(), any(), any()
+ )
} throws EmptyResultDataAccessException(1)
runBlocking {
val res =
resourceResolutionDBService.findByBlueprintNameAndBlueprintVersionAndArtifactNameAndResolutionKeyAndOccurrence(
- bluePrintRuntimeService, resolutionKey, occurrence, artifactPrefix)
+ bluePrintRuntimeService, resolutionKey, occurrence, artifactPrefix
+ )
assert(res.isEmpty())
}
@@ -107,13 +111,15 @@ open class ResourceResolutionDBServiceTest {
val list = listOf(rr1, rr2)
every {
resourceResolutionRepository.findByBlueprintNameAndBlueprintVersionAndArtifactNameAndResourceIdAndResourceTypeAndOccurrence(
- any(), any(), any(), any(), any(), any())
+ any(), any(), any(), any(), any(), any()
+ )
} returns list
runBlocking {
val res =
resourceResolutionDBService.findByBlueprintNameAndBlueprintVersionAndArtifactNameAndResourceIdAndResourceTypeAndOccurrence(
- bluePrintRuntimeService, resourceId, resourceType, occurrence, artifactPrefix)
+ bluePrintRuntimeService, resourceId, resourceType, occurrence, artifactPrefix
+ )
assertEquals(2, res.size)
}
@@ -123,12 +129,14 @@ open class ResourceResolutionDBServiceTest {
fun findByBlueprintNameAndBlueprintVersionAndArtifactNameAndResourceIdAndResourceTypeAndOccurrenceTestException() {
every {
resourceResolutionRepository.findByBlueprintNameAndBlueprintVersionAndArtifactNameAndResourceIdAndResourceTypeAndOccurrence(
- any(), any(), any(), any(), any(), any())
+ any(), any(), any(), any(), any(), any()
+ )
} throws EmptyResultDataAccessException(1)
runBlocking {
val res =
resourceResolutionDBService.findByBlueprintNameAndBlueprintVersionAndArtifactNameAndResourceIdAndResourceTypeAndOccurrence(
- bluePrintRuntimeService, resourceId, resourceType, occurrence, artifactPrefix)
+ bluePrintRuntimeService, resourceId, resourceType, occurrence, artifactPrefix
+ )
assert(res.isEmpty())
}
@@ -141,12 +149,14 @@ open class ResourceResolutionDBServiceTest {
rr.value = "testValue"
every {
resourceResolutionRepository.findByResolutionKeyAndBlueprintNameAndBlueprintVersionAndArtifactNameAndName(
- any(), any(), any(), any(), any())
+ any(), any(), any(), any(), any()
+ )
} returns rr
runBlocking {
val res =
resourceResolutionDBService.readValue(
- blueprintName, blueprintVersion, artifactPrefix, resolutionKey, "bob")
+ blueprintName, blueprintVersion, artifactPrefix, resolutionKey, "bob"
+ )
assertEquals(rr.name, res.name)
assertEquals(rr.value, res.value)
@@ -160,12 +170,14 @@ open class ResourceResolutionDBServiceTest {
val list = listOf(rr1, rr2)
every {
resourceResolutionRepository.findByResolutionKeyAndBlueprintNameAndBlueprintVersionAndArtifactName(
- any(), any(), any(), any())
+ any(), any(), any(), any()
+ )
} returns list
runBlocking {
val res =
resourceResolutionDBService.readWithResolutionKey(
- blueprintName, blueprintVersion, artifactPrefix, resolutionKey)
+ blueprintName, blueprintVersion, artifactPrefix, resolutionKey
+ )
assertEquals(2, res.size)
}
}
@@ -177,12 +189,14 @@ open class ResourceResolutionDBServiceTest {
val list = listOf(rr1, rr2)
every {
resourceResolutionRepository.findByBlueprintNameAndBlueprintVersionAndResourceIdAndResourceType(
- any(), any(), any(), any())
+ any(), any(), any(), any()
+ )
} returns list
runBlocking {
val res =
resourceResolutionDBService.readWithResourceIdAndResourceType(
- blueprintName, blueprintVersion, resourceId, resourceType)
+ blueprintName, blueprintVersion, resourceId, resourceType
+ )
assertEquals(2, res.size)
}
}
@@ -203,9 +217,10 @@ open class ResourceResolutionDBServiceTest {
runBlocking {
val res =
resourceResolutionDBService.write(
- props, bluePrintRuntimeService, artifactPrefix, resourceAssignment)
+ props, bluePrintRuntimeService, artifactPrefix, resourceAssignment
+ )
assertEquals(resourceResolution, res)
}
}
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/TemplateResolutionServiceTest.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/TemplateResolutionServiceTest.kt
index 48c6f02ef..18a9f3233 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/TemplateResolutionServiceTest.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/TemplateResolutionServiceTest.kt
@@ -54,11 +54,13 @@ class TemplateResolutionServiceTest {
runBlocking {
every {
templateResolutionRepository.findByResolutionKeyAndBlueprintNameAndBlueprintVersionAndArtifactNameAndOccurrence(
- any(), any(), any(), any(), any())
+ any(), any(), any(), any(), any()
+ )
} returns tr
val res =
templateResolutionService.findByResolutionKeyAndBlueprintNameAndBlueprintVersionAndArtifactName(
- bluePrintRuntimeService, artifactPrefix, resolutionKey)
+ bluePrintRuntimeService, artifactPrefix, resolutionKey
+ )
assertEquals(tr.result, res)
}
}
@@ -69,10 +71,12 @@ class TemplateResolutionServiceTest {
runBlocking {
every {
templateResolutionRepository.findByResolutionKeyAndBlueprintNameAndBlueprintVersionAndArtifactNameAndOccurrence(
- any(), any(), any(), any(), any())
+ any(), any(), any(), any(), any()
+ )
} returns tr
templateResolutionService.findByResolutionKeyAndBlueprintNameAndBlueprintVersionAndArtifactName(
- bluePrintRuntimeService, artifactPrefix, resolutionKey)
+ bluePrintRuntimeService, artifactPrefix, resolutionKey
+ )
}
}
@@ -83,7 +87,8 @@ class TemplateResolutionServiceTest {
every { templateResolutionRepository.saveAndFlush(any<TemplateResolution>()) } returns tr
every {
templateResolutionRepository.findByResolutionKeyAndBlueprintNameAndBlueprintVersionAndArtifactNameAndOccurrence(
- any(), any(), any(), any(), any())
+ any(), any(), any(), any(), any()
+ )
} returns null
val res = templateResolutionService.write(props, result, bluePrintRuntimeService, artifactPrefix)
assertEquals(tr, res)
@@ -97,16 +102,19 @@ class TemplateResolutionServiceTest {
every { templateResolutionRepository.saveAndFlush(any<TemplateResolution>()) } returns tr
every {
templateResolutionRepository.findByResolutionKeyAndBlueprintNameAndBlueprintVersionAndArtifactNameAndOccurrence(
- any(), any(), any(), any(), any())
+ any(), any(), any(), any(), any()
+ )
} returns tr
every {
templateResolutionRepository.deleteByResolutionKeyAndBlueprintNameAndBlueprintVersionAndArtifactNameAndOccurrence(
- any(), any(), any(), any(), any())
+ any(), any(), any(), any(), any()
+ )
} returns Unit
val res = templateResolutionService.write(props, result, bluePrintRuntimeService, artifactPrefix)
verify {
templateResolutionRepository.deleteByResolutionKeyAndBlueprintNameAndBlueprintVersionAndArtifactNameAndOccurrence(
- eq(resolutionKey), eq(blueprintName), eq(blueprintVersion), eq(artifactPrefix), eq(occurrence))
+ eq(resolutionKey), eq(blueprintName), eq(blueprintVersion), eq(artifactPrefix), eq(occurrence)
+ )
}
assertEquals(tr, res)
}
@@ -120,18 +128,21 @@ class TemplateResolutionServiceTest {
every { templateResolutionRepository.saveAndFlush(any<TemplateResolution>()) } returns tr
every {
templateResolutionRepository.findByResourceIdAndResourceTypeAndBlueprintNameAndBlueprintVersionAndArtifactNameAndOccurrence(
- any(), any(), any(), any(), any(), any())
+ any(), any(), any(), any(), any(), any()
+ )
} returns tr
every {
templateResolutionRepository.deleteByResourceIdAndResourceTypeAndBlueprintNameAndBlueprintVersionAndArtifactNameAndOccurrence(
- any(), any(), any(), any(), any(), any())
+ any(), any(), any(), any(), any(), any()
+ )
} returns Unit
val res = templateResolutionService.write(props, result, bluePrintRuntimeService, artifactPrefix)
verify {
templateResolutionRepository.deleteByResourceIdAndResourceTypeAndBlueprintNameAndBlueprintVersionAndArtifactNameAndOccurrence(
- eq(resourceId), eq(resourceType), eq(blueprintName), eq(blueprintVersion), eq(artifactPrefix), eq(occurrence))
+ eq(resourceId), eq(resourceType), eq(blueprintName), eq(blueprintVersion), eq(artifactPrefix), eq(occurrence)
+ )
}
assertEquals(tr, res)
}
}
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/mock/MockBlueprintResLibPropertyService.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/mock/MockBluePrintRestLibPropertyService.kt
index f64ba2bbd..d6331fe33 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/mock/MockBlueprintResLibPropertyService.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/mock/MockBluePrintRestLibPropertyService.kt
@@ -20,9 +20,9 @@ import org.onap.ccsdk.cds.blueprintsprocessor.rest.RestClientProperties
import org.onap.ccsdk.cds.blueprintsprocessor.rest.service.BluePrintRestLibPropertyService
class MockBluePrintRestLibPropertyService(bluePrintProperties: BluePrintPropertiesService) :
- BluePrintRestLibPropertyService(bluePrintProperties) {
+ BluePrintRestLibPropertyService(bluePrintProperties) {
- fun mockBlueprintWebClientService (selector: String):
+ fun mockBlueprintWebClientService(selector: String):
MockBlueprintWebClientService {
val prefix = "blueprintsprocessor.restclient.$selector"
val restClientProperties = restClientProperties(prefix)
@@ -33,4 +33,4 @@ class MockBluePrintRestLibPropertyService(bluePrintProperties: BluePrintProperti
MockBlueprintWebClientService {
return MockBlueprintWebClientService(restClientProperties)
}
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/mock/MockBlueprintWebClientService.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/mock/MockBlueprintWebClientService.kt
index fede7be7b..ef5c79eab 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/mock/MockBlueprintWebClientService.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/mock/MockBlueprintWebClientService.kt
@@ -25,32 +25,37 @@ import org.onap.ccsdk.cds.blueprintsprocessor.rest.service.BlueprintWebClientSer
import org.springframework.http.HttpHeaders
import org.springframework.http.MediaType
import java.nio.charset.Charset
-import java.util.*
+import java.util.Base64
-class MockBlueprintWebClientService(private var restClientProperties: RestClientProperties): BlueprintWebClientService {
+class MockBlueprintWebClientService(private var restClientProperties: RestClientProperties) : BlueprintWebClientService {
private var mockServer: ClientAndServer
private var port: String = if (restClientProperties.url.split(":")[2].isEmpty()) "8080"
- else restClientProperties.url.split(":")[2]
+ else restClientProperties.url.split(":")[2]
private var headers: Map<String, String>
init {
- mockServer = ClientAndServer.startClientAndServer(port.toInt())
- headers = defaultHeaders()
+ mockServer = ClientAndServer.startClientAndServer(port.toInt())
+ headers = defaultHeaders()
// Create expected requests and responses
setRequest("GET", "/aai/v14/network/generic-vnfs/generic-vnf/123456")
- setRequest("GET", "/config/GENERIC-RESOURCE-API:services/service/10/service-data/vnfs/vnf/123456/" +
- "vnf-data/vnf-topology/vnf-parameters-data/param/vnf_name")
- setRequestWithPayload("PUT", "/query",
- "{\r\n\"start\": \"\\/nodes\\/vf-modules?vf-module-name=vf-module-name\",\r\n\"query\": \"\\/query\\/related-to?startingNodeType=vf-module&relatedToNodeType=generic-vnf\"\r\n}")
+ setRequest(
+ "GET", "/config/GENERIC-RESOURCE-API:services/service/10/service-data/vnfs/vnf/123456/" +
+ "vnf-data/vnf-topology/vnf-parameters-data/param/vnf_name"
+ )
+ setRequestWithPayload(
+ "PUT", "/query",
+ "{\r\n\"start\": \"\\/nodes\\/vf-modules?vf-module-name=vf-module-name\",\r\n\"query\": \"\\/query\\/related-to?startingNodeType=vf-module&relatedToNodeType=generic-vnf\"\r\n}"
+ )
}
override fun defaultHeaders(): Map<String, String> {
val encodedCredentials = this.setBasicAuth("admin", "aaiTest")
return mapOf(
- HttpHeaders.CONTENT_TYPE to MediaType.APPLICATION_JSON_VALUE,
- HttpHeaders.ACCEPT to MediaType.APPLICATION_JSON_VALUE,
- HttpHeaders.AUTHORIZATION to "Basic $encodedCredentials")
+ HttpHeaders.CONTENT_TYPE to MediaType.APPLICATION_JSON_VALUE,
+ HttpHeaders.ACCEPT to MediaType.APPLICATION_JSON_VALUE,
+ HttpHeaders.AUTHORIZATION to "Basic $encodedCredentials"
+ )
}
override fun host(uri: String): String {
@@ -87,11 +92,11 @@ class MockBlueprintWebClientService(private var restClientProperties: RestClient
else -> {
"Get response"
}
-
}
- mockServer.`when`(request().withHeaders(Header(HttpHeaders.AUTHORIZATION, headers[HttpHeaders.AUTHORIZATION]))
- .withMethod(method)
- .withPath(path)
+ mockServer.`when`(
+ request().withHeaders(Header(HttpHeaders.AUTHORIZATION, headers[HttpHeaders.AUTHORIZATION]))
+ .withMethod(method)
+ .withPath(path)
).respond(response().withStatusCode(200).withBody("{\"aai-resource\":\"$requestResponse\"}"))
}
@@ -106,9 +111,9 @@ class MockBlueprintWebClientService(private var restClientProperties: RestClient
else -> {
"Get response"
}
-
}
- mockServer.`when`(request().withHeaders(Header(HttpHeaders.AUTHORIZATION, headers[HttpHeaders.AUTHORIZATION]))
+ mockServer.`when`(
+ request().withHeaders(Header(HttpHeaders.AUTHORIZATION, headers[HttpHeaders.AUTHORIZATION]))
.withMethod(method)
.withPath(path)
.withQueryStringParameter("format", "resource")
@@ -119,6 +124,7 @@ class MockBlueprintWebClientService(private var restClientProperties: RestClient
private fun setBasicAuth(username: String, password: String): String {
val credentialsString = "$username:$password"
return Base64.getEncoder().encodeToString(
- credentialsString.toByteArray(Charset.defaultCharset()))
+ credentialsString.toByteArray(Charset.defaultCharset())
+ )
}
}
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/mock/MockDatabaseConfiguration.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/mock/MockDatabaseConfiguration.kt
index 7644df37a..0a4de9218 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/mock/MockDatabaseConfiguration.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/mock/MockDatabaseConfiguration.kt
@@ -28,7 +28,7 @@ open class MockDatabaseConfiguration {
@Bean(name = ["MariaDatabaseConfiguration", "MySqlDatabaseConfiguration", "PrimaryDatabaseConfiguration"])
open fun createDatabaseConfiguration(): BluePrintDBLibGenericService {
- return mockk<BluePrintDBLibGenericService>()
+ return mockk<BluePrintDBLibGenericService>()
}
}
@@ -42,6 +42,4 @@ open class MockBlueprintProcessorCatalogServiceImpl {
every { bluePrintValidatorService.validateBluePrints(any<BluePrintRuntimeService<*>>()) } returns true
return bluePrintValidatorService
}
-
-
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/mock/MockRestResourceResolutionProcessor.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/mock/MockRestResourceResolutionProcessor.kt
index e5b559826..a7379e22a 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/mock/MockRestResourceResolutionProcessor.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/mock/MockRestResourceResolutionProcessor.kt
@@ -29,10 +29,12 @@ import org.onap.ccsdk.cds.controllerblueprints.core.nullToEmpty
import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils
import org.onap.ccsdk.cds.controllerblueprints.resource.dict.ResourceAssignment
import org.slf4j.LoggerFactory
-import java.util.*
+import java.util.HashMap
-class MockRestResourceResolutionProcessor(private val blueprintRestLibPropertyService:
- MockBluePrintRestLibPropertyService) : ResourceAssignmentProcessor() {
+class MockRestResourceResolutionProcessor(
+ private val blueprintRestLibPropertyService:
+ MockBluePrintRestLibPropertyService
+) : ResourceAssignmentProcessor() {
private val logger = LoggerFactory.getLogger(MockRestResourceResolutionProcessor::class.java)
@@ -77,8 +79,10 @@ class MockRestResourceResolutionProcessor(private val blueprintRestLibPropertySe
resolveFromInputKeyMapping(checkNotNull(sourceProperties.urlPath), resolvedInputKeyMapping)
val verb = resolveFromInputKeyMapping(nullToEmpty(sourceProperties.verb), resolvedInputKeyMapping)
- logger.info("MockRestResource ($dSource) dictionary information: " +
- "URL:($urlPath), input-key-mapping:($inputKeyMapping), output-key-mapping:(${sourceProperties.outputKeyMapping})")
+ logger.info(
+ "MockRestResource ($dSource) dictionary information: " +
+ "URL:($urlPath), input-key-mapping:($inputKeyMapping), output-key-mapping:(${sourceProperties.outputKeyMapping})"
+ )
// Get the Rest Client Service
val restClientService = blueprintWebClientService(executionRequest)
@@ -90,7 +94,8 @@ class MockRestResourceResolutionProcessor(private val blueprintRestLibPropertySe
populateResource(executionRequest, sourceProperties, responseBody, path)
restClientService.tearDown()
} else {
- val errMsg = "Failed to get $dSource result for dictionary name ($dName) using urlPath ($urlPath) response_code: ($responseStatusCode)"
+ val errMsg =
+ "Failed to get $dSource result for dictionary name ($dName) using urlPath ($urlPath) response_code: ($responseStatusCode)"
logger.warn(errMsg)
throw BluePrintProcessorException(errMsg)
}
@@ -110,8 +115,12 @@ class MockRestResourceResolutionProcessor(private val blueprintRestLibPropertySe
}
@Throws(BluePrintProcessorException::class)
- private fun populateResource(resourceAssignment: ResourceAssignment, sourceProperties: RestResourceSource,
- restResponse: String, path: String) {
+ private fun populateResource(
+ resourceAssignment: ResourceAssignment,
+ sourceProperties: RestResourceSource,
+ restResponse: String,
+ path: String
+ ) {
val type = nullToEmpty(resourceAssignment.property?.type)
lateinit var entrySchemaType: String
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/CapabilityResourceResolutionProcessorTest.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/CapabilityResourceResolutionProcessorTest.kt
index 98f68ebaa..8f6ac9fd5 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/CapabilityResourceResolutionProcessorTest.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/CapabilityResourceResolutionProcessorTest.kt
@@ -140,9 +140,7 @@ class CapabilityResourceResolutionProcessorTest {
}
}
-open class MockCapabilityService {
-
-}
+open class MockCapabilityService
open class MockCapabilityScriptRA : ResourceAssignmentProcessor() {
val log = logger(MockCapabilityScriptRA::class)
@@ -157,6 +155,6 @@ open class MockCapabilityScriptRA : ResourceAssignmentProcessor() {
}
override suspend fun recoverNB(runtimeException: RuntimeException, executionRequest: ResourceAssignment) {
- TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
+ TODO("not implemented") // To change body of created functions use File | Settings | File Templates.
}
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/DatabaseResourceResolutionProcessorTest.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/DatabaseResourceResolutionProcessorTest.kt
index ac5ba3c46..da2282018 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/DatabaseResourceResolutionProcessorTest.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/DatabaseResourceResolutionProcessorTest.kt
@@ -22,7 +22,7 @@ import org.onap.ccsdk.cds.blueprintsprocessor.core.BluePrintCoreConfiguration
import org.onap.ccsdk.cds.blueprintsprocessor.core.BluePrintPropertiesService
import org.onap.ccsdk.cds.blueprintsprocessor.core.BluePrintPropertyConfiguration
import org.onap.ccsdk.cds.blueprintsprocessor.db.BluePrintDBLibConfiguration
-import org.onap.ccsdk.cds.blueprintsprocessor.db.primary.BluePrintDBLibPropertySevice
+import org.onap.ccsdk.cds.blueprintsprocessor.db.primary.BluePrintDBLibPropertyService
import org.onap.ccsdk.cds.blueprintsprocessor.db.primary.PrimaryDatabaseConfiguration
import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.ResourceAssignmentRuntimeService
import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.mock.MockBlueprintProcessorCatalogServiceImpl
@@ -38,10 +38,12 @@ import org.springframework.test.context.junit4.SpringRunner
import kotlin.test.assertNotNull
@RunWith(SpringRunner::class)
-@ContextConfiguration(classes = [DatabaseResourceAssignmentProcessor::class, BluePrintPropertyConfiguration::class,
- BluePrintPropertiesService::class, BluePrintDBLibPropertySevice::class, BluePrintDBLibConfiguration::class,
- BluePrintCoreConfiguration::class, MockDatabaseConfiguration::class, MockBlueprintProcessorCatalogServiceImpl::class,
- BluePrintPropertiesService::class, PrimaryDatabaseConfiguration::class])
+@ContextConfiguration(
+ classes = [DatabaseResourceAssignmentProcessor::class, BluePrintPropertyConfiguration::class,
+ BluePrintPropertiesService::class, BluePrintDBLibPropertyService::class, BluePrintDBLibConfiguration::class,
+ BluePrintCoreConfiguration::class, MockDatabaseConfiguration::class, MockBlueprintProcessorCatalogServiceImpl::class,
+ BluePrintPropertiesService::class, PrimaryDatabaseConfiguration::class]
+)
@TestPropertySource(locations = ["classpath:application-test.properties"])
class DatabaseResourceResolutionProcessorTest {
@@ -52,13 +54,14 @@ class DatabaseResourceResolutionProcessorTest {
fun `test database resource resolution processor db`() {
runBlocking {
val bluePrintContext = BluePrintMetadataUtils.getBluePrintContext(
- "./../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration")
+ "./../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration"
+ )
val resourceAssignmentRuntimeService = ResourceAssignmentRuntimeService("1234", bluePrintContext)
databaseResourceAssignmentProcessor.raRuntimeService = resourceAssignmentRuntimeService
databaseResourceAssignmentProcessor.resourceDictionaries = ResourceAssignmentUtils
- .resourceDefinitions(bluePrintContext.rootPath)
+ .resourceDefinitions(bluePrintContext.rootPath)
val resourceAssignment = ResourceAssignment().apply {
name = "service-instance-id"
@@ -73,4 +76,4 @@ class DatabaseResourceResolutionProcessorTest {
assertNotNull(processorName, "couldn't get Database resource assignment processor name")
}
}
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/DefaultResourceResolutionProcessorTest.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/DefaultResourceResolutionProcessorTest.kt
index 093a3347a..a109131fe 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/DefaultResourceResolutionProcessorTest.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/DefaultResourceResolutionProcessorTest.kt
@@ -40,7 +40,8 @@ class DefaultResourceResolutionProcessorTest {
fun `test default resource resolution`() {
runBlocking {
val bluePrintContext = BluePrintMetadataUtils.getBluePrintContext(
- "./../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration")
+ "./../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration"
+ )
val resourceAssignmentRuntimeService = ResourceAssignmentRuntimeService("1234", bluePrintContext)
@@ -61,4 +62,4 @@ class DefaultResourceResolutionProcessorTest {
println(processorName)
}
}
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/InputResourceResolutionProcessorTest.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/InputResourceResolutionProcessorTest.kt
index 242739067..17bb5e6b0 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/InputResourceResolutionProcessorTest.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/InputResourceResolutionProcessorTest.kt
@@ -46,13 +46,14 @@ class InputResourceResolutionProcessorTest {
runBlocking {
val bluePrintContext = BluePrintMetadataUtils.getBluePrintContext(
- "./../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration")
+ "./../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration"
+ )
val resourceAssignmentRuntimeService = spyk(ResourceAssignmentRuntimeService("1234", bluePrintContext))
// mocking input for resource resolution
val textNode: JsonNode = TextNode("any value")
- every {resourceAssignmentRuntimeService.getInputValue("rr-name") } returns textNode
+ every { resourceAssignmentRuntimeService.getInputValue("rr-name") } returns textNode
inputResourceResolutionProcessor.raRuntimeService = resourceAssignmentRuntimeService
inputResourceResolutionProcessor.resourceDictionaries = ResourceAssignmentUtils.resourceDefinitions(bluePrintContext.rootPath)
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/RestResourceResolutionProcessorTest.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/RestResourceResolutionProcessorTest.kt
index 1c0f33fcd..af78a604a 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/RestResourceResolutionProcessorTest.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/RestResourceResolutionProcessorTest.kt
@@ -36,17 +36,20 @@ import kotlin.test.BeforeTest
import kotlin.test.assertNotNull
@RunWith(SpringRunner::class)
-@ContextConfiguration(classes = [MockRestResourceResolutionProcessor::class, MockBluePrintRestLibPropertyService::class,
- BluePrintPropertyConfiguration::class, BluePrintPropertiesService::class, RestClientProperties::class])
+@ContextConfiguration(
+ classes = [MockRestResourceResolutionProcessor::class, MockBluePrintRestLibPropertyService::class,
+ BluePrintPropertyConfiguration::class, BluePrintPropertiesService::class, RestClientProperties::class]
+)
@TestPropertySource(locations = ["classpath:application-test.properties"])
class RestResourceResolutionProcessorTest {
+
@Autowired
lateinit var bluePrintRestLibPropertyService: MockBluePrintRestLibPropertyService
private lateinit var restResourceResolutionProcessor: MockRestResourceResolutionProcessor
@BeforeTest
- fun init(){
+ fun init() {
restResourceResolutionProcessor = MockRestResourceResolutionProcessor(bluePrintRestLibPropertyService)
}
@@ -54,13 +57,14 @@ class RestResourceResolutionProcessorTest {
fun `test rest resource resolution`() {
runBlocking {
val bluePrintContext = BluePrintMetadataUtils.getBluePrintContext(
- "./../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration")
+ "./../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration"
+ )
val resourceAssignmentRuntimeService = ResourceAssignmentRuntimeService("1234", bluePrintContext)
restResourceResolutionProcessor.raRuntimeService = resourceAssignmentRuntimeService
restResourceResolutionProcessor.resourceDictionaries = ResourceAssignmentUtils
- .resourceDefinitions(bluePrintContext.rootPath)
+ .resourceDefinitions(bluePrintContext.rootPath)
val scriptPropertyInstances: MutableMap<String, Any> = mutableMapOf()
scriptPropertyInstances["mock-service1"] = MockCapabilityService()
@@ -87,13 +91,14 @@ class RestResourceResolutionProcessorTest {
fun `test rest aai get resource resolution`() {
runBlocking {
val bluePrintContext = BluePrintMetadataUtils.getBluePrintContext(
- "./../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration")
+ "./../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration"
+ )
val resourceAssignmentRuntimeService = ResourceAssignmentRuntimeService("1234", bluePrintContext)
restResourceResolutionProcessor.raRuntimeService = resourceAssignmentRuntimeService
restResourceResolutionProcessor.resourceDictionaries = ResourceAssignmentUtils
- .resourceDefinitions(bluePrintContext.rootPath)
+ .resourceDefinitions(bluePrintContext.rootPath)
val scriptPropertyInstances: MutableMap<String, Any> = mutableMapOf()
scriptPropertyInstances["mock-service1"] = MockCapabilityService()
@@ -120,13 +125,14 @@ class RestResourceResolutionProcessorTest {
fun `test rest aai put resource resolution`() {
runBlocking {
val bluePrintContext = BluePrintMetadataUtils.getBluePrintContext(
- "./../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration")
+ "./../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration"
+ )
val resourceAssignmentRuntimeService = ResourceAssignmentRuntimeService("1234", bluePrintContext)
restResourceResolutionProcessor.raRuntimeService = resourceAssignmentRuntimeService
restResourceResolutionProcessor.resourceDictionaries = ResourceAssignmentUtils
- .resourceDefinitions(bluePrintContext.rootPath)
+ .resourceDefinitions(bluePrintContext.rootPath)
val scriptPropertyInstances: MutableMap<String, Any> = mutableMapOf()
scriptPropertyInstances["mock-service1"] = MockCapabilityService()
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 d7a696848..7631339e8 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
@@ -64,11 +64,12 @@ class ResourceAssignmentUtilsTest {
fun setup() {
val bluePrintContext = BluePrintMetadataUtils.getBluePrintContext(
- "./../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration")
+ "./../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration"
+ )
resourceAssignmentRuntimeService = spyk(ResourceAssignmentRuntimeService("1234", bluePrintContext))
- //Init input map and expected values for tests
+ // Init input map and expected values for tests
initInputMapAndExpectedValuesForPrimitiveType()
initInputMapAndExpectedValuesForCollection()
initInputMapAndExpectedValuesForComplexType()
@@ -120,35 +121,34 @@ class ResourceAssignmentUtilsTest {
@Test
fun `generateResourceDataForAssignments - positive test`() {
- //given a valid resource assignment
+ // given a valid resource assignment
val validResourceAssignment = createResourceAssignmentForTest("valid_value")
- //and a list containing that resource assignment
+ // and a list containing that resource assignment
val resourceAssignmentList = listOf<ResourceAssignment>(validResourceAssignment)
- //when the values of the resources are evaluated
+ // when the values of the resources are evaluated
val outcome = ResourceAssignmentUtils.generateResourceDataForAssignments(resourceAssignmentList)
- //then the assignment should produce a valid result
+ // then the assignment should produce a valid result
val expected = "{\n" + " \"pnf-id\" : \"valid_value\"\n" + "}"
- assertEquals(expected, outcome.replace("\r\n","\n"), "unexpected outcome generated")
+ assertEquals(expected, outcome.replace("\r\n", "\n"), "unexpected outcome generated")
}
@Test
fun `generateResourceDataForAssignments - resource without value is not resolved as null`() {
- //given a valid resource assignment
+ // given a valid resource assignment
val resourceAssignmentWithNullValue = createResourceAssignmentForTest(null)
- //and a list containing that resource assignment
+ // and a list containing that resource assignment
val resourceAssignmentList = listOf<ResourceAssignment>(resourceAssignmentWithNullValue)
- //when the values of the resources are evaluated
+ // when the values of the resources are evaluated
val outcome = ResourceAssignmentUtils.generateResourceDataForAssignments(resourceAssignmentList)
- //then the assignment should produce a valid result
+ // then the assignment should produce a valid result
val expected = "{\n" + " \"pnf-id\" : \"\${pnf-id}\"\n" + "}"
- assertEquals(expected, outcome.replace("\r\n","\n"), "unexpected outcome generated")
-
+ assertEquals(expected, outcome.replace("\r\n", "\n"), "unexpected outcome generated")
}
private fun createResourceAssignmentForTest(resourceValue: String?): ResourceAssignment {
@@ -166,61 +166,77 @@ class ResourceAssignmentUtilsTest {
}
@Test
- fun parseResponseNodeTestForPrimitivesTypes(){
- var outcome = prepareResponseNodeForTest("sample-value", "string", "",
- inputMapToTestPrimitiveTypeWithValue)
+ fun parseResponseNodeTestForPrimitivesTypes() {
+ var outcome = prepareResponseNodeForTest(
+ "sample-value", "string", "",
+ inputMapToTestPrimitiveTypeWithValue
+ )
assertEquals(expectedValueToTestPrimitiveType, outcome, "Unexpected outcome returned for primitive type of simple String")
- outcome = prepareResponseNodeForTest("sample-key-value", "string", "",
- inputMapToTestPrimitiveTypeWithKeyValue)
+ outcome = prepareResponseNodeForTest(
+ "sample-key-value", "string", "",
+ inputMapToTestPrimitiveTypeWithKeyValue
+ )
assertEquals(expectedValueToTestPrimitiveType, outcome, "Unexpected outcome returned for primitive type of key-value String")
}
@Test
- fun parseResponseNodeTestForCollectionsOfString(){
- var outcome = prepareResponseNodeForTest("listOfString", "list",
- "string", inputMapToTestCollectionOfPrimitiveType)
+ fun parseResponseNodeTestForCollectionsOfString() {
+ var outcome = prepareResponseNodeForTest(
+ "listOfString", "list",
+ "string", inputMapToTestCollectionOfPrimitiveType
+ )
assertEquals(expectedValueToTesCollectionOfPrimitiveType, outcome, "unexpected outcome returned for list of String")
- outcome = prepareResponseNodeForTest("mapOfString", "map", "string",
- inputMapToTestCollectionOfPrimitiveType)
+ outcome = prepareResponseNodeForTest(
+ "mapOfString", "map", "string",
+ inputMapToTestCollectionOfPrimitiveType
+ )
assertEquals(expectedValueToTesCollectionOfPrimitiveType, outcome, "unexpected outcome returned for map of String")
}
@Test
- fun parseResponseNodeTestForCollectionsOfComplexType(){
- var outcome = prepareResponseNodeForTest("listOfMyDataTypeWithOneOutputKeyMapping", "list",
- "ip-address", inputMapToTestCollectionOfComplexTypeWithOneOutputKeyMapping)
+ fun parseResponseNodeTestForCollectionsOfComplexType() {
+ var outcome = prepareResponseNodeForTest(
+ "listOfMyDataTypeWithOneOutputKeyMapping", "list",
+ "ip-address", inputMapToTestCollectionOfComplexTypeWithOneOutputKeyMapping
+ )
assertEquals(expectedValueToTestCollectionOfComplexTypeWithOneOutputKeyMapping, outcome, "unexpected outcome returned for list of String")
- outcome = prepareResponseNodeForTest("listOfMyDataTypeWithAllOutputKeyMapping", "list",
- "ip-address", inputMapToTestCollectionOfComplexTypeWithAllOutputKeyMapping)
+ outcome = prepareResponseNodeForTest(
+ "listOfMyDataTypeWithAllOutputKeyMapping", "list",
+ "ip-address", inputMapToTestCollectionOfComplexTypeWithAllOutputKeyMapping
+ )
assertEquals(expectedValueToTestCollectionOfComplexTypeWithAllOutputKeyMapping, outcome, "unexpected outcome returned for list of String")
}
@Test
- fun `parseResponseNodeTestForComplexType find one output key mapping`(){
- val outcome = prepareResponseNodeForTest("complexTypeOneKeys", "host",
- "", inputMapToTestComplexTypeWithOneOutputKeyMapping)
+ fun `parseResponseNodeTestForComplexType find one output key mapping`() {
+ val outcome = prepareResponseNodeForTest(
+ "complexTypeOneKeys", "host",
+ "", inputMapToTestComplexTypeWithOneOutputKeyMapping
+ )
assertEquals(expectedValueToTestComplexTypeWithOneOutputKeyMapping, outcome, "Unexpected outcome returned for complex type")
}
@Test
- fun `parseResponseNodeTestForComplexType find all output key mapping`(){
- val outcome = prepareResponseNodeForTest("complexTypeAllKeys", "host",
- "", inputMapToTestComplexTypeWithAllOutputKeyMapping)
+ fun `parseResponseNodeTestForComplexType find all output key mapping`() {
+ val outcome = prepareResponseNodeForTest(
+ "complexTypeAllKeys", "host",
+ "", inputMapToTestComplexTypeWithAllOutputKeyMapping
+ )
assertEquals(expectedValueToTestComplexTypeWithAllOutputKeyMapping, outcome, "Unexpected outcome returned for complex type")
}
private fun initInputMapAndExpectedValuesForPrimitiveType() {
inputMapToTestPrimitiveTypeWithValue = "1.2.3.1".asJsonType()
val keyValue = mutableMapOf<String, String>()
- keyValue["value"]= "1.2.3.1"
+ keyValue["value"] = "1.2.3.1"
inputMapToTestPrimitiveTypeWithKeyValue = keyValue.asJsonType()
expectedValueToTestPrimitiveType = TextNode("1.2.3.1")
}
- private fun initInputMapAndExpectedValuesForCollection(){
+ private fun initInputMapAndExpectedValuesForCollection() {
val listOfIps = arrayListOf("1.2.3.1", "1.2.3.2", "1.2.3.3")
val arrayNodeForList1 = JacksonUtils.objectMapper.createArrayNode()
listOfIps.forEach {
@@ -230,12 +246,15 @@ class ResourceAssignmentUtilsTest {
}
inputMapToTestCollectionOfPrimitiveType = arrayNodeForList1
- expectedValueToTesCollectionOfPrimitiveType = arrayListOf(ExpectedResponseIp("1.2.3.1"),
- ExpectedResponseIp( "1.2.3.2"), ExpectedResponseIp("1.2.3.3")).asJsonType()
-
+ expectedValueToTesCollectionOfPrimitiveType = arrayListOf(
+ ExpectedResponseIp("1.2.3.1"),
+ ExpectedResponseIp("1.2.3.2"), ExpectedResponseIp("1.2.3.3")
+ ).asJsonType()
- val listOfIpAddresses = arrayListOf(IpAddress("1111", "1.2.3.1").asJsonType(),
- IpAddress("2222", "1.2.3.2").asJsonType(), IpAddress("3333", "1.2.3.3").asJsonType())
+ val listOfIpAddresses = arrayListOf(
+ IpAddress("1111", "1.2.3.1").asJsonType(),
+ IpAddress("2222", "1.2.3.2").asJsonType(), IpAddress("3333", "1.2.3.3").asJsonType()
+ )
val arrayNodeForList2 = JacksonUtils.objectMapper.createArrayNode()
listOfIpAddresses.forEach {
val arrayChildNode = JacksonUtils.objectMapper.createObjectNode()
@@ -259,15 +278,20 @@ class ResourceAssignmentUtilsTest {
arrayNodeForList3.add(childNode)
inputMapToTestCollectionOfComplexTypeWithAllOutputKeyMapping = arrayNodeForList3
- expectedValueToTestCollectionOfComplexTypeWithOneOutputKeyMapping = arrayListOf(ExpectedResponseIpAddress(IpAddress("1111", "1.2.3.1")),
- ExpectedResponseIpAddress(IpAddress("2222", "1.2.3.2")), ExpectedResponseIpAddress(
- IpAddress("3333", "1.2.3.3"))).asJsonType()
- expectedValueToTestCollectionOfComplexTypeWithAllOutputKeyMapping = arrayListOf(IpAddress("1111", "1.2.3.1"),
- IpAddress("2222", "1.2.3.2"),
- IpAddress("3333", "1.2.3.3")).asJsonType()
+ expectedValueToTestCollectionOfComplexTypeWithOneOutputKeyMapping = arrayListOf(
+ ExpectedResponseIpAddress(IpAddress("1111", "1.2.3.1")),
+ ExpectedResponseIpAddress(IpAddress("2222", "1.2.3.2")), ExpectedResponseIpAddress(
+ IpAddress("3333", "1.2.3.3")
+ )
+ ).asJsonType()
+ expectedValueToTestCollectionOfComplexTypeWithAllOutputKeyMapping = arrayListOf(
+ IpAddress("1111", "1.2.3.1"),
+ IpAddress("2222", "1.2.3.2"),
+ IpAddress("3333", "1.2.3.3")
+ ).asJsonType()
}
- private fun initInputMapAndExpectedValuesForComplexType(){
+ private fun initInputMapAndExpectedValuesForComplexType() {
val mapOfComplexType = mutableMapOf<String, JsonNode>()
mapOfComplexType["value"] = Host("my-ipAddress", IpAddress("1111", "1.2.3.1")).asJsonType()
mapOfComplexType["port"] = "8888".asJsonType()
@@ -275,7 +299,8 @@ class ResourceAssignmentUtilsTest {
inputMapToTestComplexTypeWithOneOutputKeyMapping = mapOfComplexType.asJsonType()
val objectNode = JacksonUtils.objectMapper.createObjectNode()
- expectedValueToTestComplexTypeWithOneOutputKeyMapping = objectNode.set("host", Host("my-ipAddress", IpAddress("1111", "1.2.3.1")).asJsonType())
+ expectedValueToTestComplexTypeWithOneOutputKeyMapping =
+ objectNode.set("host", Host("my-ipAddress", IpAddress("1111", "1.2.3.1")).asJsonType())
val childNode1 = JacksonUtils.objectMapper.createObjectNode()
childNode1.set("name", "my-ipAddress".asJsonPrimitive())
@@ -290,8 +315,12 @@ class ResourceAssignmentUtilsTest {
expectedValueToTestComplexTypeWithAllOutputKeyMapping = childNode2
}
- private fun prepareResponseNodeForTest(dictionary_source: String, sourceType: String, entrySchema: String,
- response: Any): JsonNode {
+ private fun prepareResponseNodeForTest(
+ dictionary_source: String,
+ sourceType: String,
+ entrySchema: String,
+ response: Any
+ ): JsonNode {
val resourceAssignment = when (sourceType) {
"list", "map" -> {
@@ -355,16 +384,16 @@ class ResourceAssignmentUtilsTest {
when (dictionary_source) {
"sample-key-value", "sample-value" -> {
- //Primary Type
- if (dictionary_source=="sample-key-value")
+ // Primary Type
+ if (dictionary_source == "sample-key-value")
outputMapping["sample-ip"] = "value"
}
"listOfString", "mapOfString" -> {
- //List of string
+ // List of string
outputMapping["ip"] = "value"
}
"listOfMyDataTypeWithOneOutputKeyMapping", "listOfMyDataTypeWithAllOutputKeyMapping" -> {
- //List or map of complex Type
+ // List or map of complex Type
if (dictionary_source == "listOfMyDataTypeWithOneOutputKeyMapping")
outputMapping["ipAddress"] = "value"
else {
@@ -373,16 +402,15 @@ class ResourceAssignmentUtilsTest {
}
}
else -> {
- //Complex Type
+ // Complex Type
if (dictionary_source == "complexTypeOneKeys")
outputMapping["host"] = "value"
else {
outputMapping["name"] = "name"
outputMapping["ipAddress"] = "ipAddress"
}
-
}
}
return outputMapping
}
-} \ No newline at end of file
+}