diff options
author | Muthuramalingam, Brinda Santh <bs2796@att.com> | 2019-01-08 11:17:05 -0500 |
---|---|---|
committer | Brinda Santh Muthuramalingam <bs2796@att.com> | 2019-01-10 19:59:36 +0000 |
commit | 8bec4a04cffac2ba03af3078d090c0b9466d78d7 (patch) | |
tree | 8581d954431f7c7e30a958e7b6cd122872d1f3f5 /ms/controllerblueprints/modules/service/src/test | |
parent | 404a3c2babcf581806340e314b77379f7047f8f9 (diff) |
Add relationships type files load structure.
Change-Id: I1be3ba493956674b476058094e05d681ce358711
Issue-ID: CCSDK-746
Signed-off-by: Muthuramalingam, Brinda Santh <bs2796@att.com>
Diffstat (limited to 'ms/controllerblueprints/modules/service/src/test')
4 files changed, 115 insertions, 129 deletions
diff --git a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintEnhancerServiceImplTest.java b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintEnhancerServiceImplTest.java deleted file mode 100644 index 23e5294f..00000000 --- a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintEnhancerServiceImplTest.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * - * 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.service.enhancer; - -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.onap.ccsdk.apps.controllerblueprints.TestApplication; -import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintEnhancerService; -import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintValidatorService; -import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintContext; -import org.onap.ccsdk.apps.controllerblueprints.service.load.ModelTypeLoadService; -import org.onap.ccsdk.apps.controllerblueprints.service.load.ResourceDictionaryLoadService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.TestPropertySource; -import org.springframework.test.context.junit4.SpringRunner; - -import java.nio.file.Paths; - -@RunWith(SpringRunner.class) -@ContextConfiguration(classes = {TestApplication.class}) -@TestPropertySource(locations = {"classpath:application.properties"}) -public class BluePrintEnhancerServiceImplTest { - - @Autowired - private ModelTypeLoadService modelTypeLoadService; - - @Autowired - private ResourceDictionaryLoadService resourceDictionaryLoadService; - - @Autowired - private BluePrintEnhancerService bluePrintEnhancerService; - - @Autowired - private BluePrintValidatorService bluePrintValidatorService; - - @Before - public void init() { - modelTypeLoadService.loadPathModelType("./../../../../components/model-catalog/definition-type/starter-type"); - resourceDictionaryLoadService.loadPathResourceDictionary("./../../../../components/model-catalog/resource-dictionary/starter-dictionary"); - } - - @Test - public void testEnhancementAndValidation() throws Exception { - - String basePath = "./../../../../components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration"; - - String targetPath = Paths.get("target", "bp-enhance").toUri().getPath(); - - BluePrintContext bluePrintContext = bluePrintEnhancerService.enhance(basePath, targetPath); - Assert.assertNotNull("failed to get blueprintContext ", bluePrintContext); - - // Validate the Generated BluePrints - Boolean valid = bluePrintValidatorService.validateBluePrints(targetPath); - Assert.assertTrue("blueprint validation failed ", valid); - } -}
\ No newline at end of file diff --git a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/validator/ModelTypeValidatorTest.java b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/validator/ModelTypeValidatorTest.java deleted file mode 100644 index 16b2bc81..00000000 --- a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/validator/ModelTypeValidatorTest.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * 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.service.validator; - -import com.fasterxml.jackson.databind.JsonNode; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException; -import org.onap.ccsdk.apps.controllerblueprints.service.domain.ModelType; - -public class ModelTypeValidatorTest { - - @Before - public void setup(){ - ModelTypeValidator modelTypeValidator; - } - - @Test - public void testGetValidModelDefinitionType_definitionContentNULL() throws Exception{ - String definitionType=null; - JsonNode definitionContent=null; - boolean valid= ModelTypeValidator.validateModelTypeDefinition(definitionType, definitionContent); - Assert.assertTrue(valid); - - } - - @Test(expected=BluePrintException.class) - public void testvalidateModelType() throws Exception{ - ModelType modelType = new ModelType(); - modelType.setDefinitionType(""); - modelType.setDerivedFrom(""); - modelType.setDescription(""); - JsonNode definitionContent=null; - modelType.setDefinition(definitionContent); - modelType.setModelName(""); - modelType.setVersion(""); - modelType.setTags(""); - modelType.setUpdatedBy(""); - ModelTypeValidator.validateModelType(modelType); - } -} diff --git a/ms/controllerblueprints/modules/service/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintEnhancerServiceImplTest.kt b/ms/controllerblueprints/modules/service/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintEnhancerServiceImplTest.kt new file mode 100644 index 00000000..4ab67084 --- /dev/null +++ b/ms/controllerblueprints/modules/service/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintEnhancerServiceImplTest.kt @@ -0,0 +1,75 @@ +/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * + * 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.service.enhancer + +import kotlinx.coroutines.runBlocking +import org.junit.Assert +import org.junit.Before +import org.junit.Test +import org.junit.runner.RunWith +import org.onap.ccsdk.apps.controllerblueprints.TestApplication +import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintEnhancerService +import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintValidatorService +import org.onap.ccsdk.apps.controllerblueprints.service.load.ModelTypeLoadService +import org.onap.ccsdk.apps.controllerblueprints.service.load.ResourceDictionaryLoadService +import org.springframework.beans.factory.annotation.Autowired +import org.springframework.test.context.ContextConfiguration +import org.springframework.test.context.TestPropertySource +import org.springframework.test.context.junit4.SpringRunner +import java.nio.file.Paths + +@RunWith(SpringRunner::class) +@ContextConfiguration(classes = arrayOf(TestApplication::class)) +@TestPropertySource(locations = arrayOf("classpath:application.properties")) +class BluePrintEnhancerServiceImplTest { + + @Autowired + private val modelTypeLoadService: ModelTypeLoadService? = null + + @Autowired + private val resourceDictionaryLoadService: ResourceDictionaryLoadService? = null + + @Autowired + private val bluePrintEnhancerService: BluePrintEnhancerService? = null + + @Autowired + private val bluePrintValidatorService: BluePrintValidatorService? = null + + @Before + fun init() { + runBlocking { + modelTypeLoadService!!.loadPathModelType("./../../../../components/model-catalog/definition-type/starter-type") + resourceDictionaryLoadService!!.loadPathResourceDictionary("./../../../../components/model-catalog/resource-dictionary/starter-dictionary") + } + } + + @Test + @Throws(Exception::class) + fun testEnhancementAndValidation() { + + val basePath = "./../../../../components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration" + + val targetPath = Paths.get("target", "bp-enhance").toUri().path + + val bluePrintContext = bluePrintEnhancerService!!.enhance(basePath, targetPath) + Assert.assertNotNull("failed to get blueprintContext ", bluePrintContext) + + // Validate the Generated BluePrints + val valid = bluePrintValidatorService!!.validateBluePrints(targetPath) + Assert.assertTrue("blueprint validation failed ", valid) + } +}
\ No newline at end of file diff --git a/ms/controllerblueprints/modules/service/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/validator/ModelTypeValidatorTest.kt b/ms/controllerblueprints/modules/service/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/validator/ModelTypeValidatorTest.kt new file mode 100644 index 00000000..db4ee5c9 --- /dev/null +++ b/ms/controllerblueprints/modules/service/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/validator/ModelTypeValidatorTest.kt @@ -0,0 +1,40 @@ +/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * + * 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.service.validator + +import com.fasterxml.jackson.databind.JsonNode +import org.junit.Test +import org.onap.ccsdk.apps.controllerblueprints.service.domain.ModelType + +class ModelTypeValidatorTest { + + @Test(expected = IllegalStateException::class) + @Throws(Exception::class) + fun testvalidateModelType() { + val modelType = ModelType() + modelType.definitionType = "" + modelType.derivedFrom = "" + modelType.description = "" + val definitionContent: JsonNode? = null + modelType.definition = definitionContent + modelType.modelName = "" + modelType.version = "" + modelType.tags = "" + modelType.updatedBy = "" + ModelTypeValidator.validateModelType(modelType) + } +} |