Controller Blueprints Microservice
authorMuthuramalingam, Brinda Santh(bs2796) <bs2796@att.com>
Thu, 13 Sep 2018 14:25:49 +0000 (14:25 +0000)
committerMuthuramalingam, Brinda Santh(bs2796) <bs2796@att.com>
Thu, 13 Sep 2018 14:25:49 +0000 (14:25 +0000)
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>
ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintEnhancerService.kt
ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/ResourceAssignmentEnhancerServiceTest.java
ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/validator/ServiceTemplateValidationTest.java

index cf9e96e..46709c5 100644 (file)
@@ -171,7 +171,7 @@ open class BluePrintEnhancerDefaultService(val bluePrintRepoService: BluePrintRe
     }\r
 \r
     open fun enrichNodeTypeCapabilityProperties(nodeTypeName: String, nodeType: NodeType) {\r
-        nodeType.capabilities?.forEach { capabilityDefinitionName, capabilityDefinition ->\r
+        nodeType.capabilities?.forEach { _, capabilityDefinition ->\r
             capabilityDefinition.properties?.let { properties ->\r
                 enrichPropertyDefinitions(properties)\r
             }\r
@@ -246,7 +246,7 @@ open class BluePrintEnhancerDefaultService(val bluePrintRepoService: BluePrintRe
     open fun populateNodeType(nodeTypeName: String): NodeType {\r
 \r
         val nodeType = serviceTemplate.nodeTypes?.get(nodeTypeName)\r
-                ?: bluePrintRepoService.getNodeType(nodeTypeName)?.block()\r
+                ?: bluePrintRepoService.getNodeType(nodeTypeName).block()\r
                 ?: throw BluePrintException(format("Couldn't get NodeType({}) from repo.", nodeTypeName))\r
         serviceTemplate.nodeTypes?.put(nodeTypeName, nodeType)\r
         return nodeType\r
@@ -254,7 +254,7 @@ open class BluePrintEnhancerDefaultService(val bluePrintRepoService: BluePrintRe
 \r
     open fun populateArtifactType(artifactTypeName: String): ArtifactType {\r
         val artifactType = serviceTemplate.artifactTypes?.get(artifactTypeName)\r
-                ?: bluePrintRepoService.getArtifactType(artifactTypeName)?.block()\r
+                ?: bluePrintRepoService.getArtifactType(artifactTypeName).block()\r
                 ?: throw BluePrintException(format("Couldn't get ArtifactType({}) from repo.", artifactTypeName))\r
         serviceTemplate.artifactTypes?.put(artifactTypeName, artifactType)\r
         return artifactType\r
@@ -262,7 +262,7 @@ open class BluePrintEnhancerDefaultService(val bluePrintRepoService: BluePrintRe
 \r
     open fun populateDataTypes(dataTypeName: String): DataType {\r
         val dataType = serviceTemplate.dataTypes?.get(dataTypeName)\r
-                ?: bluePrintRepoService.getDataType(dataTypeName)?.block()\r
+                ?: bluePrintRepoService.getDataType(dataTypeName).block()\r
                 ?: throw BluePrintException(format("Couldn't get DataType({}) from repo.", dataTypeName))\r
         serviceTemplate.dataTypes?.put(dataTypeName, dataType)\r
         return dataType\r
index e279ec9..a5d1e41 100644 (file)
@@ -26,9 +26,9 @@ import org.onap.ccsdk.apps.controllerblueprints.core.data.ServiceTemplate;
 import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonReactorUtils;\r
 import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils;\r
 import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment;\r
-import org.onap.ccsdk.apps.controllerblueprints.resource.dict.factory.ResourceSourceMappingFactory;\r
 import org.onap.ccsdk.apps.controllerblueprints.resource.dict.service.ResourceDefinitionFileRepoService;\r
 import org.onap.ccsdk.apps.controllerblueprints.resource.dict.service.ResourceDefinitionRepoService;\r
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.utils.ResourceDictionaryTestUtils;\r
 \r
 import java.util.List;\r
 \r
@@ -42,10 +42,8 @@ public class ResourceAssignmentEnhancerServiceTest {
 \r
     @Before\r
     public void setUp(){\r
-        ResourceSourceMappingFactory.INSTANCE.registerSourceMapping("db", "source-db");\r
-        ResourceSourceMappingFactory.INSTANCE.registerSourceMapping("input", "source-input");\r
-        ResourceSourceMappingFactory.INSTANCE.registerSourceMapping("default", "source-default");\r
-        ResourceSourceMappingFactory.INSTANCE.registerSourceMapping("mdsal", "source-rest");\r
+        // Setup dummy Source Instance Mapping\r
+        ResourceDictionaryTestUtils.setUpResourceSourceMapping();\r
     }\r
 \r
     @Test\r
index 5f34b55..26fb1d3 100644 (file)
@@ -24,6 +24,7 @@ import org.junit.Test;
 import org.onap.ccsdk.apps.controllerblueprints.core.data.ServiceTemplate;\r
 import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils;\r
 import org.onap.ccsdk.apps.controllerblueprints.resource.dict.factory.ResourceSourceMappingFactory;\r
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.utils.ResourceDictionaryTestUtils;\r
 import org.onap.ccsdk.apps.controllerblueprints.service.utils.ConfigModelUtils;\r
 import com.att.eelf.configuration.EELFLogger;\r
 import com.att.eelf.configuration.EELFManager;\r
@@ -37,10 +38,8 @@ public class ServiceTemplateValidationTest {
 \r
     @Before\r
     public void setUp(){\r
-        ResourceSourceMappingFactory.INSTANCE.registerSourceMapping("db", "source-db");\r
-        ResourceSourceMappingFactory.INSTANCE.registerSourceMapping("input", "source-input");\r
-        ResourceSourceMappingFactory.INSTANCE.registerSourceMapping("default", "source-default");\r
-        ResourceSourceMappingFactory.INSTANCE.registerSourceMapping("mdsal", "source-rest");\r
+        // Setup dummy Source Instance Mapping\r
+        ResourceDictionaryTestUtils.setUpResourceSourceMapping();\r
     }\r
 \r
     @Test\r