diff options
Diffstat (limited to 'ms/blueprintsprocessor')
13 files changed, 495 insertions, 75 deletions
diff --git a/ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/ComponentJythonExecutor.kt b/ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/ComponentJythonExecutor.kt index 5eb40225e..9e2ba0b94 100644 --- a/ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/ComponentJythonExecutor.kt +++ b/ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/ComponentJythonExecutor.kt @@ -22,7 +22,7 @@ import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceInp import org.onap.ccsdk.apps.blueprintsprocessor.functions.python.executor.utils.PythonExecutorUtils import org.onap.ccsdk.apps.blueprintsprocessor.services.execution.AbstractComponentFunction import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException -import org.onap.ccsdk.apps.controllerblueprints.core.checkNotEmptyNThrow +import org.onap.ccsdk.apps.controllerblueprints.core.checkNotEmptyOrThrow import org.onap.ccsdk.apps.controllerblueprints.core.data.OperationAssignment import org.slf4j.LoggerFactory import org.springframework.beans.factory.annotation.Autowired @@ -62,7 +62,7 @@ open class ComponentJythonExecutor(private val pythonExecutorProperty: PythonExe val content: String? = bluePrintRuntimeService.resolveNodeTemplateArtifact(nodeTemplateName, artifactName) - checkNotEmptyNThrow(content, "artifact ($artifactName) content is empty") + checkNotEmptyOrThrow(content, "artifact ($artifactName) content is empty") val pythonPath: MutableList<String> = operationAssignment.implementation?.dependencies ?: arrayListOf() pythonPath.add(blueprintBasePath) diff --git a/ms/blueprintsprocessor/functions/resource-resolution/pom.xml b/ms/blueprintsprocessor/functions/resource-resolution/pom.xml index 2f08c5807..925f9e337 100644 --- a/ms/blueprintsprocessor/functions/resource-resolution/pom.xml +++ b/ms/blueprintsprocessor/functions/resource-resolution/pom.xml @@ -14,7 +14,8 @@ ~ See the License for the specific language governing permissions and ~ limitations under the License. --> -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.onap.ccsdk.apps.blueprintsprocessor</groupId> @@ -27,4 +28,29 @@ <name>Blueprints Processor Function - Resource Resolution</name> <description>Blueprints Processor Function - Resource Resolution</description> + <dependencies> + <!--<dependency> + <groupId>org.onap.ccsdk.apps.controllerblueprints</groupId> + <artifactId>db-resources</artifactId> + <version>${project.version}</version> + </dependency>--> + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-data-jpa</artifactId> + </dependency> + <dependency> + <groupId>com.h2database</groupId> + <artifactId>h2</artifactId> + </dependency> + <dependency> + <groupId>org.mariadb.jdbc</groupId> + <artifactId>mariadb-java-client</artifactId> + </dependency> + <dependency> + <groupId>org.hibernate</groupId> + <artifactId>hibernate-testing</artifactId> + <scope>test</scope> + </dependency> + </dependencies> + </project> diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceAssignmentRuntimeService.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceAssignmentRuntimeService.kt index 9d6f4a6b5..c4ae13975 100644 --- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceAssignmentRuntimeService.kt +++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceAssignmentRuntimeService.kt @@ -6,53 +6,83 @@ import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintContext import org.onap.ccsdk.apps.controllerblueprints.core.service.DefaultBluePrintRuntimeService
class ResourceAssignmentRuntimeService(private var id: String, private var bluePrintContext: BluePrintContext)
- : DefaultBluePrintRuntimeService(id, bluePrintContext){
+ : DefaultBluePrintRuntimeService(id, bluePrintContext) {
- private var resourceResolutionStore: MutableMap<String, JsonNode> = hashMapOf()
+ private lateinit var resolutionId: String
+ private var resourceStore: MutableMap<String, JsonNode> = hashMapOf()
- override fun getExecutionContext(): MutableMap<String, JsonNode> {
- return resourceResolutionStore
+ fun createUniqueId(key: String) {
+ resolutionId = "$id-$key"
}
- @Suppress("UNCHECKED_CAST")
- override fun setExecutionContext(executionContext: MutableMap<String, JsonNode>) {
- this.resourceResolutionStore = executionContext
+ fun cleanResourceStore() {
+ resourceStore.clear()
}
- override fun put(key: String, value: JsonNode) {
- resourceResolutionStore[key] = value
+ fun putResolutionStore(key: String, value: JsonNode) {
+ resourceStore[key] = value
}
- override fun get(key: String): JsonNode {
- return resourceResolutionStore[key] ?: throw BluePrintProcessorException("failed to get execution property($key)")
+ fun getResolutionStore(key: String): JsonNode {
+ return resourceStore[key]
+ ?: throw BluePrintProcessorException("failed to get execution property ($key)")
}
- override fun check(key: String): Boolean {
- return resourceResolutionStore.containsKey(key)
+ fun checkResolutionStore(key: String): Boolean {
+ return resourceStore.containsKey(key)
}
- override fun cleanRuntime() {
- resourceResolutionStore.clear()
+ fun getJsonNodeFromResolutionStore(key: String): JsonNode {
+ return getResolutionStore(key)
}
- private fun getJsonNode(key: String): JsonNode {
- return get(key)
+ fun getStringFromResolutionStore(key: String): String? {
+ return getResolutionStore(key).asText()
}
- override fun getAsString(key: String): String? {
- return get(key).asText()
+ fun getBooleanFromResolutionStore(key: String): Boolean? {
+ return getResolutionStore(key).asBoolean()
}
- override fun getAsBoolean(key: String): Boolean? {
- return get(key).asBoolean()
+ fun getIntFromResolutionStore(key: String): Int? {
+ return getResolutionStore(key).asInt()
}
- override fun getAsInt(key: String): Int? {
- return get(key).asInt()
+ fun getDoubleFromResolutionStore(key: String): Double? {
+ return getResolutionStore(key).asDouble()
}
- override fun getAsDouble(key: String): Double? {
- return get(key).asDouble()
+ fun putDictionaryStore(key: String, value: JsonNode) {
+ resourceStore["dictionary-$key"] = value
+ }
+
+ fun getDictionaryStore(key: String): JsonNode {
+ return resourceStore["dictionary-$key"]
+ ?: throw BluePrintProcessorException("failed to get execution property (dictionary-$key)")
+ }
+
+ fun checkDictionaryStore(key: String): Boolean {
+ return resourceStore.containsKey("dictionary-$key")
+ }
+
+ fun getJsonNodeFromDictionaryStore(key: String): JsonNode {
+ return getResolutionStore("dictionary-$key")
+ }
+
+ fun getStringFromDictionaryStore(key: String): String? {
+ return getResolutionStore("dictionary-$key").asText()
+ }
+
+ fun getBooleanFromDictionaryStore(key: String): Boolean? {
+ return getResolutionStore("dictionary-$key").asBoolean()
+ }
+
+ fun getIntFromDictionaryStore(key: String): Int? {
+ return getResolutionStore("dictionary-$key").asInt()
+ }
+
+ fun getDoubleFromDictionaryStore(key: String): Double? {
+ return getResolutionStore("dictionary-$key").asDouble()
}
}
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionService.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionService.kt index 5a7161da6..38e5c95fd 100644 --- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionService.kt +++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionService.kt @@ -18,6 +18,7 @@ package org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution
import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.processor.ResourceAssignmentProcessor
+import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.utils.ResourceAssignmentUtils
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException
import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService
@@ -88,7 +89,7 @@ class ResourceResolutionService { val resourceDictionaries: MutableMap<String, ResourceDefinition> = JacksonUtils.getMapFromFile(dictionaryFile, ResourceDefinition::class.java)
?: throw BluePrintProcessorException("couldn't get Dictionary Definitions")
- executeProcessors(bluePrintRuntimeService, resourceDictionaries, resourceAssignments)
+ executeProcessors(bluePrintRuntimeService, resourceDictionaries, resourceAssignments, templateArtifactName)
// Check Template is there
val templateContent = bluePrintRuntimeService.resolveNodeTemplateArtifact(nodeTemplateName, mappingArtifactName)
@@ -107,11 +108,13 @@ class ResourceResolutionService { }
- fun executeProcessors(bluePrintRuntimeService: BluePrintRuntimeService<*>,
- resourceDictionaries: MutableMap<String, ResourceDefinition>,
- resourceAssignments: MutableList<ResourceAssignment>) {
+ private fun executeProcessors(blueprintRuntimeService: BluePrintRuntimeService<*>,
+ resourceDictionaries: MutableMap<String, ResourceDefinition>,
+ resourceAssignments: MutableList<ResourceAssignment>,
+ templateArtifactName: String) {
val bulkSequenced = BulkResourceSequencingUtils.process(resourceAssignments)
+ val resourceAssignmentRuntimeService = ResourceAssignmentUtils.transformToRARuntimeService(blueprintRuntimeService, templateArtifactName)
bulkSequenced.map { batchResourceAssignments ->
batchResourceAssignments.filter { it.name != "*" && it.name != "start" }
@@ -124,7 +127,7 @@ class ResourceResolutionService { "for resource assignment(${resourceAssignment.name})")
try {
// Set BluePrint Runtime Service
- resourceAssignmentProcessor.bluePrintRuntimeService = bluePrintRuntimeService
+ resourceAssignmentProcessor.raRuntimeService = resourceAssignmentRuntimeService
// Set Resource Dictionaries
resourceAssignmentProcessor.resourceDictionaries = resourceDictionaries
// Invoke Apply Method
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceSourceProperties.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceSourceProperties.kt index b141025dc..9bad09988 100644 --- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceSourceProperties.kt +++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceSourceProperties.kt @@ -33,8 +33,8 @@ open class DefaultResourceSource : ResourceSourceProperties() { open class DatabaseResourceSource : ResourceSourceProperties() { lateinit var type: String lateinit var query: String - var inputKeyMapping: MutableList<String>? = null - var outputKeyMapping: MutableList<String>? = null + var inputKeyMapping: MutableMap<String, String>? = null + var outputKeyMapping: MutableMap<String, String>? = null lateinit var keyDependencies: MutableList<String> } @@ -43,8 +43,8 @@ open class RestResourceSource : ResourceSourceProperties() { lateinit var urlPath: String lateinit var path: String lateinit var expressionType: String - var inputKeyMapping: MutableList<String>? = null - var outputKeyMapping: MutableList<String>? = null + var inputKeyMapping: MutableMap<String, String>? = null + var outputKeyMapping: MutableMap<String, String>? = null lateinit var keyDependencies: MutableList<String> } @@ -53,7 +53,7 @@ open class CapabilityResourceSource : ResourceSourceProperties() { lateinit var instanceName: String lateinit var path: String lateinit var expressionType: String - var inputKeyMapping: MutableList<String>? = null - var outputKeyMapping: MutableList<String>? = null + var inputKeyMapping: MutableMap<String, String>? = null + var outputKeyMapping: MutableMap<String, String>? = null 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/apps/blueprintsprocessor/functions/resource/resolution/processor/CapabilityResourceAssignmentProcessor.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/CapabilityResourceAssignmentProcessor.kt index 993384985..6c2355994 100644 --- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/CapabilityResourceAssignmentProcessor.kt +++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/CapabilityResourceAssignmentProcessor.kt @@ -18,8 +18,8 @@ package org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.pr import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.CapabilityResourceSource import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException +import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment -import org.onap.ccsdk.apps.controllerblueprints.resource.dict.utils.ResourceAssignmentUtils import org.springframework.beans.factory.annotation.Autowired import org.springframework.context.ApplicationContext import org.springframework.stereotype.Service @@ -40,17 +40,16 @@ open class CapabilityResourceAssignmentProcessor : ResourceAssignmentProcessor() return "resource-assignment-processor-capability" } - override fun process(executionRequest: ResourceAssignment) { + override fun process(resourceAssignment: ResourceAssignment) { - val resourceDefinition = resourceDictionaries[executionRequest.dictionaryName] - ?: throw BluePrintProcessorException("couldn't get resource definition for ${executionRequest.dictionaryName}") + val resourceDefinition = resourceDictionaries[resourceAssignment.dictionaryName] + ?: throw BluePrintProcessorException("couldn't get resource definition for ${resourceAssignment.dictionaryName}") - val resourceSource = resourceDefinition.sources[executionRequest.dictionarySource] - ?: throw BluePrintProcessorException("couldn't get resource definition ${executionRequest.dictionaryName} source(${executionRequest.dictionarySource})") + val resourceSource = resourceDefinition.sources[resourceAssignment.dictionarySource] + ?: throw BluePrintProcessorException("couldn't get resource definition ${resourceAssignment.dictionaryName} source(${resourceAssignment.dictionarySource})") - checkNotNull(resourceSource.properties) { "failed to get ${executionRequest.dictionarySource} properties" } - - val capabilityResourceSourceProperty = ResourceAssignmentUtils.transformResourceSource(resourceSource.properties!!, CapabilityResourceSource::class.java) + val resourceSourceProps = checkNotNull(resourceSource.properties) { "failed to get $resourceSource properties" } + val capabilityResourceSourceProperty = JacksonUtils.getInstanceFromMap(resourceSourceProps, CapabilityResourceSource::class.java) val instanceType = capabilityResourceSourceProperty.type val instanceName = capabilityResourceSourceProperty.instanceName @@ -74,14 +73,14 @@ open class CapabilityResourceAssignmentProcessor : ResourceAssignmentProcessor() checkNotNull(componentResourceAssignmentProcessor) { "failed to get capability resource assignment processor($instanceName)" } // Assign Current Blueprint runtime and ResourceDictionaries - componentResourceAssignmentProcessor.bluePrintRuntimeService = bluePrintRuntimeService + componentResourceAssignmentProcessor.raRuntimeService = raRuntimeService componentResourceAssignmentProcessor.resourceDictionaries = resourceDictionaries // Invoke componentResourceAssignmentProcessor - componentResourceAssignmentProcessor.apply(executionRequest) + componentResourceAssignmentProcessor.apply(resourceAssignment) } - override fun recover(runtimeException: RuntimeException, executionRequest: ResourceAssignment) { + override fun recover(runtimeException: RuntimeException, resourceAssignment: ResourceAssignment) { TODO("To Implement") } diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/InputResourceAssignmentProcessor.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/InputResourceAssignmentProcessor.kt index bd9c188ac..5757de2af 100644 --- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/InputResourceAssignmentProcessor.kt +++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/InputResourceAssignmentProcessor.kt @@ -17,41 +17,46 @@ package org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.processor -import org.onap.ccsdk.apps.controllerblueprints.core.* +import com.fasterxml.jackson.databind.node.NullNode +import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.utils.ResourceAssignmentUtils +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException +import org.onap.ccsdk.apps.controllerblueprints.core.checkNotEmpty import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment +import org.slf4j.LoggerFactory import org.springframework.stereotype.Service -import com.fasterxml.jackson.databind.node.NullNode -import org.onap.ccsdk.apps.controllerblueprints.resource.dict.utils.ResourceAssignmentUtils /** * InputResourceAssignmentProcessor * - * @author Brinda Santh + * @author Kapil Singal */ @Service("resource-assignment-processor-input") open class InputResourceAssignmentProcessor : ResourceAssignmentProcessor() { + private val logger = LoggerFactory.getLogger(InputResourceAssignmentProcessor::class.java) + override fun getName(): String { return "resource-assignment-processor-input" } - override fun process(executionRequest: ResourceAssignment) { + override fun process(resourceAssignment: ResourceAssignment) { try { - if (checkNotEmpty(executionRequest.name)) { - val value = bluePrintRuntimeService!!.getInputValue(executionRequest.name) + if (checkNotEmpty(resourceAssignment.name)) { + val value = raRuntimeService.getInputValue(resourceAssignment.name) // if value is null don't call setResourceDataValue to populate the value if (value != null && value !is NullNode) { - ResourceAssignmentUtils.setResourceDataValue(executionRequest, value) + logger.info("input source template key (${resourceAssignment.name}) found from input and value is ($value)") + ResourceAssignmentUtils.setResourceDataValue(resourceAssignment, raRuntimeService, value) } } // Check the value has populated for mandatory case - ResourceAssignmentUtils.assertTemplateKeyValueNotNull(executionRequest) + ResourceAssignmentUtils.assertTemplateKeyValueNotNull(resourceAssignment) } catch (e: Exception) { - ResourceAssignmentUtils.setFailedResourceDataValue(executionRequest, e.message) - throw BluePrintProcessorException("Failed in template key ($executionRequest) assignments with : (${e.message})", e) + ResourceAssignmentUtils.setFailedResourceDataValue(resourceAssignment, e.message) + throw BluePrintProcessorException("Failed in template key ($resourceAssignment) assignments with : (${e.message})", e) } } - override fun recover(runtimeException: RuntimeException, executionRequest: ResourceAssignment) { + override fun recover(runtimeException: RuntimeException, resourceAssignment: ResourceAssignment) { } }
\ No newline at end of file diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/PrimaryDataResourceAssignmentProcessor.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/PrimaryDataResourceAssignmentProcessor.kt index ec98d09e8..2b3270e65 100644 --- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/PrimaryDataResourceAssignmentProcessor.kt +++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/PrimaryDataResourceAssignmentProcessor.kt @@ -17,8 +17,18 @@ package org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.processor +import com.fasterxml.jackson.databind.node.JsonNodeFactory +import com.fasterxml.jackson.databind.node.NullNode +import org.onap.ccsdk.apps.blueprintsprocessor.db.primary.service.PrimaryDBLibGenericService +import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.DatabaseResourceSource +import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.utils.ResourceAssignmentUtils +import org.onap.ccsdk.apps.controllerblueprints.core.* +import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment +import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDictionaryConstants +import org.slf4j.LoggerFactory import org.springframework.stereotype.Service +import java.util.* /** * PrimaryDataResourceAssignmentProcessor @@ -26,15 +36,129 @@ import org.springframework.stereotype.Service * @author Brinda Santh */ @Service("resource-assignment-processor-primary-db") -open class PrimaryDataResourceAssignmentProcessor : ResourceAssignmentProcessor(){ +open class PrimaryDataResourceAssignmentProcessor(private val primaryDBLibGenericService: PrimaryDBLibGenericService) + : ResourceAssignmentProcessor() { + + private val logger = LoggerFactory.getLogger(PrimaryDataResourceAssignmentProcessor::class.java) override fun getName(): String { return "resource-assignment-processor-primary-db" } - override fun process(executionRequest: ResourceAssignment) { + override fun process(resourceAssignment: ResourceAssignment) { + try { + validate(resourceAssignment) + + // Check if It has Input + val value = raRuntimeService.getInputValue(resourceAssignment.name) + if (value != null && value !is NullNode) { + logger.info("primary-db source template key (${resourceAssignment.name}) found from input and value is ($value)") + ResourceAssignmentUtils.setResourceDataValue(resourceAssignment, raRuntimeService, value) + return + } + + val dName = resourceAssignment.dictionaryName + val dSource = resourceAssignment.dictionarySource + val resourceDefinition = resourceDictionaries[dName] + ?: throw BluePrintProcessorException("couldn't get resource dictionary definition for $dName") + val resourceSource = resourceDefinition.sources[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 sql = checkNotNull(sourceProperties.query) { "failed to get request query for $dName under $dSource properties" } + val inputKeyMapping = checkNotNull(sourceProperties.inputKeyMapping) { "failed to get input-key-mappings for $dName under $dSource properties" } + + logger.info("$dSource dictionary information : ($sql), ($inputKeyMapping), (${sourceProperties.outputKeyMapping})") + + val rows = primaryDBLibGenericService.query(sql, populateNamedParameter(inputKeyMapping)) + if (rows.isNullOrEmpty()) { + logger.warn("Failed to get $dSource result for dictionary name ($dName) the query ($sql)") + } else { + processDBResults(resourceAssignment, sourceProperties, rows) + } + + // Check the value has populated for mandatory case + ResourceAssignmentUtils.assertTemplateKeyValueNotNull(resourceAssignment) + } catch (e: Exception) { + ResourceAssignmentUtils.setFailedResourceDataValue(resourceAssignment, e.message) + throw BluePrintProcessorException("Failed in template key ($resourceAssignment) assignments with: ${e.message}", e) + } + } + + @Throws(BluePrintProcessorException::class) + private fun validate(resourceAssignment: ResourceAssignment) { + checkNotEmptyOrThrow(resourceAssignment.name, "resource assignment template key is not defined") + checkNotEmptyOrThrow(resourceAssignment.dictionaryName, "resource assignment dictionary name is not defined for template key (${resourceAssignment.name})") + checkEqualsOrThrow(ResourceDictionaryConstants.SOURCE_PRIMARY_DB, resourceAssignment.dictionarySource) { + "resource assignment source is not ${ResourceDictionaryConstants.SOURCE_PRIMARY_DB} but it is ${resourceAssignment.dictionarySource}" + } + } + + private fun populateNamedParameter(inputKeyMapping: Map<String, String>): Map<String, Any> { + val namedParameters = HashMap<String, Any>() + inputKeyMapping.forEach { + val expressionValue = raRuntimeService.getDictionaryStore(it.value) + logger.trace("Reference dictionary key (${it.key}) resulted in value ($expressionValue)") + namedParameters[it.key] = expressionValue + } + logger.info("Parameter information : ({})", namedParameters) + return namedParameters + } + + @Throws(BluePrintProcessorException::class) + private fun processDBResults(resourceAssignment: ResourceAssignment, sourceProperties: DatabaseResourceSource, rows: List<Map<String, Any>>) { + val dName = resourceAssignment.dictionaryName + val dSource = resourceAssignment.dictionarySource + val type = nullToEmpty(resourceAssignment.property?.type) + + val outputKeyMapping = checkNotNull(sourceProperties.outputKeyMapping) { "failed to get output-key-mappings for $dName under $dSource properties" } + logger.info("Response processing type($type)") + + // Primitive Types + if (BluePrintTypes.validPrimitiveTypes().contains(type)) { + val dbColumnValue = rows[0][outputKeyMapping[dName]] + ResourceAssignmentUtils.setResourceDataValue(resourceAssignment, raRuntimeService, dbColumnValue) + } + // Array Types + else if (BluePrintTypes.validCollectionTypes().contains(type)) { + lateinit var entrySchemaType: String + if (resourceAssignment.property?.entrySchema != null) { + entrySchemaType = nullToEmpty(resourceAssignment.property?.entrySchema?.type) + } + + if (checkNotEmptyOrThrow(entrySchemaType, "Entry schema is not defined for dictionary ($dName) info")) { + val arrayNode = JsonNodeFactory.instance.arrayNode() + rows.forEach { + if (BluePrintTypes.validPrimitiveTypes().contains(entrySchemaType)) { + val dbColumnValue = it[outputKeyMapping[dName]] + // Add Array JSON + JacksonUtils.populatePrimitiveValues(dbColumnValue!!, entrySchemaType, arrayNode) + } else { + val arrayChildNode = JsonNodeFactory.instance.objectNode() + for (mapping in outputKeyMapping.entries) { + val dbColumnValue = checkNotNull(it[mapping.key]) + val propertyTypeForDataType = ResourceAssignmentUtils.getPropertyType(raRuntimeService, entrySchemaType, mapping.key) + JacksonUtils.populatePrimitiveValues(mapping.key, dbColumnValue, propertyTypeForDataType, arrayChildNode) + } + arrayNode.add(arrayChildNode) + } + } + // Set the List of Complex Values + ResourceAssignmentUtils.setResourceDataValue(resourceAssignment, raRuntimeService, arrayNode) + } + } else { + // Complex Types + val row = rows[0] + val objectNode = JsonNodeFactory.instance.objectNode() + for (mapping in outputKeyMapping.entries) { + val dbColumnValue = checkNotNull(row[mapping.key]) + val propertyTypeForDataType = ResourceAssignmentUtils.getPropertyType(raRuntimeService, type, mapping.key) + JacksonUtils.populatePrimitiveValues(mapping.key, dbColumnValue, propertyTypeForDataType, objectNode) + } + ResourceAssignmentUtils.setResourceDataValue(resourceAssignment, raRuntimeService, objectNode) + } } - override fun recover(runtimeException: RuntimeException, executionRequest: ResourceAssignment) { + override fun recover(runtimeException: RuntimeException, resourceAssignment: ResourceAssignment) { } }
\ No newline at end of file diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/ResourceAssignmentProcessor.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/ResourceAssignmentProcessor.kt index 11cd3faa7..43238a530 100644 --- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/ResourceAssignmentProcessor.kt +++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/ResourceAssignmentProcessor.kt @@ -17,9 +17,9 @@ package org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.processor +import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.ResourceAssignmentRuntimeService import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BlueprintFunctionNode -import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDefinition import org.slf4j.LoggerFactory @@ -28,14 +28,12 @@ abstract class ResourceAssignmentProcessor : BlueprintFunctionNode<ResourceAssig private val log = LoggerFactory.getLogger(ResourceAssignmentProcessor::class.java) - lateinit var bluePrintRuntimeService: BluePrintRuntimeService<*> - + lateinit var raRuntimeService: ResourceAssignmentRuntimeService lateinit var resourceDictionaries: Map<String, ResourceDefinition> - open fun resourceDefinition(name: String): ResourceDefinition { return resourceDictionaries[name] - ?: throw BluePrintProcessorException("couldn't get resource definition($name)") + ?: throw BluePrintProcessorException("couldn't get resource definition for ($name)") } override fun prepareRequest(resourceAssignment: ResourceAssignment): ResourceAssignment { diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/utils/ResourceAssignmentUtils.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/utils/ResourceAssignmentUtils.kt new file mode 100644 index 000000000..ee8911ee5 --- /dev/null +++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/utils/ResourceAssignmentUtils.kt @@ -0,0 +1,178 @@ +/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.utils + +import com.att.eelf.configuration.EELFLogger +import com.att.eelf.configuration.EELFManager +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.ObjectMapper +import com.fasterxml.jackson.databind.node.NullNode +import com.fasterxml.jackson.databind.node.ObjectNode +import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.ResourceAssignmentRuntimeService +import org.onap.ccsdk.apps.controllerblueprints.core.* +import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService +import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils +import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment +import java.util.* + +class ResourceAssignmentUtils { + companion object { + + private val logger: EELFLogger = EELFManager.getInstance().getLogger(ResourceAssignmentUtils::class.toString()) + + @Synchronized + @Throws(BluePrintProcessorException::class) + fun setResourceDataValue(resourceAssignment: ResourceAssignment, raRuntimeService: ResourceAssignmentRuntimeService, value: Any?) { + + val resourceProp = checkNotNull(resourceAssignment.property) { "Failed in setting resource value for resource mapping $resourceAssignment" } + checkNotEmptyOrThrow(resourceAssignment.name, "Failed in setting resource value for resource mapping $resourceAssignment") + + if (checkNotEmpty(resourceAssignment.dictionaryName)) { + resourceAssignment.dictionaryName = resourceAssignment.name + logger.warn("Missing dictionary key, setting with template key (${resourceAssignment.name}) as dictionary key (${resourceAssignment.dictionaryName})") + } + + try { + if (checkNotEmpty(resourceProp.type)) { + val convertedValue = convertResourceValue(resourceProp.type, value) + logger.info("Setting Resource Value ($convertedValue) for Resource Name (${resourceAssignment.dictionaryName}) of type (${resourceProp.type})") + setResourceValue(resourceAssignment, raRuntimeService, convertedValue) + resourceAssignment.updatedDate = Date() + resourceAssignment.updatedBy = BluePrintConstants.USER_SYSTEM + resourceAssignment.status = BluePrintConstants.STATUS_SUCCESS + } + } catch (e: Exception) { + throw BluePrintProcessorException("Failed in setting value for template key (${resourceAssignment.name}) and " + + "dictionary key (${resourceAssignment.dictionaryName}) of type (${resourceProp.type}) with error message (${e.message})", e) + } + } + + private fun setResourceValue(resourceAssignment: ResourceAssignment, raRuntimeService: ResourceAssignmentRuntimeService, value: JsonNode) { + raRuntimeService.putResolutionStore(resourceAssignment.name, value) + raRuntimeService.putDictionaryStore(resourceAssignment.dictionaryName!!, value) + resourceAssignment.property!!.value = value + } + + private fun convertResourceValue(type: String, value: Any?): JsonNode { + + return if (value == null || value is NullNode) { + logger.info("Returning {} value from convertResourceValue", value) + NullNode.instance + } else if (BluePrintTypes.validPrimitiveTypes().contains(type) && value is String) { + JacksonUtils.convertPrimitiveResourceValue(type, value) + } else if (value is String) { + JacksonUtils.jsonNode(value) + } else { + JacksonUtils.getJsonNode(value) + } + + } + + @Synchronized + fun setFailedResourceDataValue(resourceAssignment: ResourceAssignment, message: String?) { + if (checkNotEmpty(resourceAssignment.name)) { + resourceAssignment.updatedDate = Date() + resourceAssignment.updatedBy = BluePrintConstants.USER_SYSTEM + resourceAssignment.status = BluePrintConstants.STATUS_FAILURE + resourceAssignment.message = message + } + } + + @Synchronized + @Throws(BluePrintProcessorException::class) + fun assertTemplateKeyValueNotNull(resourceAssignment: ResourceAssignment) { + val resourceProp = checkNotNull(resourceAssignment.property) { "Failed to populate mandatory resource resource mapping $resourceAssignment" } + if (resourceProp.required != null && resourceProp.required!! && (resourceProp.value == null || resourceProp.value !is NullNode)) { + logger.error("failed to populate mandatory resource mapping ($resourceAssignment)") + throw BluePrintProcessorException("failed to populate mandatory resource mapping ($resourceAssignment)") + } + } + + @Synchronized + @Throws(BluePrintProcessorException::class) + fun generateResourceDataForAssignments(assignments: List<ResourceAssignment>): String { + var result = "{}" + try { + val mapper = ObjectMapper() + val root = mapper.readTree(result) + + assignments.forEach { + if (checkNotEmpty(it.name) && it.property != null) { + val rName = it.name + val type = nullToEmpty(it.property?.type).toLowerCase() + val value = it.property?.value + logger.info("Generating Resource name ($rName), type ($type), value ($value)") + + when (value) { + null -> (root as ObjectNode).set(rName, null) + is JsonNode -> (root as ObjectNode).set(rName, value) + else -> { + when (type) { + BluePrintConstants.DATA_TYPE_TIMESTAMP -> (root as ObjectNode).put(rName, value as String) + BluePrintConstants.DATA_TYPE_STRING -> (root as ObjectNode).put(rName, value as String) + BluePrintConstants.DATA_TYPE_BOOLEAN -> (root as ObjectNode).put(rName, value as Boolean) + BluePrintConstants.DATA_TYPE_INTEGER -> (root as ObjectNode).put(rName, value as Int) + BluePrintConstants.DATA_TYPE_FLOAT -> (root as ObjectNode).put(rName, value as Float) + else -> { + if (JacksonUtils.getJsonNode(value) != null) { + (root as ObjectNode).set(rName, JacksonUtils.getJsonNode(value)) + } else { + (root as ObjectNode).set(rName, null) + } + } + } + } + } + } + } + result = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(root) + logger.info("Generated Resource Param Data ($result)") + } catch (e: Exception) { + throw BluePrintProcessorException("Resource Assignment is failed with $e.message", e) + } + + return result + } + + fun transformToRARuntimeService(blueprintRuntimeService: BluePrintRuntimeService<*>, templateArtifactName: String): ResourceAssignmentRuntimeService { + val resourceAssignmentRuntimeService = ResourceAssignmentRuntimeService(blueprintRuntimeService.id(), blueprintRuntimeService.bluePrintContext()) + resourceAssignmentRuntimeService.createUniqueId(templateArtifactName) + resourceAssignmentRuntimeService.setExecutionContext(blueprintRuntimeService.getExecutionContext() as MutableMap<String, JsonNode>) + + return resourceAssignmentRuntimeService + } + + /* + * Populate the Field property type for the Data type + */ + @Synchronized + @Throws(BluePrintProcessorException::class) + fun getPropertyType(raRuntimeService: ResourceAssignmentRuntimeService, dataTypeName: String, propertyName: String): String { + lateinit var type: String + try { + val dataTypeProps = checkNotNull(raRuntimeService.bluePrintContext().dataTypeByName(dataTypeName)?.properties) + val propertyDefinition = checkNotNull(dataTypeProps[propertyName]) + type = returnNotEmptyOrThrow(propertyDefinition.type) { "Couldn't get data type ($dataTypeName)" } + logger.trace("Data type({})'s property ({}) is ({})", dataTypeName, propertyName, type) + } catch (e: Exception) { + logger.error("couldn't get data type($dataTypeName)'s property ($propertyName), error message $e") + throw BluePrintProcessorException("${e.message}", e) + } + return type + } + } +}
\ No newline at end of file diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponentTest.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponentTest.kt index 8adde8639..574d235b4 100644 --- a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponentTest.kt +++ b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponentTest.kt @@ -19,23 +19,36 @@ package org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution import com.fasterxml.jackson.databind.JsonNode import org.junit.Test import org.junit.runner.RunWith +import org.onap.ccsdk.apps.blueprintsprocessor.core.BluePrintProperties +import org.onap.ccsdk.apps.blueprintsprocessor.core.BlueprintPropertyConfiguration import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceInput import org.onap.ccsdk.apps.blueprintsprocessor.core.utils.PayloadUtils +import org.onap.ccsdk.apps.blueprintsprocessor.db.BluePrintDBLibConfiguration +import org.onap.ccsdk.apps.blueprintsprocessor.db.primary.service.PrimaryDBLibGenericService import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.processor.* import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants import org.onap.ccsdk.apps.controllerblueprints.core.asJsonNode +import org.onap.ccsdk.apps.controllerblueprints.core.config.BluePrintLoadConfiguration import org.onap.ccsdk.apps.controllerblueprints.core.putJsonElement import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintMetadataUtils import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils import org.springframework.beans.factory.annotation.Autowired +import org.springframework.boot.autoconfigure.EnableAutoConfiguration +import org.springframework.context.annotation.ComponentScan import org.springframework.test.context.ContextConfiguration +import org.springframework.test.context.TestPropertySource import org.springframework.test.context.junit4.SpringRunner @RunWith(SpringRunner::class) -@ContextConfiguration(classes = [ResourceResolutionComponent::class, ResourceResolutionService::class, +@ContextConfiguration(classes = [ResourceResolutionService::class, InputResourceAssignmentProcessor::class, DefaultResourceAssignmentProcessor::class, PrimaryDataResourceAssignmentProcessor::class, SimpleRestResourceAssignmentProcessor::class, - CapabilityResourceAssignmentProcessor::class]) + CapabilityResourceAssignmentProcessor::class, PrimaryDBLibGenericService::class, + BlueprintPropertyConfiguration::class, BluePrintProperties::class, + BluePrintDBLibConfiguration::class, BluePrintLoadConfiguration::class]) +@TestPropertySource(locations = ["classpath:application-test.properties"]) +@ComponentScan(basePackages = ["org.onap.ccsdk.apps.blueprintsprocessor", "org.onap.ccsdk.apps.controllerblueprints"]) +@EnableAutoConfiguration class ResourceResolutionComponentTest { @Autowired diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionServiceTest.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionServiceTest.kt index 6c6867532..9a846d698 100644 --- a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionServiceTest.kt +++ b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionServiceTest.kt @@ -19,14 +19,22 @@ package org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution import org.junit.Assert import org.junit.Test import org.junit.runner.RunWith +import org.onap.ccsdk.apps.blueprintsprocessor.core.BluePrintProperties +import org.onap.ccsdk.apps.blueprintsprocessor.core.BlueprintPropertyConfiguration import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceInput import org.onap.ccsdk.apps.blueprintsprocessor.core.utils.PayloadUtils +import org.onap.ccsdk.apps.blueprintsprocessor.db.BluePrintDBLibConfiguration +import org.onap.ccsdk.apps.blueprintsprocessor.db.primary.service.PrimaryDBLibGenericService import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.processor.* +import org.onap.ccsdk.apps.controllerblueprints.core.config.BluePrintLoadConfiguration import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintMetadataUtils import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils import org.slf4j.LoggerFactory import org.springframework.beans.factory.annotation.Autowired +import org.springframework.boot.autoconfigure.EnableAutoConfiguration +import org.springframework.context.annotation.ComponentScan import org.springframework.test.context.ContextConfiguration +import org.springframework.test.context.TestPropertySource import org.springframework.test.context.junit4.SpringRunner import kotlin.test.assertNotNull import kotlin.test.assertTrue @@ -40,7 +48,12 @@ import kotlin.test.assertTrue @ContextConfiguration(classes = [ResourceResolutionService::class, InputResourceAssignmentProcessor::class, DefaultResourceAssignmentProcessor::class, PrimaryDataResourceAssignmentProcessor::class, SimpleRestResourceAssignmentProcessor::class, - CapabilityResourceAssignmentProcessor::class]) + CapabilityResourceAssignmentProcessor::class, PrimaryDBLibGenericService::class, + BlueprintPropertyConfiguration::class, BluePrintProperties::class, + BluePrintDBLibConfiguration::class, BluePrintLoadConfiguration::class]) +@TestPropertySource(locations = ["classpath:application-test.properties"]) +@ComponentScan(basePackages = ["org.onap.ccsdk.apps.blueprintsprocessor", "org.onap.ccsdk.apps.controllerblueprints"]) +@EnableAutoConfiguration class ResourceResolutionServiceTest { private val log = LoggerFactory.getLogger(ResourceResolutionServiceTest::class.java) @@ -48,7 +61,6 @@ class ResourceResolutionServiceTest { @Autowired lateinit var resourceResolutionService: ResourceResolutionService - @Test fun testRegisteredSource() { val sources = resourceResolutionService.registeredResourceSources() diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/application-test.properties b/ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/application-test.properties new file mode 100644 index 000000000..aed61c466 --- /dev/null +++ b/ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/application-test.properties @@ -0,0 +1,32 @@ +# suppress inspection "UnusedProperty" for whole file +# +# Copyright © 2017-2018 AT&T Intellectual Property. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +blueprintsprocessor.db.primary.url=jdbc:h2:mem:testdb;DB_CLOSE_ON_EXIT=FALSE +blueprintsprocessor.db.primary.username=sa +blueprintsprocessor.db.primary.password= +blueprintsprocessor.db.primary.driverClassName=org.h2.Driver +blueprintsprocessor.db.primary.hibernateHbm2ddlAuto=create-drop +blueprintsprocessor.db.primary.hibernateDDLAuto=update +blueprintsprocessor.db.primary.hibernateNamingStrategy=org.hibernate.cfg.ImprovedNamingStrategy +blueprintsprocessor.db.primary.hibernateDialect=org.hibernate.dialect.H2Dialect +# Controller Blueprints Core Configuration +blueprintsprocessor.blueprintDeployPath=./target/blueprints/deploy +blueprintsprocessor.blueprintArchivePath=./target/blueprints/archive + +blueprintsprocessor.restclient.primary-config-data.type=basic-auth +blueprintsprocessor.restclient.primary-config-data.url=http://127.0.0.1:9111 +blueprintsprocessor.restclient.primary-config-data.userId=sampleuser +blueprintsprocessor.restclient.primary-config-data.token=sampletoken
\ No newline at end of file |