Controller Blueprints Microservice
authorMuthuramalingam, Brinda Santh(bs2796) <bs2796@att.com>
Mon, 27 Aug 2018 13:53:21 +0000 (13:53 +0000)
committerMuthuramalingam, Brinda Santh(bs2796) <bs2796@att.com>
Mon, 27 Aug 2018 14:01:51 +0000 (14:01 +0000)
Add junit test case for input, default and rest resource definition validation.

Change-Id: I5ee37891768e5985bc7a4df6f6b917396f439bf2
Issue-ID: CCSDK-487
Signed-off-by: Muthuramalingam, Brinda Santh(bs2796) <bs2796@att.com>
ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/mdsal-source.json
ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDictionaryConstants.java
ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDefinitionTest.java [moved from ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/util/ResourceDefinitionTest.java with 92% similarity]
ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDictionaryValidationServiceTest.java

index 73d835c..413d904 100644 (file)
@@ -24,7 +24,7 @@
         "output-key-mapping": {\r
           "oam-local-ipv4-address": "v4-ip-prefix"\r
         },\r
-        "key-dependency": [\r
+        "key-dependencies": [\r
           "service-instance-id",\r
           "network-role",\r
           "v4-ip-type",\r
index ddbd88b..48b89bd 100644 (file)
@@ -26,5 +26,5 @@ public class ResourceDictionaryConstants {
     public static final String PROPERTY_TYPE = "type";\r
     public static final String PROPERTY_INPUT_KEY_MAPPING = "input-key-mapping";\r
     public static final String PROPERTY_OUTPUT_KEY_MAPPING = "output-key-mapping";\r
-    public static final String PROPERTY_KEY_DEPENDENCY = "key-dependency";\r
+    public static final String PROPERTY_KEY_DEPENDENCIES = "key-dependencies";\r
 }\r
  *  limitations under the License.\r
  */\r
 \r
-package org.onap.ccsdk.apps.controllerblueprints.resource.dict.util;\r
+package org.onap.ccsdk.apps.controllerblueprints.resource.dict;\r
 \r
 import org.junit.Assert;\r
 import org.junit.Test;\r
 import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils;\r
-import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDefinition;\r
 import org.slf4j.Logger;\r
 import org.slf4j.LoggerFactory;\r
 \r
index 6eebdb2..b50c0e4 100644 (file)
@@ -25,18 +25,32 @@ import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDefinition
 public class ResourceDictionaryValidationServiceTest {
     private String basePath = "load/model_type";
     String dictionaryPath = "load/resource_dictionary";
+    BluePrintRepoFileService bluePrintRepoFileService = new BluePrintRepoFileService(basePath);
 
     @Test
-    public void testValidate() throws Exception {
-        BluePrintRepoFileService bluePrintRepoFileService = new BluePrintRepoFileService(basePath);
+    public void testValidateSource() throws Exception {
+
+        String inputFileName = dictionaryPath + "/db-source.json";
+        testValidate(inputFileName);
+
+        String dbFileName = dictionaryPath + "/db-source.json";
+        testValidate(dbFileName);
+
+        String defaultFileName = dictionaryPath + "/default-source.json";
+        testValidate(defaultFileName);
+
+        String restFileName = dictionaryPath + "/mdsal-source.json";
+        testValidate(restFileName);
+    }
+
+    private void testValidate(String fileName) throws Exception {
 
-        String fileName = dictionaryPath + "/db-source.json";
         ResourceDefinition resourceDefinition = JacksonUtils.readValueFromFile(fileName, ResourceDefinition.class);
-        Assert.assertNotNull("Failed to populate dictionaryDefinition for db type", resourceDefinition);
+        Assert.assertNotNull("Failed to populate dictionaryDefinition for  type", resourceDefinition);
 
         ResourceDictionaryValidationService resourceDictionaryValidationService =
                 new ResourceDictionaryDefaultValidationService(bluePrintRepoFileService);
         resourceDictionaryValidationService.validate(resourceDefinition);
-
+        Assert.assertNotNull(String.format("Failed to populate dictionaryDefinition for : %s", fileName), resourceDefinition);
     }
 }