From: Muthuramalingam, Brinda Santh(bs2796) Date: Mon, 27 Aug 2018 13:53:21 +0000 (+0000) Subject: Controller Blueprints Microservice X-Git-Tag: 0.4.2~160^2~144 X-Git-Url: https://gerrit.onap.org/r/gitweb?a=commitdiff_plain;h=2b5c7e5b12440f35009d17d008b4061445b0524c;p=ccsdk%2Fcds.git Controller Blueprints Microservice 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) --- diff --git a/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/mdsal-source.json b/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/mdsal-source.json index 73d835c10..413d90446 100644 --- a/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/mdsal-source.json +++ b/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/mdsal-source.json @@ -24,7 +24,7 @@ "output-key-mapping": { "oam-local-ipv4-address": "v4-ip-prefix" }, - "key-dependency": [ + "key-dependencies": [ "service-instance-id", "network-role", "v4-ip-type", diff --git a/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDictionaryConstants.java b/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDictionaryConstants.java index ddbd88bda..48b89bd6d 100644 --- a/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDictionaryConstants.java +++ b/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDictionaryConstants.java @@ -26,5 +26,5 @@ public class ResourceDictionaryConstants { public static final String PROPERTY_TYPE = "type"; public static final String PROPERTY_INPUT_KEY_MAPPING = "input-key-mapping"; public static final String PROPERTY_OUTPUT_KEY_MAPPING = "output-key-mapping"; - public static final String PROPERTY_KEY_DEPENDENCY = "key-dependency"; + public static final String PROPERTY_KEY_DEPENDENCIES = "key-dependencies"; } diff --git a/ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/util/ResourceDefinitionTest.java b/ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDefinitionTest.java similarity index 92% rename from ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/util/ResourceDefinitionTest.java rename to ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDefinitionTest.java index c71843804..3e68d0991 100644 --- a/ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/util/ResourceDefinitionTest.java +++ b/ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDefinitionTest.java @@ -15,12 +15,11 @@ * limitations under the License. */ -package org.onap.ccsdk.apps.controllerblueprints.resource.dict.util; +package org.onap.ccsdk.apps.controllerblueprints.resource.dict; import org.junit.Assert; import org.junit.Test; import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils; -import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDefinition; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDictionaryValidationServiceTest.java b/ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDictionaryValidationServiceTest.java index 6eebdb2f0..b50c0e44b 100644 --- a/ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDictionaryValidationServiceTest.java +++ b/ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDictionaryValidationServiceTest.java @@ -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); } }