diff options
85 files changed, 2007 insertions, 679 deletions
@@ -16,4 +16,14 @@ **/*versionsBackup
**/blackDuckHub*
-**/*.jsonld
\ No newline at end of file +**/*.jsonld
+**/.checkstyle
+**/.gitignore
+**/.gitignore
+**/.gitignore
+**/.gitignore
+**/.gitignore
+**/.gitignore
+**/.gitignore
+**/.gitignore
+
diff --git a/components/core/load/blueprints/baseconfiguration/Definitions/activation-blueprint.json b/components/core/load/blueprints/baseconfiguration/Definitions/activation-blueprint.json index 9c70d6ea..bc10f767 100644 --- a/components/core/load/blueprints/baseconfiguration/Definitions/activation-blueprint.json +++ b/components/core/load/blueprints/baseconfiguration/Definitions/activation-blueprint.json @@ -66,8 +66,8 @@ }
},
"outputs": {
- "resource-assignment-params": "success",
- "status": "status"
+ "resource-assignment-params": { "get_attribute" : ["SELF", "params"] },
+ "status": "Success"
}
}
}
diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintTypes.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintTypes.kt index e25b3eea..a971898d 100644 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintTypes.kt +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintTypes.kt @@ -16,6 +16,8 @@ package org.onap.ccsdk.apps.controllerblueprints.core
+import org.onap.ccsdk.apps.controllerblueprints.core.data.PropertyDefinition
+
/**
*
*
@@ -104,6 +106,7 @@ object BluePrintTypes { validTypes.add(BluePrintConstants.DATA_TYPE_TIMESTAMP)
validTypes.add(BluePrintConstants.DATA_TYPE_NULL)
validTypes.add(BluePrintConstants.DATA_TYPE_LIST)
+ validTypes.add(BluePrintConstants.DATA_TYPE_MAP)
return validTypes
}
@@ -128,6 +131,13 @@ object BluePrintTypes { }
@JvmStatic
+ fun validPrimitiveOrCollectionPrimitive(propertyDefinition: PropertyDefinition): Boolean {
+ val entrySchema = propertyDefinition.entrySchema?.type ?: BluePrintConstants.DATA_TYPE_NULL
+ return BluePrintTypes.validPropertyTypes().contains(propertyDefinition.type)
+ && BluePrintTypes.validPrimitiveTypes().contains(entrySchema)
+ }
+
+ @JvmStatic
fun validCommands(): List<String> {
return listOf(BluePrintConstants.EXPRESSION_GET_INPUT,
BluePrintConstants.EXPRESSION_GET_ATTRIBUTE,
diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/factory/BluePrintEnhancerFactory.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/factory/BluePrintEnhancerFactory.kt deleted file mode 100644 index d796597b..00000000 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/factory/BluePrintEnhancerFactory.kt +++ /dev/null @@ -1,45 +0,0 @@ -/*
- * 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.controllerblueprints.core.factory
-
-import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintEnhancerService
-import com.att.eelf.configuration.EELFLogger
-import com.att.eelf.configuration.EELFManager
-
-
-/**
- * BluePrintEnhancerFactory
- * @author Brinda Santh
- *
- */
-
-object BluePrintEnhancerFactory {
- private val log: EELFLogger = EELFManager.getInstance().getLogger(this::class.toString())
-
- var bluePrintEnhancerServices: MutableMap<String, BluePrintEnhancerService> = HashMap()
-
- fun register(key: String, bluePrintEnhancerService: BluePrintEnhancerService) {
- bluePrintEnhancerServices[key] = bluePrintEnhancerService
- }
-
- /**
- * Called by clients to get a Blueprint Parser for the Blueprint parser type
- */
- fun instance(key: String): BluePrintEnhancerService? {
- return bluePrintEnhancerServices.get(key)
- }
-}
diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintContext.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintContext.kt index 875cbea6..46da9d95 100644 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintContext.kt +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintContext.kt @@ -71,7 +71,7 @@ class BluePrintContext(serviceTemplate: ServiceTemplate) { }
fun nodeTypeInterface(nodeTypeName: String, interfaceName: String): InterfaceDefinition? {
- return nodeTypeByName(nodeTypeName).interfaces?.values?.first()
+ return nodeTypeByName(nodeTypeName).interfaces?.get(interfaceName)
}
fun nodeTypeInterfaceOperation(nodeTypeName: String, interfaceName: String, operationName: String): OperationDefinition? {
@@ -155,9 +155,9 @@ class BluePrintContext(serviceTemplate: ServiceTemplate) { }
fun nodeTemplateRequirementNode(nodeTemplateName: String, requirementName: String): NodeTemplate {
- val nodeTemplateName: String = nodeTemplateByName(nodeTemplateName).requirements?.get(requirementName)?.node
+ val requirementNodeTemplateName: String = nodeTemplateByName(nodeTemplateName).requirements?.get(requirementName)?.node
?: throw BluePrintException(String.format("failed to get node name for node template's (%s) requirement's (%s) " + nodeTemplateName, requirementName))
- return nodeTemplateByName(nodeTemplateName)
+ return nodeTemplateByName(requirementNodeTemplateName)
}
fun nodeTemplateCapabilityProperty(nodeTemplateName: String, capabilityName: String, propertyName: String): Any? {
diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintExpressionService.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintExpressionService.kt index 82e232d0..6a50680e 100644 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintExpressionService.kt +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintExpressionService.kt @@ -99,7 +99,7 @@ object BluePrintExpressionService { arrayNode.size() > 3 -> {
reqOrCapEntityName = arrayNode[1].textValue()
propertyName = arrayNode[2].textValue()
- val propertyPaths: List<String> = arrayNode.filterIndexed { index, obj ->
+ val propertyPaths: List<String> = arrayNode.filterIndexed { index, _ ->
index >= 3
}.map { it.textValue() }
subProperty = propertyPaths.joinToString("/")
diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRepoService.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRepoService.kt index a7c14adf..dec7a50d 100644 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRepoService.kt +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRepoService.kt @@ -35,19 +35,19 @@ import java.io.Serializable interface BluePrintRepoService : Serializable {
@Throws(BluePrintException::class)
- fun getNodeType(nodeTypeName: String): Mono<NodeType>?
+ fun getNodeType(nodeTypeName: String): Mono<NodeType>
@Throws(BluePrintException::class)
- fun getDataType(dataTypeName: String): Mono<DataType>?
+ fun getDataType(dataTypeName: String): Mono<DataType>
@Throws(BluePrintException::class)
- fun getArtifactType(artifactTypeName: String): Mono<ArtifactType>?
+ fun getArtifactType(artifactTypeName: String): Mono<ArtifactType>
@Throws(BluePrintException::class)
- fun getRelationshipType(relationshipTypeName: String): Mono<RelationshipType>?
+ fun getRelationshipType(relationshipTypeName: String): Mono<RelationshipType>
@Throws(BluePrintException::class)
- fun getCapabilityDefinition(capabilityDefinitionName: String): Mono<CapabilityDefinition>?
+ fun getCapabilityDefinition(capabilityDefinitionName: String): Mono<CapabilityDefinition>
}
@@ -63,30 +63,30 @@ open class BluePrintRepoFileService(modelTypePath: String) : BluePrintRepoServic private val relationshipTypePath = modelTypePath.plus(BluePrintConstants.PATH_DIVIDER).plus(BluePrintConstants.MODEL_DEFINITION_TYPE_RELATIONSHIP_TYPE)
private val extension = ".json"
- override fun getDataType(dataTypeName: String): Mono<DataType>? {
+ override fun getDataType(dataTypeName: String): Mono<DataType> {
val fileName = dataTypePath.plus(BluePrintConstants.PATH_DIVIDER)
.plus(dataTypeName).plus(extension)
return getModelType(fileName, DataType::class.java)
}
- override fun getNodeType(nodeTypeName: String): Mono<NodeType>? {
+ override fun getNodeType(nodeTypeName: String): Mono<NodeType> {
val fileName = nodeTypePath.plus(BluePrintConstants.PATH_DIVIDER).plus(nodeTypeName).plus(extension)
return getModelType(fileName, NodeType::class.java)
}
- override fun getArtifactType(artifactTypeName: String): Mono<ArtifactType>? {
+ override fun getArtifactType(artifactTypeName: String): Mono<ArtifactType> {
val fileName = artifactTypePath.plus(BluePrintConstants.PATH_DIVIDER)
.plus(artifactTypeName).plus(extension)
return getModelType(fileName, ArtifactType::class.java)
}
- override fun getRelationshipType(relationshipTypeName: String): Mono<RelationshipType>? {
+ override fun getRelationshipType(relationshipTypeName: String): Mono<RelationshipType> {
val fileName = relationshipTypePath.plus(BluePrintConstants.PATH_DIVIDER)
.plus(relationshipTypeName).plus(extension)
return getModelType(fileName, RelationshipType::class.java)
}
- override fun getCapabilityDefinition(capabilityDefinitionName: String): Mono<CapabilityDefinition>? {
+ override fun getCapabilityDefinition(capabilityDefinitionName: String): Mono<CapabilityDefinition> {
val fileName = capabilityTypePath.plus(BluePrintConstants.PATH_DIVIDER)
.plus(capabilityDefinitionName).plus(extension)
return getModelType(fileName, CapabilityDefinition::class.java)
diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeService.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeService.kt index ce0bceee..2485abdb 100644 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeService.kt +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeService.kt @@ -29,6 +29,9 @@ import org.onap.ccsdk.apps.controllerblueprints.core.data.PropertyDefinition import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils
import com.att.eelf.configuration.EELFLogger
import com.att.eelf.configuration.EELFManager
+import com.fasterxml.jackson.databind.node.ObjectNode
+import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
+
/**
*
*
@@ -78,8 +81,8 @@ open class BluePrintRuntimeService(var bluePrintContext: BluePrintContext, var c }
open fun resolveNodeTemplateInterfaceOperationInputs(nodeTemplateName: String,
- interfaceName: String, operationName: String): MutableMap<String, Any?> {
- log.info("nodeTemplateInterfaceOperationInputsResolvedExpression for node template ({}),interface name ({}), " +
+ interfaceName: String, operationName: String): MutableMap<String, Any?> {
+ log.info("resolveNodeTemplateInterfaceOperationInputs for node template ({}),interface name ({}), " +
"operationName({})", nodeTemplateName, interfaceName, operationName)
val propertyAssignmentValue: MutableMap<String, Any?> = hashMapOf()
@@ -117,17 +120,25 @@ open class BluePrintRuntimeService(var bluePrintContext: BluePrintContext, var c // Set for Return of method
propertyAssignmentValue[nodeTypePropertyName] = resolvedValue
}
- log.info("resolved input assignments for node template ({}), values ({})", nodeTemplateName, propertyAssignmentValue)
+ log.trace("resolved input assignments for node template ({}), values ({})", nodeTemplateName,
+ propertyAssignmentValue)
return propertyAssignmentValue
}
open fun resolveNodeTemplateInterfaceOperationOutputs(nodeTemplateName: String,
- interfaceName: String, operationName: String, componentContext: MutableMap<String, Any?>) {
- log.info("nodeTemplateInterfaceOperationInputsResolvedExpression for node template ({}),interface name ({}), " +
+ interfaceName: String, operationName: String): MutableMap<String, Any?> {
+ log.info("resolveNodeTemplateInterfaceOperationOutputs for node template ({}),interface name ({}), " +
"operationName({})", nodeTemplateName, interfaceName, operationName)
+ val propertyAssignmentValue: MutableMap<String, Any?> = hashMapOf()
+
+ val propertyAssignments: MutableMap<String, Any> =
+ bluePrintContext.nodeTemplateInterfaceOperationOutputs(nodeTemplateName, interfaceName, operationName) as? MutableMap<String, Any>
+ ?: throw BluePrintException(String.format("failed to get output definitions for node template (%s), " +
+ "interface name (%s), operationName(%s)", nodeTemplateName, interfaceName, operationName))
+
val nodeTypeName = bluePrintContext.nodeTemplateByName(nodeTemplateName).type
val nodeTypeInterfaceOperationOutputs: MutableMap<String, PropertyDefinition> =
@@ -138,21 +149,32 @@ open class BluePrintRuntimeService(var bluePrintContext: BluePrintContext, var c // Iterate Node Type Properties
nodeTypeInterfaceOperationOutputs.forEach { nodeTypePropertyName, nodeTypeProperty ->
- val operationOutputPropertyName: String = StringBuilder().append(nodeTemplateName)
- .append(".").append(interfaceName)
- .append(".").append(operationName)
- .append(".").append(nodeTypePropertyName).toString()
- // Get the Value from component context
- val resolvedValue: JsonNode = componentContext[operationOutputPropertyName] as? JsonNode
- ?: NullNode.getInstance()
+ // Get the Express or Value for the Node Template
+ val propertyAssignment: Any? = propertyAssignments[nodeTypePropertyName]
+
+ var resolvedValue: JsonNode = NullNode.getInstance()
+ if (propertyAssignment != null) {
+ // Resolve the Expressing
+ val propertyAssignmentExpression = PropertyAssignmentService(context, this)
+ resolvedValue = propertyAssignmentExpression.resolveAssignmentExpression(nodeTemplateName, nodeTypePropertyName, propertyAssignment)
+ } else {
+ // Assign default value to the Operation
+ nodeTypeProperty.defaultValue?.let {
+ resolvedValue = JacksonUtils.jsonNodeFromObject(nodeTypeProperty.defaultValue!!)
+ }
+ }
+ // Set for Return of method
+ propertyAssignmentValue[nodeTypePropertyName] = resolvedValue
+
// Store operation output values into context
- setNodeTemplateOperationPropertyValue(nodeTemplateName, interfaceName, operationName, nodeTypePropertyName, resolvedValue)
- log.debug("resolved output assignments for node template ({}), property name ({}), value ({})", nodeTemplateName, nodeTypePropertyName, resolvedValue)
+ setNodeTemplateOperationOutputValue(nodeTemplateName, interfaceName, operationName, nodeTypePropertyName, resolvedValue)
+ log.trace("resolved output assignments for node template ({}), property name ({}), value ({})", nodeTemplateName, nodeTypePropertyName, resolvedValue)
}
+ return propertyAssignmentValue
}
open fun resolveNodeTemplateArtifact(nodeTemplateName: String,
- artifactName: String): String {
+ artifactName: String): String {
val nodeTemplate = bluePrintContext.nodeTemplateByName(nodeTemplateName)
val artifactDefinition: ArtifactDefinition = nodeTemplate.artifacts?.get(artifactName)
@@ -186,8 +208,16 @@ open class BluePrintRuntimeService(var bluePrintContext: BluePrintContext, var c context[path] = value
}
+ open fun setNodeTemplateAttributeValue(nodeTemplateName: String, attributeName: String, value: JsonNode) {
+
+ val path: String = StringBuilder(BluePrintConstants.PATH_NODE_TEMPLATES).append(BluePrintConstants.PATH_DIVIDER).append(nodeTemplateName)
+ .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_ATTRIBUTES)
+ .append(BluePrintConstants.PATH_DIVIDER).append(attributeName).toString()
+ context[path] = value
+ }
+
open fun setNodeTemplateOperationPropertyValue(nodeTemplateName: String, interfaceName: String, operationName: String, propertyName: String,
- value: JsonNode) {
+ value: JsonNode) {
val path: String = StringBuilder(BluePrintConstants.PATH_NODE_TEMPLATES).append(BluePrintConstants.PATH_DIVIDER).append(nodeTemplateName)
.append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_INTERFACES).append(BluePrintConstants.PATH_DIVIDER).append(interfaceName)
.append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_OPERATIONS).append(BluePrintConstants.PATH_DIVIDER).append(operationName)
@@ -198,10 +228,10 @@ open class BluePrintRuntimeService(var bluePrintContext: BluePrintContext, var c }
open fun setNodeTemplateOperationInputValue(nodeTemplateName: String, interfaceName: String, operationName: String, propertyName: String,
- value: JsonNode) {
+ value: JsonNode) {
val path: String = StringBuilder(BluePrintConstants.PATH_NODE_TEMPLATES).append(BluePrintConstants.PATH_DIVIDER).append(nodeTemplateName)
- .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_INTERFACES).append(interfaceName)
- .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_OPERATIONS).append(operationName)
+ .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_INTERFACES).append(BluePrintConstants.PATH_DIVIDER).append(interfaceName)
+ .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_OPERATIONS).append(BluePrintConstants.PATH_DIVIDER).append(operationName)
.append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_INPUTS)
.append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_PROPERTIES)
.append(BluePrintConstants.PATH_DIVIDER).append(propertyName).toString()
@@ -209,10 +239,10 @@ open class BluePrintRuntimeService(var bluePrintContext: BluePrintContext, var c }
open fun setNodeTemplateOperationOutputValue(nodeTemplateName: String, interfaceName: String, operationName: String, propertyName: String,
- value: JsonNode) {
+ value: JsonNode) {
val path: String = StringBuilder(BluePrintConstants.PATH_NODE_TEMPLATES).append(BluePrintConstants.PATH_DIVIDER).append(nodeTemplateName)
- .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_INTERFACES).append(interfaceName)
- .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_OPERATIONS).append(operationName)
+ .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_INTERFACES).append(BluePrintConstants.PATH_DIVIDER).append(interfaceName)
+ .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_OPERATIONS).append(BluePrintConstants.PATH_DIVIDER).append(operationName)
.append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_OUTPUTS)
.append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_PROPERTIES)
.append(BluePrintConstants.PATH_DIVIDER).append(propertyName).toString()
@@ -230,19 +260,27 @@ open class BluePrintRuntimeService(var bluePrintContext: BluePrintContext, var c val path: String = StringBuilder(BluePrintConstants.PATH_NODE_TEMPLATES).append(BluePrintConstants.PATH_DIVIDER).append(nodeTemplateName)
.append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_INTERFACES).append(BluePrintConstants.PATH_DIVIDER).append(interfaceName)
.append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_OPERATIONS).append(BluePrintConstants.PATH_DIVIDER).append(operationName)
- .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_PROPERTIES)
+ .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_OUTPUTS).append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_PROPERTIES)
.append(BluePrintConstants.PATH_DIVIDER).append(propertyName).toString()
return context[path] as JsonNode
}
- open fun getPropertyValue(nodeTemplateName: String, propertyName: String): JsonNode? {
+ open fun getNodeTemplatePropertyValue(nodeTemplateName: String, propertyName: String): JsonNode? {
val path: String = StringBuilder(BluePrintConstants.PATH_NODE_TEMPLATES).append(BluePrintConstants.PATH_DIVIDER).append(nodeTemplateName)
.append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_PROPERTIES)
.append(BluePrintConstants.PATH_DIVIDER).append(propertyName).toString()
return context[path] as JsonNode
}
- open fun getRequirementPropertyValue(nodeTemplateName: String, requirementName: String, propertyName: String): JsonNode? {
+ open fun getNodeTemplateAttributeValue(nodeTemplateName: String, attributeName: String): JsonNode? {
+ val path: String = StringBuilder(BluePrintConstants.PATH_NODE_TEMPLATES).append(BluePrintConstants.PATH_DIVIDER).append(nodeTemplateName)
+ .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_ATTRIBUTES)
+ .append(BluePrintConstants.PATH_DIVIDER).append(attributeName).toString()
+ return context[path] as JsonNode
+ }
+
+ open fun getNodeTemplateRequirementPropertyValue(nodeTemplateName: String, requirementName: String, propertyName:
+ String): JsonNode? {
val path: String = StringBuilder(BluePrintConstants.PATH_NODE_TEMPLATES).append(BluePrintConstants.PATH_DIVIDER).append(nodeTemplateName)
.append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_REQUIREMENTS).append(requirementName)
.append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_PROPERTIES)
@@ -250,7 +288,8 @@ open class BluePrintRuntimeService(var bluePrintContext: BluePrintContext, var c return context[path] as JsonNode
}
- open fun getCapabilityPropertyValue(nodeTemplateName: String, capabilityName: String, propertyName: String): JsonNode? {
+ open fun getNodeTemplateCapabilityPropertyValue(nodeTemplateName: String, capabilityName: String, propertyName:
+ String): JsonNode? {
val path: String = StringBuilder(BluePrintConstants.PATH_NODE_TEMPLATES).append(BluePrintConstants.PATH_DIVIDER).append(nodeTemplateName)
.append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_CAPABILITIES).append(capabilityName)
.append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_PROPERTIES)
@@ -269,10 +308,30 @@ open class BluePrintRuntimeService(var bluePrintContext: BluePrintContext, var c open fun assignWorkflowInputs(workflowName: String, jsonNode: JsonNode) {
log.info("assign workflow {} input value ({})", workflowName, jsonNode.toString())
- bluePrintContext.workflowByName(workflowName)?.inputs?.forEach { propertyName, property ->
+ bluePrintContext.workflowByName(workflowName)?.inputs?.forEach { propertyName, _ ->
val valueNode: JsonNode = jsonNode.at(BluePrintConstants.PATH_DIVIDER + propertyName)
?: NullNode.getInstance()
setWorkflowInputValue(workflowName, propertyName, valueNode)
}
}
+
+ open fun getJsonForNodeTemplateAttributeProperties(nodeTemplateName: String, keys: List<String>): JsonNode {
+
+ val jsonNode: ObjectNode = jacksonObjectMapper().createObjectNode()
+ val path: String = StringBuilder(BluePrintConstants.PATH_NODE_TEMPLATES).append(BluePrintConstants.PATH_DIVIDER).append(nodeTemplateName)
+ .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_ATTRIBUTES)
+ .append(BluePrintConstants.PATH_DIVIDER).toString()
+ context.keys.filter {
+ it.startsWith(path)
+ }.map {
+ val key = it.replace(path, "")
+ if (keys.contains(key)) {
+ val value = context[it] as JsonNode
+ jsonNode.set(key, value)
+ }
+ }
+ return jsonNode
+ }
+
+
}
\ No newline at end of file diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintValidatorService.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintValidatorService.kt index 3bea59f9..7ad38332 100644 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintValidatorService.kt +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintValidatorService.kt @@ -236,7 +236,7 @@ open class BluePrintValidatorDefaultService : BluePrintValidatorService { message.appendln("---> Workflow :" + paths.joinToString(separator))
// Step Validation Start
paths.add("steps")
- workflow.steps?.forEach { stepName, step ->
+ workflow.steps?.forEach { stepName, _ ->
paths.add(stepName)
message.appendln("----> Steps :" + paths.joinToString(separator))
paths.removeAt(paths.lastIndex)
@@ -583,10 +583,10 @@ open class BluePrintValidatorDefaultService : BluePrintValidatorService { }
}
- private fun checkPropertyDataType(dataType: String, propertyName: String) {
+ private fun checkPropertyDataType(dataTypeName: String, propertyName: String) {
- val dataType = serviceTemplate.dataTypes?.get(dataType)
- ?: throw BluePrintException(format("DataType ({}) for the property ({}) not found", dataType, propertyName))
+ val dataType = serviceTemplate.dataTypes?.get(dataTypeName)
+ ?: throw BluePrintException(format("DataType ({}) for the property ({}) not found", dataTypeName, propertyName))
checkValidDataTypeDerivedFrom(propertyName, dataType.derivedFrom)
@@ -596,7 +596,7 @@ open class BluePrintValidatorDefaultService : BluePrintValidatorService { if (BluePrintTypes.validPrimitiveTypes().contains(dataType) || checkDataType(dataType)) {
return true
} else {
- throw BluePrintException(format("DataType ({}) for the property ({}) is not valid", dataType))
+ throw BluePrintException(format("DataType({}) for the property({}) is not valid", dataType, propertyName))
}
}
diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/PropertyAssignmentService.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/PropertyAssignmentService.kt index ece09d6e..131bb30a 100644 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/PropertyAssignmentService.kt +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/PropertyAssignmentService.kt @@ -20,6 +20,7 @@ package org.onap.ccsdk.apps.controllerblueprints.core.service import com.fasterxml.jackson.databind.JsonNode
import com.fasterxml.jackson.databind.node.NullNode
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException
import org.onap.ccsdk.apps.controllerblueprints.core.data.*
import org.onap.ccsdk.apps.controllerblueprints.core.format
@@ -27,6 +28,7 @@ import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils import org.onap.ccsdk.apps.controllerblueprints.core.utils.ResourceResolverUtils
import com.att.eelf.configuration.EELFLogger
import com.att.eelf.configuration.EELFManager
+
/**
*
*
@@ -42,11 +44,11 @@ class PropertyAssignmentService(var context: MutableMap<String, Any>, If Property Assignment is Expression.
Get the Expression
- Recurssely resolve the expression
+ Recursively resolve the expression
*/
fun resolveAssignmentExpression(nodeTemplateName: String, assignmentName: String,
- assignment: Any): JsonNode {
+ assignment: Any): JsonNode {
val valueNode: JsonNode
log.trace("Assignment ({})", assignment)
val expressionData = BluePrintExpressionService.getExpressionData(assignment)
@@ -63,30 +65,30 @@ If Property Assignment is Expression. var valueNode: JsonNode = NullNode.getInstance()
- if(expressionData.isExpression) {
+ if (expressionData.isExpression) {
val command = expressionData.command!!
- when(command){
- org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants.EXPRESSION_GET_INPUT ->{
+ when (command) {
+ BluePrintConstants.EXPRESSION_GET_INPUT -> {
valueNode = bluePrintRuntimeService.getInputValue(expressionData.inputExpression?.propertyName!!)
}
- org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants.EXPRESSION_GET_ATTRIBUTE ->{
+ BluePrintConstants.EXPRESSION_GET_ATTRIBUTE -> {
valueNode = resolveAttributeExpression(nodeTemplateName, expressionData.attributeExpression!!)
}
- org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants.EXPRESSION_GET_PROPERTY ->{
+ BluePrintConstants.EXPRESSION_GET_PROPERTY -> {
valueNode = resolvePropertyExpression(nodeTemplateName, expressionData.propertyExpression!!)
}
- org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants.EXPRESSION_GET_OPERATION_OUTPUT ->{
+ BluePrintConstants.EXPRESSION_GET_OPERATION_OUTPUT -> {
valueNode = resolveOperationOutputExpression(nodeTemplateName, expressionData.operationOutputExpression!!)
}
- org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants.EXPRESSION_GET_ARTIFACT ->{
+ BluePrintConstants.EXPRESSION_GET_ARTIFACT -> {
valueNode = resolveArtifactExpression(nodeTemplateName, expressionData.artifactExpression!!)
}
- org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants.EXPRESSION_GET_NODE_OF_TYPE ->{
+ BluePrintConstants.EXPRESSION_GET_NODE_OF_TYPE -> {
}
- else ->{
- throw BluePrintException(String.format("for property ({}), command ({}) is not supported ", propName, command))
+ else -> {
+ throw BluePrintException(format("for property ({}), command ({}) is not supported ", propName, command))
}
}
}
@@ -104,20 +106,30 @@ If Property Assignment is Expression. val subAttributeName: String? = attributeExpression.subAttributeName
var attributeNodeTemplateName = nodeTemplateName
- if (!attributeExpression.modelableEntityName.equals("SELF", true)) {
- attributeNodeTemplateName = attributeExpression.modelableEntityName
- }
-
- val nodeTemplateAttributeExpression = bluePrintContext.nodeTemplateByName(attributeNodeTemplateName).attributes?.get(attributeName)
- ?: throw BluePrintException(String.format("failed to get property definitions for node template ({})'s property name ({}) ", nodeTemplateName, attributeName))
+ when (attributeExpression.modelableEntityName) {
+ "ENV" -> {
+ val environmentValue = System.getProperty(attributeName)
+ valueNode = JacksonUtils.jsonNode(environmentValue)
+ }
+ else -> {
+ if (!attributeExpression.modelableEntityName.equals("SELF", true)) {
+ attributeNodeTemplateName = attributeExpression.modelableEntityName
+ }
+ /* Enable in ONAP Dublin Release
+ val nodeTemplateAttributeExpression = bluePrintContext.nodeTemplateByName(attributeNodeTemplateName).attributes?.get(attributeName)
+ ?: throw BluePrintException(format("failed to get attribute definitions for node template " +
+ "({})'s property name ({}) ", nodeTemplateName, attributeName))
- var propertyDefinition: AttributeDefinition = bluePrintContext.nodeTemplateNodeType(attributeNodeTemplateName).attributes?.get(attributeName)!!
+ var attributeDefinition: AttributeDefinition = bluePrintContext.nodeTemplateNodeType(attributeNodeTemplateName).attributes?.get(attributeName)!!
- log.info("node template name ({}), property Name ({}) resolved value ({})", attributeNodeTemplateName, attributeName, nodeTemplateAttributeExpression)
+ log.info("node template name ({}), property Name ({}) resolved value ({})", attributeNodeTemplateName, attributeName, nodeTemplateAttributeExpression)
+ */
- // Check it it is a nested expression
- valueNode = resolveAssignmentExpression(attributeNodeTemplateName, attributeName, nodeTemplateAttributeExpression)
+ valueNode = bluePrintRuntimeService.getNodeTemplateAttributeValue(attributeNodeTemplateName, attributeName)
+ ?: throw BluePrintException(format("failed to get node template ({})'s attribute ({}) ", nodeTemplateName, attributeName))
+ }
+ }
// subPropertyName?.let {
// valueNode = valueNode.at(JsonPointer.valueOf(subPropertyName))
// }
@@ -171,7 +183,7 @@ If Property Assignment is Expression. /*
get_artifact: [ <modelable_entity_name>, <artifact_name>, <location>, <remove> ]
*/
- fun resolveArtifactExpression(nodeTemplateName: String, artifactExpression: ArtifactExpression): JsonNode {
+ fun resolveArtifactExpression(nodeTemplateName: String, artifactExpression: ArtifactExpression): JsonNode {
var artifactNodeTemplateName = nodeTemplateName
if (!artifactExpression.modelableEntityName.equals("SELF", true)) {
@@ -179,15 +191,15 @@ If Property Assignment is Expression. }
val artifactDefinition: ArtifactDefinition = bluePrintContext.nodeTemplateByName(artifactNodeTemplateName)
.artifacts?.get(artifactExpression.artifactName)
- ?: throw BluePrintException(String.format("failed to get artifact definitions for node template ({})'s " +
+ ?: throw BluePrintException(format("failed to get artifact definitions for node template ({})'s " +
"artifact name ({}) ", nodeTemplateName, artifactExpression.artifactName))
return JacksonUtils.jsonNodeFromObject(artifactContent(artifactDefinition))
}
fun artifactContent(artifactDefinition: ArtifactDefinition): String {
- val bluePrintBasePath: String = context[org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants.PROPERTY_BLUEPRINT_BASE_PATH] as? String
- ?: throw BluePrintException(String.format("failed to get property (%s) from context", org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants.PROPERTY_BLUEPRINT_BASE_PATH))
+ val bluePrintBasePath: String = context[BluePrintConstants.PROPERTY_BLUEPRINT_BASE_PATH] as? String
+ ?: throw BluePrintException(format("failed to get property (%s) from context", BluePrintConstants.PROPERTY_BLUEPRINT_BASE_PATH))
if (artifactDefinition.repository != null) {
TODO()
diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintRuntimeUtils.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintRuntimeUtils.kt index 07b819ff..0e4c3e3e 100644 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintRuntimeUtils.kt +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintRuntimeUtils.kt @@ -43,7 +43,7 @@ object BluePrintRuntimeUtils { fun assignInputs(bluePrintContext: BluePrintContext, jsonNode: JsonNode, context: MutableMap<String, Any>) {
log.info("assignInputs from input JSON ({})", jsonNode.toString())
- bluePrintContext.inputs?.forEach { propertyName, property ->
+ bluePrintContext.inputs?.forEach { propertyName, _ ->
val valueNode: JsonNode = jsonNode.at("/".plus(propertyName)) ?: NullNode.getInstance()
val path = BluePrintConstants.PATH_INPUTS.plus(BluePrintConstants.PATH_DIVIDER).plus(propertyName)
diff --git a/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintEnhancerServiceTest.kt b/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintEnhancerServiceTest.kt deleted file mode 100644 index 8e6d5efd..00000000 --- a/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintEnhancerServiceTest.kt +++ /dev/null @@ -1,41 +0,0 @@ -/*
- * Copyright © 2017-2018 AT&T Intellectual Property.
- * Modifications Copyright © 2018 IBM.
- *
- * 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.controllerblueprints.core.service
-
-import org.junit.Test
-import org.onap.ccsdk.apps.controllerblueprints.core.utils.ServiceTemplateUtils
-
-/**
- * BluePrintEnhancerServiceTest
- * @author Brinda Santh
- *
- */
-
-class BluePrintEnhancerServiceTest {
- val basePath = "load/model_type"
-
- @Test
- fun testEnrichBlueprint() {
- val bluePrintEnhancerRepoFileService = BluePrintRepoFileService(basePath)
- val bluePrintEnhancerService: BluePrintEnhancerService = BluePrintEnhancerDefaultService(bluePrintEnhancerRepoFileService)
-
- val serviceTemplate = ServiceTemplateUtils.getServiceTemplate("load/blueprints/simple-baseconfig/Definitions/simple-baseconfig.json")
- bluePrintEnhancerService.enhance(serviceTemplate)
-
- }
-}
\ No newline at end of file diff --git a/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRepoFileServiceTest.kt b/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRepoFileServiceTest.kt index 88aea919..b8cfdd40 100644 --- a/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRepoFileServiceTest.kt +++ b/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRepoFileServiceTest.kt @@ -33,25 +33,25 @@ class BluePrintRepoFileServiceTest { @Test
fun testGetDataType() {
- val dataType = bluePrintEnhancerRepoFileService.getDataType("dt-v4-aggregate")?.block()
+ val dataType = bluePrintEnhancerRepoFileService.getDataType("dt-v4-aggregate").block()
assertNotNull(dataType, "Failed to get DataType from repo")
}
@Test
fun testGetNodeType() {
- val nodeType = bluePrintEnhancerRepoFileService.getNodeType("component-resource-assignment")?.block()
+ val nodeType = bluePrintEnhancerRepoFileService.getNodeType("component-resource-assignment").block()
assertNotNull(nodeType, "Failed to get NodeType from repo")
}
@Test
fun testGetArtifactType() {
- val nodeType = bluePrintEnhancerRepoFileService.getArtifactType("artifact-template-velocity")?.block()
+ val nodeType = bluePrintEnhancerRepoFileService.getArtifactType("artifact-template-velocity").block()
assertNotNull(nodeType, "Failed to get ArtifactType from repo")
}
@Test(expected = FileNotFoundException::class)
fun testModelNotFound() {
- val dataType = bluePrintEnhancerRepoFileService.getDataType("dt-not-found")?.block()
+ val dataType = bluePrintEnhancerRepoFileService.getDataType("dt-not-found").block()
assertNotNull(dataType, "Failed to get DataType from repo")
}
}
\ No newline at end of file diff --git a/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeServiceTest.kt b/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeServiceTest.kt index 277ec3ac..f1980d27 100644 --- a/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeServiceTest.kt +++ b/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeServiceTest.kt @@ -1,5 +1,6 @@ /*
* Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -17,7 +18,6 @@ package org.onap.ccsdk.apps.controllerblueprints.core.service
import com.fasterxml.jackson.databind.JsonNode
-import com.fasterxml.jackson.databind.node.NullNode
import org.junit.Before
import org.junit.Test
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants
@@ -48,12 +48,8 @@ class BluePrintRuntimeServiceTest { @Test
fun testResolveNodeTemplateProperties() {
log.info("************************ testResolveNodeTemplateProperties **********************")
- val bluePrintContext: BluePrintContext = BluePrintParserFactory.instance(BluePrintConstants.TYPE_DEFAULT)!!
- .readBlueprintFile("baseconfiguration/Definitions/activation-blueprint.json", basepath)
- val context: MutableMap<String, Any> = hashMapOf()
- context[BluePrintConstants.PROPERTY_BLUEPRINT_BASE_PATH] = basepath.plus("/simple-baseconfig")
- val bluePrintRuntimeService = BluePrintRuntimeService(bluePrintContext, context)
+ val bluePrintRuntimeService = getBluePrintRuntimeService()
val inputDataPath = "src/test/resources/data/default-context.json"
@@ -99,31 +95,59 @@ class BluePrintRuntimeServiceTest { @Test
fun testResolveNodeTemplateInterfaceOperationOutputs() {
log.info("************************ testResolveNodeTemplateInterfaceOperationOutputs **********************")
- val bluePrintContext: BluePrintContext = BluePrintParserFactory.instance(BluePrintConstants.TYPE_DEFAULT)!!
- .readBlueprintFile("baseconfiguration/Definitions/activation-blueprint.json", basepath)
- assertNotNull(bluePrintContext, "Failed to populate Blueprint context")
-
- val context: MutableMap<String, Any> = hashMapOf()
- context[BluePrintConstants.PROPERTY_BLUEPRINT_BASE_PATH] = basepath.plus("/simple-baseconfig")
- val bluePrintRuntimeService = BluePrintRuntimeService(bluePrintContext, context)
+ val bluePrintRuntimeService = getBluePrintRuntimeService()
- val componentContext: MutableMap<String, Any?> = hashMapOf()
val successValue: JsonNode = jsonNodeFromObject("Success")
- componentContext["resource-assignment-ra-component.org-onap-ccsdk-config-assignment-service-ConfigAssignmentNode.process.status"] = successValue
- componentContext["resource-assignment-ra-component.org-onap-ccsdk-config-assignment-service-ConfigAssignmentNode.process.resource-assignment-params"] = null
+ val paramValue: JsonNode = jsonNodeFromObject("param-content")
+
+ bluePrintRuntimeService.setNodeTemplateAttributeValue("resource-assignment-ra-component", "params", paramValue)
bluePrintRuntimeService.resolveNodeTemplateInterfaceOperationOutputs("resource-assignment-ra-component",
- "org-onap-ccsdk-config-assignment-service-ConfigAssignmentNode", "process", componentContext)
+ "org-onap-ccsdk-config-assignment-service-ConfigAssignmentNode", "process")
- assertEquals(NullNode.instance,
- context.get("node_templates/resource-assignment-ra-component/interfaces/org-onap-ccsdk-config-assignment-service-ConfigAssignmentNode/operations/process/properties/resource-assignment-params"),
- "Failed to get operation property resource-assignment-params")
+ val resourceAssignmentParamsNode = bluePrintRuntimeService.getNodeTemplateOperationOutputValue("resource-assignment-ra-component",
+ "org-onap-ccsdk-config-assignment-service-ConfigAssignmentNode", "process", "resource-assignment-params")
- assertEquals(successValue,
- context.get("node_templates/resource-assignment-ra-component/interfaces/org-onap-ccsdk-config-assignment-service-ConfigAssignmentNode/operations/process/properties/status"),
- "Failed to get operation property status")
+ val statusNode = bluePrintRuntimeService.getNodeTemplateOperationOutputValue("resource-assignment-ra-component",
+ "org-onap-ccsdk-config-assignment-service-ConfigAssignmentNode", "process", "status")
+
+ assertEquals(paramValue, resourceAssignmentParamsNode, "Failed to get operation property resource-assignment-params")
+
+ assertEquals(successValue, statusNode, "Failed to get operation property status")
}
+
+ @Test
+ fun testNodeTemplateContextProperty() {
+ log.info("************************ testNodeTemplateContextProperty **********************")
+ val bluePrintRuntimeService = getBluePrintRuntimeService()
+
+ bluePrintRuntimeService.setNodeTemplateAttributeValue("resource-assignment-ra-component", "context1",
+ jsonNodeFromObject("context1-value"))
+ bluePrintRuntimeService.setNodeTemplateAttributeValue("resource-assignment-ra-component", "context2",
+ jsonNodeFromObject("context2-value"))
+
+ log.info("Context {}", bluePrintRuntimeService.context)
+
+ val keys = listOf("context1", "context2")
+
+ val jsonValueNode = bluePrintRuntimeService.getJsonForNodeTemplateAttributeProperties("resource-assignment-ra-component", keys)
+ assertNotNull(jsonValueNode, "Failed to get Json for Node Template Context Properties")
+ log.info("JSON Prepared Value Context {}", jsonValueNode)
+
+ }
+
+ private fun getBluePrintRuntimeService(): BluePrintRuntimeService {
+ val bluePrintContext: BluePrintContext = BluePrintParserFactory.instance(BluePrintConstants.TYPE_DEFAULT)!!
+ .readBlueprintFile("baseconfiguration/Definitions/activation-blueprint.json", basepath)
+ assertNotNull(bluePrintContext, "Failed to populate Blueprint context")
+
+ val context: MutableMap<String, Any> = hashMapOf()
+ context[BluePrintConstants.PROPERTY_BLUEPRINT_BASE_PATH] = basepath.plus("/simple-baseconfig")
+
+ return BluePrintRuntimeService(bluePrintContext, context)
+ }
+
}
\ No newline at end of file diff --git a/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDefinition.kt b/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDefinition.kt index ff260871..d141ed0c 100644 --- a/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDefinition.kt +++ b/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDefinition.kt @@ -1,5 +1,6 @@ /* * Copyright © 2018 IBM. + * Modifications 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. @@ -92,3 +93,8 @@ open class ResourceAssignment { * Default Source, Database Source, Rest Sources, etc) */ interface ResourceSource : Serializable + + +open class ResourceSourceMapping { + lateinit var resourceSourceMappings: MutableMap<String, String> +} diff --git a/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/factory/ResourceSourceMappingFactory.kt b/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/factory/ResourceSourceMappingFactory.kt new file mode 100644 index 00000000..2911ab26 --- /dev/null +++ b/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/factory/ResourceSourceMappingFactory.kt @@ -0,0 +1,47 @@ +/*
+ * 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.controllerblueprints.resource.dict.factory
+
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException
+import org.onap.ccsdk.apps.controllerblueprints.core.format
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceSourceMapping
+
+/**
+ * ResourceSourceMappingFactory.
+ *
+ * @author Brinda Santh
+ */
+object ResourceSourceMappingFactory {
+
+ private val resourceSourceMappings: MutableMap<String, String> = hashMapOf()
+
+ fun registerSourceMapping(sourceInstance: String, nodeTypeName: String) {
+ resourceSourceMappings[sourceInstance] = nodeTypeName
+ }
+
+ fun getRegisterSourceMapping(sourceInstance: String): String {
+ return resourceSourceMappings[sourceInstance]
+ ?: throw BluePrintException(format("failed to get source({}) mapping", sourceInstance))
+ }
+
+ fun getRegisterSourceMapping(): ResourceSourceMapping {
+ val resourceSourceMapping = ResourceSourceMapping()
+ resourceSourceMapping.resourceSourceMappings = resourceSourceMappings
+ return resourceSourceMapping
+ }
+}
+
diff --git a/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceAssignmentValidationService.kt b/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceAssignmentValidationService.kt index 228b39e2..fc7f1092 100644 --- a/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceAssignmentValidationService.kt +++ b/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceAssignmentValidationService.kt @@ -1,5 +1,6 @@ /* * Copyright © 2017-2018 AT&T Intellectual Property. + * Modifications Copyright © 2018 IBM. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,6 +25,8 @@ import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException import org.onap.ccsdk.apps.controllerblueprints.core.utils.TopologicalSortingUtils import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment import com.att.eelf.configuration.EELFManager +import org.onap.ccsdk.apps.controllerblueprints.core.format +import org.onap.ccsdk.apps.controllerblueprints.resource.dict.factory.ResourceSourceMappingFactory import java.io.Serializable /** @@ -64,12 +67,21 @@ open class ResourceAssignmentValidationDefaultService : ResourceAssignmentValida open fun validateSources(resourceAssignments: List<ResourceAssignment>) { log.info("validating resource assignment sources") + // Check the Resource Assignment Source(Dynamic Instance) is valid. + resourceAssignments.forEach { resourceAssignment -> + try { + ResourceSourceMappingFactory.getRegisterSourceMapping(resourceAssignment.dictionarySource!!) + } catch (e: BluePrintException) { + validationMessage.appendln(e.message + format(" for resource assignment({})", resourceAssignment.name)) + } + } } open fun validateTemplateNDictionaryKeys(resourceAssignments: List<ResourceAssignment>) { resourceAssignmentMap = resourceAssignments.map { it.name to it }.toMap() + // Check the Resource Assignment has Duplicate Key Names val duplicateKeyNames = resourceAssignments.groupBy { it.name } .filter { it.value.size > 1 } .map { it.key } @@ -78,6 +90,7 @@ open class ResourceAssignmentValidationDefaultService : ResourceAssignmentValida validationMessage.appendln(String.format("Duplicate Assignment Template Keys (%s) is Present", duplicateKeyNames)) } + // Check the Resource Assignment has Duplicate Dictionary Names val duplicateDictionaryKeyNames = resourceAssignments.groupBy { it.dictionaryName } .filter { it.value.size > 1 } .map { it.key } @@ -85,11 +98,10 @@ open class ResourceAssignmentValidationDefaultService : ResourceAssignmentValida validationMessage.appendln(String.format("Duplicate Assignment Dictionary Keys (%s) is Present", duplicateDictionaryKeyNames)) } + // Collect all the dependencies as a single list val dependenciesNames = resourceAssignments.mapNotNull { it.dependencies }.flatten() - log.info("Resource assignment definitions : {}", resourceAssignmentMap.keys) - log.info("Resource assignment Dictionary dependencies : {}", dependenciesNames) - + // Check all the dependencies keys have Resource Assignment mappings. val notPresentDictionaries = dependenciesNames.filter { !resourceAssignmentMap.containsKey(it) }.distinct() if (notPresentDictionaries.isNotEmpty()) { validationMessage.appendln(String.format("No assignments for Dictionary Keys (%s)", notPresentDictionaries)) diff --git a/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionRepoService.kt b/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionRepoService.kt index 370e1ec8..6c83e5f9 100644 --- a/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionRepoService.kt +++ b/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionRepoService.kt @@ -18,11 +18,13 @@ package org.onap.ccsdk.apps.controllerblueprints.resource.dict.service
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException
import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRepoFileService
import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRepoService
import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonReactorUtils
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDefinition
import reactor.core.publisher.Mono
+
/**
* ResourceDefinitionRepoService.
*
@@ -30,6 +32,7 @@ import reactor.core.publisher.Mono */
interface ResourceDefinitionRepoService : BluePrintRepoService {
+ @Throws(BluePrintException::class)
fun getResourceDefinition(resourceDefinitionName: String): Mono<ResourceDefinition>
}
diff --git a/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionValidationService.kt b/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionValidationService.kt index 14855d4b..9f45d166 100644 --- a/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionValidationService.kt +++ b/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionValidationService.kt @@ -59,7 +59,7 @@ open class ResourceDefinitionDefaultValidationService(private val bluePrintRepoS resourceDefinition.sources.forEach { (name, nodeTemplate) -> val sourceType = nodeTemplate.type - val sourceNodeType = bluePrintRepoService.getNodeType(sourceType)?.block() + val sourceNodeType = bluePrintRepoService.getNodeType(sourceType).block() ?: throw BluePrintException(format("Failed to get source({}) node type definition({})", name, sourceType)) // Validate Property Name, expression, values and Data Type @@ -100,7 +100,7 @@ open class ResourceDefinitionDefaultValidationService(private val bluePrintRepoS isValid = JacksonUtils.checkJsonNodeValueOfCollectionType(propertyType, propertyAssignment) } else { - bluePrintRepoService.getDataType(propertyType) + bluePrintRepoService.getDataType(propertyType).block() ?: throw BluePrintException(format("property({}) defined of data type({}) is not in repository", propertyName, propertyType)) isValid = true diff --git a/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceDictionaryTestUtils.kt b/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceDictionaryTestUtils.kt new file mode 100644 index 00000000..bebe27d8 --- /dev/null +++ b/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceDictionaryTestUtils.kt @@ -0,0 +1,30 @@ +/*
+ * 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.controllerblueprints.resource.dict.utils
+
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.factory.ResourceSourceMappingFactory
+
+object ResourceDictionaryTestUtils {
+
+ @JvmStatic
+ fun setUpResourceSourceMapping() {
+ ResourceSourceMappingFactory.registerSourceMapping("db", "source-db")
+ ResourceSourceMappingFactory.registerSourceMapping("input", "source-input")
+ ResourceSourceMappingFactory.registerSourceMapping("default", "source-default")
+ ResourceSourceMappingFactory.registerSourceMapping("mdsal", "source-rest")
+ }
+}
\ No newline at end of file diff --git a/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/factory/ResourceSourceMappingFactoryTest.java b/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/factory/ResourceSourceMappingFactoryTest.java new file mode 100644 index 00000000..b67aa799 --- /dev/null +++ b/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/factory/ResourceSourceMappingFactoryTest.java @@ -0,0 +1,42 @@ +/*
+ * 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.controllerblueprints.resource.dict.factory;
+
+import org.junit.Test;
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceSourceMapping;
+import org.springframework.util.Assert;
+
+public class ResourceSourceMappingFactoryTest {
+
+ @Test
+ public void testRegisterResourceMapping() {
+
+ ResourceSourceMappingFactory.INSTANCE.registerSourceMapping("db", "source-db");
+ ResourceSourceMappingFactory.INSTANCE.registerSourceMapping("input", "source-input");
+ ResourceSourceMappingFactory.INSTANCE.registerSourceMapping("default", "source-default");
+ ResourceSourceMappingFactory.INSTANCE.registerSourceMapping("mdsal", "source-rest");
+
+ String nodeTypeName = ResourceSourceMappingFactory.INSTANCE.getRegisterSourceMapping("db");
+ Assert.notNull(nodeTypeName, "Failed to get db mapping");
+
+ ResourceSourceMapping resourceSourceMapping = ResourceSourceMappingFactory.INSTANCE.getRegisterSourceMapping();
+ Assert.notNull(resourceSourceMapping, "Failed to get resource source mapping");
+ Assert.notNull(resourceSourceMapping.getResourceSourceMappings(), "Failed to get resource source mappings");
+
+ }
+
+}
diff --git a/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceAssignmentValidationServiceTest.kt b/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceAssignmentValidationServiceTest.kt index 6216d5bf..87ebb700 100644 --- a/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceAssignmentValidationServiceTest.kt +++ b/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceAssignmentValidationServiceTest.kt @@ -23,6 +23,9 @@ import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment
import com.att.eelf.configuration.EELFManager
+import org.junit.Before
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.utils.ResourceDictionaryTestUtils
+
/**
* ResourceAssignmentValidationServiceTest.
*
@@ -30,6 +33,12 @@ import com.att.eelf.configuration.EELFManager */
class ResourceAssignmentValidationServiceTest {
private val log: EELFLogger = EELFManager.getInstance().getLogger(ResourceAssignmentValidationServiceTest::class.java)
+ @Before
+ fun setUp() {
+ // Setup dummy Source Instance Mapping
+ ResourceDictionaryTestUtils.setUpResourceSourceMapping()
+ }
+
@Test
fun testValidateSuccess() {
log.info("**************** testValidateSuccess *****************")
diff --git a/components/resource-dict/src/test/resources/enrich/simple-enrich.json b/components/resource-dict/src/test/resources/enrich/simple-enrich.json deleted file mode 100644 index 641da80a..00000000 --- a/components/resource-dict/src/test/resources/enrich/simple-enrich.json +++ /dev/null @@ -1,37 +0,0 @@ -[
- {
- "name": "rs-db-source",
- "input-param": true,
- "property": {
- "type": "string",
- "required": true
- },
- "dictionary-name": "db-source",
- "dictionary-source": "db",
- "dependencies": [
- "input-source"
- ]
- },
- {
- "name": "ra-default-source",
- "input-param": true,
- "property": {
- "type": "string",
- "required": true
- },
- "dictionary-name": "default-source",
- "dictionary-source": "default",
- "dependencies": []
- },
- {
- "name": "ra-input-source",
- "input-param": true,
- "property": {
- "type": "string",
- "required": true
- },
- "dictionary-name": "input-source",
- "dictionary-source": "input",
- "dependencies": []
- }
-]
diff --git a/ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/api/data/BlueprintProcessorData.kt b/ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/api/data/BlueprintProcessorData.kt index 4836cd24..6fed53e6 100644 --- a/ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/api/data/BlueprintProcessorData.kt +++ b/ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/api/data/BlueprintProcessorData.kt @@ -1,5 +1,6 @@ /*
* Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,22 +22,6 @@ import com.fasterxml.jackson.databind.node.ObjectNode import io.swagger.annotations.ApiModelProperty
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment
-/*
- * 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.
- */
-
/**
* BlueprintProcessorData
* @author Brinda Santh
@@ -49,7 +34,7 @@ open class ResourceResolutionInput { @get:ApiModelProperty(required=true)
lateinit var actionIdentifiers: ActionIdentifiers
@get:ApiModelProperty(required=true)
- lateinit var resourceAssignments: List<ResourceAssignment>
+ lateinit var resourceAssignments: MutableList<ResourceAssignment>
@get:ApiModelProperty(required=true )
lateinit var payload: ObjectNode
}
@@ -62,7 +47,7 @@ open class ResourceResolutionOutput { @get:ApiModelProperty(required=true)
lateinit var status: Status
@get:ApiModelProperty(required=true)
- lateinit var resourceAssignments: List<ResourceAssignment>
+ lateinit var resourceAssignments: MutableList<ResourceAssignment>
}
open class ExecutionServiceInput {
diff --git a/ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/factory/ComponentNodeFactory.kt b/ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/factory/ComponentNodeFactory.kt index f42613cc..feacbcab 100644 --- a/ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/factory/ComponentNodeFactory.kt +++ b/ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/factory/ComponentNodeFactory.kt @@ -1,5 +1,6 @@ /*
* Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -18,12 +19,15 @@ package org.onap.ccsdk.apps.blueprintsprocessor.core.factory import com.att.eelf.configuration.EELFManager
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException
-import org.slf4j.Logger
-import org.slf4j.LoggerFactory
import org.springframework.context.ApplicationContext
import org.springframework.context.ApplicationContextAware
import org.springframework.stereotype.Service
+/**
+ * ComponentNode
+ *
+ * @author Brinda Santh
+ */
interface ComponentNode {
@Throws(BluePrintProcessorException::class)
@@ -39,8 +43,13 @@ interface ComponentNode { fun reTrigger(context: MutableMap<String, Any>, componentContext: MutableMap<String, Any?>)
}
+/**
+ * ComponentNodeFactory
+ *
+ * @author Brinda Santh
+ */
@Service
-class ComponentNodeFactory : ApplicationContextAware {
+open class ComponentNodeFactory : ApplicationContextAware {
private val log = EELFManager.getInstance().getLogger(ComponentNodeFactory::class.java)
var componentNodes: MutableMap<String, ComponentNode> = hashMapOf()
diff --git a/ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/factory/ResourceAssignmentProcessorFactory.kt b/ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/factory/ResourceAssignmentProcessorFactory.kt index 8104c104..01a110d5 100644 --- a/ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/factory/ResourceAssignmentProcessorFactory.kt +++ b/ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/factory/ResourceAssignmentProcessorFactory.kt @@ -1,5 +1,6 @@ /*
* Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -18,14 +19,17 @@ package org.onap.ccsdk.apps.blueprintsprocessor.core.factory import com.att.eelf.configuration.EELFManager
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignmentProcessor
-import org.slf4j.Logger
-import org.slf4j.LoggerFactory
import org.springframework.context.ApplicationContext
import org.springframework.context.ApplicationContextAware
import org.springframework.stereotype.Service
+/**
+ * ResourceAssignmentProcessorFactory
+ *
+ * @author Brinda Santh
+ */
@Service
-class ResourceAssignmentProcessorFactory : ApplicationContextAware {
+open class ResourceAssignmentProcessorFactory : ApplicationContextAware {
private val log = EELFManager.getInstance().getLogger(ResourceAssignmentProcessorFactory::class.java)
diff --git a/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/execution/JavaScriptExecuteComponent.kt b/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/execution/JavaScriptExecuteComponent.kt new file mode 100644 index 00000000..427dc873 --- /dev/null +++ b/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/execution/JavaScriptExecuteComponent.kt @@ -0,0 +1,45 @@ +/* + * Copyright © 2018 IBM. + * + * 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.services.execution + +import org.onap.ccsdk.apps.blueprintsprocessor.core.factory.ComponentNode +import org.springframework.stereotype.Component + +/** + * JavaScriptExecuteComponent + * + * @author Brinda Santh + */ +@Component("component-javascript-executor") +class JavaScriptExecuteComponent : ComponentNode { + + override fun validate(context: MutableMap<String, Any>, componentContext: MutableMap<String, Any?>) { + TODO("not implemented") //To change body of created functions use File | Settings | File Templates. + } + + override fun process(context: MutableMap<String, Any>, componentContext: MutableMap<String, Any?>) { + TODO("not implemented") //To change body of created functions use File | Settings | File Templates. + } + + override fun errorHandle(context: MutableMap<String, Any>, componentContext: MutableMap<String, Any?>) { + TODO("not implemented") //To change body of created functions use File | Settings | File Templates. + } + + override fun reTrigger(context: MutableMap<String, Any>, componentContext: MutableMap<String, Any?>) { + 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/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/execution/PythonExecuteComponent.kt b/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/execution/PythonExecuteComponent.kt new file mode 100644 index 00000000..59be1f51 --- /dev/null +++ b/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/execution/PythonExecuteComponent.kt @@ -0,0 +1,44 @@ +/* + * Copyright © 2018 IBM. + * + * 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.services.execution + +import org.onap.ccsdk.apps.blueprintsprocessor.core.factory.ComponentNode +import org.springframework.stereotype.Component + +/** + * PythonExecuteComponent + * + * @author Brinda Santh + */ +@Component("component-python-executor") +class PythonExecuteComponent : ComponentNode { + override fun validate(context: MutableMap<String, Any>, componentContext: MutableMap<String, Any?>) { + TODO("not implemented") //To change body of created functions use File | Settings | File Templates. + } + + override fun process(context: MutableMap<String, Any>, componentContext: MutableMap<String, Any?>) { + TODO("not implemented") //To change body of created functions use File | Settings | File Templates. + } + + override fun errorHandle(context: MutableMap<String, Any>, componentContext: MutableMap<String, Any?>) { + TODO("not implemented") //To change body of created functions use File | Settings | File Templates. + } + + override fun reTrigger(context: MutableMap<String, Any>, componentContext: MutableMap<String, Any?>) { + 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/modules/services/resolution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/ResourceResolutionService.kt b/ms/blueprintsprocessor/modules/services/resolution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/ResourceResolutionService.kt index 14ab7842..d442c96b 100644 --- a/ms/blueprintsprocessor/modules/services/resolution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/ResourceResolutionService.kt +++ b/ms/blueprintsprocessor/modules/services/resolution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/ResourceResolutionService.kt @@ -1,5 +1,6 @@ /*
* Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,9 +17,14 @@ package org.onap.ccsdk.apps.blueprintsprocessor.services.resolution
+import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.BlueprintProcessorException
+import org.onap.ccsdk.apps.blueprintsprocessor.core.factory.ResourceAssignmentProcessorFactory
import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ResourceResolutionInput
import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ResourceResolutionOutput
import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.Status
+import org.onap.ccsdk.apps.controllerblueprints.core.format
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.utils.BulkResourceSequencingUtils
import org.springframework.stereotype.Service
/**
@@ -28,7 +34,7 @@ import org.springframework.stereotype.Service */
@Service
-class ResourceResolutionService {
+class ResourceResolutionService(private val resourceAssignmentProcessorFactory: ResourceAssignmentProcessorFactory) {
fun resolveResource(resourceResolutionInput: ResourceResolutionInput): ResourceResolutionOutput {
val resourceResolutionOutput = ResourceResolutionOutput()
@@ -36,6 +42,10 @@ class ResourceResolutionService { resourceResolutionOutput.commonHeader = resourceResolutionInput.commonHeader
resourceResolutionOutput.resourceAssignments = resourceResolutionInput.resourceAssignments
+ val context = hashMapOf<String, Any>()
+
+ process(resourceResolutionOutput.resourceAssignments, context)
+
val status = Status()
status.code = 200
status.message = "Success"
@@ -43,4 +53,28 @@ class ResourceResolutionService { return resourceResolutionOutput
}
+
+ fun process(resourceAssignments: MutableList<ResourceAssignment>, context: MutableMap<String, Any>): Unit {
+
+ val bulkSequenced = BulkResourceSequencingUtils.process(resourceAssignments)
+
+ bulkSequenced.map { batchResourceAssignments ->
+ batchResourceAssignments.filter { it.name != "*" && it.name != "start"}
+ .map { resourceAssignment ->
+ val dictionarySource = resourceAssignment.dictionarySource
+ val processorInstanceName = "resource-assignment-processor-".plus(dictionarySource)
+ val resourceAssignmentProcessor = resourceAssignmentProcessorFactory.getInstance(processorInstanceName)
+ ?: throw BlueprintProcessorException(format("failed to get resource processor for instance name({}) " +
+ "for resource assignment({})", processorInstanceName, resourceAssignment.name))
+ try {
+ resourceAssignmentProcessor.validate(resourceAssignment, context)
+ resourceAssignmentProcessor.process(resourceAssignment, context)
+ } catch (e: Exception) {
+ resourceAssignmentProcessor.errorHandle(resourceAssignment, context)
+ throw BlueprintProcessorException(e)
+ }
+
+ }
+ }
+ }
}
diff --git a/ms/blueprintsprocessor/modules/services/resolution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/processor/DefaultResourceAssignmentProcessor.kt b/ms/blueprintsprocessor/modules/services/resolution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/processor/DefaultResourceAssignmentProcessor.kt index 396ca1d7..9580ca49 100644 --- a/ms/blueprintsprocessor/modules/services/resolution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/processor/DefaultResourceAssignmentProcessor.kt +++ b/ms/blueprintsprocessor/modules/services/resolution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/processor/DefaultResourceAssignmentProcessor.kt @@ -1,5 +1,6 @@ /*
* Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,25 +17,33 @@ package org.onap.ccsdk.apps.blueprintsprocessor.services.resolution.processor
+import com.att.eelf.configuration.EELFManager
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignmentProcessor
import org.springframework.stereotype.Service
+/**
+ * DefaultResourceAssignmentProcessor
+ *
+ * @author Brinda Santh
+ */
@Service("resource-assignment-processor-default")
open class DefaultResourceAssignmentProcessor : ResourceAssignmentProcessor {
- override fun errorHandle(resourceAssignment: ResourceAssignment, context: MutableMap<String, Any>) {
- TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
+ private val log = EELFManager.getInstance().getLogger(DefaultResourceAssignmentProcessor::class.java)
+
+ override fun validate(resourceAssignment: ResourceAssignment, context: MutableMap<String, Any>) {
+ log.info("Validation Resource Assignments")
}
override fun process(resourceAssignment: ResourceAssignment, context: MutableMap<String, Any>) {
- TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
+ log.info("Processing Resource Assignments")
}
- override fun reTrigger(resourceAssignment: ResourceAssignment, context: MutableMap<String, Any>) {
- TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
+ override fun errorHandle(resourceAssignment: ResourceAssignment, context: MutableMap<String, Any>) {
+ log.info("ErrorHandle Resource Assignments")
}
- override fun validate(resourceAssignment: ResourceAssignment, context: MutableMap<String, Any>) {
- TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
+ override fun reTrigger(resourceAssignment: ResourceAssignment, context: MutableMap<String, Any>) {
+ log.info("Re Trigger Resource Assignments")
}
}
\ No newline at end of file diff --git a/ms/blueprintsprocessor/modules/services/resolution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/processor/InputResourceAssignmentProcessor.kt b/ms/blueprintsprocessor/modules/services/resolution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/processor/InputResourceAssignmentProcessor.kt index 9d0734e6..05f7d5cd 100644 --- a/ms/blueprintsprocessor/modules/services/resolution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/processor/InputResourceAssignmentProcessor.kt +++ b/ms/blueprintsprocessor/modules/services/resolution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/processor/InputResourceAssignmentProcessor.kt @@ -1,5 +1,6 @@ /*
* Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,25 +17,33 @@ package org.onap.ccsdk.apps.blueprintsprocessor.services.resolution.processor
+import com.att.eelf.configuration.EELFManager
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignmentProcessor
import org.springframework.stereotype.Service
+/**
+ * InputResourceAssignmentProcessor
+ *
+ * @author Brinda Santh
+ */
@Service("resource-assignment-processor-input")
open class InputResourceAssignmentProcessor : ResourceAssignmentProcessor {
- override fun errorHandle(resourceAssignment: ResourceAssignment, context: MutableMap<String, Any>) {
- TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
+ private val log = EELFManager.getInstance().getLogger(InputResourceAssignmentProcessor::class.java)
+
+ override fun validate(resourceAssignment: ResourceAssignment, context: MutableMap<String, Any>) {
+ log.info("Validation Resource Assignments")
}
override fun process(resourceAssignment: ResourceAssignment, context: MutableMap<String, Any>) {
- TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
+ log.info("Processing Resource Assignments")
}
- override fun reTrigger(resourceAssignment: ResourceAssignment, context: MutableMap<String, Any>) {
- TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
+ override fun errorHandle(resourceAssignment: ResourceAssignment, context: MutableMap<String, Any>) {
+ log.info("ErrorHandle Resource Assignments")
}
- override fun validate(resourceAssignment: ResourceAssignment, context: MutableMap<String, Any>) {
- TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
+ override fun reTrigger(resourceAssignment: ResourceAssignment, context: MutableMap<String, Any>) {
+ log.info("Re Trigger Resource Assignments")
}
}
\ No newline at end of file diff --git a/ms/blueprintsprocessor/modules/services/resolution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/processor/MDSALResourceAssignmentProcessor.kt b/ms/blueprintsprocessor/modules/services/resolution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/processor/MDSALResourceAssignmentProcessor.kt new file mode 100644 index 00000000..9d54cd46 --- /dev/null +++ b/ms/blueprintsprocessor/modules/services/resolution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/processor/MDSALResourceAssignmentProcessor.kt @@ -0,0 +1,48 @@ +/* + * Copyright © 2018 IBM. + * + * 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.services.resolution.processor + +import com.att.eelf.configuration.EELFManager +import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment +import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignmentProcessor +import org.springframework.stereotype.Service + +/** + * MDSALResourceAssignmentProcessor + * + * @author Brinda Santh + */ +@Service("resource-assignment-processor-mdsal") +open class MDSALResourceAssignmentProcessor : ResourceAssignmentProcessor { + private val log = EELFManager.getInstance().getLogger(MDSALResourceAssignmentProcessor::class.java) + + override fun validate(resourceAssignment: ResourceAssignment, context: MutableMap<String, Any>) { + log.info("Validation Resource Assignments") + } + + override fun process(resourceAssignment: ResourceAssignment, context: MutableMap<String, Any>) { + log.info("Processing Resource Assignments") + } + + override fun errorHandle(resourceAssignment: ResourceAssignment, context: MutableMap<String, Any>) { + log.info("ErrorHandle Resource Assignments") + } + + override fun reTrigger(resourceAssignment: ResourceAssignment, context: MutableMap<String, Any>) { + log.info("Re Trigger Resource Assignments") + } +}
\ No newline at end of file diff --git a/ms/blueprintsprocessor/modules/services/resolution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/processor/SdncResourceAssignmentProcessor.kt b/ms/blueprintsprocessor/modules/services/resolution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/processor/SdncResourceAssignmentProcessor.kt new file mode 100644 index 00000000..4b11f580 --- /dev/null +++ b/ms/blueprintsprocessor/modules/services/resolution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/processor/SdncResourceAssignmentProcessor.kt @@ -0,0 +1,50 @@ +/* + * Copyright © 2018 IBM. + * + * 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.services.resolution.processor + +import com.att.eelf.configuration.EELFManager +import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment +import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignmentProcessor +import org.springframework.stereotype.Service + +/** + * SdncResourceAssignmentProcessor + * + * @author Brinda Santh + */ +@Service("resource-assignment-processor-db") +open class SdncResourceAssignmentProcessor : ResourceAssignmentProcessor { + + private val log = EELFManager.getInstance().getLogger(SdncResourceAssignmentProcessor::class.java) + + override fun validate(resourceAssignment: ResourceAssignment, context: MutableMap<String, Any>) { + log.info("Validation Resource Assignments") + } + + override fun process(resourceAssignment: ResourceAssignment, context: MutableMap<String, Any>) { + log.info("Processing Resource Assignments") + } + + override fun errorHandle(resourceAssignment: ResourceAssignment, context: MutableMap<String, Any>) { + log.info("ErrorHandle Resource Assignments") + } + + override fun reTrigger(resourceAssignment: ResourceAssignment, context: MutableMap<String, Any>) { + log.info("Re Trigger Resource Assignments") + } + +}
\ No newline at end of file diff --git a/ms/blueprintsprocessor/modules/services/resolution-service/src/test/java/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/ResourceResolutionServiceTest.java b/ms/blueprintsprocessor/modules/services/resolution-service/src/test/java/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/ResourceResolutionServiceTest.java index 63359908..0768c609 100644 --- a/ms/blueprintsprocessor/modules/services/resolution-service/src/test/java/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/ResourceResolutionServiceTest.java +++ b/ms/blueprintsprocessor/modules/services/resolution-service/src/test/java/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/ResourceResolutionServiceTest.java @@ -1,5 +1,6 @@ /*
* Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -24,6 +25,11 @@ import org.junit.Test; import org.junit.runner.RunWith;
import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ResourceResolutionInput;
import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ResourceResolutionOutput;
+import org.onap.ccsdk.apps.blueprintsprocessor.core.factory.ResourceAssignmentProcessorFactory;
+import org.onap.ccsdk.apps.blueprintsprocessor.services.resolution.processor.DefaultResourceAssignmentProcessor;
+import org.onap.ccsdk.apps.blueprintsprocessor.services.resolution.processor.InputResourceAssignmentProcessor;
+import org.onap.ccsdk.apps.blueprintsprocessor.services.resolution.processor.MDSALResourceAssignmentProcessor;
+import org.onap.ccsdk.apps.blueprintsprocessor.services.resolution.processor.SdncResourceAssignmentProcessor;
import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils;
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment;
import org.slf4j.Logger;
@@ -42,7 +48,9 @@ import java.util.List; * @author Brinda Santh DATE : 8/15/2018
*/
@RunWith(SpringRunner.class)
-@ContextConfiguration(classes = ResourceResolutionService.class)
+@ContextConfiguration(classes = {ResourceResolutionService.class, ResourceAssignmentProcessorFactory.class,
+ InputResourceAssignmentProcessor.class, DefaultResourceAssignmentProcessor.class,
+ SdncResourceAssignmentProcessor.class, MDSALResourceAssignmentProcessor.class})
public class ResourceResolutionServiceTest {
private static Logger log = LoggerFactory.getLogger(ResourceResolutionServiceTest.class);
@@ -57,8 +65,8 @@ public class ResourceResolutionServiceTest { String resourceResolutionInputContent = FileUtils.readFileToString(
new File("src/test/resources/payload/requests/sample-resourceresolution-request.json"), Charset.defaultCharset());
- ResourceResolutionInput resourceResolutionInput = JacksonUtils.readValue(resourceResolutionInputContent, ResourceResolutionInput.class );
- Assert.assertNotNull("failed to populate resourceResolutionInput request ",resourceResolutionInput);
+ ResourceResolutionInput resourceResolutionInput = JacksonUtils.readValue(resourceResolutionInputContent, ResourceResolutionInput.class);
+ Assert.assertNotNull("failed to populate resourceResolutionInput request ", resourceResolutionInput);
String resourceAssignmentContent = FileUtils.readFileToString(
new File("src/test/resources/mapping/db/resource-assignments-simple.json"), Charset.defaultCharset());
@@ -68,13 +76,13 @@ public class ResourceResolutionServiceTest { Assert.assertTrue("failed to create ResourceAssignment from file", CollectionUtils.isNotEmpty(batchResourceAssignment));
resourceResolutionInput.setResourceAssignments(batchResourceAssignment);
- ObjectNode inputContent = (ObjectNode)JacksonUtils.jsonNodeFromFile("src/test/resources/payload/inputs/input.json");
- Assert.assertNotNull("failed to populate input payload ",inputContent);
+ ObjectNode inputContent = (ObjectNode) JacksonUtils.jsonNodeFromFile("src/test/resources/payload/inputs/input.json");
+ Assert.assertNotNull("failed to populate input payload ", inputContent);
resourceResolutionInput.setPayload(inputContent);
log.info("ResourceResolutionInput : {}", JacksonUtils.getJson(resourceResolutionInput, true));
ResourceResolutionOutput resourceResolutionOutput = resourceResolutionService.resolveResource(resourceResolutionInput);
- Assert.assertNotNull("failed to populate output",resourceResolutionOutput);
+ Assert.assertNotNull("failed to populate output", resourceResolutionOutput);
}
}
diff --git a/ms/blueprintsprocessor/modules/services/resolution-service/src/test/resources/mapping/db/resource-assignments-simple.json b/ms/blueprintsprocessor/modules/services/resolution-service/src/test/resources/mapping/db/resource-assignments-simple.json index 02ce68be..ddcf32ee 100644 --- a/ms/blueprintsprocessor/modules/services/resolution-service/src/test/resources/mapping/db/resource-assignments-simple.json +++ b/ms/blueprintsprocessor/modules/services/resolution-service/src/test/resources/mapping/db/resource-assignments-simple.json @@ -1,12 +1,22 @@ [
- {
- "name": "country",
- "input-param": true,
- "property": {
- "type": "string"
- },
- "dictionary-name": "country",
- "dictionary-source": "db",
- "dependencies": []
- }
+ {
+ "name": "country",
+ "input-param": true,
+ "property": {
+ "type": "string"
+ },
+ "dictionary-name": "country",
+ "dictionary-source": "db",
+ "dependencies": ["state"]
+ },
+ {
+ "name": "state",
+ "input-param": true,
+ "property": {
+ "type": "string"
+ },
+ "dictionary-name": "state",
+ "dictionary-source": "input",
+ "dependencies": []
+ }
]
diff --git a/ms/controllerblueprints/.gitignore b/ms/controllerblueprints/.gitignore index 644e3b49..8cda363d 100644 --- a/ms/controllerblueprints/.gitignore +++ b/ms/controllerblueprints/.gitignore @@ -20,4 +20,5 @@ **/*versionsBackup
**/blackDuckHub*
-**/*.jsonld
\ No newline at end of file +**/*.jsonld +/target-ide/ diff --git a/ms/controllerblueprints/application/load/resource_dictionary/db-source.json b/ms/controllerblueprints/application/load/resource_dictionary/sample-db-source.json index a0c78af0..90775aee 100644 --- a/ms/controllerblueprints/application/load/resource_dictionary/db-source.json +++ b/ms/controllerblueprints/application/load/resource_dictionary/sample-db-source.json @@ -1,5 +1,5 @@ {
- "name": "db-source",
+ "name": "sample-db-source",
"property" :{
"description": "name of the ",
"type": "string"
diff --git a/ms/controllerblueprints/application/load/resource_dictionary/sample-default-source.json b/ms/controllerblueprints/application/load/resource_dictionary/sample-default-source.json new file mode 100644 index 00000000..395b0ddd --- /dev/null +++ b/ms/controllerblueprints/application/load/resource_dictionary/sample-default-source.json @@ -0,0 +1,16 @@ +{
+ "tags": "sample-default-source",
+ "name": "sample-default-source",
+ "property" :{
+ "description": "name of the ",
+ "type": "string"
+ },
+ "updated-by": "brindasanth@onap.com",
+ "sources": {
+ "default": {
+ "type": "source-default",
+ "properties": {
+ }
+ }
+ }
+}
\ No newline at end of file diff --git a/ms/controllerblueprints/application/load/resource_dictionary/input-source.json b/ms/controllerblueprints/application/load/resource_dictionary/sample-input-source.json index acfad16b..73c0d408 100644 --- a/ms/controllerblueprints/application/load/resource_dictionary/input-source.json +++ b/ms/controllerblueprints/application/load/resource_dictionary/sample-input-source.json @@ -1,16 +1,16 @@ {
- "name": "input-source",
+ "name": "sample-input-source",
"property" :{
"description": "name of the ",
"type": "string"
},
"updated-by": "brindasanth@onap.com",
- "tags": "action-name, brindasanth",
+ "tags": "sample-input-source",
"sources": {
"input": {
"type": "source-input",
"properties": {
- "key": "action-name"
+ "key": "input-source"
}
}
}
diff --git a/ms/controllerblueprints/application/load/resource_dictionary/sample-licenses.json b/ms/controllerblueprints/application/load/resource_dictionary/sample-licenses.json new file mode 100644 index 00000000..5834dd49 --- /dev/null +++ b/ms/controllerblueprints/application/load/resource_dictionary/sample-licenses.json @@ -0,0 +1,29 @@ +{
+ "tags": "sample-licenses",
+ "name": "sample-licenses",
+ "property": {
+ "description" : " Sample Data for licences",
+ "required": true,
+ "type": "list",
+ "entry_schema": {
+ "type": "dt-license-key"
+ }
+ },
+ "updated-by": "brindasanth@onap.com",
+ "sources": {
+ "mdsal": {
+ "type": "source-rest",
+ "properties": {
+ "type": "JSON",
+ "url-path": "config/L3VNF-API:services/service-list/",
+ "path": "/licenses",
+ "input-key-mapping": {
+ },
+ "output-key-mapping": {
+ "licenses": "licenses"
+ },
+ "key-dependencies": []
+ }
+ }
+ }
+}
\ No newline at end of file diff --git a/ms/controllerblueprints/application/load/resource_dictionary/sample-mdsal-source.json b/ms/controllerblueprints/application/load/resource_dictionary/sample-mdsal-source.json new file mode 100644 index 00000000..25464d3f --- /dev/null +++ b/ms/controllerblueprints/application/load/resource_dictionary/sample-mdsal-source.json @@ -0,0 +1,25 @@ +{
+ "tags": "sample-mdsal-source",
+ "name": "sample-mdsal-source",
+ "property": {
+ "description": "Sample sample-mdsal-source",
+ "type": "string"
+ },
+ "updated-by": "brindasanth@onap.com",
+ "sources": {
+ "mdsal": {
+ "type": "source-rest",
+ "properties": {
+ "type": "JSON",
+ "url-path": "config/L3VNF-API:services/service-list/$service-instance-id/service-data/vnf-topology-information/vnf-assignments/vnf-vms/$vm-type/vm-networks/$network-role/v4-assigned-ip-list/$v4-ip-type",
+ "path": "/v4-assigned-ip-list/0/v4-ip-prefix",
+ "input-key-mapping": {
+ },
+ "output-key-mapping": {
+ "mdsal-source": "v4-ip-prefix"
+ },
+ "key-dependencies": []
+ }
+ }
+ }
+}
\ No newline at end of file diff --git a/ms/controllerblueprints/application/load/resource_dictionary/v4-ip-type.json b/ms/controllerblueprints/application/load/resource_dictionary/sample-v4-ip-type.json index 1b4432d5..055279c1 100644 --- a/ms/controllerblueprints/application/load/resource_dictionary/v4-ip-type.json +++ b/ms/controllerblueprints/application/load/resource_dictionary/sample-v4-ip-type.json @@ -1,16 +1,16 @@ {
- "name": "v4-ip-type",
+ "name": "sample-v4-ip-type",
"property": {
- "description": "name of the ",
+ "description": "sample-v4-ip-type",
"type": "string"
},
"updated-by": "brindasanth@onap.com",
- "tags": "v4-ip-type, source-input, brindasanth",
+ "tags": "sample-v4-ip-type",
"sources": {
"input": {
"type": "source-input",
"properties": {
- "key": "v4-ip-type"
+ "key": "sample-v4-ip-type"
}
}
}
diff --git a/ms/controllerblueprints/application/opt/app/onap/config/application.properties b/ms/controllerblueprints/application/opt/app/onap/config/application.properties index 2d355d65..d2814827 100644 --- a/ms/controllerblueprints/application/opt/app/onap/config/application.properties +++ b/ms/controllerblueprints/application/opt/app/onap/config/application.properties @@ -40,11 +40,11 @@ spring.jpa.properties.hibernate.format_sql=true spring.datasource.url=jdbc:mysql://localhost:3306/sdnctl spring.datasource.username=sdnctl spring.datasource.password=sdnctl -spring.datasource.driver-class-name=com.mysql.jdbc.Driver +spring.datasource.driver-class-name=org.mariadb.jdbc.Driver spring.jpa.show-sql = true spring.jpa.hibernate.ddl-auto = none spring.jpa.hibernate.naming-strategy = org.hibernate.cfg.ImprovedNamingStrategy -spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5Dialect +spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5InnoDBDialect #Load Blueprints # blueprints.load.initial-data may be overridden by ENV variables @@ -53,4 +53,7 @@ load.dataTypePath=load/model_type/data_type load.nodeTypePath=load/model_type/node_type load.artifactTypePath=load/model_type/artifact_type load.resourceDictionaryPath=load/resource_dictionary -load.blueprintsPath=load/blueprints
\ No newline at end of file +load.blueprintsPath=load/blueprints + +# Load Resource Source Mappings +resourceSourceMappings=db=source-db,input=source-input,default=source-default,mdsal=source-rest
\ No newline at end of file diff --git a/ms/controllerblueprints/application/pom.xml b/ms/controllerblueprints/application/pom.xml index 38f81c16..24f4debe 100644 --- a/ms/controllerblueprints/application/pom.xml +++ b/ms/controllerblueprints/application/pom.xml @@ -198,5 +198,7 @@ </plugin>
</plugins>
</build>
+
+
</project>
diff --git a/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/WebConfig.java b/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/WebConfig.java index c5cdee62..83f5f19e 100644 --- a/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/WebConfig.java +++ b/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/WebConfig.java @@ -1,6 +1,6 @@ /*
* Copyright © 2017-2018 AT&T Intellectual Property.
- *
+ * Modifications Copyright © 2018 IBM.
* 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
@@ -28,6 +28,7 @@ import org.springframework.web.reactive.config.WebFluxConfigurationSupport; @Configuration
@SuppressWarnings("unused")
public class WebConfig extends WebFluxConfigurationSupport {
+ @Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("swagger-ui.html")
.addResourceLocations("classpath:/META-INF/resources/");
diff --git a/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/filters/ApplicationLoggingFilter.java b/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/filters/ApplicationLoggingFilter.java index 9a556e71..fbef55fb 100644 --- a/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/filters/ApplicationLoggingFilter.java +++ b/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/filters/ApplicationLoggingFilter.java @@ -1,5 +1,6 @@ /*
* Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -71,11 +72,11 @@ public class ApplicationLoggingFilter implements Filter { @Override
public void init(FilterConfig filterConfig) {
-
+ //method does nothing
}
@Override
public void destroy() {
-
+ //method does nothing
}
}
\ No newline at end of file diff --git a/ms/controllerblueprints/application/src/test/resources/application.properties b/ms/controllerblueprints/application/src/test/resources/application.properties index 3bcbbd9c..5c6acf93 100644 --- a/ms/controllerblueprints/application/src/test/resources/application.properties +++ b/ms/controllerblueprints/application/src/test/resources/application.properties @@ -14,6 +14,8 @@ # See the License for the specific language governing permissions and
# limitations under the License.
#
+spring.main.banner-mode=off
+
appName=ControllerBluePrints
ms_name=org.onap.ccsdk.apps.controllerblueprints
appVersion=1.0.0
@@ -33,4 +35,7 @@ load.dataTypePath=load/model_type/data_type load.nodeTypePath=load/model_type/node_type
load.artifactTypePath=load/model_type/artifact_type
load.resourceDictionaryPath=load/resource_dictionary
-load.blueprintsPath=load/blueprints
\ No newline at end of file +load.blueprintsPath=load/blueprints
+
+# Load Resource Source Mappings
+resourceSourceMappings=db=source-db,input=source-input,default=source-default,mdsal=source-rest
\ No newline at end of file diff --git a/ms/controllerblueprints/distribution/pom.xml b/ms/controllerblueprints/distribution/pom.xml index 37c0b844..7a2c6792 100644 --- a/ms/controllerblueprints/distribution/pom.xml +++ b/ms/controllerblueprints/distribution/pom.xml @@ -34,7 +34,10 @@ <name.space>org.onap.ccsdk.apps</name.space> <!-- <name.space>${namespace}</name.space> -->
<serviceArtifactName>controllerblueprints</serviceArtifactName>
<image.name>onap/ccsdk-controllerblueprints</image.name>
- </properties>
+ <docker.buildArg.https_proxy>${https_proxy}</docker.buildArg.https_proxy>
+ <docker.push.phase>deploy</docker.push.phase>
+ <docker.verbose>true</docker.verbose>
+ </properties>
<dependencies>
<dependency>
@@ -141,47 +144,52 @@ </execution>
</executions>
</plugin>
- <plugin>
- <groupId>io.fabric8</groupId>
- <artifactId>docker-maven-plugin</artifactId>
- <version>0.26.1</version>
- <inherited>false</inherited>
- <configuration>
- <images>
- <image>
- <name>${image.name}</name>
- <build>
- <cleanup>try</cleanup>
- <dockerFileDir>${basedir}/target/docker-stage</dockerFileDir>
- <tags>
- <tag>${project.version}</tag>
- <tag>${project.version}-STAGING-${maven.build.timestamp}</tag>
- <tag>${project.docker.latesttag.version}</tag>
- </tags>
- </build>
- </image>
- </images>
- <verbose>true</verbose>
- </configuration>
- <executions>
- <!--<execution>-->
- <!--<id>build-images</id>-->
- <!--<phase>package</phase>-->
- <!--<goals>-->
- <!--<goal>build</goal>-->
- <!--</goals>-->
- <!--</execution>-->
- <execution>
- <id>push-images</id>
- <phase>deploy</phase>
- <goals>
- <goal>build</goal>
- <goal>push</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
+
</plugins>
</build>
+
+ <profiles>
+ <profile>
+ <id>docker</id>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>io.fabric8</groupId>
+ <artifactId>docker-maven-plugin</artifactId>
+ <version>0.26.1</version>
+ <inherited>false</inherited>
+ <configuration>
+ <images>
+ <image>
+ <name>${image.name}</name>
+ <build>
+ <cleanup>try</cleanup>
+ <dockerFileDir>${basedir}/target/docker-stage</dockerFileDir>
+ <tags>
+ <tag>${project.version}</tag>
+ <tag>${project.version}-STAGING-${maven.build.timestamp}</tag>
+ <tag>${project.docker.latesttag.version}</tag>
+ </tags>
+ </build>
+ </image>
+ </images>
+ <verbose>true</verbose>
+ </configuration>
+ <executions>
+ <execution>
+ <id>push-images</id>
+ <phase>${docker.build.phase}</phase>
+ <goals>
+ <goal>build</goal>
+ <goal>push</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+
+ </profiles>
</project>
diff --git a/ms/controllerblueprints/modules/service/pom.xml b/ms/controllerblueprints/modules/service/pom.xml index 9efadd18..e95c1f73 100644 --- a/ms/controllerblueprints/modules/service/pom.xml +++ b/ms/controllerblueprints/modules/service/pom.xml @@ -55,19 +55,14 @@ <artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
- <groupId>mysql</groupId>
- <artifactId>mysql-connector-java</artifactId>
- </dependency>
- <dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>runtime</scope>
</dependency>
- <!--<dependency>-->
- <!--<groupId>org.mariadb.jdbc</groupId>-->
- <!--<artifactId>mariadb-java-client</artifactId>-->
- <!--</dependency>-->
-
+ <dependency>
+ <groupId>org.mariadb.jdbc</groupId>
+ <artifactId>mariadb-java-client</artifactId>
+ </dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-api-mockito2</artifactId>
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ApplicationRegistrationService.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ApplicationRegistrationService.java index 5a4a2877..fc7410f9 100644 --- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ApplicationRegistrationService.java +++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ApplicationRegistrationService.java @@ -17,20 +17,40 @@ package org.onap.ccsdk.apps.controllerblueprints.service;
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+import org.apache.commons.collections.CollectionUtils;
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.factory.ResourceSourceMappingFactory;
+import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
+import java.util.List;
@Component
@SuppressWarnings("unused")
public class ApplicationRegistrationService {
+ private static EELFLogger log = EELFManager.getInstance().getLogger(ApplicationRegistrationService.class);
+
+ @Value("#{'${resourceSourceMappings}'.split(',')}")
+ private List<String> resourceSourceMappings;
@PostConstruct
- public void register(){
+ public void register() {
registerDictionarySources();
}
- public void registerDictionarySources(){
-
+ public void registerDictionarySources() {
+ log.info("Registering Dictionary Sources : {}", resourceSourceMappings);
+ if (CollectionUtils.isNotEmpty(resourceSourceMappings)) {
+ resourceSourceMappings.forEach(resourceSourceMapping -> {
+ String[] mappingKeyValue = resourceSourceMapping.split("=");
+ if (mappingKeyValue != null && mappingKeyValue.length == 2) {
+ ResourceSourceMappingFactory.INSTANCE.registerSourceMapping(mappingKeyValue[0].trim(), mappingKeyValue[1].trim());
+ } else {
+ log.warn("failed to get resource source mapping {}", resourceSourceMapping);
+ }
+ });
+ }
}
}
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/BluePrintEnhancerService.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/BluePrintEnhancerService.java index 8e98f947..ef3b4a48 100644 --- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/BluePrintEnhancerService.java +++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/BluePrintEnhancerService.java @@ -25,12 +25,13 @@ import org.jetbrains.annotations.NotNull; import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException;
import org.onap.ccsdk.apps.controllerblueprints.core.ConfigModelConstant;
import org.onap.ccsdk.apps.controllerblueprints.core.data.*;
-import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintEnhancerDefaultService;
-import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRepoService;
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.service.ResourceDefinitionRepoService;
+import org.onap.ccsdk.apps.controllerblueprints.service.enhancer.BluePrintEnhancerDefaultService;
import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils;
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment;
import com.att.eelf.configuration.EELFLogger;
import com.att.eelf.configuration.EELFManager;
+import org.onap.ccsdk.apps.controllerblueprints.service.enhancer.ResourceAssignmentEnhancerService;
import org.springframework.stereotype.Service;
import java.util.HashMap;
@@ -48,14 +49,18 @@ public class BluePrintEnhancerService extends BluePrintEnhancerDefaultService { private static EELFLogger log = EELFManager.getInstance().getLogger(BluePrintEnhancerService.class);
+ private ResourceAssignmentEnhancerService resourceAssignmentEnhancerService;
+
private Map<String, DataType> recipeDataTypes = new HashMap<>();
- public BluePrintEnhancerService(BluePrintRepoService bluePrintEnhancerRepoDBService) {
- super(bluePrintEnhancerRepoDBService);
+ public BluePrintEnhancerService(ResourceDefinitionRepoService resourceDefinitionRepoService,
+ ResourceAssignmentEnhancerService resourceAssignmentEnhancerService) {
+ super(resourceDefinitionRepoService);
+ this.resourceAssignmentEnhancerService = resourceAssignmentEnhancerService;
}
@Override
- public void enrichTopologyTemplate(@NotNull ServiceTemplate serviceTemplate) throws BluePrintException{
+ public void enrichTopologyTemplate(@NotNull ServiceTemplate serviceTemplate) throws BluePrintException {
super.enrichTopologyTemplate(serviceTemplate);
// Update the Recipe Inputs and DataTypes
@@ -101,7 +106,7 @@ public class BluePrintEnhancerService extends BluePrintEnhancerDefaultService { // Modified for ONAP converted Object to JsonNode
JsonNode recipeNames = nodeTemplate.getProperties().get(ConfigModelConstant.PROPERTY_RECIPE_NAMES);
- log.info("Processing Receipe Names : {} ", recipeNames);
+ log.info("Processing Recipe Names : {} ", recipeNames);
if (recipeNames != null && recipeNames.isArray() && recipeNames.size() > 0) {
@@ -159,6 +164,9 @@ public class BluePrintEnhancerService extends BluePrintEnhancerDefaultService { JacksonUtils.getListFromJson(resourceAssignmentContent, ResourceAssignment.class);
Preconditions.checkNotNull(resourceAssignments, "Failed to Processing Resource Mapping " + resourceAssignmentContent);
+ // Enhance Resource Assignment
+ resourceAssignmentEnhancerService.enhanceBluePrint(this, resourceAssignments);
+
dataTypeProperties = new HashMap<>();
for (ResourceAssignment resourceAssignment : resourceAssignments) {
@@ -167,9 +175,6 @@ public class BluePrintEnhancerService extends BluePrintEnhancerDefaultService { && resourceAssignment.getProperty() != null
&& StringUtils.isNotBlank(resourceAssignment.getName())) {
- // Enrich the Property Definition
- super.enrichPropertyDefinition(resourceAssignment.getName(), resourceAssignment.getProperty());
-
dataTypeProperties.put(resourceAssignment.getName(), resourceAssignment.getProperty());
}
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ModelTypeService.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ModelTypeService.java index 2bc2963b..925a6c49 100644 --- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ModelTypeService.java +++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ModelTypeService.java @@ -1,5 +1,6 @@ /*
* Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,6 +17,7 @@ package org.onap.ccsdk.apps.controllerblueprints.service;
+import com.google.common.base.Preconditions;
import org.apache.commons.lang3.StringUtils;
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException;
import org.onap.ccsdk.apps.controllerblueprints.service.domain.ModelType;
@@ -43,7 +45,7 @@ public class ModelTypeService { /**
* This is a ModelTypeService, used to save and get the model types stored in database
*
- * @param modelTypeRepository
+ * @param modelTypeRepository modelTypeRepository
*/
public ModelTypeService(ModelTypeRepository modelTypeRepository) {
this.modelTypeRepository = modelTypeRepository;
@@ -53,19 +55,15 @@ public class ModelTypeService { /**
* This is a getModelTypeByName service
*
- * @param modelTypeName
+ * @param modelTypeName modelTypeName
* @return ModelType
- * @throws BluePrintException
*/
- public ModelType getModelTypeByName(String modelTypeName) throws BluePrintException {
+ public ModelType getModelTypeByName(String modelTypeName) {
ModelType modelType = null;
- if (StringUtils.isNotBlank(modelTypeName)) {
- Optional<ModelType> modelTypeOption = modelTypeRepository.findByModelName(modelTypeName);
- if (modelTypeOption.isPresent()) {
- modelType = modelTypeOption.get();
- }
- } else {
- throw new BluePrintException("Model Name Information is missing.");
+ Preconditions.checkArgument(StringUtils.isNotBlank(modelTypeName), "Model Name Information is missing.");
+ Optional<ModelType> modelTypeOption = modelTypeRepository.findByModelName(modelTypeName);
+ if (modelTypeOption.isPresent()) {
+ modelType = modelTypeOption.get();
}
return modelType;
}
@@ -74,27 +72,25 @@ public class ModelTypeService { /**
* This is a searchModelTypes service
*
- * @param tags
+ * @param tags tags
* @return List<ModelType>
- * @throws BluePrintException
*/
- public List<ModelType> searchModelTypes(String tags) throws BluePrintException {
- if (tags != null) {
- return modelTypeRepository.findByTagsContainingIgnoreCase(tags);
- } else {
- throw new BluePrintException("No Search Information provide");
- }
+ public List<ModelType> searchModelTypes(String tags) {
+ Preconditions.checkArgument(StringUtils.isNotBlank(tags), "No Search Information provide");
+ return modelTypeRepository.findByTagsContainingIgnoreCase(tags);
}
/**
* This is a saveModel service
*
- * @param modelType
+ * @param modelType modelType
* @return ModelType
- * @throws BluePrintException
+ * @throws BluePrintException BluePrintException
*/
public ModelType saveModel(ModelType modelType) throws BluePrintException {
+ Preconditions.checkNotNull(modelType, "Model Type Information is missing.");
+
ModelTypeValidator.validateModelType(modelType);
Optional<ModelType> dbModelType = modelTypeRepository.findByModelName(modelType.getModelName());
@@ -118,60 +114,34 @@ public class ModelTypeService { /**
* This is a deleteByModelName service
*
- * @param modelName
- * @throws BluePrintException
+ * @param modelName modelName
*/
- public void deleteByModelName(String modelName) throws BluePrintException {
- if (modelName != null) {
- modelTypeRepository.deleteByModelName(modelName);
- } else {
- throw new BluePrintException("Model Name Information is missing.");
- }
- }
+ public void deleteByModelName(String modelName) {
+ Preconditions.checkArgument(StringUtils.isNotBlank(modelName), "Model Name Information is missing.");
+ modelTypeRepository.deleteByModelName(modelName);
- /**
- * This is a getModelTypeByTags service
- *
- * @param tags
- * @return List<ModelType>
- * @throws BluePrintException
- */
- public List<ModelType> getModelTypeByTags(String tags) throws BluePrintException {
- if (StringUtils.isNotBlank(tags)) {
- return modelTypeRepository.findByTagsContainingIgnoreCase(tags);
- } else {
- throw new BluePrintException("Model Tag Information is missing.");
- }
}
/**
* This is a getModelTypeByDefinitionType service
*
- * @param definitionType
+ * @param definitionType definitionType
* @return List<ModelType>
- * @throws BluePrintException
*/
- public List<ModelType> getModelTypeByDefinitionType(String definitionType) throws BluePrintException {
- if (StringUtils.isNotBlank(definitionType)) {
- return modelTypeRepository.findByDefinitionType(definitionType);
- } else {
- throw new BluePrintException("Model definitionType Information is missing.");
- }
+ public List<ModelType> getModelTypeByDefinitionType(String definitionType) {
+ Preconditions.checkArgument(StringUtils.isNotBlank(definitionType), "Model definitionType Information is missing.");
+ return modelTypeRepository.findByDefinitionType(definitionType);
}
/**
* This is a getModelTypeByDerivedFrom service
*
- * @param derivedFrom
+ * @param derivedFrom derivedFrom
* @return List<ModelType>
- * @throws BluePrintException
*/
- public List<ModelType> getModelTypeByDerivedFrom(String derivedFrom) throws BluePrintException {
- if (StringUtils.isNotBlank(derivedFrom)) {
- return modelTypeRepository.findByDerivedFrom(derivedFrom);
- } else {
- throw new BluePrintException("Model derivedFrom Information is missing.");
- }
+ public List<ModelType> getModelTypeByDerivedFrom(String derivedFrom) {
+ Preconditions.checkArgument(StringUtils.isNotBlank(derivedFrom), "Model derivedFrom Information is missing.");
+ return modelTypeRepository.findByDerivedFrom(derivedFrom);
}
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/BluePrintRepoDBService.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ResourceDefinitionRepoDBService.java index 5510e480..16cc8415 100644 --- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/BluePrintRepoDBService.java +++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ResourceDefinitionRepoDBService.java @@ -23,28 +23,35 @@ import org.apache.commons.lang3.StringUtils; import org.jetbrains.annotations.NotNull;
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException;
import org.onap.ccsdk.apps.controllerblueprints.core.data.*;
-import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRepoService;
import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils;
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDefinition;
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.service.ResourceDefinitionRepoService;
import org.onap.ccsdk.apps.controllerblueprints.service.domain.ModelType;
+import org.onap.ccsdk.apps.controllerblueprints.service.domain.ResourceDictionary;
import org.onap.ccsdk.apps.controllerblueprints.service.repository.ModelTypeRepository;
+import org.onap.ccsdk.apps.controllerblueprints.service.repository.ResourceDictionaryRepository;
import org.springframework.stereotype.Service;
import reactor.core.publisher.Mono;
import java.util.Optional;
/**
- * BluePrintRepoDBService
+ * ResourceDefinitionRepoDBService
*
* @author Brinda Santh
*/
@Service
@SuppressWarnings("unused")
-public class BluePrintRepoDBService implements BluePrintRepoService {
+public class ResourceDefinitionRepoDBService implements ResourceDefinitionRepoService {
private ModelTypeRepository modelTypeRepository;
+ private ResourceDictionaryRepository resourceDictionaryRepository;
+
@SuppressWarnings("unused")
- public BluePrintRepoDBService(ModelTypeRepository modelTypeRepository) {
+ public ResourceDefinitionRepoDBService(ModelTypeRepository modelTypeRepository,
+ ResourceDictionaryRepository resourceDictionaryRepository) {
this.modelTypeRepository = modelTypeRepository;
+ this.resourceDictionaryRepository = resourceDictionaryRepository;
}
@Override
@@ -72,6 +79,17 @@ public class BluePrintRepoDBService implements BluePrintRepoService { return getModelType(capabilityDefinitionName, CapabilityDefinition.class);
}
+ @NotNull
+ @Override
+ public Mono<ResourceDefinition> getResourceDefinition(@NotNull String resourceDefinitionName) throws BluePrintException{
+ Optional<ResourceDictionary> dbResourceDictionary = resourceDictionaryRepository.findByName(resourceDefinitionName);
+ if(dbResourceDictionary.isPresent()){
+ return Mono.just(dbResourceDictionary.get().getDefinition());
+ }else{
+ throw new BluePrintException(String.format("failed to get resource dictionary (%s) from repo", resourceDefinitionName));
+ }
+ }
+
private <T> Mono<T> getModelType(String modelName, Class<T> valueClass) throws BluePrintException {
Preconditions.checkArgument(StringUtils.isNotBlank(modelName),
"Failed to get model from repo, model name is missing");
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ResourceDictionaryService.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ResourceDictionaryService.java index 62aa0e29..fd73db3b 100644 --- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ResourceDictionaryService.java +++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ResourceDictionaryService.java @@ -22,8 +22,9 @@ import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang3.StringUtils;
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException;
import org.onap.ccsdk.apps.controllerblueprints.core.data.PropertyDefinition;
-import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils;
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDefinition;
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceSourceMapping;
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.factory.ResourceSourceMappingFactory;
import org.onap.ccsdk.apps.controllerblueprints.service.domain.ResourceDictionary;
import org.onap.ccsdk.apps.controllerblueprints.service.repository.ResourceDictionaryRepository;
import org.onap.ccsdk.apps.controllerblueprints.service.validator.ResourceDictionaryValidator;
@@ -105,7 +106,7 @@ public class ResourceDictionaryService { */
public ResourceDictionary saveResourceDictionary(ResourceDictionary resourceDictionary) {
Preconditions.checkNotNull(resourceDictionary, "Resource Dictionary information is missing");
- Preconditions.checkNotNull(resourceDictionary.getDefinition(),"Resource Dictionary definition information is missing");
+ Preconditions.checkNotNull(resourceDictionary.getDefinition(), "Resource Dictionary definition information is missing");
ResourceDefinition resourceDefinition = resourceDictionary.getDefinition();
Preconditions.checkNotNull(resourceDefinition, "failed to get resource definition from content");
@@ -153,4 +154,12 @@ public class ResourceDictionaryService { Preconditions.checkArgument(StringUtils.isNotBlank(name), "Resource dictionary Name Information is missing.");
resourceDictionaryRepository.deleteByName(name);
}
+
+ /**
+ * This is a getResourceSourceMapping service
+ *
+ */
+ public ResourceSourceMapping getResourceSourceMapping() {
+ return ResourceSourceMappingFactory.INSTANCE.getRegisterSourceMapping();
+ }
}
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/ResourceDictionaryRepository.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/ResourceDictionaryRepository.java index 16031b6e..c53040e2 100644 --- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/ResourceDictionaryRepository.java +++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/ResourceDictionaryRepository.java @@ -37,7 +37,7 @@ public interface ResourceDictionaryRepository extends JpaRepository<ResourceDict /**
* This is a findByName method
*
- * @param name
+ * @param name name
* @return Optional<ResourceMapping>
*/
Optional<ResourceDictionary> findByName(String name);
@@ -45,7 +45,7 @@ public interface ResourceDictionaryRepository extends JpaRepository<ResourceDict /**
* This is a findByNameIn method
*
- * @param names
+ * @param names names
* @return Optional<ResourceMapping>
*/
List<ResourceDictionary> findByNameIn(List<String> names);
@@ -53,7 +53,7 @@ public interface ResourceDictionaryRepository extends JpaRepository<ResourceDict /**
* This is a findByTagsContainingIgnoreCase method
*
- * @param tags
+ * @param tags tags
* @return Optional<ModelType>
*/
List<ResourceDictionary> findByTagsContainingIgnoreCase(String tags);
@@ -61,9 +61,9 @@ public interface ResourceDictionaryRepository extends JpaRepository<ResourceDict /**
* This is a deleteByName method
*
- * @param name
+ * @param name name
*/
- ResourceDictionary deleteByName(String name);
+ void deleteByName(String name);
}
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ResourceDictionaryRest.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ResourceDictionaryRest.java index e0cf6c69..287d413c 100644 --- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ResourceDictionaryRest.java +++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ResourceDictionaryRest.java @@ -18,6 +18,7 @@ package org.onap.ccsdk.apps.controllerblueprints.service.rs;
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException;
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceSourceMapping;
import org.onap.ccsdk.apps.controllerblueprints.service.ResourceDictionaryService;
import org.onap.ccsdk.apps.controllerblueprints.service.domain.ResourceDictionary;
import org.springframework.http.MediaType;
@@ -76,4 +77,10 @@ public class ResourceDictionaryRest { }
+ @GetMapping(path = "/source-mapping", produces = MediaType.APPLICATION_JSON_VALUE)
+ public @ResponseBody
+ ResourceSourceMapping getResourceSourceMapping() {
+ return resourceDictionaryService.getResourceSourceMapping();
+ }
+
}
diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintEnhancerService.kt b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintEnhancerService.kt index b125c594..46709c5f 100644 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintEnhancerService.kt +++ b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintEnhancerService.kt @@ -15,7 +15,7 @@ * limitations under the License.
*/
-package org.onap.ccsdk.apps.controllerblueprints.core.service
+package org.onap.ccsdk.apps.controllerblueprints.service.enhancer
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintTypes
@@ -23,6 +23,7 @@ import org.onap.ccsdk.apps.controllerblueprints.core.data.* import org.onap.ccsdk.apps.controllerblueprints.core.format
import com.att.eelf.configuration.EELFLogger
import com.att.eelf.configuration.EELFManager
+import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRepoService
import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonReactorUtils
import java.io.Serializable
@@ -170,7 +171,7 @@ open class BluePrintEnhancerDefaultService(val bluePrintRepoService: BluePrintRe }
open fun enrichNodeTypeCapabilityProperties(nodeTypeName: String, nodeType: NodeType) {
- nodeType.capabilities?.forEach { capabilityDefinitionName, capabilityDefinition ->
+ nodeType.capabilities?.forEach { _, capabilityDefinition ->
capabilityDefinition.properties?.let { properties ->
enrichPropertyDefinitions(properties)
}
@@ -245,7 +246,7 @@ open class BluePrintEnhancerDefaultService(val bluePrintRepoService: BluePrintRe open fun populateNodeType(nodeTypeName: String): NodeType {
val nodeType = serviceTemplate.nodeTypes?.get(nodeTypeName)
- ?: bluePrintRepoService.getNodeType(nodeTypeName)?.block()
+ ?: bluePrintRepoService.getNodeType(nodeTypeName).block()
?: throw BluePrintException(format("Couldn't get NodeType({}) from repo.", nodeTypeName))
serviceTemplate.nodeTypes?.put(nodeTypeName, nodeType)
return nodeType
@@ -253,7 +254,7 @@ open class BluePrintEnhancerDefaultService(val bluePrintRepoService: BluePrintRe open fun populateArtifactType(artifactTypeName: String): ArtifactType {
val artifactType = serviceTemplate.artifactTypes?.get(artifactTypeName)
- ?: bluePrintRepoService.getArtifactType(artifactTypeName)?.block()
+ ?: bluePrintRepoService.getArtifactType(artifactTypeName).block()
?: throw BluePrintException(format("Couldn't get ArtifactType({}) from repo.", artifactTypeName))
serviceTemplate.artifactTypes?.put(artifactTypeName, artifactType)
return artifactType
@@ -261,7 +262,7 @@ open class BluePrintEnhancerDefaultService(val bluePrintRepoService: BluePrintRe open fun populateDataTypes(dataTypeName: String): DataType {
val dataType = serviceTemplate.dataTypes?.get(dataTypeName)
- ?: bluePrintRepoService.getDataType(dataTypeName)?.block()
+ ?: bluePrintRepoService.getDataType(dataTypeName).block()
?: throw BluePrintException(format("Couldn't get DataType({}) from repo.", dataTypeName))
serviceTemplate.dataTypes?.put(dataTypeName, dataType)
return dataType
diff --git a/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceAssignmentEnhancerService.kt b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/ResourceAssignmentEnhancerService.kt index c5a78a9c..de6f82ff 100644 --- a/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceAssignmentEnhancerService.kt +++ b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/ResourceAssignmentEnhancerService.kt @@ -14,16 +14,21 @@ * limitations under the License.
*/
-package org.onap.ccsdk.apps.controllerblueprints.resource.dict.service
+package org.onap.ccsdk.apps.controllerblueprints.service.enhancer
import com.att.eelf.configuration.EELFLogger
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException
import org.onap.ccsdk.apps.controllerblueprints.core.data.ServiceTemplate
-import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintEnhancerDefaultService
-import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintEnhancerService
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDefinition
import com.att.eelf.configuration.EELFManager
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintTypes
+import org.onap.ccsdk.apps.controllerblueprints.core.format
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDictionaryConstants
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.factory.ResourceSourceMappingFactory
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.service.ResourceAssignmentValidationDefaultService
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.service.ResourceDefinitionRepoService
+import org.springframework.stereotype.Service
/**
* ResourceAssignmentEnhancerService.
@@ -45,6 +50,7 @@ interface ResourceAssignmentEnhancerService { *
* @author Brinda Santh
*/
+@Service
open class ResourceAssignmentEnhancerDefaultService(private val resourceDefinitionRepoService: ResourceDefinitionRepoService)
: ResourceAssignmentEnhancerService {
private val log: EELFLogger = EELFManager.getInstance().getLogger(ResourceAssignmentValidationDefaultService::class.java)
@@ -56,20 +62,41 @@ open class ResourceAssignmentEnhancerDefaultService(private val resourceDefiniti override fun enhanceBluePrint(bluePrintEnhancerService: BluePrintEnhancerService,
resourceAssignments: List<ResourceAssignment>) {
+ val uniqueSourceNodeTypeNames = hashSetOf<String>()
+
// Iterate the Resource Assignment and
resourceAssignments.map { resourceAssignment ->
val dictionaryName = resourceAssignment.dictionaryName!!
val dictionarySource = resourceAssignment.dictionarySource!!
- log.info("Enriching Assignment name({}), dictionary name({}), source({})", resourceAssignment.name,
+ log.debug("Enriching Assignment name({}), dictionary name({}), source({})", resourceAssignment.name,
dictionaryName, dictionarySource)
- // Get the Resource Definition from Repo
- val resourceDefinition: ResourceDefinition = getResourceDefinition(dictionaryName)
+ val sourceNodeTypeName = ResourceSourceMappingFactory.getRegisterSourceMapping(dictionarySource)
+
+ // Add Unique Node Types
+ uniqueSourceNodeTypeNames.add(sourceNodeTypeName)
+
+ // TODO("Candidate for Optimisation")
+ if (checkResourceDefinitionNeeded(resourceAssignment)) {
+
+ bluePrintEnhancerService.enrichPropertyDefinition(resourceAssignment.name, resourceAssignment.property!!);
+
+ // Get the Resource Definition from Repo
+ val resourceDefinition: ResourceDefinition = getResourceDefinition(dictionaryName)
- val sourceNodeTemplate = resourceDefinition.sources.get(dictionarySource)
+ val sourceNodeTemplate = resourceDefinition.sources.get(dictionarySource)
+ ?: throw BluePrintException(format("failed to get assigned dictionarySource({}) from resourceDefinition({})", dictionarySource, dictionaryName))
- // Enrich as NodeTemplate
- bluePrintEnhancerService.enrichNodeTemplate(dictionarySource, sourceNodeTemplate!!)
+ // Enrich as NodeTemplate
+ bluePrintEnhancerService.enrichNodeTemplate(dictionarySource, sourceNodeTemplate)
+ }
}
+ // Enrich the ResourceSource NodeTypes
+ uniqueSourceNodeTypeNames.map { nodeTypeName ->
+ resourceDefinitionRepoService.getNodeType(nodeTypeName).subscribe { nodeType ->
+ bluePrintEnhancerService.enrichNodeType(nodeTypeName, nodeType)
+ }
+ }
+
}
override fun enhanceBluePrint(resourceAssignments: List<ResourceAssignment>): ServiceTemplate {
@@ -80,7 +107,14 @@ open class ResourceAssignmentEnhancerDefaultService(private val resourceDefiniti return bluePrintEnhancerService.serviceTemplate
}
+ private fun checkResourceDefinitionNeeded(resourceAssignment: ResourceAssignment): Boolean {
+ return !((resourceAssignment.dictionarySource.equals(ResourceDictionaryConstants.SOURCE_INPUT)
+ || resourceAssignment.dictionarySource.equals(ResourceDictionaryConstants.SOURCE_DEFAULT))
+ && BluePrintTypes.validPrimitiveOrCollectionPrimitive(resourceAssignment.property!!))
+ }
+
private fun getResourceDefinition(name: String): ResourceDefinition {
- return resourceDefinitionRepoService.getResourceDefinition(name)!!.block()!!
+ return resourceDefinitionRepoService.getResourceDefinition(name).block()
+ ?: throw BluePrintException(format("failed to get dictionary definition({})", name))
}
}
\ No newline at end of file diff --git a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/repository/BluePrintsReactRepository.kt b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/repository/BluePrintsReactRepository.kt new file mode 100644 index 00000000..141ba92c --- /dev/null +++ b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/repository/BluePrintsReactRepository.kt @@ -0,0 +1,76 @@ +/* + * Copyright © 2018 IBM. + * + * 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.controllerblueprints.service.repository + +import org.onap.ccsdk.apps.controllerblueprints.service.domain.ModelType +import org.springframework.stereotype.Service +import reactor.core.publisher.Flux +import reactor.core.publisher.Mono +import reactor.core.scheduler.Schedulers + +/** + * ModelTypeReactRepository. + * + * @author Brinda Santh + */ +@Service +open class ModelTypeReactRepository(private val modelTypeRepository: ModelTypeRepository) { + + fun save(modelType: ModelType): Mono<ModelType> { + return Mono.justOrEmpty(modelTypeRepository.save(modelType)) + } + + fun findByModelName(modelName: String): Mono<ModelType> { + return Mono.justOrEmpty(modelTypeRepository.findByModelName(modelName)) + } + + fun findByModelNameIn(modelNames: List<String>): Flux<ModelType> { + return Flux.fromIterable(modelTypeRepository.findByModelNameIn(modelNames)) + .subscribeOn(Schedulers.elastic()) + } + + fun findByDerivedFrom(derivedFrom: String): Flux<ModelType> { + return Flux.fromIterable(modelTypeRepository.findByDerivedFrom(derivedFrom)) + .subscribeOn(Schedulers.elastic()) + } + + fun findByDerivedFromIn(derivedFroms: List<String>): Flux<ModelType> { + return Flux.fromIterable(modelTypeRepository.findByDerivedFromIn(derivedFroms)) + .subscribeOn(Schedulers.elastic()) + } + + fun findByDefinitionType(definitionType: String): Flux<ModelType> { + return Flux.fromIterable(modelTypeRepository.findByDefinitionType(definitionType)) + .subscribeOn(Schedulers.elastic()) + } + + fun findByDefinitionTypeIn(definitionTypes: List<String>): Flux<ModelType> { + return Flux.fromIterable(modelTypeRepository.findByDefinitionTypeIn(definitionTypes)) + .subscribeOn(Schedulers.elastic()) + } + + fun findByTagsContainingIgnoreCase(tags: String): Flux<ModelType> { + return Flux.fromIterable(modelTypeRepository.findByTagsContainingIgnoreCase(tags)) + .subscribeOn(Schedulers.elastic()) + } + + fun deleteByModelName(modelName: String): Mono<Void> { + modelTypeRepository.deleteByModelName(modelName) + return Mono.empty() + } + +}
\ No newline at end of file diff --git a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/repository/ResourceDictionaryReactRepository.kt b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/repository/ResourceDictionaryReactRepository.kt index 064b5c38..0865b69d 100644 --- a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/repository/ResourceDictionaryReactRepository.kt +++ b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/repository/ResourceDictionaryReactRepository.kt @@ -16,7 +16,6 @@ package org.onap.ccsdk.apps.controllerblueprints.service.repository -import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException import org.onap.ccsdk.apps.controllerblueprints.service.domain.ResourceDictionary import org.springframework.stereotype.Service import reactor.core.publisher.Flux @@ -49,10 +48,9 @@ open class ResourceDictionaryReactRepository(private val resourceDictionaryRepos .subscribeOn(Schedulers.elastic()) } - fun deleteByName(name: String): Mono<ResourceDictionary> { - return Mono.fromCallable { - resourceDictionaryRepository.deleteByName(name) - } + fun deleteByName(name: String): Mono<Void> { + resourceDictionaryRepository.deleteByName(name) + return Mono.empty() } }
\ No newline at end of file diff --git a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/ModelTypeServiceTest.java b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/ModelTypeServiceTest.java new file mode 100644 index 00000000..8e258ab6 --- /dev/null +++ b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/ModelTypeServiceTest.java @@ -0,0 +1,123 @@ +/* + * Copyright © 2018 IBM. + * + * 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.controllerblueprints.service; + +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; +import org.junit.*; +import org.junit.runner.RunWith; +import org.junit.runners.MethodSorters; +import org.onap.ccsdk.apps.controllerblueprints.TestApplication; +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants; +import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils; +import org.onap.ccsdk.apps.controllerblueprints.service.domain.ModelType; +import org.onap.ccsdk.apps.controllerblueprints.service.rs.ModelTypeRestTest; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.transaction.annotation.Propagation; +import org.springframework.transaction.annotation.Transactional; + +import java.util.List; + +@RunWith(SpringRunner.class) +@DataJpaTest +@Transactional(propagation = Propagation.NOT_SUPPORTED) +@ContextConfiguration(classes = {TestApplication.class}) +@FixMethodOrder(MethodSorters.NAME_ASCENDING) +public class ModelTypeServiceTest { + private static EELFLogger log = EELFManager.getInstance().getLogger(ModelTypeRestTest.class); + @Autowired + ModelTypeService modelTypeService; + + String modelName = "test-datatype"; + + @Test + public void test01SaveModelType() throws Exception { + log.info("**************** test01SaveModelType ********************"); + + String content = JacksonUtils.getClassPathFileContent("model_type/data_type/datatype-property.json"); + ModelType modelType = new ModelType(); + modelType.setDefinitionType(BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE); + modelType.setDerivedFrom(BluePrintConstants.MODEL_TYPE_DATATYPES_ROOT); + modelType.setDescription("Definition for Sample Datatype "); + modelType.setDefinition(JacksonUtils.jsonNode(content)); + modelType.setModelName(modelName); + modelType.setVersion("1.0.0"); + modelType.setTags("test-datatype ," + BluePrintConstants.MODEL_TYPE_DATATYPES_ROOT + "," + + BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE); + modelType.setUpdatedBy("xxxxxx@xxx.com"); + modelType = modelTypeService.saveModel(modelType); + log.info("Saved Mode {}", modelType.toString()); + Assert.assertNotNull("Failed to get Saved ModelType", modelType); + Assert.assertNotNull("Failed to get Saved ModelType, Id", modelType.getModelName()); + + ModelType dbModelType = modelTypeService.getModelTypeByName(modelType.getModelName()); + Assert.assertNotNull("Failed to query ResourceMapping for ID (" + dbModelType.getModelName() + ")", + dbModelType); + + // Model Update + modelType.setUpdatedBy("bs2796@xxx.com"); + modelType = modelTypeService.saveModel(modelType); + Assert.assertNotNull("Failed to get Saved ModelType", modelType); + Assert.assertEquals("Failed to get Saved getUpdatedBy ", "bs2796@xxx.com", modelType.getUpdatedBy()); + + } + + @Test + public void test02SearchModelTypes() throws Exception { + log.info("*********************** test02SearchModelTypes ***************************"); + + String tags = "test-datatype"; + + List<ModelType> dbModelTypes = modelTypeService.searchModelTypes(tags); + Assert.assertNotNull("Failed to search ResourceMapping by tags", dbModelTypes); + Assert.assertTrue("Failed to search ResourceMapping by tags count", dbModelTypes.size() > 0); + + } + + @Test + public void test03GetModelType() throws Exception { + log.info("************************* test03GetModelType *********************************"); + ModelType dbModelType = modelTypeService.getModelTypeByName(modelName); + Assert.assertNotNull("Failed to get response for api call getModelByName ", dbModelType); + Assert.assertNotNull("Failed to get Id for api call getModelByName ", dbModelType.getModelName()); + + List<ModelType> dbDatatypeModelTypes = + modelTypeService.getModelTypeByDefinitionType(BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE); + Assert.assertNotNull("Failed to find getModelTypeByDefinitionType by tags", dbDatatypeModelTypes); + Assert.assertTrue("Failed to find getModelTypeByDefinitionType by count", dbDatatypeModelTypes.size() > 0); + + List<ModelType> dbModelTypeByDerivedFroms = + modelTypeService.getModelTypeByDerivedFrom(BluePrintConstants.MODEL_TYPE_DATATYPES_ROOT); + Assert.assertNotNull("Failed to find getModelTypeByDerivedFrom by tags", dbModelTypeByDerivedFroms); + Assert.assertTrue("Failed to find getModelTypeByDerivedFrom by count", dbModelTypeByDerivedFroms.size() > 0); + + } + + @Test + public void test04DeleteModelType() throws Exception { + log.info( + "************************ test03DeleteModelType ***********************"); + ModelType dbResourceMapping = modelTypeService.getModelTypeByName(modelName); + Assert.assertNotNull("Failed to get response for api call getModelByName ", dbResourceMapping); + Assert.assertNotNull("Failed to get Id for api call getModelByName ", dbResourceMapping.getModelName()); + + modelTypeService.deleteByModelName(dbResourceMapping.getModelName()); + } +}
\ No newline at end of file diff --git a/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceAssignmentEnhancerServiceTest.java b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/ResourceAssignmentEnhancerServiceTest.java index 57c8509d..a5d1e417 100644 --- a/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceAssignmentEnhancerServiceTest.java +++ b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/ResourceAssignmentEnhancerServiceTest.java @@ -14,14 +14,21 @@ * limitations under the License.
*/
-package org.onap.ccsdk.apps.controllerblueprints.resource.dict.service;
+package org.onap.ccsdk.apps.controllerblueprints.service.enhancer;
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
import org.junit.Assert;
+import org.junit.Before;
import org.junit.Test;
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException;
import org.onap.ccsdk.apps.controllerblueprints.core.data.ServiceTemplate;
import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonReactorUtils;
+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.service.ResourceDefinitionFileRepoService;
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.service.ResourceDefinitionRepoService;
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.utils.ResourceDictionaryTestUtils;
import java.util.List;
@@ -31,18 +38,26 @@ import java.util.List; * @author Brinda Santh
*/
public class ResourceAssignmentEnhancerServiceTest {
+ private static EELFLogger log = EELFManager.getInstance().getLogger(ResourceAssignmentEnhancerServiceTest.class);
+
+ @Before
+ public void setUp(){
+ // Setup dummy Source Instance Mapping
+ ResourceDictionaryTestUtils.setUpResourceSourceMapping();
+ }
@Test
public void testEnhanceBluePrint() throws BluePrintException {
List<ResourceAssignment> resourceAssignments = JacksonReactorUtils
- .getListFromClassPathFile("enrich/simple-enrich.json", ResourceAssignment.class).block();
+ .getListFromClassPathFile("enhance/enhance-resource-assignment.json", ResourceAssignment.class).block();
Assert.assertNotNull("Failed to get Resource Assignment", resourceAssignments);
- ResourceDefinitionRepoService resourceDefinitionRepoService = new ResourceDefinitionFileRepoService("load");
+ ResourceDefinitionRepoService resourceDefinitionRepoService = new ResourceDefinitionFileRepoService("./../../application/load");
ResourceAssignmentEnhancerService resourceAssignmentEnhancerService =
new ResourceAssignmentEnhancerDefaultService(resourceDefinitionRepoService);
ServiceTemplate serviceTemplate = resourceAssignmentEnhancerService.enhanceBluePrint(resourceAssignments);
Assert.assertNotNull("Failed to get Enriched service Template", serviceTemplate);
+ log.trace("Enhanced Service Template : {}", JacksonUtils.getJson(serviceTemplate, true));
}
}
diff --git a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/ModelTypeReactRepositoryTest.java b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/ModelTypeReactRepositoryTest.java new file mode 100644 index 00000000..7549b780 --- /dev/null +++ b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/ModelTypeReactRepositoryTest.java @@ -0,0 +1,110 @@ +/* + * Copyright © 2018 IBM. + * + * 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.controllerblueprints.service.repository; + +import org.junit.Assert; +import org.junit.FixMethodOrder; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.MethodSorters; +import org.onap.ccsdk.apps.controllerblueprints.TestApplication; +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants; +import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils; +import org.onap.ccsdk.apps.controllerblueprints.service.domain.ModelType; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; +import org.springframework.test.annotation.Commit; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringRunner; + +import java.util.Arrays; +import java.util.List; + +/** + * ModelTypeReactRepositoryTest. + * + * @author Brinda Santh + */ + +@RunWith(SpringRunner.class) +@DataJpaTest +@ContextConfiguration(classes = {TestApplication.class}) +@FixMethodOrder(MethodSorters.NAME_ASCENDING) +public class ModelTypeReactRepositoryTest { + + @Autowired + private ModelTypeReactRepository modelTypeReactRepository; + + String modelName = "test-datatype"; + + @Test + @Commit + public void test01Save() { + String content = JacksonUtils.getClassPathFileContent("model_type/data_type/datatype-property.json"); + ModelType modelType = new ModelType(); + modelType.setDefinitionType(BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE); + modelType.setDerivedFrom(BluePrintConstants.MODEL_TYPE_DATATYPES_ROOT); + modelType.setDescription("Definition for Sample Datatype "); + modelType.setDefinition(JacksonUtils.jsonNode(content)); + modelType.setModelName(modelName); + modelType.setVersion("1.0.0"); + modelType.setTags("test-datatype ," + BluePrintConstants.MODEL_TYPE_DATATYPES_ROOT + "," + + BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE); + modelType.setUpdatedBy("xxxxxx@xxx.com"); + + ModelType dbModelType = modelTypeReactRepository.save(modelType).block(); + Assert.assertNotNull("Failed to get Saved ModelType", dbModelType); + } + + @Test + public void test02Finds() { + ModelType dbFindByModelName = modelTypeReactRepository.findByModelName(modelName).block(); + Assert.assertNotNull("Failed to findByModelName ", dbFindByModelName); + + List<ModelType> dbFindByDefinitionType = + modelTypeReactRepository.findByDefinitionType(BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE).collectList().block(); + Assert.assertNotNull("Failed to findByDefinitionType ", dbFindByDefinitionType); + Assert.assertTrue("Failed to findByDefinitionType count", dbFindByDefinitionType.size() > 0); + + List<ModelType> dbFindByDerivedFrom = + modelTypeReactRepository.findByDerivedFrom(BluePrintConstants.MODEL_TYPE_DATATYPES_ROOT).collectList().block(); + Assert.assertNotNull("Failed to find findByDerivedFrom", dbFindByDerivedFrom); + Assert.assertTrue("Failed to find findByDerivedFrom by count", dbFindByDerivedFrom.size() > 0); + + List<ModelType> dbFindByModelNameIn = + modelTypeReactRepository.findByModelNameIn(Arrays.asList(modelName)).collectList().block(); + Assert.assertNotNull("Failed to findByModelNameIn ", dbFindByModelNameIn); + Assert.assertTrue("Failed to findByModelNameIn by count", dbFindByModelNameIn.size() > 0); + + List<ModelType> dbFindByDefinitionTypeIn = + modelTypeReactRepository.findByDefinitionTypeIn(Arrays.asList(BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE)).collectList().block(); + Assert.assertNotNull("Failed to findByDefinitionTypeIn", dbFindByDefinitionTypeIn); + Assert.assertTrue("Failed to findByDefinitionTypeIn by count", dbFindByDefinitionTypeIn.size() > 0); + + List<ModelType> dbFindByDerivedFromIn = + modelTypeReactRepository.findByDerivedFromIn(Arrays.asList(BluePrintConstants.MODEL_TYPE_DATATYPES_ROOT)).collectList().block(); + Assert.assertNotNull("Failed to find findByDerivedFromIn", dbFindByDerivedFromIn); + Assert.assertTrue("Failed to find findByDerivedFromIn by count", dbFindByDerivedFromIn.size() > 0); + } + + @Test + @Commit + public void test03Delete() { + modelTypeReactRepository.deleteByModelName(modelName).block(); + } + +} diff --git a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/ResourceDictionaryReactRepositoryTest.java b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/ResourceDictionaryReactRepositoryTest.java index 7034b7e2..b2e29018 100644 --- a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/ResourceDictionaryReactRepositoryTest.java +++ b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/ResourceDictionaryReactRepositoryTest.java @@ -1,5 +1,6 @@ /* * Copyright © 2018 IBM. + * Modifications 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. @@ -17,7 +18,6 @@ package org.onap.ccsdk.apps.controllerblueprints.service.repository; import org.junit.Assert; -import org.junit.Before; import org.junit.FixMethodOrder; import org.junit.Test; import org.junit.runner.RunWith; @@ -28,6 +28,7 @@ import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDefinition import org.onap.ccsdk.apps.controllerblueprints.service.domain.ResourceDictionary; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; +import org.springframework.test.annotation.Commit; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringRunner; @@ -46,39 +47,50 @@ import java.util.List; @FixMethodOrder(MethodSorters.NAME_ASCENDING) public class ResourceDictionaryReactRepositoryTest { + private String sourceName = "test-source"; + @Autowired protected ResourceDictionaryReactRepository resourceDictionaryReactRepository; - @Before - public void init() { - ResourceDefinition resourceDefinition = JacksonUtils.readValueFromFile("./../../application/load/resource_dictionary/db-source" + + @Test + @Commit + public void test01Save() { + ResourceDefinition resourceDefinition = JacksonUtils.readValueFromFile("./../../application/load/resource_dictionary/sample-db-source" + ".json", ResourceDefinition.class); + Assert.assertNotNull("Failed to get resourceDefinition from content", resourceDefinition); + resourceDefinition.setName(sourceName); ResourceDictionary resourceDictionary = transformResourceDictionary(resourceDefinition); ResourceDictionary dbResourceDictionary = resourceDictionaryReactRepository.save(resourceDictionary).block(); - Assert.assertNotNull("Failed to query React Resource Dictionary by Name", dbResourceDictionary); + Assert.assertNotNull("Failed to save ResourceDictionary", dbResourceDictionary); } @Test - public void test01FindByNameReact() throws Exception { - ResourceDictionary dbResourceDictionary = resourceDictionaryReactRepository.findByName("db-source").block(); + public void test02FindByNameReact() { + ResourceDictionary dbResourceDictionary = resourceDictionaryReactRepository.findByName(sourceName).block(); Assert.assertNotNull("Failed to query React Resource Dictionary by Name", dbResourceDictionary); } @Test - public void test02FindByNameInReact() throws Exception { + public void test03FindByNameInReact() { List<ResourceDictionary> dbResourceDictionaries = - resourceDictionaryReactRepository.findByNameIn(Arrays.asList("db-source")).collectList().block(); + resourceDictionaryReactRepository.findByNameIn(Arrays.asList(sourceName)).collectList().block(); Assert.assertNotNull("Failed to query React Resource Dictionary by Names", dbResourceDictionaries); } @Test - public void test03FindByTagsContainingIgnoreCaseReact() throws Exception { + public void test04FindByTagsContainingIgnoreCaseReact() { List<ResourceDictionary> dbTagsResourceDictionaries = - resourceDictionaryReactRepository.findByTagsContainingIgnoreCase("db-source").collectList().block(); + resourceDictionaryReactRepository.findByTagsContainingIgnoreCase(sourceName).collectList().block(); Assert.assertNotNull("Failed to query React Resource Dictionary by Tags", dbTagsResourceDictionaries); } + @Test + @Commit + public void test05Delete() { + resourceDictionaryReactRepository.deleteByName(sourceName).block(); + } + private ResourceDictionary transformResourceDictionary(ResourceDefinition resourceDefinition) { ResourceDictionary resourceDictionary = new ResourceDictionary(); resourceDictionary.setName(resourceDefinition.getName()); diff --git a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ResourceDictionaryRestTest.java b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ResourceDictionaryRestTest.java index 5955ae19..272cdd08 100644 --- a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ResourceDictionaryRestTest.java +++ b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ResourceDictionaryRestTest.java @@ -26,6 +26,7 @@ import org.junit.runners.MethodSorters; import org.onap.ccsdk.apps.controllerblueprints.TestApplication;
import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils;
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDefinition;
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceSourceMapping;
import org.onap.ccsdk.apps.controllerblueprints.service.domain.ResourceDictionary;
import com.att.eelf.configuration.EELFLogger;
import com.att.eelf.configuration.EELFManager;
@@ -41,7 +42,7 @@ import java.util.List; @RunWith(SpringRunner.class)
-@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
+@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT, properties = {"blueprints.load.initial-data=true"})
@ContextConfiguration(classes = {TestApplication.class})
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class ResourceDictionaryRestTest {
@@ -103,4 +104,11 @@ public class ResourceDictionaryRestTest { }
+ @Test
+ public void test03GetResourceSourceMapping() {
+ ResourceSourceMapping resourceSourceMapping = resourceDictionaryRest.getResourceSourceMapping();
+ org.springframework.util.Assert.notNull(resourceSourceMapping, "Failed to get resource source mapping");
+ org.springframework.util.Assert.notNull(resourceSourceMapping.getResourceSourceMappings(), "Failed to get resource source mappings");
+ }
+
}
diff --git a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ServiceTemplateRestTest.java b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ServiceTemplateRestTest.java index faa10825..37cc61d1 100644 --- a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ServiceTemplateRestTest.java +++ b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ServiceTemplateRestTest.java @@ -45,7 +45,7 @@ import java.util.List; @RunWith(SpringRunner.class)
-@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
+@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT, properties = {"blueprints.load.initial-data=true"})
@ContextConfiguration(classes = {TestApplication.class})
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class ServiceTemplateRestTest {
@@ -143,7 +143,7 @@ public class ServiceTemplateRestTest { List<ResourceAssignment> autoMappedResourceAssignment = autoMapResponse.getResourceAssignments();
autoMappedResourceAssignment.forEach(resourceAssignment -> {
- if ("bundle-id".equals(resourceAssignment.getName())) {
+ if ("sample-db-source".equals(resourceAssignment.getName())) {
Assert.assertEquals("Failed to assign default first source", "db",
resourceAssignment.getDictionarySource());
}
diff --git a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/validator/ServiceTemplateValidationTest.java b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/validator/ServiceTemplateValidationTest.java index 46b725f8..26fb1d32 100644 --- a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/validator/ServiceTemplateValidationTest.java +++ b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/validator/ServiceTemplateValidationTest.java @@ -19,9 +19,12 @@ package org.onap.ccsdk.apps.controllerblueprints.service.validator; import org.apache.commons.io.FileUtils;
import org.junit.Assert;
+import org.junit.Before;
import org.junit.Test;
import org.onap.ccsdk.apps.controllerblueprints.core.data.ServiceTemplate;
import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils;
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.factory.ResourceSourceMappingFactory;
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.utils.ResourceDictionaryTestUtils;
import org.onap.ccsdk.apps.controllerblueprints.service.utils.ConfigModelUtils;
import com.att.eelf.configuration.EELFLogger;
import com.att.eelf.configuration.EELFManager;
@@ -33,6 +36,12 @@ import java.util.List; public class ServiceTemplateValidationTest {
private static EELFLogger log = EELFManager.getInstance().getLogger(ServiceTemplateValidationTest.class);
+ @Before
+ public void setUp(){
+ // Setup dummy Source Instance Mapping
+ ResourceDictionaryTestUtils.setUpResourceSourceMapping();
+ }
+
@Test
public void testBluePrintDirs() {
List<String> dirs = ConfigModelUtils.getBlueprintNames("load/blueprints");
diff --git a/ms/controllerblueprints/modules/service/src/test/resources/application.properties b/ms/controllerblueprints/modules/service/src/test/resources/application.properties index 429588b3..397f3b13 100644 --- a/ms/controllerblueprints/modules/service/src/test/resources/application.properties +++ b/ms/controllerblueprints/modules/service/src/test/resources/application.properties @@ -14,7 +14,7 @@ # See the License for the specific language governing permissions and # limitations under the License. # - +spring.main.banner-mode=off spring.jackson.serialization.WRITE_DATES_AS_TIMESTAMPS = false @@ -23,9 +23,12 @@ logging.level.org.hibernate.SQL=warn logging.level.org.hibernate.type.descriptor.sql=debug -blueprints.load.initial-data=true +blueprints.load.initial-data=false load.dataTypePath=./../../application/load/model_type/data_type load.nodeTypePath=./../../application/load/model_type/node_type load.artifactTypePath=./../../application/load/model_type/artifact_type load.resourceDictionaryPath=./../../application/load/resource_dictionary -load.blueprintsPath=./../../application/load/blueprints
\ No newline at end of file +load.blueprintsPath=./../../application/load/blueprints + +# Load Resource Source Mappings +resourceSourceMappings=db=source-db,input=source-input,default=source-default,mdsal=source-rest
\ No newline at end of file diff --git a/ms/controllerblueprints/modules/service/src/test/resources/enhance/enhance-resource-assignment.json b/ms/controllerblueprints/modules/service/src/test/resources/enhance/enhance-resource-assignment.json new file mode 100644 index 00000000..3715beca --- /dev/null +++ b/ms/controllerblueprints/modules/service/src/test/resources/enhance/enhance-resource-assignment.json @@ -0,0 +1,62 @@ +[
+ {
+ "name": "rs-db-source",
+ "input-param": true,
+ "property": {
+ "type": "string",
+ "required": true
+ },
+ "dictionary-name": "sample-db-source",
+ "dictionary-source": "db",
+ "dependencies": [
+ "input-source"
+ ]
+ },
+ {
+ "name": "ra-default-source",
+ "input-param": true,
+ "property": {
+ "type": "string",
+ "required": true
+ },
+ "dictionary-name": "sample-default-source",
+ "dictionary-source": "default",
+ "dependencies": []
+ },
+ {
+ "name": "ra-input-source",
+ "input-param": true,
+ "property": {
+ "type": "string",
+ "required": true
+ },
+ "dictionary-name": "sample-input-source",
+ "dictionary-source": "input",
+ "dependencies": []
+ },
+ {
+ "name": "ra-list-input-source",
+ "input-param": true,
+ "property": {
+ "type": "list",
+ "required": true,
+ "entry_schema": {
+ "type": "string"
+ }
+ },
+ "dictionary-name": "ra-list-input-source",
+ "dictionary-source": "input",
+ "dependencies": []
+ },
+ {
+ "name": "ra-complex-input-source",
+ "input-param": true,
+ "property": {
+ "type": "dt-v4-aggregate",
+ "required": true
+ },
+ "dictionary-name": "sample-mdsal-source",
+ "dictionary-source": "mdsal",
+ "dependencies": []
+ }
+]
diff --git a/ms/controllerblueprints/modules/service/src/test/resources/enhance/enhance-template.json b/ms/controllerblueprints/modules/service/src/test/resources/enhance/enhance-template.json index 70d03e0a..782ed505 100644 --- a/ms/controllerblueprints/modules/service/src/test/resources/enhance/enhance-template.json +++ b/ms/controllerblueprints/modules/service/src/test/resources/enhance/enhance-template.json @@ -218,13 +218,13 @@ "properties": {
"mapping": [
{
- "name": "bundle-mac",
+ "name": "rs-db-source",
"property": {
"required": true,
"type": "string"
},
"input-param": false,
- "dictionary-name": "bundle-mac",
+ "dictionary-name": "sample-db-source",
"dictionary-source": "db",
"dependencies": [
"hostname"
@@ -232,7 +232,7 @@ "version": 0
},
{
- "name": "wan-aggregate-ipv4-addresses",
+ "name": "mdsal-source",
"property": {
"description": "",
"required": true,
@@ -242,7 +242,7 @@ }
},
"input-param": false,
- "dictionary-name": "wan-aggregate-ipv4-addresses",
+ "dictionary-name": "sample-mdsal-source",
"dictionary-source": "mdsal",
"dependencies": [
"service-instance-id"
@@ -313,7 +313,7 @@ }
},
"input-param": false,
- "dictionary-name": "licenses",
+ "dictionary-name": "sample-licenses",
"dictionary-source": "mdsal",
"dependencies": [
"service-instance-id"
diff --git a/ms/controllerblueprints/modules/service/src/test/resources/enhance/enhanced-template.json b/ms/controllerblueprints/modules/service/src/test/resources/enhance/enhanced-template.json index bf3deffb..531d756b 100644 --- a/ms/controllerblueprints/modules/service/src/test/resources/enhance/enhanced-template.json +++ b/ms/controllerblueprints/modules/service/src/test/resources/enhance/enhanced-template.json @@ -114,10 +114,6 @@ "description" : "This is Dynamic Data type definition generated from resource mapping for the config template name base-config-template.",
"version" : "1.0.0",
"properties" : {
- "bundle-mac" : {
- "required" : true,
- "type" : "string"
- },
"hostname" : {
"required" : true,
"type" : "string"
@@ -129,13 +125,9 @@ "type" : "dt-license-key"
}
},
- "wan-aggregate-ipv4-addresses" : {
- "description" : "",
+ "rs-db-source" : {
"required" : true,
- "type" : "list",
- "entry_schema" : {
- "type" : "dt-v4-aggregate"
- }
+ "type" : "string"
},
"service" : {
"required" : true,
@@ -144,6 +136,14 @@ "service-instance-id" : {
"required" : true,
"type" : "string"
+ },
+ "mdsal-source" : {
+ "description" : "",
+ "required" : true,
+ "type" : "list",
+ "entry_schema" : {
+ "type" : "dt-v4-aggregate"
+ }
}
},
"derived_from" : "tosca.datatypes.Dynamic"
@@ -206,6 +206,127 @@ "version" : "1.0.0",
"derived_from" : "tosca.nodes.Root"
},
+ "artifact-config-template" : {
+ "description" : "This is Configuration Velocity Template",
+ "version" : "1.0.0",
+ "properties" : {
+ "action-names" : {
+ "required" : true,
+ "type" : "list",
+ "entry_schema" : {
+ "type" : "string"
+ }
+ }
+ },
+ "capabilities" : {
+ "content" : {
+ "type" : "tosca.capabilities.Content",
+ "properties" : {
+ "content" : {
+ "required" : true,
+ "type" : "string"
+ }
+ }
+ },
+ "mapping" : {
+ "type" : "tosca.capabilities.Mapping",
+ "properties" : {
+ "mapping" : {
+ "required" : false,
+ "type" : "list",
+ "entry_schema" : {
+ "type" : "datatype-resource-assignment"
+ }
+ }
+ }
+ }
+ },
+ "derived_from" : "tosca.nodes.Artifact"
+ },
+ "tosca.nodes.Vnf" : {
+ "description" : "This is VNF Node Type",
+ "version" : "1.0.0",
+ "derived_from" : "tosca.nodes.Root"
+ },
+ "tosca.nodes.Artifact" : {
+ "description" : "This is Deprecated Artifact Node Type.",
+ "version" : "1.0.0",
+ "derived_from" : "tosca.nodes.Root"
+ },
+ "dg-activate-netconf" : {
+ "description" : "This is Download Netconf Directed Graph",
+ "version" : "1.0.0",
+ "properties" : {
+ "mode" : {
+ "required" : false,
+ "type" : "string",
+ "default" : "sync"
+ },
+ "version" : {
+ "required" : false,
+ "type" : "string",
+ "default" : "LATEST"
+ },
+ "is-start-flow" : {
+ "required" : false,
+ "type" : "boolean",
+ "default" : false
+ }
+ },
+ "capabilities" : {
+ "dg-node" : {
+ "type" : "tosca.capabilities.Node"
+ }
+ },
+ "requirements" : {
+ "component-dependency" : {
+ "capability" : "component-node",
+ "node" : "component-netconf-executor",
+ "relationship" : "tosca.relationships.DependsOn"
+ }
+ },
+ "interfaces" : {
+ "CONFIG" : {
+ "operations" : {
+ "ActivateNetconf" : {
+ "inputs" : {
+ "params" : {
+ "required" : false,
+ "type" : "list",
+ "entry_schema" : {
+ "type" : "datatype-property"
+ }
+ }
+ }
+ }
+ }
+ }
+ },
+ "derived_from" : "tosca.nodes.DG"
+ },
+ "source-input" : {
+ "description" : "This is Input Resource Source Node Type",
+ "version" : "1.0.0",
+ "properties" : {
+ "key" : {
+ "required" : false,
+ "type" : "string"
+ },
+ "key-dependencies" : {
+ "required" : true,
+ "type" : "list",
+ "entry_schema" : {
+ "type" : "string"
+ }
+ }
+ },
+ "derived_from" : "tosca.nodes.ResourceSource"
+ },
+ "tosca.nodes.ResourceSource" : {
+ "description" : "TOSCA base type for Resource Sources",
+ "version" : "1.0.0",
+ "derived_from" : "tosca.nodes.Root"
+ },
"component-resource-assignment" : {
"description" : "This is Resource Assignment Component API",
"version" : "1.0.0",
@@ -279,42 +400,44 @@ "version" : "1.0.0",
"derived_from" : "tosca.nodes.Root"
},
- "artifact-config-template" : {
- "description" : "This is Configuration Velocity Template",
+ "source-db" : {
+ "description" : "This is Database Resource Source Node Type",
"version" : "1.0.0",
"properties" : {
- "action-names" : {
+ "type" : {
"required" : true,
- "type" : "list",
+ "type" : "string",
+ "constraints" : [ {
+ "valid_values" : [ "SQL", "PLSQL" ]
+ } ]
+ },
+ "query" : {
+ "required" : true,
+ "type" : "string"
+ },
+ "input-key-mapping" : {
+ "required" : false,
+ "type" : "map",
"entry_schema" : {
"type" : "string"
}
- }
- },
- "capabilities" : {
- "content" : {
- "type" : "tosca.capabilities.Content",
- "properties" : {
- "content" : {
- "required" : true,
- "type" : "string"
- }
+ },
+ "output-key-mapping" : {
+ "required" : false,
+ "type" : "map",
+ "entry_schema" : {
+ "type" : "string"
}
},
- "mapping" : {
- "type" : "tosca.capabilities.Mapping",
- "properties" : {
- "mapping" : {
- "required" : false,
- "type" : "list",
- "entry_schema" : {
- "type" : "datatype-resource-assignment"
- }
- }
+ "key-dependencies" : {
+ "required" : true,
+ "type" : "list",
+ "entry_schema" : {
+ "type" : "string"
}
}
},
- "derived_from" : "tosca.nodes.Artifact"
+ "derived_from" : "tosca.nodes.ResourceSource"
},
"vnf-netconf-device" : {
"description" : "This is VNF Device with Netconf Capability",
@@ -357,10 +480,57 @@ },
"derived_from" : "tosca.nodes.Vnf"
},
- "tosca.nodes.Vnf" : {
- "description" : "This is VNF Node Type",
+ "source-rest" : {
+ "description" : "This is Rest Resource Source Node Type",
"version" : "1.0.0",
- "derived_from" : "tosca.nodes.Root"
+ "properties" : {
+ "type" : {
+ "required" : false,
+ "type" : "string",
+ "constraints" : [ {
+ "valid_values" : [ "JSON" ]
+ } ],
+ "default" : "JSON"
+ },
+ "url-path" : {
+ "required" : true,
+ "type" : "string"
+ },
+ "path" : {
+ "required" : true,
+ "type" : "string"
+ },
+ "expression-type" : {
+ "required" : false,
+ "type" : "string",
+ "constraints" : [ {
+ "valid_values" : [ "JSON_PATH", "JSON_POINTER" ]
+ } ],
+ "default" : "JSON_PATH"
+ },
+ "input-key-mapping" : {
+ "required" : false,
+ "type" : "map",
+ "entry_schema" : {
+ "type" : "string"
+ }
+ },
+ "output-key-mapping" : {
+ "required" : false,
+ "type" : "map",
+ "entry_schema" : {
+ "type" : "string"
+ }
+ },
+ "key-dependencies" : {
+ "required" : true,
+ "type" : "list",
+ "entry_schema" : {
+ "type" : "string"
+ }
+ }
+ },
+ "derived_from" : "tosca.nodes.ResourceSource"
},
"component-netconf-executor" : {
"description" : "This is Netconf Transaction Configuration Component API",
@@ -440,62 +610,6 @@ }
},
"derived_from" : "tosca.nodes.Component"
- },
- "tosca.nodes.Artifact" : {
- "description" : "This is Deprecated Artifact Node Type.",
- "version" : "1.0.0",
- "derived_from" : "tosca.nodes.Root"
- },
- "dg-activate-netconf" : {
- "description" : "This is Download Netconf Directed Graph",
- "version" : "1.0.0",
- "properties" : {
- "mode" : {
- "required" : false,
- "type" : "string",
- "default" : "sync"
- },
- "version" : {
- "required" : false,
- "type" : "string",
- "default" : "LATEST"
- },
- "is-start-flow" : {
- "required" : false,
- "type" : "boolean",
- "default" : false
- }
- },
- "capabilities" : {
- "dg-node" : {
- "type" : "tosca.capabilities.Node"
- }
- },
- "requirements" : {
- "component-dependency" : {
- "capability" : "component-node",
- "node" : "component-netconf-executor",
- "relationship" : "tosca.relationships.DependsOn"
- }
- },
- "interfaces" : {
- "CONFIG" : {
- "operations" : {
- "ActivateNetconf" : {
- "inputs" : {
- "params" : {
- "required" : false,
- "type" : "list",
- "entry_schema" : {
- "type" : "datatype-property"
- }
- }
- }
- }
- }
- }
- },
- "derived_from" : "tosca.nodes.DG"
}
},
"topology_template" : {
@@ -704,18 +818,18 @@ "mapping" : {
"properties" : {
"mapping" : [ {
- "name" : "bundle-mac",
+ "name" : "rs-db-source",
"property" : {
"required" : true,
"type" : "string"
},
"input-param" : false,
- "dictionary-name" : "bundle-mac",
+ "dictionary-name" : "sample-db-source",
"dictionary-source" : "db",
"dependencies" : [ "hostname" ],
"version" : 0
}, {
- "name" : "wan-aggregate-ipv4-addresses",
+ "name" : "mdsal-source",
"property" : {
"description" : "",
"required" : true,
@@ -725,7 +839,7 @@ }
},
"input-param" : false,
- "dictionary-name" : "wan-aggregate-ipv4-addresses",
+ "dictionary-name" : "sample-mdsal-source",
"dictionary-source" : "mdsal",
"dependencies" : [ "service-instance-id" ],
"version" : 0
@@ -787,7 +901,7 @@ }
},
"input-param" : false,
- "dictionary-name" : "licenses",
+ "dictionary-name" : "sample-licenses",
"dictionary-source" : "mdsal",
"dependencies" : [ "service-instance-id" ],
"version" : 0
diff --git a/ms/controllerblueprints/modules/service/src/test/resources/logback.xml b/ms/controllerblueprints/modules/service/src/test/resources/logback.xml index 4a04cfdc..7b7ef756 100644 --- a/ms/controllerblueprints/modules/service/src/test/resources/logback.xml +++ b/ms/controllerblueprints/modules/service/src/test/resources/logback.xml @@ -1,5 +1,6 @@ <!-- ~ Copyright © 2018 IBM. + ~ Modifications 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. @@ -27,8 +28,8 @@ </appender> - <logger name="org.springframework" level="info"/> - <logger name="org.springframework.web" level="info"/> + <logger name="org.springframework" level="warn"/> + <logger name="org.springframework.web" level="warn"/> <logger name="org.hibernate" level="error"/> <logger name="org.onap.ccsdk.apps" level="info"/> diff --git a/ms/controllerblueprints/modules/service/src/test/resources/resourcedictionary/automap.json b/ms/controllerblueprints/modules/service/src/test/resources/resourcedictionary/automap.json index 5a2a4ec0..c6dd7948 100644 --- a/ms/controllerblueprints/modules/service/src/test/resources/resourcedictionary/automap.json +++ b/ms/controllerblueprints/modules/service/src/test/resources/resourcedictionary/automap.json @@ -1,11 +1,14 @@ [
{
- "name": "input-source"
+ "name": "sample-input-source"
},
{
- "name": "v4-ip-type"
+ "name": "sample-default-source"
},
{
- "name": "db-source"
+ "name": "sample-db-source"
+ },
+ {
+ "name": "sample-mdsal-source"
}
]
\ No newline at end of file diff --git a/ms/controllerblueprints/pom.xml b/ms/controllerblueprints/pom.xml index 798bdae4..5c190db5 100644 --- a/ms/controllerblueprints/pom.xml +++ b/ms/controllerblueprints/pom.xml @@ -19,7 +19,7 @@ xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <parent> <groupId>org.onap.ccsdk.apps</groupId> - <artifactId>ccsdk-apps</artifactId> + <artifactId>ccsdk-apps-ms</artifactId> <version>0.3.0-SNAPSHOT</version> </parent> <modelVersion>4.0.0</modelVersion> diff --git a/ms/neng/.classpath b/ms/neng/.classpath index 1272921b..760fe4ae 100644 --- a/ms/neng/.classpath +++ b/ms/neng/.classpath @@ -6,22 +6,12 @@ <attribute name="maven.pomderived" value="true"/> </attributes> </classpathentry> - <classpathentry kind="src" output="target-ide/classes" path="opt/etc/config"> + <classpathentry excluding="**" kind="src" output="target-ide/classes" path="opt/etc/config"> <attributes> <attribute name="maven.pomderived" value="true"/> </attributes> </classpathentry> - <classpathentry kind="src" output="target-ide/classes" path="opt/etc/keystore"> - <attributes> - <attribute name="maven.pomderived" value="true"/> - </attributes> - </classpathentry> - <classpathentry kind="src" output="target-ide/classes" path="opt/etc/truststore"> - <attributes> - <attribute name="maven.pomderived" value="true"/> - </attributes> - </classpathentry> - <classpathentry kind="src" output="target-ide/classes" path="src/main/resources"> + <classpathentry excluding="**" kind="src" output="target-ide/classes" path="src/main/resources"> <attributes> <attribute name="maven.pomderived" value="true"/> </attributes> @@ -32,12 +22,7 @@ <attribute name="maven.pomderived" value="true"/> </attributes> </classpathentry> - <classpathentry kind="src" output="target-ide/test-classes" path="src/test/resources"> - <attributes> - <attribute name="maven.pomderived" value="true"/> - </attributes> - </classpathentry> - <classpathentry kind="src" output="target-ide/classes" path="opt/aai/keystore"> + <classpathentry excluding="**" kind="src" output="target-ide/test-classes" path="src/test/resources"> <attributes> <attribute name="maven.pomderived" value="true"/> </attributes> diff --git a/ms/neng/pom.xml b/ms/neng/pom.xml index 8390350a..87ac192e 100644 --- a/ms/neng/pom.xml +++ b/ms/neng/pom.xml @@ -54,6 +54,10 @@ <serviceArtifactName>ms-networkelementnamegen</serviceArtifactName> <project.version>0.3.0</project.version> <ccsdk.distribution.version>0.2.4</ccsdk.distribution.version> + <docker.buildArg.https_proxy>${https_proxy}</docker.buildArg.https_proxy> + <docker.push.phase>deploy</docker.push.phase> + <docker.verbose>true</docker.verbose> + <ccsdk.project.version>${project.version}</ccsdk.project.version> </properties> <profiles> @@ -109,6 +113,63 @@ </build> </profile> + <profile> + <id>docker</id> + <build> + <plugins> + <plugin> + <groupId>com.spotify</groupId> + <artifactId>docker-maven-plugin</artifactId> + <version>0.4.11</version> + <configuration> + <imageName>onap/ccsdk-apps-ms-neng:${project.version}</imageName> + <dockerDirectory>src/main/docker</dockerDirectory> + <serverId>docker-hub</serverId> + <registryUrl>https://${docker.registry}</registryUrl> + <imageTags> + <imageTag>${project.version}</imageTag> + <imageTag>${project.version}-STAGING-${maven.build.timestamp}</imageTag> + <imageTag>${project.docker.latesttag.version}</imageTag> + </imageTags> + <forceTags>true</forceTags> + <resources> + <resource> + <targetPath>/</targetPath> + <directory>${project.build.directory}</directory> + <include>${project.build.finalName}.jar</include> + </resource> + <resource> + <targetPath>/</targetPath> + <directory>${project.build.directory}</directory> + <include>opt/etc/config/*</include> + </resource> + <resource> + <targetPath>/</targetPath> + <directory>${project.build.directory}</directory> + <include>opt/etc/keystore/*</include> + </resource> + <resource> + <targetPath>/</targetPath> + <directory>${project.build.directory}</directory> + <include>opt/etc/truststore/*</include> + </resource> + <resource> + <targetPath>/</targetPath> + <directory>${project.build.directory}</directory> + <include>opt/aai/keystore/*</include> + </resource> + <resource> + <targetPath>/</targetPath> + <directory>${project.build.directory}</directory> + <include>etc/*</include> + </resource> + </resources> + </configuration> + </plugin> + </plugins> + </build> + </profile> + </profiles> <developers> @@ -199,11 +260,11 @@ <groupId>org.liquibase</groupId> <artifactId>liquibase-core</artifactId> </dependency> - <dependency> - <groupId>org.wisdom-framework</groupId> - <artifactId>mysql-connector-java</artifactId> - <version>5.1.34_1</version> - </dependency> + <dependency> + <groupId>org.mariadb.jdbc</groupId> + <artifactId>mariadb-java-client</artifactId> + <version>${mariadb.connector.version}</version> + </dependency> <dependency> <groupId>com.h2database</groupId> <artifactId>h2</artifactId> @@ -260,6 +321,37 @@ <finalName>NetworkElementNameGen</finalName> <plugins> <plugin> + <groupId>org.codehaus.groovy.maven</groupId> + <artifactId>gmaven-plugin</artifactId> + <version>1.0</version> + <executions> + <execution> + <phase>validate</phase> + <goals> + <goal>execute</goal> + </goals> + <configuration> + <source> + println project.properties['ccsdk.project.version']; + def versionArray; + if (project.properties['ccsdk.project.version'] != null ) { + versionArray = project.properties['ccsdk.project.version'].split('\\.'); + } + + if (project.properties['ccsdk.project.version'].endsWith("-SNAPSHOT")) + { + project.properties['project.docker.latesttag.version']=versionArray[0] + '.' + versionArray[1] + "-STAGING-latest"; + } else { + project.properties['project.docker.latesttag.version']=versionArray[0]+'.' + versionArray[1]+"-STAGING-latest"; + } + + println 'New Tag for docker:' + project.properties['project.docker.latesttag.version']; + </source> + </configuration> + </execution> + </executions> + </plugin> + <plugin> <groupId>org.jacoco</groupId> <artifactId>jacoco-maven-plugin</artifactId> <version>0.7.5.201505241946</version> @@ -433,54 +525,7 @@ </plugin> --> - <plugin> - <groupId>com.spotify</groupId> - <artifactId>docker-maven-plugin</artifactId> - <version>0.4.11</version> - <configuration> - <imageName>onap/ccsdk-apps-ms-neng:${project.version}</imageName> - <dockerDirectory>src/main/docker</dockerDirectory> - <serverId>docker-hub</serverId> - <registryUrl>https://${docker.registry}</registryUrl> - <imageTags> - <imageTag>${project.version}</imageTag> - <imageTag>latest</imageTag> - </imageTags> - <forceTags>true</forceTags> - <resources> - <resource> - <targetPath>/</targetPath> - <directory>${project.build.directory}</directory> - <include>${project.build.finalName}.jar</include> - </resource> - <resource> - <targetPath>/</targetPath> - <directory>${project.build.directory}</directory> - <include>opt/etc/config/*</include> - </resource> - <resource> - <targetPath>/</targetPath> - <directory>${project.build.directory}</directory> - <include>opt/etc/keystore/*</include> - </resource> - <resource> - <targetPath>/</targetPath> - <directory>${project.build.directory}</directory> - <include>opt/etc/truststore/*</include> - </resource> - <resource> - <targetPath>/</targetPath> - <directory>${project.build.directory}</directory> - <include>opt/aai/keystore/*</include> - </resource> - <resource> - <targetPath>/</targetPath> - <directory>${project.build.directory}</directory> - <include>etc/*</include> - </resource> - </resources> - </configuration> - </plugin> + <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> @@ -593,5 +638,6 @@ </plugins> </pluginManagement> </build> + </project> diff --git a/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/core/JerseyConfiguration.java b/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/core/JerseyConfiguration.java index 4905e6eb..ead6a1b4 100644 --- a/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/core/JerseyConfiguration.java +++ b/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/core/JerseyConfiguration.java @@ -40,6 +40,13 @@ import org.springframework.stereotype.Component; @Component @ApplicationPath("/") public class JerseyConfiguration extends ResourceConfig { + + @Autowired + public JerseyConfiguration() { + register(RestServiceImpl.class); + property(ServletProperties.FILTER_FORWARD_ON_404, true); + } + /** * Builds the bean configuring Jackson for JSON serialization. */ @@ -53,10 +60,4 @@ public class JerseyConfiguration extends ResourceConfig { objectMapper.enable(DeserializationFeature.READ_ENUMS_USING_TO_STRING); return objectMapper; } - - @Autowired - public JerseyConfiguration() { - register(RestServiceImpl.class); - property(ServletProperties.FILTER_FORWARD_ON_404, true); - } } diff --git a/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/core/service/SpringServiceImpl.java b/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/core/service/SpringServiceImpl.java index 79e46575..daf8f574 100644 --- a/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/core/service/SpringServiceImpl.java +++ b/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/core/service/SpringServiceImpl.java @@ -4,6 +4,8 @@ * ================================================================================ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. * ================================================================================ + * Modifications Copyright (C) 2018 IBM. + * ================================================================================ * 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 @@ -94,12 +96,12 @@ public class SpringServiceImpl implements SpringService { @Transactional(rollbackOn = Exception.class) public NameGenResponse genNetworkElementName(NameGenRequest request) throws Exception { try { - Map<String, Map<String, String>> earlierNames = new HashMap<String, Map<String, String>>(); - List<Map<String, String>> allElements = new ArrayList<Map<String, String>>(); - Map<String, Map<String, ?>> policyCache = new HashMap<String, Map<String, ?>>(); - List<Map<String, String>> generatedNames = new ArrayList<Map<String, String>>(); + Map<String, Map<String, String>> earlierNames = new HashMap<>(); + List<Map<String, String>> allElements = new ArrayList<>(); + Map<String, Map<String, ?>> policyCache = new HashMap<>(); + List<Map<String, String>> generatedNames = new ArrayList<>(); validateRequest(request); - if (request.getElements() != null && request.getElements().size() > 0) { + if (!request.getElements().isEmpty()) { allElements.addAll(request.getElements()); } PolicyFinder policyFinderImpl = findPolicyFinderImpl(request); @@ -194,7 +196,7 @@ public class SpringServiceImpl implements SpringService { void validateRequest(NameGenRequest request) throws Exception { List<Map<String, String>> elems = request.getElements(); - if (elems != null && elems.size() > 0) { + if (!elems.isEmpty()) { boolean error = false; Set<String> externalKeySet = elems.stream().map(s -> s.get("external-key")).collect(Collectors.toSet()); if (externalKeySet.size() != request.getElements().size()) { diff --git a/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/gen/SequenceFormatterTest.java b/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/gen/SequenceFormatterTest.java index df28ccce..5a161319 100644 --- a/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/gen/SequenceFormatterTest.java +++ b/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/gen/SequenceFormatterTest.java @@ -4,6 +4,8 @@ * ================================================================================ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. * ================================================================================ + * Modifications Copyright (C) 2018 IBM. + * ================================================================================ * 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 @@ -22,13 +24,22 @@ package org.onap.ccsdk.apps.ms.neng.core.gen; import static org.junit.Assert.assertEquals; +import org.junit.Before; import org.junit.Test; import org.onap.ccsdk.apps.ms.neng.core.policy.PolicySequence; public class SequenceFormatterTest { + + private PolicySequence poly; + + @Before + public void setUp() + { + poly = new PolicySequence(); + } + @Test public void formatSequence() throws Exception { - PolicySequence poly = new PolicySequence(); poly.setLength(3);; assertEquals("001", SequenceFormatter.formatSequence(1, poly)); poly.setLength(2);; @@ -39,7 +50,6 @@ public class SequenceFormatterTest { @Test public void formatSequenceAlpha() throws Exception { - PolicySequence poly = new PolicySequence(); poly.setLength(3);; poly.setType(PolicySequence.Type.ALPHA); assertEquals("001", SequenceFormatter.formatSequence(1, poly)); @@ -48,4 +58,33 @@ public class SequenceFormatterTest { poly.setLength(4);; assertEquals("000b", SequenceFormatter.formatSequence(11, poly)); } + + @Test + public void testGetSetIncrement() + { + poly.setIncrement(1L); + assertEquals(1L, poly.getIncrement()); + } + + @Test + public void testGetSetMaxValue() + { + poly.setMaxValue(1L); + assertEquals(1L, poly.getMaxValue()); + } + + @Test + public void testGetSetKey() + { + poly.setKey("testKey"); + assertEquals("testKey", poly.getKey()); + } + + @Test + public void testGetSetLastReleaseSeqNumTried() + { + poly.setLastReleaseSeqNumTried(1L); + Long expected=1L; + assertEquals(expected, poly.getLastReleaseSeqNumTried()); + } } diff --git a/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/policy/PropertyOperatorTest.java b/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/policy/PropertyOperatorTest.java index 9d6c3f92..38d44f18 100644 --- a/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/policy/PropertyOperatorTest.java +++ b/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/policy/PropertyOperatorTest.java @@ -4,6 +4,8 @@ * ================================================================================ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. * ================================================================================ + * Modifications Copyright (C) 2018 IBM. + * ================================================================================ * 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 @@ -21,6 +23,7 @@ package org.onap.ccsdk.apps.ms.neng.core.policy; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @@ -72,6 +75,12 @@ public class PropertyOperatorTest { PropertyOperator op = new PropertyOperator(); assertEquals("ASDF", op.apply("asdf", props, params)); } + + @Test + public void testApply() throws Exception { + PropertyOperator op = new PropertyOperator(); + assertNull("ASDF", op.apply("asdf", "", params)); + } @Test public void applySubstr() throws Exception { diff --git a/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/persistence/entity/TestExternalInterface.java b/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/persistence/entity/TestExternalInterface.java new file mode 100644 index 00000000..26d2ef0e --- /dev/null +++ b/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/persistence/entity/TestExternalInterface.java @@ -0,0 +1,97 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : CCSDK.apps + * ================================================================================ + * Copyright (C) 2018 IBM. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.onap.ccsdk.apps.ms.neng.persistence.entity; + +import java.sql.Timestamp; +import java.text.DateFormat; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.Date; + +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +public class TestExternalInterface { + private ExternalInterface externalInterface; + + @Before + public void setUp() { + externalInterface = new ExternalInterface(); + } + + @Test + public void testGetSetExternalInteraceId() { + externalInterface.setExternalInteraceId(1); + Integer expected = 1; + Assert.assertEquals(expected, externalInterface.getExternalInteraceId()); + } + + @Test + public void testGetSetSystem() { + externalInterface.setSystem("testSystem"); + Assert.assertEquals("testSystem", externalInterface.getSystem()); + } + + @Test + public void testGetSetParam() { + externalInterface.setParam("testParam"); + Assert.assertEquals("testParam", externalInterface.getParam()); + } + + @Test + public void testGetSetUrlSuffix() { + externalInterface.setUrlSuffix("testUrlSuffix"); + Assert.assertEquals("testUrlSuffix", externalInterface.getUrlSuffix()); + } + + @Test + public void testGetSetTimeStamp() throws ParseException { + DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy"); + Date date = dateFormat.parse("23/09/2007"); + long time = date.getTime(); + Timestamp timeStamp = new Timestamp(time); + externalInterface.setCreatedTime(timeStamp); + Assert.assertEquals(timeStamp, externalInterface.getCreatedTime()); + } + + @Test + public void testGetSetCreatedBy() { + externalInterface.setCreatedBy("testUser"); + Assert.assertEquals("testUser", externalInterface.getCreatedBy()); + } + + @Test + public void testGetSetLastUpdatedTime() throws ParseException { + DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy"); + Date date = dateFormat.parse("23/09/2007"); + long time = date.getTime(); + Timestamp timeStamp = new Timestamp(time); + externalInterface.setLastUpdatedTime(timeStamp); + Assert.assertEquals(timeStamp, externalInterface.getLastUpdatedTime()); + } + + @Test + public void testGetSetLastUpdatedBy() { + externalInterface.setLastUpdatedBy("testUser"); + Assert.assertEquals("testUser", externalInterface.getLastUpdatedBy()); + } +} @@ -38,8 +38,9 @@ <description>Micro-services</description> <modules> + <module>controllerblueprints</module> <module>neng</module> - <module>vlantag-api</module> + <module>vlantag-api</module> </modules> </project> diff --git a/ms/vlantag-api/pom.xml b/ms/vlantag-api/pom.xml index 431d0a32..08466dcd 100644 --- a/ms/vlantag-api/pom.xml +++ b/ms/vlantag-api/pom.xml @@ -17,7 +17,7 @@ <swagger.annotations.version>1.5.8</swagger.annotations.version> <java.version>1.8</java.version> <springboot.version>2.0.4.RELEASE</springboot.version> - <mysql.connector.version>5.1.46</mysql.connector.version> + <mariadb.connector.version>2.1.1</mariadb.connector.version> <ccsdk.sli.adaptors.version>0.3.0-SNAPSHOT</ccsdk.sli.adaptors.version> <docker.registry>TBD:5100</docker.registry> <serviceArtifactName>vlantagapi</serviceArtifactName> @@ -33,12 +33,16 @@ <sonar.jacoco.itReportPath>${basedir}/target/jacoco-it.exec</sonar.jacoco.itReportPath> <sonar.language>java</sonar.language> <ilib.version>2.0.7</ilib.version> + <docker.buildArg.https_proxy>${https_proxy}</docker.buildArg.https_proxy> + <docker.push.phase>deploy</docker.push.phase> + <docker.verbose>true</docker.verbose> + <ccsdk.project.version>${project.version}</ccsdk.project.version> </properties> <parent> - <groupId>org.springframework.boot</groupId> + <groupId>org.onap.ccsdk.parent</groupId> <artifactId>spring-boot-starter-parent</artifactId> - <version>2.0.4.RELEASE</version> + <version>1.1.0-SNAPSHOT</version> <relativePath /> </parent> @@ -82,9 +86,9 @@ </dependency> <dependency> - <groupId>mysql</groupId> - <artifactId>mysql-connector-java</artifactId> - <version>5.1.46</version> + <groupId>org.mariadb.jdbc</groupId> + <artifactId>mariadb-java-client</artifactId> + <version>${mariadb.connector.version}</version> </dependency> <dependency> @@ -98,6 +102,37 @@ <build> <plugins> + <plugin> + <groupId>org.codehaus.groovy.maven</groupId> + <artifactId>gmaven-plugin</artifactId> + <version>1.0</version> + <executions> + <execution> + <phase>validate</phase> + <goals> + <goal>execute</goal> + </goals> + <configuration> + <source> + println project.properties['ccsdk.project.version']; + def versionArray; + if (project.properties['ccsdk.project.version'] != null ) { + versionArray = project.properties['ccsdk.project.version'].split('\\.'); + } + + if (project.properties['ccsdk.project.version'].endsWith("-SNAPSHOT")) + { + project.properties['project.docker.latesttag.version']=versionArray[0] + '.' + versionArray[1] + "-STAGING-latest"; + } else { + project.properties['project.docker.latesttag.version']=versionArray[0]+'.' + versionArray[1]+"-STAGING-latest"; + } + + println 'New Tag for docker:' + project.properties['project.docker.latesttag.version']; + </source> + </configuration> + </execution> + </executions> + </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> @@ -224,5 +259,39 @@ </plugins> </build> + <profiles> + <profile> + <id>docker</id> + <build> + <plugins> + <plugin> + <groupId>com.spotify</groupId> + <artifactId>docker-maven-plugin</artifactId> + <version>0.4.11</version> + <configuration> + <imageName>${docker.registry}/org.onap.ccsdk.apps/${serviceArtifactName}</imageName> + <dockerDirectory>src/main/docker</dockerDirectory> + <serverId>docker-hub</serverId> + <registryUrl>https://${docker.registry}</registryUrl> + <imageTags> + <imageTag>${project.version}</imageTag> + <imageTag>${project.version}-STAGING-${maven.build.timestamp}</imageTag> + <imageTag>${project.docker.latesttag.version}</imageTag> + </imageTags> + <forceTags>true</forceTags> + <resources> + <resource> + <targetPath>/</targetPath> + <directory>${project.build.directory}</directory> + <include>${project.build.finalName}.jar</include> + </resource> + </resources> + </configuration> + </plugin> + </plugins> + </build> + </profile> + </profiles> + </project> diff --git a/ms/vlantag-api/src/main/java/org/onap/ccsdk/apps/ms/vlantagapi/core/Application.java b/ms/vlantag-api/src/main/java/org/onap/ccsdk/apps/ms/vlantagapi/core/Application.java index bd18a986..00489655 100644 --- a/ms/vlantag-api/src/main/java/org/onap/ccsdk/apps/ms/vlantagapi/core/Application.java +++ b/ms/vlantag-api/src/main/java/org/onap/ccsdk/apps/ms/vlantagapi/core/Application.java @@ -16,7 +16,6 @@ package org.onap.ccsdk.apps.ms.vlantagapi.core;
import org.springframework.boot.SpringApplication;
-import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
/**
diff --git a/version.properties b/version.properties index 60a8d1ca..4c1c6c69 100644 --- a/version.properties +++ b/version.properties @@ -4,8 +4,8 @@ # because they are used in Jenkins, whose plug-in doesn't support -release_name=1 -sprint_number=1 +release_name=0 +sprint_number=3 feature_revision=0 base_version=${release_name}.${sprint_number}.${feature_revision} |