diff options
author | AviZi <avi.ziv@amdocs.com> | 2017-06-09 02:39:56 +0300 |
---|---|---|
committer | AviZi <avi.ziv@amdocs.com> | 2017-06-09 02:39:56 +0300 |
commit | 280f8015d06af1f41a3ef12e8300801c7a5e0d54 (patch) | |
tree | 9c1d3978c04cd28068f02073038c936bb49ca9e0 /openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-core | |
parent | fd3821dad11780d33c5373d74c957c442489945e (diff) |
[SDC-29] Amdocs OnBoard 1707 initial commit.
Change-Id: Ie4d12a3f574008b792899b368a0902a8b46b5370
Signed-off-by: AviZi <avi.ziv@amdocs.com>
Diffstat (limited to 'openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-core')
11 files changed, 372 insertions, 286 deletions
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-core/pom.xml b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-core/pom.xml index 968d71c04a..c0e928a2af 100644 --- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-core/pom.xml +++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-core/pom.xml @@ -1,7 +1,12 @@ -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" +<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns="http://maven.apache.org/POM/4.0.0" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> + <name>openecomp-sdc-validation-core</name> + <artifactId>openecomp-sdc-validation-core</artifactId> + + <parent> <groupId>org.openecomp.sdc</groupId> <artifactId>openecomp-sdc-lib</artifactId> @@ -9,56 +14,26 @@ <relativePath>../..</relativePath> </parent> - <name>openecomp-sdc-validation-core</name> - <artifactId>openecomp-sdc-validation-core</artifactId> - <dependencies> <dependency> - <groupId>com.google.code.gson</groupId> - <artifactId>gson</artifactId> - <version>2.3.1</version> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.yaml</groupId> - <artifactId>snakeyaml</artifactId> - <version>1.14</version> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.slf4j</groupId> - <artifactId>slf4j-api</artifactId> - <version>1.7.10</version> - - </dependency> - - - <dependency> <groupId>ch.qos.logback</groupId> <artifactId>logback-classic</artifactId> - <version>1.1.2</version> + <version>${logback.version}</version> </dependency> <dependency> - <groupId>org.testng</groupId> - <artifactId>testng</artifactId> - <scope>test</scope> - <version>6.8.5</version> - <exclusions> - <exclusion> - <artifactId>snakeyaml</artifactId> - <groupId>org.yaml</groupId> - </exclusion> - </exclusions> + <groupId>org.openecomp.sdc</groupId> + <artifactId>openecomp-sdc-logging-core</artifactId> + <version>${project.version}</version> </dependency> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> - <version>RELEASE</version> + <version>${junit.version}</version> <scope>test</scope> </dependency> <dependency> - <groupId>org.openecomp.sdc</groupId> + <groupId>org.openecomp.core</groupId> <artifactId>openecomp-utilities-lib</artifactId> <version>${project.version}</version> </dependency> @@ -69,9 +44,8 @@ </dependency> <dependency> <groupId>org.openecomp.sdc</groupId> - <artifactId>openecomp-sdc-validation-impl</artifactId> + <artifactId>openecomp-sdc-validation-sdk</artifactId> <version>${project.version}</version> - <!--scope>runtime</scope--> </dependency> <dependency> <groupId>org.openecomp.sdc</groupId> @@ -82,12 +56,43 @@ <groupId>org.mockito</groupId> <artifactId>mockito-all</artifactId> <scope>test</scope> - <version>1.10.19</version> + <version>${mockito.all.version}</version> + </dependency> + <dependency> + <groupId>org.openecomp.sdc.common</groupId> + <artifactId>openecomp-configuration-management-core</artifactId> + <version>${openecomp.sdc.common.version}</version> + <scope>runtime</scope> + <exclusions> + <exclusion> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-log4j12</artifactId> + </exclusion> + </exclusions> + </dependency> + <dependency> + <groupId>org.openecomp.core</groupId> + <artifactId>openecomp-heat-lib</artifactId> + <version>${project.version}</version> </dependency> <dependency> - <groupId>com.google.guava</groupId> - <artifactId>guava</artifactId> - <version>19.0</version> + <groupId>org.testng</groupId> + <artifactId>testng</artifactId> + <version>${testng.version}</version> </dependency> </dependencies> -</project>
\ No newline at end of file + + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-surefire-plugin</artifactId> + <version>${mvn.surefire.version}</version> + <configuration> + <useSystemClassLoader>false</useSystemClassLoader> + <redirectTestOutputToFile>true</redirectTestOutputToFile> + </configuration> + </plugin> + </plugins> + </build> +</project> diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-core/pom.xml.versionsBackup b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-core/pom.xml.versionsBackup new file mode 100644 index 0000000000..8731097f41 --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-core/pom.xml.versionsBackup @@ -0,0 +1,110 @@ +<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns="http://maven.apache.org/POM/4.0.0" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <name>openecomp-sdc-validation-core</name> + <artifactId>openecomp-sdc-validation-core</artifactId> + + + <parent> + <groupId>org.openecomp.sdc</groupId> + <artifactId>openecomp-sdc-lib</artifactId> + <version>1.0-SNAPSHOT</version> + <relativePath>../..</relativePath> + </parent> + + <dependencies> + <dependency> + <groupId>ch.qos.logback</groupId> + <artifactId>logback-classic</artifactId> + <version>${logback.version}</version> + + </dependency> + <dependency> + <groupId>org.openecomp.sdc</groupId> + <artifactId>openecomp-sdc-logging-core</artifactId> + <version>1.0-SNAPSHOT</version> + </dependency> + <dependency> + <groupId>org.testng</groupId> + <artifactId>testng</artifactId> + <scope>test</scope> + <version>6.8.5</version> + <exclusions> + <exclusion> + <artifactId>snakeyaml</artifactId> + <groupId>org.yaml</groupId> + </exclusion> + </exclusions> + </dependency> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>RELEASE</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.openecomp.core</groupId> + <artifactId>openecomp-utilities-lib</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.openecomp.sdc</groupId> + <artifactId>openecomp-sdc-validation-api</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.openecomp.sdc</groupId> + <artifactId>openecomp-sdc-validation-sdk</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.openecomp.sdc</groupId> + <artifactId>openecomp-sdc-datatypes-lib</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.mockito</groupId> + <artifactId>mockito-all</artifactId> + <scope>test</scope> + <version>1.10.19</version> + </dependency> + <dependency> + <groupId>org.openecomp.sdc.common</groupId> + <artifactId>openecomp-configuration-management-core</artifactId> + <version>1707.0.0-SNAPSHOT</version> + <scope>runtime</scope> + <exclusions> + <exclusion> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-log4j12</artifactId> + </exclusion> + </exclusions> + </dependency> + <dependency> + <groupId>org.openecomp.core</groupId> + <artifactId>openecomp-heat-lib</artifactId> + <version>1.0-SNAPSHOT</version> + </dependency> + <dependency> + <groupId>org.testng</groupId> + <artifactId>testng</artifactId> + <version>6.9.10</version> + </dependency> + </dependencies> + + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-surefire-plugin</artifactId> + <version>2.19.1</version> + <configuration> + <useSystemClassLoader>false</useSystemClassLoader> + <redirectTestOutputToFile>true</redirectTestOutputToFile> + </configuration> + </plugin> + </plugins> + </build> +</project>
\ No newline at end of file diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-core/src/main/java/org/openecomp/sdc/validation/impl/ValidationManagerImpl.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-core/src/main/java/org/openecomp/sdc/validation/impl/ValidationManagerImpl.java index 64c409b463..acb4eed448 100644 --- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-core/src/main/java/org/openecomp/sdc/validation/impl/ValidationManagerImpl.java +++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-core/src/main/java/org/openecomp/sdc/validation/impl/ValidationManagerImpl.java @@ -21,28 +21,40 @@ package org.openecomp.sdc.validation.impl; import org.apache.commons.collections4.CollectionUtils; +import org.openecomp.sdc.logging.api.Logger; +import org.openecomp.sdc.logging.api.LoggerFactory; import org.openecomp.core.validation.api.ValidationManager; -import org.openecomp.core.validation.interfaces.Validator; +import org.openecomp.sdc.validation.Validator; import org.openecomp.core.validation.types.GlobalValidationContext; import org.openecomp.core.validation.types.MessageContainer; import org.openecomp.sdc.datatypes.error.ErrorMessage; -import org.openecomp.sdc.validation.utils.ValidationConfigurationManager; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import org.openecomp.sdc.validation.services.ValidationFactory; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Objects; public class ValidationManagerImpl implements ValidationManager { - private static Logger logger = LoggerFactory.getLogger(ValidationManagerImpl.class); + private static Logger logger = (Logger) LoggerFactory.getLogger(ValidationManagerImpl.class); + private GlobalValidationContext globalContext; private List<Validator> validators; public ValidationManagerImpl() { globalContext = new GlobalValidationContext(); - validators = ValidationConfigurationManager.initValidators(); + validators = ValidationFactory.getValidators(); + } + + @Override + public Map<String, List<ErrorMessage>> validate() { + for (Validator validator : validators) { + if(Objects.nonNull(validator)) { + validator.validate(globalContext); + } + } + return convertMessageContainsToErrorMessage(globalContext.getContextMessageContainers()); } @Override @@ -51,11 +63,8 @@ public class ValidationManagerImpl implements ValidationManager { } @Override - public Map<String, List<ErrorMessage>> validate() { - for (Validator validator : validators) { - validator.validate(globalContext); - } - return convertMessageContainsToErrorMessage(globalContext.getContextMessageContainers()); + public void updateGlobalContext(GlobalValidationContext globalContext) { + this.globalContext = globalContext; } private Map<String, List<ErrorMessage>> convertMessageContainsToErrorMessage( @@ -66,4 +75,5 @@ public class ValidationManagerImpl implements ValidationManager { .forEach(entry -> errors.put(entry.getKey(), entry.getValue().getErrorMessageList())); return errors; } + } diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-core/src/main/java/org/openecomp/sdc/validation/services/ValidationFactory.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-core/src/main/java/org/openecomp/sdc/validation/services/ValidationFactory.java new file mode 100644 index 0000000000..b290e7cda9 --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-core/src/main/java/org/openecomp/sdc/validation/services/ValidationFactory.java @@ -0,0 +1,58 @@ +package org.openecomp.sdc.validation.services; + +import org.apache.commons.collections4.CollectionUtils; +import org.openecomp.config.api.Configuration; +import org.openecomp.config.api.ConfigurationManager; +import org.openecomp.core.utilities.CommonMethods; +import org.openecomp.sdc.datatypes.configuration.ImplementationConfiguration; +import org.openecomp.sdc.logging.api.Logger; +import org.openecomp.sdc.logging.api.LoggerFactory; +import org.openecomp.sdc.validation.Validator; +import org.openecomp.sdc.validation.type.ConfigConstants; + +import java.io.File; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +public class ValidationFactory { + private static final List<Validator> validators = new ArrayList<>(); + private static Map<String, ImplementationConfiguration> validationImplMap; + private static Logger logger = + (Logger) LoggerFactory.getLogger(ValidationFactory.class); + private static File file; + + + static { + Configuration config = ConfigurationManager.lookup(); + validationImplMap = config.populateMap(ConfigConstants.Namespace, + ConfigConstants.Validator_Impl_Key, ImplementationConfiguration.class); + validationImplMap.putAll(config.populateMap(ConfigConstants.Mandatory_Namespace, + ConfigConstants.Validator_Impl_Key, ImplementationConfiguration.class)); + } + + /** + * Initialize a validator. + */ + public static List<Validator> getValidators() { + synchronized (validators) { + if (CollectionUtils.isEmpty(validators)) { + validationImplMap.values().stream() + .filter(implementationConfiguration -> implementationConfiguration + .isEnable()).forEachOrdered(implementationConfiguration -> validators.add + (cerateValidatorImpl(implementationConfiguration))); + } + } + return validators; + } + + private static Validator cerateValidatorImpl(ImplementationConfiguration validatorConf) { + Validator validator = null; + validator = + CommonMethods.newInstance(validatorConf.getImplementationClass(), Validator.class); + validator.init(validatorConf.getProperties()); + + logger.debug("created validator" + validatorConf.getImplementationClass()); + return validator; + } +} diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-core/src/main/java/org/openecomp/sdc/validation/utils/ValidationConfiguration.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-core/src/main/java/org/openecomp/sdc/validation/utils/ValidationConfiguration.java deleted file mode 100644 index 1a74e1cc34..0000000000 --- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-core/src/main/java/org/openecomp/sdc/validation/utils/ValidationConfiguration.java +++ /dev/null @@ -1,37 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * 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. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.sdc.validation.utils; - -import java.util.Collections; -import java.util.List; - -public class ValidationConfiguration { - private List<ValidatorConfiguration> validatorConfigurationList; - - public List<ValidatorConfiguration> getValidatorConfigurationList() { - return Collections.unmodifiableList(validatorConfigurationList); - } - - public void setValidatorConfigurationList( - List<ValidatorConfiguration> validatorConfigurationList) { - this.validatorConfigurationList = validatorConfigurationList; - } -} diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-core/src/main/java/org/openecomp/sdc/validation/utils/ValidationConfigurationManager.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-core/src/main/java/org/openecomp/sdc/validation/utils/ValidationConfigurationManager.java deleted file mode 100644 index cc921ce985..0000000000 --- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-core/src/main/java/org/openecomp/sdc/validation/utils/ValidationConfigurationManager.java +++ /dev/null @@ -1,74 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * 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. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.sdc.validation.utils; - -import org.apache.commons.collections4.CollectionUtils; -import org.openecomp.core.utilities.CommonMethods; -import org.openecomp.core.utilities.file.FileUtils; -import org.openecomp.core.utilities.json.JsonUtil; -import org.openecomp.core.validation.interfaces.Validator; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.io.InputStream; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -public class ValidationConfigurationManager { - - private static final String VALIDATION_CONFIGURATION = "validationConfiguration.json"; - private static final List<Validator> validators = new ArrayList<>(); - private static Logger logger = LoggerFactory.getLogger(ValidationConfigurationManager.class); - - /** - * Init validators list. - * - * @return the list - */ - public static List<Validator> initValidators() { - synchronized (validators) { - if (CollectionUtils.isEmpty(validators)) { - InputStream validationConfigurationJson = - FileUtils.getFileInputStream(VALIDATION_CONFIGURATION); - ValidationConfiguration validationConfiguration = - JsonUtil.json2Object(validationConfigurationJson, ValidationConfiguration.class); - List<ValidatorConfiguration> conf = validationConfiguration.getValidatorConfigurationList(); - conf.stream().filter(ValidatorConfiguration::isEnableInd).forEachOrdered( - validatorConfiguration -> validators.add(validatorInit(validatorConfiguration))); - } - } - return validators; - } - - private static Validator validatorInit(ValidatorConfiguration validatorConf) { - Validator validator = null; - try { - validator = - CommonMethods.newInstance(validatorConf.getImplementationClass(), Validator.class); - } catch (IllegalArgumentException iae) { - logger.error("Validator:" + validatorConf.getName() + " Class:" - + validatorConf.getImplementationClass() + " failed in initialization. error:" - + iae.toString() + " trace:" + Arrays.toString(iae.getStackTrace())); - } - return validator; - } -} diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-core/src/main/java/org/openecomp/sdc/validation/utils/ValidationManagerUtil.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-core/src/main/java/org/openecomp/sdc/validation/utils/ValidationManagerUtil.java deleted file mode 100644 index 960bdc2165..0000000000 --- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-core/src/main/java/org/openecomp/sdc/validation/utils/ValidationManagerUtil.java +++ /dev/null @@ -1,65 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * 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. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.sdc.validation.utils; - -import org.openecomp.core.utilities.file.FileContentHandler; -import org.openecomp.core.utilities.file.FileUtils; -import org.openecomp.core.validation.api.ValidationManager; -import org.openecomp.core.validation.errors.Messages; -import org.openecomp.core.validation.factory.ValidationManagerFactory; -import org.openecomp.sdc.common.utils.AsdcCommon; -import org.openecomp.sdc.datatypes.error.ErrorLevel; -import org.openecomp.sdc.datatypes.error.ErrorMessage; - -import java.io.InputStream; -import java.util.List; -import java.util.Map; - -public class ValidationManagerUtil { - - /** - * Handle missing manifest. - * - * @param fileContentMap the file content map - * @param errors the errors - */ - public static void handleMissingManifest(FileContentHandler fileContentMap, - Map<String, List<ErrorMessage>> errors) { - InputStream manifest = fileContentMap.getFileContent(AsdcCommon.MANIFEST_NAME); - if (manifest == null) { - ErrorMessage.ErrorMessageUtil.addMessage(AsdcCommon.MANIFEST_NAME, errors) - .add(new ErrorMessage(ErrorLevel.ERROR, Messages.MANIFEST_NOT_EXIST.getErrorMessage())); - } - } - - /** - * Init validation manager validation manager. - * - * @param fileContentMap the file content map - * @return the validation manager - */ - public static ValidationManager initValidationManager(FileContentHandler fileContentMap) { - ValidationManager validationManager = ValidationManagerFactory.getInstance().createInterface(); - fileContentMap.getFileList().stream().forEach(fileName -> validationManager - .addFile(fileName, FileUtils.toByteArray(fileContentMap.getFileContent(fileName)))); - return validationManager; - } -} diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-core/src/main/java/org/openecomp/sdc/validation/utils/ValidatorConfiguration.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-core/src/main/java/org/openecomp/sdc/validation/utils/ValidatorConfiguration.java deleted file mode 100644 index 12feb641ae..0000000000 --- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-core/src/main/java/org/openecomp/sdc/validation/utils/ValidatorConfiguration.java +++ /dev/null @@ -1,51 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * 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. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.sdc.validation.utils; - -public class ValidatorConfiguration { - private String name; - private boolean enableInd = true; - private String implementationClass; - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public boolean isEnableInd() { - return enableInd; - } - - public void setEnableInd(boolean enableInd) { - this.enableInd = enableInd; - } - - public String getImplementationClass() { - return implementationClass; - } - - public void setImplementationClass(String implementationClass) { - this.implementationClass = implementationClass; - } -} diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-core/src/main/resources/config-mandatory-validaton.json b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-core/src/main/resources/config-mandatory-validaton.json new file mode 100644 index 0000000000..e221467baf --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-core/src/main/resources/config-mandatory-validaton.json @@ -0,0 +1,20 @@ +{ + "validatorImplementations": { + "yamlValidator": { + "enable": true, + "implementationClass": "org.openecomp.sdc.validation.impl.validators.YamlValidator" + }, + "heatValidator": { + "enable": true, + "implementationClass": "org.openecomp.sdc.validation.impl.validators.HeatValidator" + }, + "manifestValidator": { + "enable": true, + "implementationClass": "org.openecomp.sdc.validation.impl.validators.ManifestValidator" + } + }, + + "_config":{ + "namespace": "mandatoryValidation" + } +}
\ No newline at end of file diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-core/src/main/resources/config-validaton.json b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-core/src/main/resources/config-validaton.json new file mode 100644 index 0000000000..08c42880b2 --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-core/src/main/resources/config-validaton.json @@ -0,0 +1,87 @@ +{ + "validatorImplementations": { + "sharedResourceGuideLineValidator": { + "enable": true, + "implementationClass": "org.openecomp.sdc.validation.impl.validators.SharedResourceGuideLineValidator" + }, + "forbiddenResourceGuideLineValidator": { + "enable": true, + "implementationClass": "org.openecomp.sdc.validation.impl.validators.ForbiddenResourceGuideLineValidator", + "properties": { + "forbiddenResourceTypes": { + "OS::Neutron::FloatingIP": { + "enable": true + } + } + } + }, + "contrailValidator": { + "enable": true, + "implementationClass": "org.openecomp.sdc.validation.impl.validators.ContrailValidator" + }, + "resourceHeatValidator": { + "enable": true, + "implementationClass": "org.openecomp.sdc.validation.impl.validators.HeatResourceValidator", + "properties": { + "resourceBaseValidator": { + "OS::Nova::Server": { + "enable": true, + "implementationClass": "org.openecomp.sdc.validation.impl.validators.heatresource.NovaServerResourceValidator" + }, + "OS::Nova::ServerGroup": { + "enable": true, + "implementationClass": "org.openecomp.sdc.validation.impl.validators.heatresource.NovaServerGroupResourceValidator" + }, + "OS::Heat::ResourceGroup": { + "enable": true, + "implementationClass": "org.openecomp.sdc.validation.impl.validators.heatresource.ResourceGroupResourceValidator" + }, + "OS::Neutron::Port": { + "enable": true, + "implementationClass": "org.openecomp.sdc.validation.impl.validators.heatresource.NeutronPortResourceValidator" + }, + "OS::Contrail::NetworkPolicy": { + "enable": true, + "implementationClass": "org.openecomp.sdc.validation.impl.validators.heatresource.ContrailNetworkPolicyResourceValidator" + }, + "OS::Neutron::SecurityGroup":{ + "enable": true, + "implementationClass": "org.openecomp.sdc.validation.impl.validators.heatresource.NeutronSecurityGroupResourceValidator" + }, + "nestedResource": { + "enable": true, + "implementationClass": "org.openecomp.sdc.validation.impl.validators.heatresource.NestedResourceValidator" + } + } + } + }, + "namingConventionGuideLineValidator": { + "enable": true, + "implementationClass": "org.openecomp.sdc.validation.impl.validators.NamingConventionGuideLineValidator", + "properties": { + "resourceBaseValidator": { + "OS::Nova::Server": { + "enable": true, + "implementationClass": "org.openecomp.sdc.validation.impl.validators.namingconvention.NovaServerNamingConventionGuideLineValidator" + }, + "OS::Neutron::Port": { + "enable": true, + "implementationClass": "org.openecomp.sdc.validation.impl.validators.namingconvention.NeutronPortNamingConventionValidator" + }, + "OS::Contrail::ServiceTemplate": { + "enable": true, + "implementationClass": "org.openecomp.sdc.validation.impl.validators.namingconvention.ContrailServiceTemplateNamingConventionValidator" + }, + "OS::Contrail::ServiceInstance": { + "enable": true, + "implementationClass": "org.openecomp.sdc.validation.impl.validators.namingconvention.ContrailServiceInstanceNamingConventionValidator" + } + } + } + } + }, + + "_config":{ + "namespace": "validation" + } +}
\ No newline at end of file diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-core/src/test/java/org/openecomp/sdc/heat/services/tree/HeatTreeManagerTest.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-core/src/test/java/org/openecomp/sdc/heat/services/tree/HeatTreeManagerTest.java index 6a9f8df12d..8bb95afacd 100644 --- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-core/src/test/java/org/openecomp/sdc/heat/services/tree/HeatTreeManagerTest.java +++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-core/src/test/java/org/openecomp/sdc/heat/services/tree/HeatTreeManagerTest.java @@ -1,8 +1,29 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + package org.openecomp.sdc.heat.services.tree; -import org.openecomp.sdc.heat.datatypes.structure.HeatStructureTree; +import org.openecomp.config.ConfigurationUtils; import org.openecomp.core.utilities.file.FileContentHandler; import org.openecomp.core.utilities.file.FileUtils; +import org.openecomp.sdc.heat.datatypes.structure.HeatStructureTree; import org.testng.Assert; import org.testng.annotations.Test; @@ -10,6 +31,10 @@ import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.net.URL; +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; + public class HeatTreeManagerTest { @@ -34,7 +59,7 @@ public class HeatTreeManagerTest { heatTreeManager.createTree(); HeatStructureTree tree = heatTreeManager.getTree(); Assert.assertNotNull(tree); - Assert.assertEquals(tree.getHEAT().size(), 2); + Assert.assertEquals(tree.getHeat().size(), 2); } private byte[] getFileContent(File file) { @@ -46,6 +71,4 @@ public class HeatTreeManagerTest { return new byte[0]; } - - } |