From 522a86b6dc2d08b16ba6aba682d5d1fd8558ad25 Mon Sep 17 00:00:00 2001 From: "Muthuramalingam, Brinda Santh(bs2796)" Date: Mon, 27 Aug 2018 13:53:21 +0000 Subject: 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) --- .../load/resource_dictionary/mdsal-source.json | 2 +- .../resource/dict/ResourceDictionaryConstants.java | 2 +- .../resource/dict/ResourceDefinitionTest.java | 60 +++++++++++++++++++++ .../ResourceDictionaryValidationServiceTest.java | 24 +++++++-- .../resource/dict/util/ResourceDefinitionTest.java | 61 ---------------------- 5 files changed, 81 insertions(+), 68 deletions(-) create mode 100644 ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDefinitionTest.java delete mode 100644 ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/util/ResourceDefinitionTest.java (limited to 'ms/controllerblueprints/modules/resource-dict') 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 73d835c1..413d9044 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 ddbd88bd..48b89bd6 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/ResourceDefinitionTest.java b/ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDefinitionTest.java new file mode 100644 index 00000000..3e68d099 --- /dev/null +++ b/ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDefinitionTest.java @@ -0,0 +1,60 @@ +/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * Modifications Copyright © 2018 IBM. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +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.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class ResourceDefinitionTest { + private Logger log = LoggerFactory.getLogger(ResourceDefinitionTest.class); + String basePath = "load/resource_dictionary"; + + @Test + public void testDictionaryDefinitionInputSource(){ + + String fileName = basePath + "/input-source.json"; + ResourceDefinition resourceDefinition = JacksonUtils.readValueFromFile(fileName, ResourceDefinition.class); + Assert.assertNotNull("Failed to populate dictionaryDefinition for input type", resourceDefinition); + } + + @Test + public void testDictionaryDefinitionDefaultSource(){ + + String fileName = basePath + "/default-source.json"; + ResourceDefinition resourceDefinition = JacksonUtils.readValueFromFile(fileName, ResourceDefinition.class); + Assert.assertNotNull("Failed to populate dictionaryDefinition for default type", resourceDefinition); + } + + @Test + public void testDictionaryDefinitionDBSource(){ + + String fileName = basePath + "/db-source.json"; + ResourceDefinition resourceDefinition = JacksonUtils.readValueFromFile(fileName, ResourceDefinition.class); + Assert.assertNotNull("Failed to populate dictionaryDefinition for db type", resourceDefinition); + } + + @Test + public void testDictionaryDefinitionMDSALSource(){ + String fileName = basePath + "/mdsal-source.json"; + ResourceDefinition resourceDefinition = JacksonUtils.readValueFromFile(fileName, ResourceDefinition.class); + Assert.assertNotNull("Failed to populate dictionaryDefinition for mdsal type", resourceDefinition); + } +} 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 6eebdb2f..b50c0e44 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); } } 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/util/ResourceDefinitionTest.java deleted file mode 100644 index c7184380..00000000 --- a/ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/util/ResourceDefinitionTest.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.apps.controllerblueprints.resource.dict.util; - -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; - -public class ResourceDefinitionTest { - private Logger log = LoggerFactory.getLogger(ResourceDefinitionTest.class); - String basePath = "load/resource_dictionary"; - - @Test - public void testDictionaryDefinitionInputSource(){ - - String fileName = basePath + "/input-source.json"; - ResourceDefinition resourceDefinition = JacksonUtils.readValueFromFile(fileName, ResourceDefinition.class); - Assert.assertNotNull("Failed to populate dictionaryDefinition for input type", resourceDefinition); - } - - @Test - public void testDictionaryDefinitionDefaultSource(){ - - String fileName = basePath + "/default-source.json"; - ResourceDefinition resourceDefinition = JacksonUtils.readValueFromFile(fileName, ResourceDefinition.class); - Assert.assertNotNull("Failed to populate dictionaryDefinition for default type", resourceDefinition); - } - - @Test - public void testDictionaryDefinitionDBSource(){ - - String fileName = basePath + "/db-source.json"; - ResourceDefinition resourceDefinition = JacksonUtils.readValueFromFile(fileName, ResourceDefinition.class); - Assert.assertNotNull("Failed to populate dictionaryDefinition for db type", resourceDefinition); - } - - @Test - public void testDictionaryDefinitionMDSALSource(){ - String fileName = basePath + "/mdsal-source.json"; - ResourceDefinition resourceDefinition = JacksonUtils.readValueFromFile(fileName, ResourceDefinition.class); - Assert.assertNotNull("Failed to populate dictionaryDefinition for mdsal type", resourceDefinition); - } -} -- cgit 1.2.3-korg