diff options
author | Muthuramalingam, Brinda Santh(bs2796) <bs2796@att.com> | 2018-09-13 14:25:49 +0000 |
---|---|---|
committer | Muthuramalingam, Brinda Santh(bs2796) <bs2796@att.com> | 2018-09-13 14:25:49 +0000 |
commit | 1f9a8648b139281fdd8391949e0a54a2be2added (patch) | |
tree | 4e0253a4b29afeffa32ec5985a56fa3c9a5b5952 /components/core | |
parent | 5eebfaa6ac0d4cb4fdf20d19ead7cd0303fc6f29 (diff) |
Controller Blueprints Microservice
Optimise dictionary dummy data creation reusability and property usage optimisation.
Change-Id: Ibbd56d514f437f29943cebc0e607becb6798e4b6
Issue-ID: CCSDK-491
Signed-off-by: Muthuramalingam, Brinda Santh(bs2796) <bs2796@att.com>
Diffstat (limited to 'components/core')
6 files changed, 15 insertions, 15 deletions
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/BluePrintRuntimeService.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeService.kt index 1fdb6c3c..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 @@ -308,7 +308,7 @@ 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)
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/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/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 |