\r
package org.onap.ccsdk.apps.controllerblueprints.service;\r
\r
+import com.att.eelf.configuration.EELFLogger;\r
+import com.att.eelf.configuration.EELFManager;\r
import com.google.common.base.Preconditions;\r
import org.apache.commons.collections.CollectionUtils;\r
import org.apache.commons.io.IOUtils;\r
import org.onap.ccsdk.apps.controllerblueprints.service.domain.ConfigModel;\r
import org.onap.ccsdk.apps.controllerblueprints.service.domain.ConfigModelContent;\r
import org.onap.ccsdk.apps.controllerblueprints.service.repository.ConfigModelRepository;\r
-import com.att.eelf.configuration.EELFLogger;\r
-import com.att.eelf.configuration.EELFManager;\r
import org.springframework.stereotype.Service;\r
\r
import java.io.IOException;\r
* @author Brinda Santh\r
* @version 1.0\r
*/\r
-\r
+@Deprecated\r
@Service\r
public class ConfigModelCreateService {\r
\r
private static EELFLogger log = EELFManager.getInstance().getLogger(ConfigModelCreateService.class);\r
\r
private ConfigModelRepository configModelRepository;\r
- private ConfigModelValidatorService configModelValidatorService;\r
\r
/**\r
* This is a ConfigModelCreateService\r
*\r
- * @param configModelRepository ConfigModelRepository\r
- * @param configModelValidatorService ConfigModelValidatorService\r
+ * @param configModelRepository ConfigModelRepository\r
*/\r
- public ConfigModelCreateService(ConfigModelRepository configModelRepository,\r
- ConfigModelValidatorService configModelValidatorService) {\r
+ public ConfigModelCreateService(ConfigModelRepository configModelRepository) {\r
this.configModelRepository = configModelRepository;\r
- this.configModelValidatorService = configModelValidatorService;\r
}\r
\r
/**\r
String artifactName = configModel.getArtifactName();\r
String artifactVersion = configModel.getArtifactVersion();\r
String author = configModel.getUpdatedBy();\r
- \r
+\r
\r
if (StringUtils.isBlank(author)) {\r
throw new BluePrintException("Artifact Author is missing in the Service Template");\r
* @throws BluePrintException BluePrintException\r
*/\r
public ServiceTemplate validateServiceTemplate(ServiceTemplate serviceTemplate) throws BluePrintException {\r
- return this.configModelValidatorService.validateServiceTemplate(serviceTemplate);\r
+ // FIXME("Plug right Validator")\r
+ return serviceTemplate;\r
}\r
}\r
+++ /dev/null
-/*\r
- * Copyright © 2017-2018 AT&T Intellectual Property.\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-\r
-package org.onap.ccsdk.apps.controllerblueprints.service;\r
-\r
-import com.google.common.base.Preconditions;\r
-import org.apache.commons.lang3.StringUtils;\r
-import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException;\r
-import org.onap.ccsdk.apps.controllerblueprints.core.data.ServiceTemplate;\r
-import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils;\r
-import org.onap.ccsdk.apps.controllerblueprints.service.validator.ServiceTemplateValidator;\r
-import org.springframework.stereotype.Service;\r
-\r
-/**\r
- * ServiceTemplateValidatorService.java Purpose: Provide Service to Validate Service Model Template\r
- *\r
- * @author Brinda Santh\r
- * @version 1.0\r
- */\r
-@Deprecated\r
-@Service\r
-public class ConfigModelValidatorService {\r
-\r
- /**\r
- * This is a validateServiceTemplate\r
- *\r
- * @param serviceTemplateContent\r
- * @return ServiceTemplate\r
- * @throws BluePrintException\r
- */\r
- public ServiceTemplate validateServiceTemplate(String serviceTemplateContent) throws BluePrintException {\r
- Preconditions.checkArgument(StringUtils.isNotBlank(serviceTemplateContent), "Service Template Content is (" + serviceTemplateContent + ") not Defined.");\r
- ServiceTemplate serviceTemplate =\r
- JacksonUtils.readValue(serviceTemplateContent, ServiceTemplate.class);\r
- return validateServiceTemplate(serviceTemplate);\r
- }\r
-\r
- /**\r
- * This is a enhanceServiceTemplate\r
- *\r
- * @param serviceTemplate\r
- * @return ServiceTemplate\r
- * @throws BluePrintException\r
- */\r
- @SuppressWarnings("squid:S00112")\r
- public ServiceTemplate validateServiceTemplate(ServiceTemplate serviceTemplate) throws BluePrintException {\r
- Preconditions.checkNotNull(serviceTemplate, "Service Template is not defined.");\r
- ServiceTemplateValidator validator = new ServiceTemplateValidator();\r
- validator.validateServiceTemplate(serviceTemplate);\r
- return serviceTemplate;\r
- }\r
-\r
-\r
-}\r
+++ /dev/null
-/*\r
- * Copyright © 2017-2018 AT&T Intellectual Property.\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-\r
-package org.onap.ccsdk.apps.controllerblueprints.service;\r
-\r
-import org.onap.ccsdk.apps.controllerblueprints.resource.dict.service.ResourceAssignmentValidationDefaultService;\r
-import org.springframework.stereotype.Service;\r
-/**\r
- * ResourceAssignmentValidationService.\r
- *\r
- * @author Brinda Santh\r
- */\r
-@Service\r
-public class ResourceAssignmentValidationService extends ResourceAssignmentValidationDefaultService {\r
-\r
-}
\ No newline at end of file
+++ /dev/null
-/*
- * 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;
-
-import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintRepoService;
-import org.onap.ccsdk.apps.controllerblueprints.resource.dict.service.ResourceDefinitionDefaultValidationService;
-import org.springframework.stereotype.Service;
-
-@Service
-public class ResourceDefinitionValidationService extends ResourceDefinitionDefaultValidationService {
-
- public ResourceDefinitionValidationService(BluePrintRepoService bluePrintRepoService) {
- super(bluePrintRepoService);
- }
-}
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDefinition;\r
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceSourceMapping;\r
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.factory.ResourceSourceMappingFactory;\r
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.service.ResourceDefinitionValidationService;\r
import org.onap.ccsdk.apps.controllerblueprints.service.domain.ResourceDictionary;\r
import org.onap.ccsdk.apps.controllerblueprints.service.repository.ResourceDictionaryRepository;\r
import org.onap.ccsdk.apps.controllerblueprints.service.validator.ResourceDictionaryValidator;\r
* @param resourceDictionary resourceDictionary\r
* @return DataDictionary\r
*/\r
- public ResourceDictionary saveResourceDictionary(ResourceDictionary resourceDictionary) {\r
+ public ResourceDictionary saveResourceDictionary(ResourceDictionary resourceDictionary) throws BluePrintException {\r
Preconditions.checkNotNull(resourceDictionary, "Resource Dictionary information is missing");\r
Preconditions.checkNotNull(resourceDictionary.getDefinition(), "Resource Dictionary definition information is missing");\r
\r
\r
/**\r
* This is a getResourceSourceMapping service\r
- *\r
*/\r
public ResourceSourceMapping getResourceSourceMapping() {\r
return ResourceSourceMappingFactory.INSTANCE.getRegisterSourceMapping();\r
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException;\r
import org.onap.ccsdk.apps.controllerblueprints.core.data.ServiceTemplate;\r
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment;\r
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.service.ResourceAssignmentValidationService;\r
import org.onap.ccsdk.apps.controllerblueprints.service.domain.ConfigModelContent;\r
import org.onap.ccsdk.apps.controllerblueprints.service.model.AutoMapResponse;\r
import org.onap.ccsdk.apps.controllerblueprints.service.repository.ResourceDictionaryRepository;\r
\r
@PostMapping(path = "", produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)\r
public @ResponseBody\r
- ResourceDictionary saveResourceDictionary(@RequestBody ResourceDictionary dataDictionary) {\r
+ ResourceDictionary saveResourceDictionary(@RequestBody ResourceDictionary dataDictionary) throws BluePrintException {\r
return resourceDictionaryService.saveResourceDictionary(dataDictionary);\r
}\r
\r
import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintValidatorDefaultService;\r
import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils;\r
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment;\r
-import org.onap.ccsdk.apps.controllerblueprints.resource.dict.service.ResourceAssignmentValidationDefaultService;\r
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.service.ResourceAssignmentValidationServiceImpl;\r
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.service.ResourceAssignmentValidationService;\r
\r
import java.util.HashMap;\r
\r
if (BluePrintConstants.MODEL_TYPE_NODE_ARTIFACT.equals(derivedFrom)) {\r
List<ResourceAssignment> resourceAssignment = getResourceAssignments(nodeTemplate);\r
- ResourceAssignmentValidationService resourceAssignmentValidationService = new ResourceAssignmentValidationDefaultService();\r
+ ResourceAssignmentValidationService resourceAssignmentValidationService = new ResourceAssignmentValidationServiceImpl();\r
resourceAssignmentValidationService.validate(resourceAssignment);\r
}\r
}\r
--- /dev/null
+/*
+ * 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 org.onap.ccsdk.apps.controllerblueprints.core.interfaces.*
+import org.springframework.beans.factory.annotation.Autowired
+import org.springframework.context.ApplicationContext
+import org.springframework.stereotype.Service
+
+@Service
+class BluePrintTypeValidatorServiceImpl : BluePrintTypeValidatorService {
+
+ @Autowired
+ private lateinit var context: ApplicationContext
+
+ override fun getServiceTemplateValidators(): List<BluePrintServiceTemplateValidator> {
+ return context.getBeansOfType(BluePrintServiceTemplateValidator::class.java).mapNotNull { it.value }
+ }
+
+ override fun getDataTypeValidators(): List<BluePrintDataTypeValidator> {
+ return context.getBeansOfType(BluePrintDataTypeValidator::class.java).mapNotNull { it.value }
+ }
+
+ override fun getArtifactTypeValidators(): List<BluePrintArtifactTypeValidator> {
+ return context.getBeansOfType(BluePrintArtifactTypeValidator::class.java).mapNotNull { it.value }
+ }
+
+ override fun getNodeTypeValidators(): List<BluePrintNodeTypeValidator> {
+ return context.getBeansOfType(BluePrintNodeTypeValidator::class.java).mapNotNull { it.value }
+ }
+
+ override fun getTopologyTemplateValidators(): List<BluePrintTopologyTemplateValidator> {
+ return context.getBeansOfType(BluePrintTopologyTemplateValidator::class.java).mapNotNull { it.value }
+ }
+
+ override fun getNodeTemplateValidators(): List<BluePrintNodeTemplateValidator> {
+ return context.getBeansOfType(BluePrintNodeTemplateValidator::class.java).mapNotNull { it.value }
+ }
+
+ override fun getWorkflowValidators(): List<BluePrintWorkflowValidator> {
+ return context.getBeansOfType(BluePrintWorkflowValidator::class.java).mapNotNull { it.value }
+ }
+
+ override fun getPropertyDefinitionValidators(): List<BluePrintPropertyDefinitionValidator> {
+ return context.getBeansOfType(BluePrintPropertyDefinitionValidator::class.java).mapNotNull { it.value }
+ }
+
+ override fun getAttributeDefinitionValidators(): List<BluePrintAttributeDefinitionValidator> {
+ return context.getBeansOfType(BluePrintAttributeDefinitionValidator::class.java).mapNotNull { it.value }
+ }
+}
+
--- /dev/null
+/*
+ * 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.onap.ccsdk.apps.controllerblueprints.core.BluePrintException
+import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintRepoService
+import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintTypeValidatorService
+import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintValidatorService
+import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintMetadataUtils
+import org.onap.ccsdk.apps.controllerblueprints.core.validation.*
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.service.ResourceAssignmentValidationServiceImpl
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.service.ResourceDefinitionValidationServiceImpl
+import org.springframework.stereotype.Service
+import java.util.*
+
+@Service
+class BluePrintTypeValidatorDefaultService(private val bluePrintTypeValidatorService: BluePrintTypeValidatorService)
+ : BluePrintValidatorService {
+
+ private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintValidatorServiceImpl::class.toString())
+
+ override fun validateBluePrints(basePath: String): Boolean {
+
+ log.info("validating blueprint($basePath)")
+ val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime(UUID.randomUUID().toString(), basePath)
+ return validateBluePrints(bluePrintRuntimeService)
+ }
+
+ override fun validateBluePrints(bluePrintRuntimeService: BluePrintRuntimeService<*>): Boolean {
+
+ bluePrintTypeValidatorService.validateServiceTemplate(bluePrintRuntimeService, "service_template",
+ bluePrintRuntimeService.bluePrintContext().serviceTemplate)
+
+ if (bluePrintRuntimeService.getBluePrintError().errors.size > 0) {
+ throw BluePrintException("failed in blueprint validation : ${bluePrintRuntimeService.getBluePrintError().errors.joinToString("\n")}")
+ }
+ return true
+ }
+}
+
+// Core Validator Services
+
+@Service
+class DefaultBluePrintServiceTemplateValidator(bluePrintTypeValidatorService: BluePrintTypeValidatorService)
+ : BluePrintServiceTemplateValidatorImpl(bluePrintTypeValidatorService)
+
+@Service
+class DefaultBluePrintDataTypeValidator(bluePrintTypeValidatorService: BluePrintTypeValidatorService)
+ : BluePrintDataTypeValidatorImpl(bluePrintTypeValidatorService)
+
+@Service
+class DefaultBluePrintArtifactTypeValidator(bluePrintTypeValidatorService: BluePrintTypeValidatorService)
+ : BluePrintArtifactTypeValidatorImpl(bluePrintTypeValidatorService)
+
+@Service
+class DefaultBluePrintNodeTypeValidator(bluePrintTypeValidatorService: BluePrintTypeValidatorService)
+ : BluePrintNodeTypeValidatorImpl(bluePrintTypeValidatorService)
+
+@Service
+class DefaultBluePrintTopologyTemplateValidator(bluePrintTypeValidatorService: BluePrintTypeValidatorService)
+ : BluePrintTopologyTemplateValidatorImpl(bluePrintTypeValidatorService)
+
+@Service
+class DefaulBluePrintNodeTemplateValidator(bluePrintTypeValidatorService: BluePrintTypeValidatorService)
+ : BluePrintNodeTemplateValidatorImpl(bluePrintTypeValidatorService)
+
+@Service
+class DefaultBluePrintWorkflowValidator(bluePrintTypeValidatorService: BluePrintTypeValidatorService)
+ : BluePrintWorkflowValidatorImpl(bluePrintTypeValidatorService)
+
+@Service
+class DefaulBluePrintPropertyDefinitionValidator(bluePrintTypeValidatorService: BluePrintTypeValidatorService)
+ : BluePrintPropertyDefinitionValidatorImpl(bluePrintTypeValidatorService)
+
+@Service
+class DefaultBluePrintAttributeDefinitionValidator(bluePrintTypeValidatorService: BluePrintTypeValidatorService)
+ : BluePrintAttributeDefinitionValidatorImpl(bluePrintTypeValidatorService)
+
+// Resource Dictionary Validation Services
+
+@Service
+class DefaultResourceAssignmentValidationService : ResourceAssignmentValidationServiceImpl()
+
+@Service
+class DefalutResourceDefinitionValidationService(bluePrintRepoService: BluePrintRepoService)
+ : ResourceDefinitionValidationServiceImpl(bluePrintRepoService)
\ No newline at end of file
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.test.context.ContextConfiguration;
import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit4.SpringRunner;
+
import java.nio.file.Paths;
@RunWith(SpringRunner.class)
@Autowired
private BluePrintEnhancerService bluePrintEnhancerService;
+ @Autowired
+ private BluePrintValidatorService bluePrintValidatorService;
+
@Before
public void init() {
modelTypeLoadService.loadModelType("./../../../../components/model-catalog/definition-type/starter-type");
}
@Test
- public void testEnhancement() throws Exception {
+ public void testEnhancementAndValidation() throws Exception {
String basePath = "./../../../../components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration";
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
+++ /dev/null
-/*\r
- * Copyright © 2017-2018 AT&T Intellectual Property.\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-\r
-package org.onap.ccsdk.apps.controllerblueprints.service.enhancer;\r
-\r
-import com.att.eelf.configuration.EELFLogger;\r
-import com.att.eelf.configuration.EELFManager;\r
-import org.junit.Assert;\r
-import org.junit.Before;\r
-import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException;\r
-import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils;\r
-import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment;\r
-import org.onap.ccsdk.apps.controllerblueprints.resource.dict.utils.ResourceDictionaryTestUtils;\r
-\r
-import java.util.List;\r
-\r
-/**\r
- * ResourceAssignmentEnhancerService.\r
- *\r
- * @author Brinda Santh\r
- */\r
-public class ResourceAssignmentEnhancerServiceTest {\r
- private static EELFLogger log = EELFManager.getInstance().getLogger(ResourceAssignmentEnhancerServiceTest.class);\r
-\r
- @Before\r
- public void setUp() {\r
- // Setup dummy Source Instance Mapping\r
- ResourceDictionaryTestUtils.setUpResourceSourceMapping();\r
- }\r
-\r
- //@Test\r
- public void testEnhanceBluePrint() throws BluePrintException {\r
-\r
-\r
- List<ResourceAssignment> resourceAssignments = JacksonUtils.getListFromClassPathFile("enhance/enhance-resource-assignment.json", ResourceAssignment.class);\r
- Assert.assertNotNull("Failed to get Resource Assignment", resourceAssignments);\r
-\r
-// ResourceDefinitionRepoService resourceDefinitionRepoService = new ResourceDefinitionFileRepoService("./../../../../components/model-catalog");\r
-// ResourceAssignmentEnhancerService resourceAssignmentEnhancerService = new ResourceAssignmentEnhancerServiceImpl(resourceDefinitionRepoService);\r
-// ServiceTemplate serviceTemplate = resourceAssignmentEnhancerService.enhanceBluePrint(resourceAssignments);\r
-// Assert.assertNotNull("Failed to get Enriched service Template", serviceTemplate);\r
-// log.trace("Enhanced Service Template : {}", JacksonUtils.getJson(serviceTemplate, true));\r
-\r
- }\r
-}\r
-\r
+++ /dev/null
-/*\r
- * Copyright © 2017-2018 AT&T Intellectual Property.\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-\r
-package org.onap.ccsdk.apps.controllerblueprints.service.validator;\r
-\r
-\r
-import com.att.eelf.configuration.EELFLogger;\r
-import com.att.eelf.configuration.EELFManager;\r
-import org.apache.commons.io.FileUtils;\r
-import org.junit.Assert;\r
-import org.junit.Before;\r
-import org.junit.Test;\r
-import org.onap.ccsdk.apps.controllerblueprints.core.data.ServiceTemplate;\r
-import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils;\r
-import org.onap.ccsdk.apps.controllerblueprints.resource.dict.utils.ResourceDictionaryTestUtils;\r
-import org.onap.ccsdk.apps.controllerblueprints.service.utils.ConfigModelUtils;\r
-\r
-import java.io.File;\r
-import java.nio.charset.Charset;\r
-import java.util.List;\r
-\r
-public class ServiceTemplateValidationTest {\r
- private static EELFLogger log = EELFManager.getInstance().getLogger(ServiceTemplateValidationTest.class);\r
-\r
- @Before\r
- public void setUp(){\r
- // Setup dummy Source Instance Mapping\r
- ResourceDictionaryTestUtils.setUpResourceSourceMapping();\r
- }\r
-\r
- @Test\r
- public void testBluePrintDirs() {\r
- List<String> dirs = ConfigModelUtils.getBlueprintNames("./../../../../components/model-catalog/blueprint-model/starter-blueprint");\r
- Assert.assertNotNull("Failed to get blueprint directories", dirs);\r
- //Assert.assertEquals("Failed to get actual directories", 1, dirs.size());\r
- }\r
-\r
- @Test\r
- public void validateServiceTemplate() throws Exception {\r
- validateServiceTemplate("load/blueprints/vrr-test/Definitions/vrr-test.json");\r
- }\r
-\r
- //@Test FIXME("Enable once Complete Enhancement Service Implemented")\r
- public void validateEnhancedServiceTemplate() throws Exception {\r
- ServiceTemplate serviceTemplate = JacksonUtils\r
- .readValueFromClassPathFile("enhance/enhanced-template.json", ServiceTemplate.class);\r
- ServiceTemplateValidator serviceTemplateValidator = new ServiceTemplateValidator();\r
- Boolean valid = serviceTemplateValidator.validateServiceTemplate(serviceTemplate);\r
- Assert.assertTrue("Failed to validate blueprints", valid);\r
- }\r
-\r
- private void validateServiceTemplate(String fileName) throws Exception {\r
- String serviceTemplateContent =\r
- FileUtils.readFileToString(new File(fileName), Charset.defaultCharset());\r
- ServiceTemplateValidator serviceTemplateValidator = new ServiceTemplateValidator();\r
- serviceTemplateValidator.validateServiceTemplate(serviceTemplateContent);\r
- Assert.assertNotNull("Failed to validate blueprints", serviceTemplateValidator);\r
- }\r
-}\r