From 1f9a8648b139281fdd8391949e0a54a2be2added Mon Sep 17 00:00:00 2001 From: "Muthuramalingam, Brinda Santh(bs2796)" Date: Thu, 13 Sep 2018 14:25:49 +0000 Subject: 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) --- .../service/enhancer/BluePrintEnhancerService.kt | 8 ++++---- .../service/enhancer/ResourceAssignmentEnhancerServiceTest.java | 8 +++----- .../service/validator/ServiceTemplateValidationTest.java | 7 +++---- 3 files changed, 10 insertions(+), 13 deletions(-) (limited to 'ms') diff --git a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintEnhancerService.kt b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintEnhancerService.kt index cf9e96e7..46709c5f 100644 --- a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintEnhancerService.kt +++ b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintEnhancerService.kt @@ -171,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) } @@ -246,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 @@ -254,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 @@ -262,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/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/ResourceAssignmentEnhancerServiceTest.java b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/ResourceAssignmentEnhancerServiceTest.java index e279ec9c..a5d1e417 100644 --- a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/ResourceAssignmentEnhancerServiceTest.java +++ b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/ResourceAssignmentEnhancerServiceTest.java @@ -26,9 +26,9 @@ 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.factory.ResourceSourceMappingFactory; 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; @@ -42,10 +42,8 @@ public class ResourceAssignmentEnhancerServiceTest { @Before public void setUp(){ - ResourceSourceMappingFactory.INSTANCE.registerSourceMapping("db", "source-db"); - ResourceSourceMappingFactory.INSTANCE.registerSourceMapping("input", "source-input"); - ResourceSourceMappingFactory.INSTANCE.registerSourceMapping("default", "source-default"); - ResourceSourceMappingFactory.INSTANCE.registerSourceMapping("mdsal", "source-rest"); + // Setup dummy Source Instance Mapping + ResourceDictionaryTestUtils.setUpResourceSourceMapping(); } @Test 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 5f34b551..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 @@ -24,6 +24,7 @@ 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; @@ -37,10 +38,8 @@ public class ServiceTemplateValidationTest { @Before public void setUp(){ - ResourceSourceMappingFactory.INSTANCE.registerSourceMapping("db", "source-db"); - ResourceSourceMappingFactory.INSTANCE.registerSourceMapping("input", "source-input"); - ResourceSourceMappingFactory.INSTANCE.registerSourceMapping("default", "source-default"); - ResourceSourceMappingFactory.INSTANCE.registerSourceMapping("mdsal", "source-rest"); + // Setup dummy Source Instance Mapping + ResourceDictionaryTestUtils.setUpResourceSourceMapping(); } @Test -- cgit 1.2.3-korg