From 776d17ace2d674f3e9f5685a7a005ce4b7b91ed3 Mon Sep 17 00:00:00 2001 From: "Muthuramalingam, Brinda Santh(bs2796)" Date: Thu, 13 Dec 2018 15:10:35 -0500 Subject: Add blueprint runtime service to validator Change-Id: I0e4375e422b55002f1666ee9e61a1469482f77d2 Issue-ID: CCSDK-757 Signed-off-by: Muthuramalingam, Brinda Santh(bs2796) --- .../enhancer/BluePrintEnhancerServiceImplTest.java | 9 ++- .../ResourceAssignmentEnhancerServiceTest.java | 59 ------------------ .../validator/ServiceTemplateValidationTest.java | 72 ---------------------- 3 files changed, 8 insertions(+), 132 deletions(-) delete mode 100644 ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/ResourceAssignmentEnhancerServiceTest.java delete mode 100644 ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/validator/ServiceTemplateValidationTest.java (limited to 'ms/controllerblueprints/modules/service/src/test') 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 index abc3d56f..7d9c2e1a 100644 --- 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 @@ -22,6 +22,7 @@ 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; @@ -29,6 +30,7 @@ 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) @@ -45,6 +47,9 @@ public class BluePrintEnhancerServiceImplTest { @Autowired private BluePrintEnhancerService bluePrintEnhancerService; + @Autowired + private BluePrintValidatorService bluePrintValidatorService; + @Before public void init() { modelTypeLoadService.loadModelType("./../../../../components/model-catalog/definition-type/starter-type"); @@ -52,7 +57,7 @@ public class BluePrintEnhancerServiceImplTest { } @Test - public void testEnhancement() throws Exception { + public void testEnhancementAndValidation() throws Exception { String basePath = "./../../../../components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration"; @@ -61,6 +66,8 @@ public class BluePrintEnhancerServiceImplTest { BluePrintContext bluePrintContext = bluePrintEnhancerService.enhance(basePath, targetPath); Assert.assertNotNull("failed to get blueprintContext ", bluePrintContext); + // Validate the Generated BluePrints + bluePrintValidatorService.validateBluePrints(targetPath); } } \ No newline at end of file diff --git a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/ResourceAssignmentEnhancerServiceTest.java b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/ResourceAssignmentEnhancerServiceTest.java deleted file mode 100644 index b6e31318..00000000 --- a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/ResourceAssignmentEnhancerServiceTest.java +++ /dev/null @@ -1,59 +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 com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; -import org.junit.Assert; -import org.junit.Before; -import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException; -import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils; -import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment; -import org.onap.ccsdk.apps.controllerblueprints.resource.dict.utils.ResourceDictionaryTestUtils; - -import java.util.List; - -/** - * ResourceAssignmentEnhancerService. - * - * @author Brinda Santh - */ -public class ResourceAssignmentEnhancerServiceTest { - private static EELFLogger log = EELFManager.getInstance().getLogger(ResourceAssignmentEnhancerServiceTest.class); - - @Before - public void setUp() { - // Setup dummy Source Instance Mapping - ResourceDictionaryTestUtils.setUpResourceSourceMapping(); - } - - //@Test - public void testEnhanceBluePrint() throws BluePrintException { - - - List resourceAssignments = JacksonUtils.getListFromClassPathFile("enhance/enhance-resource-assignment.json", ResourceAssignment.class); - Assert.assertNotNull("Failed to get Resource Assignment", resourceAssignments); - -// ResourceDefinitionRepoService resourceDefinitionRepoService = new ResourceDefinitionFileRepoService("./../../../../components/model-catalog"); -// ResourceAssignmentEnhancerService resourceAssignmentEnhancerService = new ResourceAssignmentEnhancerServiceImpl(resourceDefinitionRepoService); -// ServiceTemplate serviceTemplate = resourceAssignmentEnhancerService.enhanceBluePrint(resourceAssignments); -// Assert.assertNotNull("Failed to get Enriched service Template", serviceTemplate); -// log.trace("Enhanced Service Template : {}", JacksonUtils.getJson(serviceTemplate, true)); - - } -} - diff --git a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/validator/ServiceTemplateValidationTest.java b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/validator/ServiceTemplateValidationTest.java deleted file mode 100644 index d5638ec2..00000000 --- a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/validator/ServiceTemplateValidationTest.java +++ /dev/null @@ -1,72 +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.validator; - - -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; -import org.apache.commons.io.FileUtils; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.onap.ccsdk.apps.controllerblueprints.core.data.ServiceTemplate; -import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils; -import org.onap.ccsdk.apps.controllerblueprints.resource.dict.utils.ResourceDictionaryTestUtils; -import org.onap.ccsdk.apps.controllerblueprints.service.utils.ConfigModelUtils; - -import java.io.File; -import java.nio.charset.Charset; -import java.util.List; - -public class ServiceTemplateValidationTest { - private static EELFLogger log = EELFManager.getInstance().getLogger(ServiceTemplateValidationTest.class); - - @Before - public void setUp(){ - // Setup dummy Source Instance Mapping - ResourceDictionaryTestUtils.setUpResourceSourceMapping(); - } - - @Test - public void testBluePrintDirs() { - List dirs = ConfigModelUtils.getBlueprintNames("./../../../../components/model-catalog/blueprint-model/starter-blueprint"); - Assert.assertNotNull("Failed to get blueprint directories", dirs); - //Assert.assertEquals("Failed to get actual directories", 1, dirs.size()); - } - - @Test - public void validateServiceTemplate() throws Exception { - validateServiceTemplate("load/blueprints/vrr-test/Definitions/vrr-test.json"); - } - - //@Test FIXME("Enable once Complete Enhancement Service Implemented") - public void validateEnhancedServiceTemplate() throws Exception { - ServiceTemplate serviceTemplate = JacksonUtils - .readValueFromClassPathFile("enhance/enhanced-template.json", ServiceTemplate.class); - ServiceTemplateValidator serviceTemplateValidator = new ServiceTemplateValidator(); - Boolean valid = serviceTemplateValidator.validateServiceTemplate(serviceTemplate); - Assert.assertTrue("Failed to validate blueprints", valid); - } - - private void validateServiceTemplate(String fileName) throws Exception { - String serviceTemplateContent = - FileUtils.readFileToString(new File(fileName), Charset.defaultCharset()); - ServiceTemplateValidator serviceTemplateValidator = new ServiceTemplateValidator(); - serviceTemplateValidator.validateServiceTemplate(serviceTemplateContent); - Assert.assertNotNull("Failed to validate blueprints", serviceTemplateValidator); - } -} -- cgit 1.2.3-korg