aboutsummaryrefslogtreecommitdiffstats
path: root/openecomp-be/lib/openecomp-sdc-validation-lib
diff options
context:
space:
mode:
authorJulienBe <julien.bertozzi@intl.att.com>2020-10-28 11:50:25 -0400
committerJulienBe <julien.bertozzi@intl.att.com>2021-02-23 10:57:28 +0100
commitb485c37b36ddb3ab5e8085c009b26e97c8e62d74 (patch)
treedcea5bd91cf72076295d46f430c725d13b42f275 /openecomp-be/lib/openecomp-sdc-validation-lib
parent72b29baac0c1f08b610fd4daf2078b43ee74b3d8 (diff)
Upgrade Vulnerable Direct Dependencies [snakeyaml]
Change-Id: I84417ab3d4f18634be519b837a34d1f1e774ceff Signed-off-by: amohamad <a.mohamad@queensu.ca> Issue-ID: SDC-3051 Updated MVN dependencies in the respective pom.xml files Updated the signature of some methods to match new version 1.26 Modified test cases to match the new wording of exceptions Still working on troublshooting other failing test cases Change-Id: Ifc796574e6d8d4e4fc707db04944d83427b5dbe6 Signed-off-by: amohamad <a.mohamad@queensu.ca> Signed-off-by: JulienBe <julien.bertozzi@intl.att.com>
Diffstat (limited to 'openecomp-be/lib/openecomp-sdc-validation-lib')
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-api/pom.xml3
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-core/pom.xml3
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-core/src/main/java/org/openecomp/sdc/validation/impl/ValidationManagerImpl.java4
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/pom.xml3
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/YamlValidator.java77
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/namingconvention/NeutronPortNamingConventionValidator.java210
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/ContrailValidatorTest.java16
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/ForbiddenResourceGuideLineValidatorTest.java10
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/GlobalContextUtilTest.java2
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/HeatResourceValidatorTest.java2
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/HeatValidatorTest.java34
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/ManifestValidatorTest.java38
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/PmDictionaryValidatorTest.java2
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/SharedResourceGuideLineValidatorTest.java36
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/YamlValidatorTest.java143
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/heatresource/ContrailNetworkPolicyResourceValidatorTest.java4
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/heatresource/NestedResourceValidatorTest.java8
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/heatresource/NeutronPortResourceValidatorTest.java6
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/heatresource/NeutronSecurityGroupResourceValidatorTest.java4
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/heatresource/NovaServerGroupResourceValidatorTest.java6
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/heatresource/NovaServerResourceValidatorTest.java4
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/heatresource/ResourceGroupResourceValidatorTest.java6
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/heatresource/VirtualMachineInterfaceValidatorTest.java242
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/namingconvention/ContrailServiceInstanceNamingConventionValidatorTest.java6
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/namingconvention/ContrailServiceTemplateNamingConventionValidatorTest.java8
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/namingconvention/NeutronPortNamingConventionValidatorTest.java25
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/namingconvention/NovaServerNamingConventionGuideLineValidatorTest.java36
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/namingconvention/VirtualMachineInterfaceGuidelineValidatorTest.java18
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/util/ValidationTestUtil.java22
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/guideLineValidator/heatPortNetworkNamingConvention/missingparam/first.yaml11
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/guideLineValidator/heatPortNetworkNamingConvention/positive/first.yaml11
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/guideLineValidator/vlan_validation/modeled_through_resource_group/negative_test/input/main.yml11
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/guideLineValidator/vlan_validation/modeled_through_resource_group/negative_test_non_string/input/main.yml11
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/heat_validator/vlan_resource_validation/vlan_multiple_parent_ports/negative_test/input/main.yml11
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/heat_validator/vlan_resource_validation/vlan_multiple_parent_ports/positive_test/input/main.yml11
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-sdk/pom.xml3
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-sdk/src/main/java/org/openecomp/sdc/validation/base/ResourceBaseValidator.java2
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-sdk/src/test/java/org/openecomp/sdc/validation/base/ResourceBaseValidatorTest.java303
38 files changed, 685 insertions, 667 deletions
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-api/pom.xml b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-api/pom.xml
index 79665dfe0b..ab5c35aba7 100644
--- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-api/pom.xml
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-api/pom.xml
@@ -9,9 +9,8 @@
<parent>
<groupId>org.openecomp.sdc</groupId>
- <artifactId>openecomp-sdc-lib</artifactId>
+ <artifactId>openecomp-sdc-validation-lib</artifactId>
<version>1.8.1-SNAPSHOT</version>
- <relativePath>../..</relativePath>
</parent>
<dependencies>
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 0d69912efd..b25581fa7c 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
@@ -25,9 +25,8 @@
<parent>
<groupId>org.openecomp.sdc</groupId>
- <artifactId>openecomp-sdc-lib</artifactId>
+ <artifactId>openecomp-sdc-validation-lib</artifactId>
<version>1.8.1-SNAPSHOT</version>
- <relativePath>../..</relativePath>
</parent>
<dependencies>
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 2f5a8ce399..a25b8ae88f 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
@@ -25,8 +25,6 @@ import org.openecomp.core.validation.api.ValidationManager;
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.logging.api.Logger;
-import org.openecomp.sdc.logging.api.LoggerFactory;
import org.openecomp.sdc.validation.Validator;
import org.openecomp.sdc.validation.services.ValidationFactory;
@@ -37,8 +35,6 @@ import java.util.Objects;
public class ValidationManagerImpl implements ValidationManager {
- private static Logger logger = (Logger) LoggerFactory.getLogger(ValidationManagerImpl.class);
-
private GlobalValidationContext globalContext;
private List<Validator> validators;
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/pom.xml b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/pom.xml
index 8dfea9e422..abf4fb3e67 100644
--- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/pom.xml
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/pom.xml
@@ -26,9 +26,8 @@
<parent>
<groupId>org.openecomp.sdc</groupId>
- <artifactId>openecomp-sdc-lib</artifactId>
+ <artifactId>openecomp-sdc-validation-lib</artifactId>
<version>1.8.1-SNAPSHOT</version>
- <relativePath>../..</relativePath>
</parent>
<dependencies>
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/YamlValidator.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/YamlValidator.java
index b11ff5e341..c433c3e7d4 100644
--- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/YamlValidator.java
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/YamlValidator.java
@@ -17,7 +17,8 @@
package org.openecomp.sdc.validation.impl.validators;
-import org.onap.sdc.tosca.services.YamlUtil;
+import org.onap.sdc.tosca.services.MyPropertyUtils;
+import org.onap.sdc.tosca.services.StrictMapAppenderConstructor;
import org.openecomp.core.validation.ErrorMessageCode;
import org.openecomp.core.validation.errors.ErrorMessagesFormatBuilder;
import org.openecomp.core.validation.types.GlobalValidationContext;
@@ -25,6 +26,12 @@ import org.openecomp.sdc.common.errors.Messages;
import org.openecomp.sdc.datatypes.error.ErrorLevel;
import org.openecomp.sdc.validation.Validator;
import org.openecomp.sdc.validation.impl.util.YamlValidatorUtil;
+import org.yaml.snakeyaml.DumperOptions;
+import org.yaml.snakeyaml.LoaderOptions;
+import org.yaml.snakeyaml.TypeDescription;
+import org.yaml.snakeyaml.Yaml;
+import org.yaml.snakeyaml.constructor.Constructor;
+import org.yaml.snakeyaml.representer.Representer;
import java.io.InputStream;
import java.util.Collection;
@@ -33,42 +40,50 @@ import java.util.Optional;
import java.util.Set;
public class YamlValidator implements Validator {
- private static final ErrorMessageCode ERROR_CODE_YML_1 = new ErrorMessageCode("YML1");
- private static final ErrorMessageCode ERROR_CODE_YML_2 = new ErrorMessageCode("YML2");
+ private static final ErrorMessageCode ERROR_CODE_YML_1 = new ErrorMessageCode("YML1");
+ private static final ErrorMessageCode ERROR_CODE_YML_2 = new ErrorMessageCode("YML2");
- @Override
- public void validate(GlobalValidationContext globalContext) {
- Set<String> pmDictionaryFiles = GlobalContextUtil.findPmDictionaryFiles(globalContext);
+ @Override
+ public void validate(GlobalValidationContext globalContext) {
+ Set<String> pmDictionaryFiles = GlobalContextUtil.findPmDictionaryFiles(globalContext);
- Collection<String> files = globalContext.files(
- (fileName, globalValidationContext) -> FileExtensionUtils.isYaml(fileName)
- && !pmDictionaryFiles.contains(fileName));
+ Collection<String> files = globalContext.files(
+ (fileName, globalValidationContext) -> FileExtensionUtils.isYaml(fileName)
+ && !pmDictionaryFiles.contains(fileName));
- files.forEach(fileName -> validate(fileName, globalContext));
- }
-
- private void validate(String fileName, GlobalValidationContext globalContext) {
- Optional<InputStream> rowContent = globalContext.getFileContent(fileName);
- if (rowContent.isEmpty()) {
- globalContext.addMessage(fileName, ErrorLevel.ERROR, ErrorMessagesFormatBuilder
- .getErrorWithParameters(ERROR_CODE_YML_1, Messages
- .INVALID_YAML_FORMAT_REASON.getErrorMessage(),
- Messages.EMPTY_YAML_FILE.getErrorMessage()));
- return; /* no need to continue validation */
+ files.forEach(fileName -> validate(fileName, globalContext));
}
- try {
- convert(rowContent.get(), Map.class);
- } catch (Exception exception) {
+ private void validate(String fileName, GlobalValidationContext globalContext) {
+ Optional<InputStream> rowContent = globalContext.getFileContent(fileName);
+ if (rowContent.isEmpty()) {
+ globalContext.addMessage(fileName, ErrorLevel.ERROR, ErrorMessagesFormatBuilder
+ .getErrorWithParameters(ERROR_CODE_YML_1, Messages
+ .INVALID_YAML_FORMAT_REASON.getErrorMessage(),
+ Messages.EMPTY_YAML_FILE.getErrorMessage()));
+ return; /* no need to continue validation */
+ }
+
+ try (var yamlContent = rowContent.get()) {
+ Constructor constructor = new StrictMapAppenderConstructor(Map.class);
+ constructor.setAllowDuplicateKeys(false);
+ constructor.setPropertyUtils(new MyPropertyUtils());
+ TypeDescription yamlFileDescription = new TypeDescription(Map.class);
+ constructor.addTypeDescription(yamlFileDescription);
+ LoaderOptions options = new LoaderOptions();
+ options.setAllowDuplicateKeys(false);
+ //No Yaml Constructor takes only Constructor and LoaderOptions, that is why I had to pass anonymous Representer and DumperOptions objects
+ Object yamlObj = new Yaml(constructor, new Representer(), new DumperOptions(), options).load(yamlContent);
- globalContext.addMessage(fileName, ErrorLevel.ERROR, ErrorMessagesFormatBuilder
- .getErrorWithParameters(ERROR_CODE_YML_2, Messages
- .INVALID_YAML_FORMAT_REASON.getErrorMessage(),
- YamlValidatorUtil.getParserExceptionReason(exception)));
+ if (yamlObj == null) {
+ throw new Exception();
+ }
+ } catch (Exception exception) {
+ globalContext.addMessage(fileName, ErrorLevel.ERROR, ErrorMessagesFormatBuilder
+ .getErrorWithParameters(ERROR_CODE_YML_2, Messages
+ .INVALID_YAML_FORMAT_REASON.getErrorMessage(),
+ YamlValidatorUtil.getParserExceptionReason(exception)));
+ }
}
- }
- private <T> T convert(InputStream content, Class<T> type) {
- return new YamlUtil().yamlToObject(content, type);
- }
}
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/namingconvention/NeutronPortNamingConventionValidator.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/namingconvention/NeutronPortNamingConventionValidator.java
index b3d346177b..760c73a52b 100644
--- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/namingconvention/NeutronPortNamingConventionValidator.java
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/namingconvention/NeutronPortNamingConventionValidator.java
@@ -30,146 +30,114 @@ import org.openecomp.sdc.validation.ValidationContext;
import org.openecomp.sdc.validation.type.NamingConventionValidationContext;
import org.openecomp.sdc.validation.util.ValidationUtil;
+import java.util.Arrays;
import java.util.List;
import java.util.Map;
import static java.util.Objects.nonNull;
public class NeutronPortNamingConventionValidator implements ResourceValidator {
- private static final ErrorMessageCode ERROR_CODE_NNP1 = new ErrorMessageCode("NNP1");
- private static final ErrorMessageCode ERROR_CODE_NNP2 = new ErrorMessageCode("NNP2");
- private static final ErrorMessageCode ERROR_CODE_NNP3 = new ErrorMessageCode("NNP3");
-
- @Override
- public void validate(String fileName, Map.Entry<String, Resource> resourceEntry,
- GlobalValidationContext globalContext, ValidationContext validationContext) {
-
- NamingConventionValidationContext namingConventionValidationContext =
- (NamingConventionValidationContext)validationContext;
- validatePortNetworkNamingConvention(fileName, namingConventionValidationContext.getHeatOrchestrationTemplate(),
- globalContext);
- validateFixedIpsNamingConvention(fileName, namingConventionValidationContext.getHeatOrchestrationTemplate(),
- globalContext);
- }
-
- private void validatePortNetworkNamingConvention(String fileName,
- HeatOrchestrationTemplate heatOrchestrationTemplate,
- GlobalValidationContext globalContext) {
- if (MapUtils.isEmpty(heatOrchestrationTemplate.getResources())) {
- return;
+ private static final ErrorMessageCode ERROR_CODE_NNP1 = new ErrorMessageCode("NNP1");
+ private static final ErrorMessageCode ERROR_CODE_NNP2 = new ErrorMessageCode("NNP2");
+ private static final ErrorMessageCode ERROR_CODE_NNP3 = new ErrorMessageCode("NNP3");
+
+ @Override
+ public void validate(String fileName, Map.Entry<String, Resource> resourceEntry,
+ GlobalValidationContext globalContext, ValidationContext validationContext) {
+ NamingConventionValidationContext namingConventionValidationContext = (NamingConventionValidationContext) validationContext;
+ validatePortNetworkNamingConvention(fileName, namingConventionValidationContext.getHeatOrchestrationTemplate(), globalContext);
+ validateFixedIpsNamingConvention(fileName, namingConventionValidationContext.getHeatOrchestrationTemplate(), globalContext);
}
- String[] regexList = {".*_net_id", ".*_net_name", ".*_net_fqdn"};
-
- heatOrchestrationTemplate
- .getResources()
- .entrySet()
- .stream()
- .filter(entry -> entry.getValue().getType()
- .equals(HeatResourcesTypes.NEUTRON_PORT_RESOURCE_TYPE.getHeatResource()))
- .forEach(entry -> entry.getValue()
- .getProperties()
- .entrySet()
- .stream()
- .filter(propertyEntry ->
- ("network").equalsIgnoreCase(propertyEntry.getKey())
- || ("network_id").equals(propertyEntry.getKey()))
- .forEach(propertyEntry -> validateParamNamingConvention(fileName, entry.getKey(),
- propertyEntry.getValue(), regexList,
- Messages.PARAMETER_NAME_NOT_ALIGNED_WITH_GUIDELINES, globalContext)));
- }
- private void validateFixedIpsNamingConvention(String fileName,
- HeatOrchestrationTemplate heatOrchestrationTemplate,
- GlobalValidationContext globalContext) {
- if (MapUtils.isEmpty(heatOrchestrationTemplate.getResources())) {
- return;
+ private void validatePortNetworkNamingConvention(String fileName,
+ HeatOrchestrationTemplate heatOrchestrationTemplate,
+ GlobalValidationContext globalContext) {
+ if (MapUtils.isEmpty(heatOrchestrationTemplate.getResources())) {
+ return;
+ }
+ String[] regexList = {".*_net_id", ".*_net_name", ".*_net_fqdn"};
+
+ heatOrchestrationTemplate
+ .getResources()
+ .entrySet()
+ .stream()
+ .filter(entry -> entry.getValue().getType().equals(HeatResourcesTypes.NEUTRON_PORT_RESOURCE_TYPE.getHeatResource()))
+ .forEach(entry -> entry.getValue()
+ .getProperties()
+ .entrySet()
+ .stream()
+ .filter(propertyEntry -> ("network").equalsIgnoreCase(propertyEntry.getKey()) || ("network_id").equals(propertyEntry.getKey()))
+ .forEach(propertyEntry -> validateParamNamingConvention(fileName, entry.getKey(),
+ propertyEntry.getValue(), regexList,
+ Messages.PARAMETER_NAME_NOT_ALIGNED_WITH_GUIDELINES, globalContext)));
}
- heatOrchestrationTemplate.getResources()
- .entrySet()
- .stream()
- .filter(entry -> HeatResourcesTypes.findByHeatResource(entry.getValue().getType()) != null)
- .filter(entry -> HeatResourcesTypes.findByHeatResource(entry.getValue().getType())
- .equals(HeatResourcesTypes.NEUTRON_PORT_RESOURCE_TYPE))
- .forEach(entry -> checkNeutronPortFixedIpsName(fileName, entry, globalContext));
- }
-
- private void checkNeutronPortFixedIpsName(String fileName,
- Map.Entry<String, Resource> resourceEntry,
- GlobalValidationContext globalContext) {
- String[] regexList = {"[^_]+_[^_]+_ips", "[^_]+_[^_]+_v6_ips", "[^_]+_[^_]+_ip_(\\d+)",
- "[^_]+_[^_]+_v6_ip_(\\d+)", "[^_]+_[^_]+_[^_]+_ips", "[^_]+_[^_]+_[^_]+_v6_ips",
- "[^_]+_[^_]+_[^_]+_ip_(\\d+)", "[^_]+_[^_]+_[^_]+_v6_ip_(\\d+)"};
+ private void validateFixedIpsNamingConvention(String fileName,
+ HeatOrchestrationTemplate heatOrchestrationTemplate,
+ GlobalValidationContext globalContext) {
+ if (MapUtils.isEmpty(heatOrchestrationTemplate.getResources())) {
+ return;
+ }
- if (MapUtils.isEmpty(resourceEntry.getValue().getProperties())) {
- return;
+ heatOrchestrationTemplate.getResources()
+ .entrySet()
+ .stream()
+ .filter(entry -> HeatResourcesTypes.findByHeatResource(entry.getValue().getType()) != null)
+ .filter(entry -> HeatResourcesTypes.findByHeatResource(entry.getValue().getType())
+ .equals(HeatResourcesTypes.NEUTRON_PORT_RESOURCE_TYPE))
+ .forEach(entry -> checkNeutronPortFixedIpsName(fileName, entry, globalContext));
}
- Map<String, Object> propertiesMap = resourceEntry.getValue().getProperties();
- Object fixedIps = propertiesMap.get("fixed_ips");
- if (nonNull(fixedIps) && fixedIps instanceof List) {
- List<Object> fixedIpsList = (List<Object>) fixedIps;
- for (Object fixedIpsObject : fixedIpsList) {
- Map.Entry<String, Object> fixedIpsEntry =
- ((Map<String, Object>) fixedIpsObject).entrySet().iterator().next();
-
- validateFixedIpsName(fileName, resourceEntry, globalContext, regexList, fixedIpsEntry);
+ private void checkNeutronPortFixedIpsName(String fileName,
+ Map.Entry<String, Resource> resourceEntry,
+ GlobalValidationContext globalContext) {
+ String[] regexList = {"[^_]+_[^_]+_ips", "[^_]+_[^_]+_v6_ips", "[^_]+_[^_]+_ip_(\\d+)",
+ "[^_]+_[^_]+_v6_ip_(\\d+)", "[^_]+_[^_]+_[^_]+_ips", "[^_]+_[^_]+_[^_]+_v6_ips",
+ "[^_]+_[^_]+_[^_]+_ip_(\\d+)", "[^_]+_[^_]+_[^_]+_v6_ip_(\\d+)"};
+ if (MapUtils.isEmpty(resourceEntry.getValue().getProperties())) {
+ return;
+ }
- }
+ Map<String, Object> propertiesMap = resourceEntry.getValue().getProperties();
+ Object fixedIps = propertiesMap.get("fixed_ips");
+ if (nonNull(fixedIps) && fixedIps instanceof List) {
+ List<Object> fixedIpsList = (List<Object>) fixedIps;
+ for (Object fixedIpsObject : fixedIpsList) {
+ Map.Entry<String, Object> fixedIpsEntry = ((Map<String, Object>) fixedIpsObject).entrySet().iterator().next();
+ validateFixedIpsName(fileName, resourceEntry, globalContext, regexList, fixedIpsEntry);
+ }
+ }
}
- }
-
- private void validateFixedIpsName(String fileName, Map.Entry<String, Resource> resourceEntry,
- GlobalValidationContext globalContext,
- String[] regexList, Map.Entry<String, Object> fixedIpsEntry) {
- if (nonNull(fixedIpsEntry)) {
- if (fixedIpsEntry.getValue() instanceof Map) {
-
- String fixedIpsName = ValidationUtil
- .getWantedNameFromPropertyValueGetParam(fixedIpsEntry.getValue());
- if (nonNull(fixedIpsName) && !ValidationUtil.evalPattern(fixedIpsName, regexList)) {
- globalContext.addMessage(fileName, ErrorLevel.WARNING, ErrorMessagesFormatBuilder.getErrorWithParameters(ERROR_CODE_NNP1, Messages.PARAMETER_NAME_NOT_ALIGNED_WITH_GUIDELINES.getErrorMessage(),
- "Port", "Fixed_IPS", fixedIpsName, resourceEntry.getKey()));
- }
-
-
- } else {
- globalContext.addMessage(
- fileName,
- ErrorLevel.WARNING, ErrorMessagesFormatBuilder
- .getErrorWithParameters(
- ERROR_CODE_NNP2, Messages.MISSING_GET_PARAM.getErrorMessage(),
- "fixed_ips", resourceEntry.getKey()));
- }
+ private void validateFixedIpsName(String fileName, Map.Entry<String, Resource> resourceEntry, GlobalValidationContext globalContext,
+ String[] regexList, Map.Entry<String, Object> fixedIpsEntry) {
+ if (nonNull(fixedIpsEntry)) {
+ if (fixedIpsEntry.getValue() instanceof Map) {
+ String fixedIpsName = ValidationUtil.getWantedNameFromPropertyValueGetParam(fixedIpsEntry.getValue());
+ if (nonNull(fixedIpsName) && !ValidationUtil.evalPattern(fixedIpsName, regexList)) {
+ globalContext.addMessage(fileName, ErrorLevel.WARNING, ErrorMessagesFormatBuilder
+ .getErrorWithParameters(ERROR_CODE_NNP1, Messages.PARAMETER_NAME_NOT_ALIGNED_WITH_GUIDELINES.getErrorMessage(),
+ "Port", "Fixed_IPS", fixedIpsName, resourceEntry.getKey()));
+ }
+ } else {
+ globalContext.addMessage(fileName, ErrorLevel.WARNING, ErrorMessagesFormatBuilder.
+ getErrorWithParameters(ERROR_CODE_NNP2, Messages.MISSING_GET_PARAM.getErrorMessage(), "fixed_ips", resourceEntry.getKey()));
+ }
+ }
}
- }
- private void validateParamNamingConvention(String fileName, String resourceId,
- Object propertyValue,
- String[] regexList,
- Messages message,
- GlobalValidationContext globalContext) {
- Object paramName;
- if (propertyValue instanceof Map) {
- paramName = ((Map) propertyValue).get("get_param");
- if (paramName instanceof String && !ValidationUtil.evalPattern(paramName, regexList)) {
- globalContext.addMessage(
- fileName,
- ErrorLevel.WARNING, ErrorMessagesFormatBuilder
- .getErrorWithParameters(ERROR_CODE_NNP3, message.getErrorMessage(), "Port",
- "Network", (String) paramName, resourceId));
+ private void validateParamNamingConvention(String fileName, String resourceId, Object propertyValue, String[] regexList,
+ Messages message, GlobalValidationContext globalContext) {
+ if (propertyValue instanceof Map) {
+ Object paramName = ((Map) propertyValue).get("get_param");
+ if (paramName instanceof String && !ValidationUtil.evalPattern(paramName, regexList)) {
+ globalContext.addMessage(fileName, ErrorLevel.WARNING, ErrorMessagesFormatBuilder
+ .getErrorWithParameters(ERROR_CODE_NNP3, message.getErrorMessage(), "Port", "Network", (String) paramName, resourceId));
+ }
+ } else {
+ globalContext.addMessage(fileName, ErrorLevel.WARNING, ErrorMessagesFormatBuilder
+ .getErrorWithParameters(ERROR_CODE_NNP2, Messages.MISSING_GET_PARAM.getErrorMessage(), "network or network_id", resourceId));
}
-
- } else {
- globalContext.addMessage(
- fileName,
- ErrorLevel.WARNING,
- ErrorMessagesFormatBuilder
- .getErrorWithParameters(
- ERROR_CODE_NNP2, Messages.MISSING_GET_PARAM.getErrorMessage(),
- "network or network_id", resourceId));
}
- }
}
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/ContrailValidatorTest.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/ContrailValidatorTest.java
index c0a84b5f9d..da861dc3e1 100644
--- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/ContrailValidatorTest.java
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/ContrailValidatorTest.java
@@ -40,7 +40,7 @@ public class ContrailValidatorTest {
@Test
public void testWarningMessageExistWhenConrailV1AndV2ResourcesCollidesInSameHeatFile() {
- Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(validator,
+ Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(validator,
RESOURCE_PATH + "/collidesinsameheatfile/");
validateMessage(messages,
"WARNING: [CTL2]: HEAT Package includes both Contrail 2 and Contrail 3 " +
@@ -52,7 +52,7 @@ public class ContrailValidatorTest {
@Test
public void testParseException(){
- Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(validator,
+ Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(validator,
RESOURCE_PATH + "/parseException/");
validateMessage(messages,
"ERROR: [CTL4]: Invalid HEAT format problem - [while scanning for the next " +
@@ -68,7 +68,7 @@ public class ContrailValidatorTest {
@Test
public void testWarningMessageExistWhenConrailV1AndV2ResourcesCollidesInDifferentHeatFiles() {
- Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(validator,
+ Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(validator,
RESOURCE_PATH + "/collidesindifferentheatfiles/");
validateMessage(messages,
"WARNING: [CTL2]: HEAT Package includes both Contrail 2 and Contrail 3 " +
@@ -80,7 +80,7 @@ public class ContrailValidatorTest {
@Test
public void testWarningMessageNotExistWhenConrailV1AndV2ResourcesCollidesInNonHeatFile() {
- Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(validator,
+ Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(validator,
RESOURCE_PATH + "/collidesinnontheatfiles/");
validateMessage(messages,
"WARNING: [CTL2]: HEAT Package includes both Contrail 2 and Contrail 3 " +
@@ -93,7 +93,7 @@ public class ContrailValidatorTest {
@Test
public void testWarningMessageNotExistWhenOnlyConrailV1Resources() {
- Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(validator,
+ Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(validator,
RESOURCE_PATH + "/notcollides/");
validateMessage(messages,
"WARNING: [CTL3]: Contrail 2.x deprecated resource is in use, " +
@@ -104,7 +104,7 @@ public class ContrailValidatorTest {
@Test
public void testWarningMessageOnResourceWithContrailType() {
- Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(validator,
+ Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(validator,
RESOURCE_PATH + "/validatenocontrailresource/");
validateMessage(messages,
"WARNING: [CTL3]: Contrail 2.x deprecated resource is in use, " +
@@ -114,7 +114,7 @@ public class ContrailValidatorTest {
@Test
public void testInvalidHeatStructure(){
- Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(validator,
+ Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(validator,
RESOURCE_PATH + "/invalidHeatStructure/");
validateMessage(messages,
"ERROR: [CTL1]: Invalid HEAT format problem - [The file 'first.yaml' " +
@@ -124,7 +124,7 @@ public class ContrailValidatorTest {
@Test
public void testInvalidHeatStructuredueToParsingError(){
- Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(validator,
+ Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(validator,
RESOURCE_PATH + "/invalidHeatStructure/");
validateMessage(messages,
"ERROR: [CTL1]: Invalid HEAT format problem - [The file 'first.yaml' " +
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/ForbiddenResourceGuideLineValidatorTest.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/ForbiddenResourceGuideLineValidatorTest.java
index a6e3d11cf3..64ddd61696 100644
--- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/ForbiddenResourceGuideLineValidatorTest.java
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/ForbiddenResourceGuideLineValidatorTest.java
@@ -39,7 +39,7 @@ public class ForbiddenResourceGuideLineValidatorTest {
@BeforeClass
public static void init() throws IOException {
- Map<String, Object> resourcesMap = ValidationTestUtil.getResourceMap(mockConfigFileName);
+ Map<String, Object> resourcesMap = new ValidationTestUtil().getResourceMap(mockConfigFileName);
Map<String, Object> resourceBaseValidatorMap =
(Map<String, Object>) resourcesMap.get("forbiddenResourceGuideLineValidator");
@@ -51,13 +51,13 @@ public class ForbiddenResourceGuideLineValidatorTest {
@Test
public void testFloatingIpResourceType() {
- Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(
+ Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(
forbiddenResourceGuideLineValidator, RESOURCE_PATH + "/positive");
Assert.assertNotNull(messages);
Assert.assertEquals(messages.size(), 0);
- messages = ValidationTestUtil.testValidator(forbiddenResourceGuideLineValidator,
+ messages = new ValidationTestUtil().testValidator(forbiddenResourceGuideLineValidator,
RESOURCE_PATH + "/negative");
Assert.assertNotNull(messages);
Assert.assertEquals(messages.size(), 1);
@@ -67,7 +67,7 @@ public class ForbiddenResourceGuideLineValidatorTest {
}
@Test
public void testParseException(){
- Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(
+ Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(
forbiddenResourceGuideLineValidator, RESOURCE_PATH + "/parseException");
Assert.assertEquals(messages.size(), 1);
Assert.assertEquals(messages.get("first.yaml").getErrorMessageList().size(), 1);
@@ -82,7 +82,7 @@ public class ForbiddenResourceGuideLineValidatorTest {
@Test
public void testInvalidResourceType(){
- Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(
+ Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(
forbiddenResourceGuideLineValidator, RESOURCE_PATH + "/TestInvalidResourceType");
Assert.assertEquals(messages.get("first.yaml").getErrorMessageList().get(0).getMessage(),
"WARNING: [FRG1]: A resource has an invalid or unsupported type - null, " +
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/GlobalContextUtilTest.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/GlobalContextUtilTest.java
index 5856b3f322..df6fa0676f 100644
--- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/GlobalContextUtilTest.java
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/GlobalContextUtilTest.java
@@ -34,7 +34,7 @@ class GlobalContextUtilTest {
@Test
void shouldReturnOnlyFilesWithPmDictionaryType() {
// given
- GlobalValidationContext globalContext = ValidationTestUtil.createGlobalContextFromPath(TEST_MANIFEST_PATH);
+ GlobalValidationContext globalContext = new ValidationTestUtil().createGlobalContextFromPath(TEST_MANIFEST_PATH);
// when
Set<String> pmDictionaryFiles = GlobalContextUtil.findPmDictionaryFiles(globalContext);
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/HeatResourceValidatorTest.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/HeatResourceValidatorTest.java
index d687e5e512..4492eac8e5 100644
--- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/HeatResourceValidatorTest.java
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/HeatResourceValidatorTest.java
@@ -29,7 +29,7 @@ public class HeatResourceValidatorTest {
@Test
public void testParseException(){
- Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(validator,
+ Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(validator,
"/org/openecomp/validation/validators/guideLineValidator/baseHeatDoesNotExposeNetwork/parseException/");
Assert.assertEquals(messages.size(), 1);
Assert.assertEquals(messages.get("first.yaml").getErrorMessageList().get(0).getMessage(),
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/HeatValidatorTest.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/HeatValidatorTest.java
index ffcedbbbc8..a528985909 100644
--- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/HeatValidatorTest.java
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/HeatValidatorTest.java
@@ -41,7 +41,7 @@ public class HeatValidatorTest {
@Test
public void testInvalidHeatFormat() {
- Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(validator,
+ Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(validator,
RESOURCE_PATH + "/invalid_heat_format/negative_test/input");
Assert.assertNotNull(messages);
@@ -61,7 +61,7 @@ public class HeatValidatorTest {
@Test
public void testDependsOn() {
- Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(validator,
+ Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(validator,
RESOURCE_PATH + "/depends_on_points_to_existing_resource/input");
Assert.assertNotNull(messages);
@@ -79,7 +79,7 @@ public class HeatValidatorTest {
@Test
public void testResourcesReferencesExistInHeat() throws IOException {
- Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(new HeatValidator(),
+ Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(new HeatValidator(),
RESOURCE_PATH + "/resource_references_exist_in_heat/negative_test/input");
Assert.assertNotNull(messages);
@@ -98,7 +98,7 @@ public class HeatValidatorTest {
@Test
public void testGetResourceValueIsValid() {
- Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(new HeatValidator(),
+ Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(new HeatValidator(),
RESOURCE_PATH + "/get_resource_value_valid/negative_test/input");
Assert.assertNotNull(messages);
@@ -121,7 +121,7 @@ public class HeatValidatorTest {
@Test
public void testTwoResourcesDoesNotHoldSameId() throws IOException {
- Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(new HeatValidator(),
+ Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(new HeatValidator(),
RESOURCE_PATH + "/two_resources_does_not_hold_same_id/positive_test/input");
Assert.assertNotNull(messages);
Assert.assertEquals(messages.size(), 0);
@@ -129,7 +129,7 @@ public class HeatValidatorTest {
@Test
public void testWithWrongFileExtension(){
- Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(new HeatValidator(),
+ Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(new HeatValidator(),
RESOURCE_PATH + "/wrongFileExtension");
Assert.assertNotNull(messages);
Assert.assertEquals(messages.get("single.aad").getErrorMessageList().get(0).getMessage(),
@@ -140,7 +140,7 @@ public class HeatValidatorTest {
@Test
public void testWithMissingManifestContent(){
- Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(new HeatValidator(),
+ Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(new HeatValidator(),
RESOURCE_PATH + "/missingManifestContent");
Assert.assertNotNull(messages);
Assert.assertEquals(messages.get("single.yaml").getErrorMessageList().get(0).getMessage(),
@@ -152,7 +152,7 @@ public class HeatValidatorTest {
@Test
public void testWithInvalidHeatContent(){
- Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(new HeatValidator(),
+ Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(new HeatValidator(),
RESOURCE_PATH + "/invalidHeatContent");
Assert.assertNotNull(messages);
Assert.assertEquals(messages.get("single.yaml").getErrorMessageList().get(0).getMessage(),
@@ -167,7 +167,7 @@ public class HeatValidatorTest {
@Test
public void testGeneratedArtifactExistInHeat() throws IOException {
- Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(new HeatValidator(),
+ Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(new HeatValidator(),
RESOURCE_PATH + "/generated_artifact_exist/negative_test/input");
Assert.assertNotNull(messages);
Assert.assertEquals(messages.size(), 3);
@@ -188,7 +188,7 @@ public class HeatValidatorTest {
@Test
public void negativeTestGetParamPointToExistingParameter() throws IOException {
- Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(new HeatValidator(),
+ Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(new HeatValidator(),
RESOURCE_PATH + "/get_param_points_to_existing_parameter/negative_test/input");
Assert.assertNotNull(messages);
@@ -203,7 +203,7 @@ public class HeatValidatorTest {
@Test
public void testGetAttrFromNested() throws IOException {
- Map<String, MessageContainer> messages =ValidationTestUtil.testValidator(new HeatValidator(),
+ Map<String, MessageContainer> messages =new ValidationTestUtil().testValidator(new HeatValidator(),
RESOURCE_PATH + "/get_attr_from_nested/negative_test/input");
Assert.assertNotNull(messages);
@@ -218,7 +218,7 @@ public class HeatValidatorTest {
@Test
public void testDefaultValueAlignWithType() throws IOException {
- Map<String, MessageContainer> messages =ValidationTestUtil.testValidator(new HeatValidator(),
+ Map<String, MessageContainer> messages =new ValidationTestUtil().testValidator(new HeatValidator(),
RESOURCE_PATH + "/default_value_align_with_type/negative_test/input");
Assert.assertNotNull(messages);
@@ -234,7 +234,7 @@ public class HeatValidatorTest {
@Test
public void testEnvParametersMatchDefinedHeatParameterTypes() throws IOException {
- Map<String, MessageContainer> messages =ValidationTestUtil.testValidator(new HeatValidator(),
+ Map<String, MessageContainer> messages =new ValidationTestUtil().testValidator(new HeatValidator(),
RESOURCE_PATH + "/env_parameters_match_defined_types/negative_test/input");
Assert.assertNotNull(messages);
@@ -249,7 +249,7 @@ public class HeatValidatorTest {
@Test
public void testReferencedArtifactsExist() throws IOException {
- Map<String, MessageContainer> messages =ValidationTestUtil.testValidator(new HeatValidator(),
+ Map<String, MessageContainer> messages =new ValidationTestUtil().testValidator(new HeatValidator(),
RESOURCE_PATH + "/referenced_artifacts_exist/negative_test/input");
Assert.assertNotNull(messages);
@@ -264,7 +264,7 @@ public class HeatValidatorTest {
@Test
public void testEnvContentIsSubSetOfHeatParameters() throws IOException {
- Map<String, MessageContainer> messages =ValidationTestUtil.testValidator(validator,
+ Map<String, MessageContainer> messages =new ValidationTestUtil().testValidator(validator,
RESOURCE_PATH + "/env_content_is_subset_of_heat/negative_test/input");
Assert.assertNotNull(messages);
@@ -279,7 +279,7 @@ public class HeatValidatorTest {
@Test
public void testGetParamPseudoParameters() {
- Map<String, MessageContainer> messages =ValidationTestUtil.testValidator(new HeatValidator(),
+ Map<String, MessageContainer> messages =new ValidationTestUtil().testValidator(new HeatValidator(),
RESOURCE_PATH + "/pseudo_parameters/input");
Assert.assertNotNull(messages);
@@ -288,7 +288,7 @@ public class HeatValidatorTest {
}
@Test
public void testNoErrorWhenEmptyValueForParameterInEnv() {
- Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(validator,
+ Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(validator,
RESOURCE_PATH + "/env_empty_value/input");
Assert.assertNotNull(messages);
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/ManifestValidatorTest.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/ManifestValidatorTest.java
index 9e860ef2b3..778213dea8 100644
--- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/ManifestValidatorTest.java
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/ManifestValidatorTest.java
@@ -39,7 +39,7 @@ public class ManifestValidatorTest {
@Test
public void testValidManifest() {
- Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(validator,
+ Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(validator,
RESOURCE_PATH + "/validFiles");
Assert.assertNotNull(messages);
Assert.assertNotNull(messages);
@@ -48,25 +48,25 @@ public class ManifestValidatorTest {
@Test
public void testManifestMissingFileInZip() {
- Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(new ManifestValidator(),
+ Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(new ManifestValidator(),
RESOURCE_PATH + "/missingFileInZip");
Assert.assertNotNull(messages);
Assert.assertEquals(messages.size(), 1);
Assert.assertTrue(messages.containsKey("singleVol.yaml"));
- ValidationTestUtil.validateErrorMessage(messages.get("singleVol.yaml").getErrorMessageList()
+ new ValidationTestUtil().validateErrorMessage(messages.get("singleVol.yaml").getErrorMessageList()
.get(0).getMessage(),
"ERROR: " + "[MNF4]: " + Messages.MISSING_FILE_IN_ZIP.getErrorMessage());
}
@Test
public void testInvalidManifest() {
- Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(new ManifestValidator(),
+ Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(new ManifestValidator(),
RESOURCE_PATH + "/invalidManifest");
Assert.assertNotNull(messages);
Assert.assertNotNull(messages);
Assert.assertEquals(messages.size(), 1);
Assert.assertTrue(messages.containsKey(SdcCommon.MANIFEST_NAME));
- ValidationTestUtil.validateErrorMessage(
+ new ValidationTestUtil().validateErrorMessage(
messages.get(SdcCommon.MANIFEST_NAME).getErrorMessageList().get(0).getMessage(),
"ERROR: " +"[MNF6]: " + Messages.INVALID_MANIFEST_FILE.getErrorMessage());
@@ -74,28 +74,28 @@ public class ManifestValidatorTest {
@Test
public void testMissingFileInManifest() {
- Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(new ManifestValidator(),
+ Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(new ManifestValidator(),
RESOURCE_PATH + "/missingFileInManifest");
Assert.assertNotNull(messages);
Assert.assertEquals(messages.size(), 1);
Assert.assertTrue(messages.containsKey("extraFile.env"));
- ValidationTestUtil.validateErrorMessage(messages.get("extraFile.env").getErrorMessageList()
+ new ValidationTestUtil().validateErrorMessage(messages.get("extraFile.env").getErrorMessageList()
.get(0).getMessage(),
"WARNING: " + "[MNF5]: " + Messages.MISSING_FILE_IN_MANIFEST.getErrorMessage());
}
@Test
public void testMissingFileTypeInManifest() {
- Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(new ManifestValidator(),
+ Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(new ManifestValidator(),
RESOURCE_PATH + "/missingFileTypeInManifest");
- ValidationTestUtil.validateErrorMessage(
+ new ValidationTestUtil().validateErrorMessage(
messages.get("MANIFEST.json").getErrorMessageList().get(0).getMessage(),
"ERROR: " + "[MNF7]: Missing file name in manifest");
}
@Test
public void testInvalidFileTypeInManifest() {
- Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(new ManifestValidator(),
+ Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(new ManifestValidator(),
RESOURCE_PATH + "/invalidFileTypeInManifest");
Assert.assertNotNull(messages);
Assert.assertEquals(messages.size(), 4);
@@ -103,19 +103,19 @@ public class ManifestValidatorTest {
Assert.assertTrue(messages.containsKey("illegalTypeFile.yaml"));
Assert.assertTrue(messages.containsKey("single.yaml.illegalSuffix"));
Assert.assertTrue(messages.containsKey("singleVol.yaml.illegalSuffix"));
- ValidationTestUtil.validateErrorMessage(
+ new ValidationTestUtil().validateErrorMessage(
messages.get("single.env.illegalSuffix").getErrorMessageList().get(0).getMessage(),
"ERROR: "+"[MNF3]: " + Messages.WRONG_ENV_FILE_EXTENSION.getErrorMessage(),
"single.env.illegalSuffix");
- ValidationTestUtil.validateErrorMessage(
+ new ValidationTestUtil().validateErrorMessage(
messages.get("illegalTypeFile.yaml").getErrorMessageList().get(0).getMessage(),
"ERROR: "+"[MNF8]: " + Messages.INVALID_FILE_TYPE.getErrorMessage(),
"illegalTypeFile.yaml");
- ValidationTestUtil.validateErrorMessage(
+ new ValidationTestUtil().validateErrorMessage(
messages.get("single.yaml.illegalSuffix").getErrorMessageList().get(0).getMessage(),
"ERROR: "+"[MNF2]: " + Messages.WRONG_HEAT_FILE_EXTENSION.getErrorMessage(),
"single.yaml.illegalSuffix");
- ValidationTestUtil.validateErrorMessage(
+ new ValidationTestUtil().validateErrorMessage(
messages.get("singleVol.yaml.illegalSuffix").getErrorMessageList().get(0).getMessage(),
"ERROR: "+"[MNF2]: " + Messages.WRONG_HEAT_FILE_EXTENSION.getErrorMessage(),
"singleVol.yaml.illegalSuffix");
@@ -126,16 +126,16 @@ public class ManifestValidatorTest {
@Test
public void testMissingFileInManifestAndInZip() {
- Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(new ManifestValidator(),
+ Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(new ManifestValidator(),
RESOURCE_PATH + "/missingFileInManifestAndInZip");
Assert.assertNotNull(messages);
Assert.assertEquals(messages.size(), 2);
Assert.assertTrue(messages.containsKey("extraFile.env"));
Assert.assertTrue(messages.containsKey("singleVol.yaml"));
- ValidationTestUtil.validateErrorMessage(messages.get("extraFile.env").getErrorMessageList()
+ new ValidationTestUtil().validateErrorMessage(messages.get("extraFile.env").getErrorMessageList()
.get(0).getMessage(), "WARNING: " + "[MNF5]: "+ Messages.MISSING_FILE_IN_MANIFEST
.getErrorMessage());
- ValidationTestUtil.validateErrorMessage(messages.get("singleVol.yaml").getErrorMessageList()
+ new ValidationTestUtil().validateErrorMessage(messages.get("singleVol.yaml").getErrorMessageList()
.get(0).getMessage(), "ERROR: " + "[MNF4]: " + Messages.MISSING_FILE_IN_ZIP
.getErrorMessage());
@@ -143,12 +143,12 @@ public class ManifestValidatorTest {
@Test
public void testEnvInRoot() {
- Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(new ManifestValidator(),
+ Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(new ManifestValidator(),
RESOURCE_PATH + "/envInRoot");
Assert.assertNotNull(messages);
Assert.assertEquals(messages.size(), 1);
Assert.assertTrue(messages.containsKey("second.env"));
- ValidationTestUtil.validateErrorMessage(messages.get("second.env").getErrorMessageList()
+ new ValidationTestUtil().validateErrorMessage(messages.get("second.env").getErrorMessageList()
.get(0).getMessage(),
"ERROR: [MNF1]: ENV file must be associated to a HEAT file");
}
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/PmDictionaryValidatorTest.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/PmDictionaryValidatorTest.java
index b510eeb26a..210bdd3504 100644
--- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/PmDictionaryValidatorTest.java
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/PmDictionaryValidatorTest.java
@@ -73,6 +73,6 @@ public class PmDictionaryValidatorTest {
private Map<String, MessageContainer> runValidation(String path) {
PmDictionaryValidator validator = new PmDictionaryValidator();
- return ValidationTestUtil.testValidator(validator, path);
+ return new ValidationTestUtil().testValidator(validator, path);
}
}
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/SharedResourceGuideLineValidatorTest.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/SharedResourceGuideLineValidatorTest.java
index dde43e7808..a0b18b2922 100644
--- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/SharedResourceGuideLineValidatorTest.java
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/SharedResourceGuideLineValidatorTest.java
@@ -33,12 +33,12 @@ public class SharedResourceGuideLineValidatorTest {
@Test
public void testBaseHeatExposeNetwork() {
- Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(validator,
+ Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(validator,
RESOURCE_PATH + "/baseHeatDoesNotExposeNetwork/positive/");
Assert.assertNotNull(messages);
Assert.assertEquals(messages.size(), 0);
- messages = ValidationTestUtil.testValidator(validator,
+ messages = new ValidationTestUtil().testValidator(validator,
RESOURCE_PATH + "/baseHeatDoesNotExposeNetwork/negative/");
Assert.assertNotNull(messages);
Assert.assertEquals(messages.size(), 1);
@@ -49,7 +49,7 @@ public class SharedResourceGuideLineValidatorTest {
@Test
public void testParseException(){
- Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(validator,
+ Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(validator,
RESOURCE_PATH + "/baseHeatDoesNotExposeNetwork/parseException/");
Assert.assertEquals(messages.size(), 1);
Assert.assertEquals(messages.get("first.yaml").getErrorMessageList().size(), 1);
@@ -64,7 +64,7 @@ public class SharedResourceGuideLineValidatorTest {
@Test
public void testInvalidGetResource(){
- Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(validator,
+ Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(validator,
RESOURCE_PATH + "/" +
"baseHeatDoesNotExposeNetworkInvalidGetResource");
Assert.assertEquals(messages.get("first.yaml").getErrorMessageList().get(0).getMessage(),
@@ -74,12 +74,12 @@ public class SharedResourceGuideLineValidatorTest {
@Test
public void testBaseHeatExposeNetworkAndVolume() {
- Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(validator,
+ Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(validator,
RESOURCE_PATH + "/baseHeatDoesNotExposeNetworkAndVolume/positive/");
Assert.assertNotNull(messages);
Assert.assertEquals(messages.size(), 0);
- messages = ValidationTestUtil.testValidator(validator,
+ messages = new ValidationTestUtil().testValidator(validator,
RESOURCE_PATH + "/baseHeatDoesNotExposeNetworkAndVolume/negative/");
Assert.assertNotNull(messages);
Assert.assertEquals(messages.size(), 1);
@@ -92,12 +92,12 @@ public class SharedResourceGuideLineValidatorTest {
@Test
public void testBaseHeatExposeServerGroup() {
- Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(validator,
+ Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(validator,
RESOURCE_PATH + "/baseHeatDoesNotExposeServerGroup/positive/");
Assert.assertNotNull(messages);
Assert.assertEquals(messages.size(), 0);
- messages = ValidationTestUtil.testValidator(validator,
+ messages = new ValidationTestUtil().testValidator(validator,
RESOURCE_PATH + "/baseHeatDoesNotExposeServerGroup/negative/");
Assert.assertNotNull(messages);
Assert.assertEquals(messages.size(), 1);
@@ -108,12 +108,12 @@ public class SharedResourceGuideLineValidatorTest {
@Test
public void testBaseHeatExposeSecurityGroup() {
- Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(validator,
+ Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(validator,
RESOURCE_PATH + "/baseHeatDoesNotExposeSecurityGroup/positive/");
Assert.assertNotNull(messages);
Assert.assertEquals(messages.size(), 0);
- messages = ValidationTestUtil.testValidator(validator,
+ messages = new ValidationTestUtil().testValidator(validator,
RESOURCE_PATH + "/baseHeatDoesNotExposeSecurityGroup/negative/");
Assert.assertNotNull(messages);
Assert.assertEquals(messages.size(), 1);
@@ -124,12 +124,12 @@ public class SharedResourceGuideLineValidatorTest {
@Test
public void testBaseHeatExposeVolume() {
- Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(validator,
+ Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(validator,
RESOURCE_PATH + "/baseHeatDoesNotExposeVolume/positive/");
Assert.assertNotNull(messages);
Assert.assertEquals(messages.size(), 0);
- messages = ValidationTestUtil.testValidator(validator,
+ messages = new ValidationTestUtil().testValidator(validator,
RESOURCE_PATH + "/baseHeatDoesNotExposeVolume/negative/");
Assert.assertNotNull(messages);
Assert.assertEquals(messages.size(), 1);
@@ -140,12 +140,12 @@ public class SharedResourceGuideLineValidatorTest {
@Test
public void testHeatVolumeExpose() {
- Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(validator,
+ Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(validator,
RESOURCE_PATH + "/heatVolumeExpose/positive/");
Assert.assertNotNull(messages);
Assert.assertEquals(messages.size(), 0);
- messages = ValidationTestUtil.testValidator(validator,
+ messages = new ValidationTestUtil().testValidator(validator,
RESOURCE_PATH + "/heatVolumeExpose/negative/");
Assert.assertNotNull(messages);
Assert.assertEquals(messages.size(), 1);
@@ -157,13 +157,13 @@ public class SharedResourceGuideLineValidatorTest {
@Test
public void testResourceIsExposedByCallingGetResourceNotFromOutput() {
- Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(validator,
+ Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(validator,
RESOURCE_PATH + "/baseHeatExposeResourceUsingGetResource/positive");
Assert.assertNotNull(messages);
Assert.assertEquals(messages.size(), 0);
- messages = ValidationTestUtil.testValidator(validator,
+ messages = new ValidationTestUtil().testValidator(validator,
RESOURCE_PATH + "/baseHeatExposeResourceUsingGetResource/negative");
Assert.assertNotNull(messages);
Assert.assertEquals(messages.size(), 1);
@@ -174,7 +174,7 @@ public class SharedResourceGuideLineValidatorTest {
@Test
public void testMissingBaseHeat() {
- Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(validator,
+ Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(validator,
RESOURCE_PATH + "/missingBaseHeat/");
Assert.assertNotNull(messages);
Assert.assertEquals(messages.size(), 1);
@@ -185,7 +185,7 @@ public class SharedResourceGuideLineValidatorTest {
@Test
public void testMultiBaseHeat() {
- Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(validator,
+ Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(validator,
RESOURCE_PATH + "/multiBaseHeat/");
Assert.assertNotNull(messages);
Assert.assertEquals(messages.size(), 1);
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/YamlValidatorTest.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/YamlValidatorTest.java
index 637510abba..77e2f2a837 100644
--- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/YamlValidatorTest.java
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/YamlValidatorTest.java
@@ -7,9 +7,9 @@
* 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.
@@ -31,82 +31,67 @@ import org.openecomp.sdc.validation.util.ValidationTestUtil;
public class YamlValidatorTest {
- private static final String RESOURCE_PATH = "/org/openecomp/validation/validators/yaml_validator";
-
- public Map<String, MessageContainer> runValidation(String path) {
- YamlValidator validator = new YamlValidator();
- return ValidationTestUtil.testValidator(validator, path);
-
- }
-
- @Test
- public void testValidYaml() {
-
- Map<String, MessageContainer> messages = runValidation(
- RESOURCE_PATH + "/valid_yaml/input/validHeat.yaml");
- Assert.assertNotNull(messages);
- Assert.assertEquals(messages.size(), 0);
- }
-
- @Test
- public void testInvalidTabYaml() {
-
- Map<String, MessageContainer> messages = runValidation(
- RESOURCE_PATH + "/invalid_valid_yaml_structure/input/invalidYamlTab.yaml");
- Assert.assertNotNull(messages);
- Assert.assertEquals(messages.size(), 1);
- ValidationTestUtil.validateErrorMessage(
- messages.get("invalidYamlTab.yaml").getErrorMessageList().get(0).getMessage(),
- "ERROR: " +"[YML2]: "+ Messages.INVALID_YAML_FORMAT_REASON.getErrorMessage(),
- "while scanning for the next tokenfound character '\\t(TAB)' that cannot start " +
- "any token. (Do not use \\t(TAB) for indentation) in 'reader', line 14, " +
- "column 5: \tadmin_state_up: true ^");
- }
-
- @Test
- public void testDuplicateKeyInYaml() {
-
- Map<String, MessageContainer> messages =
- runValidation(RESOURCE_PATH + "/duplicateKey.yaml");
- Assert.assertNotNull(messages);
- Assert.assertEquals(messages.size(), 1);
- Assert.assertTrue(messages.containsKey("duplicateKey.yaml"));
- ValidationTestUtil.validateErrorMessage(
- messages.get("duplicateKey.yaml").getErrorMessageList().get(0).getMessage(),
- "ERROR: " +"[YML2]: "+ Messages.INVALID_YAML_FORMAT_REASON.getErrorMessage(),
- "while parsing MappingNode in 'reader', line 6, column 3: " +
- "Key_1_unique: ^duplicate key: Key_2_not_unique in 'reader', line 31, " +
- "column 1: ^");
- }
-
- @Test
- public void testInvalidYamlStructure() {
-
- Map<String, MessageContainer> messages = runValidation(
- RESOURCE_PATH + "/invalidYamlStructure.yaml");
- Assert.assertNotNull(messages);
- Assert.assertEquals(messages.size(), 1);
- Assert.assertTrue(messages.containsKey("invalidYamlStructure.yaml"));
- ValidationTestUtil.validateErrorMessage(
- messages.get("invalidYamlStructure.yaml").getErrorMessageList().get(0).getMessage(),
- "ERROR: " +"[YML2]: "+ Messages.INVALID_YAML_FORMAT_REASON.getErrorMessage(),
- "while parsing a block mapping in 'reader', line 8, column 7: " +
- "admin_state_up: true ^expected <block end>, but found BlockEntry in 'reader', " +
- "line 10, column 7: - shared: true ^");
- }
-
- @Test
- public void testEmptyYaml() {
-
- Map<String, MessageContainer> messages =
- runValidation(RESOURCE_PATH + "/emptyYaml.yaml");
- Assert.assertNotNull(messages);
- Assert.assertEquals(messages.size(), 1);
- Assert.assertTrue(messages.containsKey("emptyYaml.yaml"));
- ValidationTestUtil.validateErrorMessage(messages.get("emptyYaml.yaml").getErrorMessageList()
- .get(0).getMessage(),
- "ERROR: " +"[YML1]: "+ Messages.INVALID_YAML_FORMAT_REASON.getErrorMessage(),
- Messages.EMPTY_YAML_FILE.getErrorMessage());
- }
+ private static final String RESOURCE_PATH = "/org/openecomp/validation/validators/yaml_validator";
+
+ public Map<String, MessageContainer> runValidation(String path) {
+ return new ValidationTestUtil().testValidator(new YamlValidator(), path);
+ }
+
+ @Test
+ public void testValidYaml() {
+ Map<String, MessageContainer> messages = runValidation(RESOURCE_PATH + "/valid_yaml/input/validHeat.yaml");
+ Assert.assertNotNull(messages);
+ Assert.assertEquals(0, messages.size());
+ }
+
+ @Test
+ public void testInvalidTabYaml() {
+
+ Map<String, MessageContainer> messages = runValidation(
+ RESOURCE_PATH + "/invalid_valid_yaml_structure/input/invalidYamlTab.yaml");
+ Assert.assertNotNull(messages);
+ Assert.assertEquals(1, messages.size());
+ new ValidationTestUtil().validateErrorMessage(
+ messages.get("invalidYamlTab.yaml").getErrorMessageList().get(0).getMessage(),
+ "ERROR: " + "[YML2]: " + Messages.INVALID_YAML_FORMAT_REASON.getErrorMessage(),
+ "while scanning for the next tokenfound character '\\t(TAB)' that cannot start " +
+ "any token. (Do not use \\t(TAB) for indentation) in 'reader', line 14, " +
+ "column 5: \tadmin_state_up: true ^");
+ }
+
+ @Test
+ public void testDuplicateKeyInYaml() {
+ Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(new YamlValidator(), RESOURCE_PATH + "/duplicateKey.yaml");
+ Assert.assertNotNull(messages);
+ Assert.assertEquals(1, messages.size());
+ Assert.assertTrue(messages.containsKey("duplicateKey.yaml"));
+ Assert.assertTrue(messages.get("duplicateKey.yaml").getErrorMessageList().get(0).getMessage().contains("Key_2_not_unique"));
+ }
+
+ @Test
+ public void testInvalidYamlStructure() {
+ Map<String, MessageContainer> messages = runValidation(RESOURCE_PATH + "/invalidYamlStructure.yaml");
+ Assert.assertNotNull(messages);
+ Assert.assertEquals(1, messages.size());
+ Assert.assertTrue(messages.containsKey("invalidYamlStructure.yaml"));
+ new ValidationTestUtil().validateErrorMessage(
+ messages.get("invalidYamlStructure.yaml").getErrorMessageList().get(0).getMessage(),
+ "ERROR: " + "[YML2]: " + Messages.INVALID_YAML_FORMAT_REASON.getErrorMessage(),
+ "while parsing a block mapping in 'reader', line 8, column 7: " +
+ "admin_state_up: true ^expected <block end>, but found '-' in 'reader', " +
+ "line 10, column 7: - shared: true ^");
+ }
+
+ @Test
+ public void testEmptyYaml() {
+ Map<String, MessageContainer> messages = runValidation(RESOURCE_PATH + "/emptyYaml.yaml");
+ Assert.assertNotNull(messages);
+ Assert.assertEquals(1, messages.size());
+ Assert.assertTrue(messages.containsKey("emptyYaml.yaml"));
+ new ValidationTestUtil().validateErrorMessage(messages.get("emptyYaml.yaml").getErrorMessageList()
+ .get(0).getMessage(),
+ "ERROR: " + "[YML1]: " + Messages.INVALID_YAML_FORMAT_REASON.getErrorMessage(),
+ Messages.EMPTY_YAML_FILE.getErrorMessage());
+ }
}
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/heatresource/ContrailNetworkPolicyResourceValidatorTest.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/heatresource/ContrailNetworkPolicyResourceValidatorTest.java
index 43041140a3..707848f1bd 100644
--- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/heatresource/ContrailNetworkPolicyResourceValidatorTest.java
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/heatresource/ContrailNetworkPolicyResourceValidatorTest.java
@@ -37,7 +37,7 @@ public class ContrailNetworkPolicyResourceValidatorTest {
private static final String PATH = "/org/openecomp/validation/validators/heat_validator/network_policy_associated_with_attach_policy/";
@Test
public void testNetworkPolicyAssociatedWithAttachPolicy() throws IOException {
- Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator, resourceValidator
+ Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(baseValidator, resourceValidator
, HeatResourcesTypes.CONTRAIL_NETWORK_RULE_RESOURCE_TYPE.getHeatResource(),
PATH + "positive");
@@ -52,7 +52,7 @@ public class ContrailNetworkPolicyResourceValidatorTest {
@Test
public void testNonNetworkPolicyResource() throws IOException {
- Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator, resourceValidator
+ Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(baseValidator, resourceValidator
, HeatResourcesTypes.CONTRAIL_VIRTUAL_NETWORK_RESOURCE_TYPE.getHeatResource(),
PATH + "negative");
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/heatresource/NestedResourceValidatorTest.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/heatresource/NestedResourceValidatorTest.java
index b864a2d557..d8cecc9ca1 100644
--- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/heatresource/NestedResourceValidatorTest.java
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/heatresource/NestedResourceValidatorTest.java
@@ -38,7 +38,7 @@ public class NestedResourceValidatorTest {
@Test
public void testNoLoopsNesting() {
- Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator,
+ Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(baseValidator,
resourceValidator, null,
PATH + "no_loops_nesting/negative_test/input");
@@ -74,7 +74,7 @@ public class NestedResourceValidatorTest {
@Test
public void testPropertiesMatchNestedParameters() {
- Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator,
+ Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(baseValidator,
resourceValidator, null,
PATH + "properties_match_nested_parameters/negative_test/input");
@@ -89,7 +89,7 @@ public class NestedResourceValidatorTest {
@Test
public void testWrongValueTypeAssigned() {
- Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator,
+ Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(baseValidator,
resourceValidator, null,
PATH + "properties_match_nested_parameters/wrong_value_type_assigned/input");
@@ -107,7 +107,7 @@ public class NestedResourceValidatorTest {
final Resource resource = new Resource();
resource.setType("nested-pps_v1.0.yaml");
- final GlobalValidationContext globalValidationContext = ValidationTestUtil.createGlobalContextFromPath(PATH + "missing_nested_file/input");
+ final GlobalValidationContext globalValidationContext = new ValidationTestUtil().createGlobalContextFromPath(PATH + "missing_nested_file/input");
NestedResourceValidator.validateAllPropertiesMatchNestedParameters(null, null, resource, Optional.empty(), globalValidationContext);
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/heatresource/NeutronPortResourceValidatorTest.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/heatresource/NeutronPortResourceValidatorTest.java
index 10c70b64d4..0e02a1d6ee 100644
--- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/heatresource/NeutronPortResourceValidatorTest.java
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/heatresource/NeutronPortResourceValidatorTest.java
@@ -36,7 +36,7 @@ public class NeutronPortResourceValidatorTest {
private static final String PATH = "/org/openecomp/validation/validators/heat_validator/";
@Test
public void testMoreThanOneBindFromNovaToPort() throws IOException {
- Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator,
+ Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(baseValidator,
resourceValidator, HeatResourcesTypes.NEUTRON_PORT_RESOURCE_TYPE.getHeatResource(),
PATH + "one_nova_points_to_one_port/negative_test/input");
@@ -51,7 +51,7 @@ public class NeutronPortResourceValidatorTest {
@Test
public void testPortNotBindToAnyNovaServerHPR1() throws IOException {
- Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator,
+ Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(baseValidator,
resourceValidator, HeatResourcesTypes.NOVA_SERVER_RESOURCE_TYPE.getHeatResource(),
PATH + "no_neutron_port/input");
@@ -66,7 +66,7 @@ public class NeutronPortResourceValidatorTest {
@Test
public void testPortNotBindToAnyNovaServerHPR3() throws IOException {
- Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator,
+ Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(baseValidator,
resourceValidator, HeatResourcesTypes.NOVA_SERVER_RESOURCE_TYPE.getHeatResource(),
PATH + "port_no_bind_to_any_nova_server/input");
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/heatresource/NeutronSecurityGroupResourceValidatorTest.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/heatresource/NeutronSecurityGroupResourceValidatorTest.java
index fabc833106..10de81350d 100644
--- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/heatresource/NeutronSecurityGroupResourceValidatorTest.java
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/heatresource/NeutronSecurityGroupResourceValidatorTest.java
@@ -37,7 +37,7 @@ public class NeutronSecurityGroupResourceValidatorTest {
@Test
public void testSecurityGroupBaseFileNoPorts() throws IOException {
- Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator,
+ Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(baseValidator,
resourceValidator,
HeatResourcesTypes.NEUTRON_SECURITY_GROUP_RESOURCE_TYPE.getHeatResource(),
PATH + "security_group_base_file_no_ports/input");
@@ -52,7 +52,7 @@ public class NeutronSecurityGroupResourceValidatorTest {
@Test
public void testSecurityGroupsCalledByPort() throws IOException {
- Map<String, MessageContainer> messages =ValidationTestUtil.testValidator(baseValidator,
+ Map<String, MessageContainer> messages =new ValidationTestUtil().testValidator(baseValidator,
resourceValidator,
HeatResourcesTypes.NEUTRON_SECURITY_GROUP_RESOURCE_TYPE.getHeatResource(),
PATH + "security_group_called_by_port/input");
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/heatresource/NovaServerGroupResourceValidatorTest.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/heatresource/NovaServerGroupResourceValidatorTest.java
index e9c70b0251..b22dd4df4a 100644
--- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/heatresource/NovaServerGroupResourceValidatorTest.java
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/heatresource/NovaServerGroupResourceValidatorTest.java
@@ -35,7 +35,7 @@ public class NovaServerGroupResourceValidatorTest {
private static final String PATH = "/org/openecomp/validation/validators/heat_validator/";
@Test
public void testPolicyIsAffinityOrAntiAffinity() throws IOException {
- Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator,
+ Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(baseValidator,
resourceValidator, HeatResourcesTypes.NOVA_SERVER_GROUP_RESOURCE_TYPE.getHeatResource(),
PATH + "policy_is_affinity_or_anti_affinity/negative_test/input");
@@ -50,7 +50,7 @@ public class NovaServerGroupResourceValidatorTest {
@Test
public void testServerGroupCalledByServer() throws IOException {
- Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator,
+ Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(baseValidator,
resourceValidator, HeatResourcesTypes.NOVA_SERVER_GROUP_RESOURCE_TYPE.getHeatResource(),
PATH + "server_group_called_by_nova_server/input");
@@ -66,7 +66,7 @@ public class NovaServerGroupResourceValidatorTest {
@Test
public void testNonServerGroup() throws IOException {
- Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator,
+ Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(baseValidator,
resourceValidator, HeatResourcesTypes.NOVA_SERVER_RESOURCE_TYPE.getHeatResource(),
PATH + "server_group_called_by_nova_server_negative/input");
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/heatresource/NovaServerResourceValidatorTest.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/heatresource/NovaServerResourceValidatorTest.java
index 63523329cc..d56a5eaf2b 100644
--- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/heatresource/NovaServerResourceValidatorTest.java
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/heatresource/NovaServerResourceValidatorTest.java
@@ -35,7 +35,7 @@ public class NovaServerResourceValidatorTest {
private static final String PATH = "/org/openecomp/validation/validators/heat_validator/";
@Test
public void testNovaPropertiesHasAssignedValue() throws IOException {
- Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator,
+ Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(baseValidator,
resourceValidator, HeatResourcesTypes.NOVA_SERVER_RESOURCE_TYPE.getHeatResource(),
PATH + "nova_properties_has_assigned_value/negative_test/input");
@@ -50,7 +50,7 @@ public class NovaServerResourceValidatorTest {
@Test
public void testServerGroupsPointedByServersDefinedCorrectly() throws IOException {
- Map<String, MessageContainer> messages =ValidationTestUtil.testValidator(baseValidator,
+ Map<String, MessageContainer> messages =new ValidationTestUtil().testValidator(baseValidator,
resourceValidator, HeatResourcesTypes.NOVA_SERVER_RESOURCE_TYPE.getHeatResource(),
PATH + "server_groups_defined_correctly/negative_test/input");
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/heatresource/ResourceGroupResourceValidatorTest.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/heatresource/ResourceGroupResourceValidatorTest.java
index 07cfaf7481..b80788a9c3 100644
--- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/heatresource/ResourceGroupResourceValidatorTest.java
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/heatresource/ResourceGroupResourceValidatorTest.java
@@ -35,7 +35,7 @@ public class ResourceGroupResourceValidatorTest {
private static final String PATH = "/org/openecomp/validation/validators/heat_validator/";
@Test
public void testResourceGroupWithInvalidIndexVar() {
- Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator,
+ Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(baseValidator,
resourceValidator, HeatResourcesTypes.RESOURCE_GROUP_RESOURCE_TYPE.getHeatResource(),
PATH + "resource_group_invalid_indexvar/negative_test/input");
@@ -89,7 +89,7 @@ public class ResourceGroupResourceValidatorTest {
@Test
public void testResourceGroupWithInvalidType() {
- Map<String, MessageContainer> messages =ValidationTestUtil.testValidator(baseValidator,
+ Map<String, MessageContainer> messages =new ValidationTestUtil().testValidator(baseValidator,
resourceValidator, HeatResourcesTypes.RESOURCE_GROUP_RESOURCE_TYPE.getHeatResource(),
PATH + "resource_group_invalid_type/negative_test/input");
@@ -110,7 +110,7 @@ public class ResourceGroupResourceValidatorTest {
@Test
public void testResourcesGroupWithNested() {
- Map<String, MessageContainer> messages =ValidationTestUtil.testValidator(baseValidator,
+ Map<String, MessageContainer> messages =new ValidationTestUtil().testValidator(baseValidator,
resourceValidator, HeatResourcesTypes.RESOURCE_GROUP_RESOURCE_TYPE.getHeatResource(),
PATH + "resources_group_with_nested/negative_test/input");
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/heatresource/VirtualMachineInterfaceValidatorTest.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/heatresource/VirtualMachineInterfaceValidatorTest.java
index 9fcef284a9..4a8e7970b5 100644
--- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/heatresource/VirtualMachineInterfaceValidatorTest.java
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/heatresource/VirtualMachineInterfaceValidatorTest.java
@@ -17,6 +17,7 @@
package org.openecomp.sdc.validation.impl.validators.heatresource;
import java.util.Map;
+
import org.junit.Assert;
import org.junit.Test;
import org.openecomp.core.validation.types.MessageContainer;
@@ -30,128 +31,121 @@ import org.openecomp.sdc.validation.util.ValidationTestUtil;
*/
public class VirtualMachineInterfaceValidatorTest {
- private static final String PATH =
- "/org/openecomp/validation/validators/heat_validator/vlan_resource_validation/";
-
-
- @Test
- public void hasSingleParentPortNegative() {
- HeatResourceValidator baseValidator = new HeatResourceValidator();
- VirtualMachineInterfaceValidator resourceValidator = new VirtualMachineInterfaceValidator();
- Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator,
- resourceValidator,
- HeatResourcesTypes.CONTRAIL_V2_VIRTUAL_MACHINE_INTERFACE_RESOURCE_TYPE.getHeatResource(),
- PATH + "vlan_multiple_parent_ports/negative_test/input");
-
- Assert.assertNotNull(messages);
- Assert.assertEquals(messages.size(), 1);
-
- Assert.assertEquals(messages.get("nested.yml").getErrorMessageList().size(), 1);
- Assert.assertEquals(
- messages.get("nested.yml").getErrorMessageList().get(0).getMessage(),
- "ERROR: [VLAN1]: More than one parent port found, " +
- "there should be only one parent port for a VLAN sub-interface ID [template_Vlan_2]");
- }
-
- @Test
- public void hasSingleParentPortNegativeWithGetResource() {
- HeatResourceValidator baseValidator = new HeatResourceValidator();
- VirtualMachineInterfaceValidator resourceValidator = new VirtualMachineInterfaceValidator();
- Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator,
- resourceValidator,
- HeatResourcesTypes.CONTRAIL_V2_VIRTUAL_MACHINE_INTERFACE_RESOURCE_TYPE.getHeatResource(),
- PATH + "vlan_multiple_parent_ports/negative_get_resource/input");
-
- Assert.assertNotNull(messages);
- Assert.assertEquals(messages.size(), 0);
- }
-
-
- @Test
- public void hasSingleParentPortPositive() {
- HeatResourceValidator baseValidator = new HeatResourceValidator();
- VirtualMachineInterfaceValidator resourceValidator = new VirtualMachineInterfaceValidator();
- Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator,
- resourceValidator,
- HeatResourcesTypes.CONTRAIL_V2_VIRTUAL_MACHINE_INTERFACE_RESOURCE_TYPE.getHeatResource(),
- PATH + "vlan_multiple_parent_ports/positive_test/input");
-
- Assert.assertNotNull(messages);
- Assert.assertEquals(messages.size(), 0);
-
-
- }
-
-
- @Test
- public void hasBothPropertiesNegativeMissingVlanTag() {
- HeatResourceValidator baseValidator = new HeatResourceValidator();
- VirtualMachineInterfaceValidator resourceValidator = new VirtualMachineInterfaceValidator();
- Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator,
- resourceValidator,
- HeatResourcesTypes.CONTRAIL_V2_VIRTUAL_MACHINE_INTERFACE_RESOURCE_TYPE.getHeatResource(),
- PATH + "vlan_has_two_properties/negative_tag_missing/input");
-
- Assert.assertNotNull(messages);
- Assert.assertEquals(messages.size(), 1);
-
- Assert.assertEquals(messages.get("nested.yml").getErrorMessageList().size(), 1);
- Assert.assertEquals(
- messages.get("nested.yml").getErrorMessageList().get(0).getMessage(),
- "WARNING: [VLAN2]: VLAN Tag property " +
- "virtual_machine_interface_properties_sub_interface_vlan_tag " +
- "is missing in VLAN Resource ID [template_Vlan_2]");
- }
-
- @Test
- public void hasBothPropertiesNegativeMissingRefs() {
- HeatResourceValidator baseValidator = new HeatResourceValidator();
- VirtualMachineInterfaceValidator resourceValidator = new VirtualMachineInterfaceValidator();
- Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator,
- resourceValidator,
- HeatResourcesTypes.CONTRAIL_V2_VIRTUAL_MACHINE_INTERFACE_RESOURCE_TYPE.getHeatResource(),
- PATH + "vlan_has_two_properties/negative_refs_missing/input");
-
- Assert.assertNotNull(messages);
- Assert.assertEquals(messages.size(), 1);
-
- Assert.assertEquals(messages.get("nested.yml").getErrorMessageList().size(), 1);
- Assert.assertEquals(
- messages.get("nested.yml").getErrorMessageList().get(0).getMessage(),
- "WARNING: [VLAN2]: Parent port property virtual_machine_interface_refs is " +
- "missing in VLAN Resource ID [template_Vlan_2]");
- }
-
- @Test
- public void hasBothPropertiesBothMissingWhichMeansPositive() {
- HeatResourceValidator baseValidator = new HeatResourceValidator();
- VirtualMachineInterfaceValidator resourceValidator = new VirtualMachineInterfaceValidator();
- Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator,
- resourceValidator,
- HeatResourcesTypes.CONTRAIL_V2_VIRTUAL_MACHINE_INTERFACE_RESOURCE_TYPE.getHeatResource(),
- PATH + "vlan_has_two_properties/negative_both_missing/input");
-
- Assert.assertNotNull(messages);
- Assert.assertEquals(messages.size(), 0);
-
- }
-
-
- @Test
- public void hasBothPropertiesPositive() {
- HeatResourceValidator baseValidator = new HeatResourceValidator();
- VirtualMachineInterfaceValidator resourceValidator = new VirtualMachineInterfaceValidator();
- Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator,
- resourceValidator,
- HeatResourcesTypes.CONTRAIL_V2_VIRTUAL_MACHINE_INTERFACE_RESOURCE_TYPE.getHeatResource(),
- PATH + "vlan_has_two_properties/positive_test/input");
-
- Assert.assertNotNull(messages);
- Assert.assertEquals(messages.size(), 0);
-
-
- }
-
-
-
+ private static final String PATH =
+ "/org/openecomp/validation/validators/heat_validator/vlan_resource_validation/";
+
+
+ @Test
+ public void hasSingleParentPortNegative() {
+ HeatResourceValidator baseValidator = new HeatResourceValidator();
+ VirtualMachineInterfaceValidator resourceValidator = new VirtualMachineInterfaceValidator();
+ Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(baseValidator,
+ resourceValidator,
+ HeatResourcesTypes.CONTRAIL_V2_VIRTUAL_MACHINE_INTERFACE_RESOURCE_TYPE.getHeatResource(),
+ PATH + "vlan_multiple_parent_ports/negative_test/input");
+
+ Assert.assertNotNull(messages);
+ Assert.assertEquals(1, messages.size());
+
+ Assert.assertEquals(1, messages.get("nested.yml").getErrorMessageList().size());
+ Assert.assertEquals(
+ messages.get("nested.yml").getErrorMessageList().get(0).getMessage(),
+ "ERROR: [VLAN1]: More than one parent port found, " +
+ "there should be only one parent port for a VLAN sub-interface ID [template_Vlan_2]");
+ }
+
+ @Test
+ public void hasSingleParentPortNegativeWithGetResource() {
+ HeatResourceValidator baseValidator = new HeatResourceValidator();
+ VirtualMachineInterfaceValidator resourceValidator = new VirtualMachineInterfaceValidator();
+ Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(baseValidator,
+ resourceValidator,
+ HeatResourcesTypes.CONTRAIL_V2_VIRTUAL_MACHINE_INTERFACE_RESOURCE_TYPE.getHeatResource(),
+ PATH + "vlan_multiple_parent_ports/negative_get_resource/input");
+
+ Assert.assertNotNull(messages);
+ Assert.assertEquals(messages.size(), 0);
+ }
+
+
+ @Test
+ public void hasSingleParentPortPositive() {
+ HeatResourceValidator baseValidator = new HeatResourceValidator();
+ VirtualMachineInterfaceValidator resourceValidator = new VirtualMachineInterfaceValidator();
+ Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(baseValidator,
+ resourceValidator,
+ HeatResourcesTypes.CONTRAIL_V2_VIRTUAL_MACHINE_INTERFACE_RESOURCE_TYPE.getHeatResource(),
+ PATH + "vlan_multiple_parent_ports/positive_test/input");
+
+ Assert.assertNotNull(messages);
+ Assert.assertEquals(0, messages.size());
+ }
+
+
+ @Test
+ public void hasBothPropertiesNegativeMissingVlanTag() {
+ HeatResourceValidator baseValidator = new HeatResourceValidator();
+ VirtualMachineInterfaceValidator resourceValidator = new VirtualMachineInterfaceValidator();
+ Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(baseValidator,
+ resourceValidator,
+ HeatResourcesTypes.CONTRAIL_V2_VIRTUAL_MACHINE_INTERFACE_RESOURCE_TYPE.getHeatResource(),
+ PATH + "vlan_has_two_properties/negative_tag_missing/input");
+
+ Assert.assertNotNull(messages);
+ Assert.assertEquals(messages.size(), 1);
+
+ Assert.assertEquals(messages.get("nested.yml").getErrorMessageList().size(), 1);
+ Assert.assertEquals(
+ messages.get("nested.yml").getErrorMessageList().get(0).getMessage(),
+ "WARNING: [VLAN2]: VLAN Tag property " +
+ "virtual_machine_interface_properties_sub_interface_vlan_tag " +
+ "is missing in VLAN Resource ID [template_Vlan_2]");
+ }
+
+ @Test
+ public void hasBothPropertiesNegativeMissingRefs() {
+ HeatResourceValidator baseValidator = new HeatResourceValidator();
+ VirtualMachineInterfaceValidator resourceValidator = new VirtualMachineInterfaceValidator();
+ Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(baseValidator,
+ resourceValidator,
+ HeatResourcesTypes.CONTRAIL_V2_VIRTUAL_MACHINE_INTERFACE_RESOURCE_TYPE.getHeatResource(),
+ PATH + "vlan_has_two_properties/negative_refs_missing/input");
+
+ Assert.assertNotNull(messages);
+ Assert.assertEquals(messages.size(), 1);
+
+ Assert.assertEquals(messages.get("nested.yml").getErrorMessageList().size(), 1);
+ Assert.assertEquals(
+ messages.get("nested.yml").getErrorMessageList().get(0).getMessage(),
+ "WARNING: [VLAN2]: Parent port property virtual_machine_interface_refs is " +
+ "missing in VLAN Resource ID [template_Vlan_2]");
+ }
+
+ @Test
+ public void hasBothPropertiesBothMissingWhichMeansPositive() {
+ HeatResourceValidator baseValidator = new HeatResourceValidator();
+ VirtualMachineInterfaceValidator resourceValidator = new VirtualMachineInterfaceValidator();
+ Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(baseValidator,
+ resourceValidator,
+ HeatResourcesTypes.CONTRAIL_V2_VIRTUAL_MACHINE_INTERFACE_RESOURCE_TYPE.getHeatResource(),
+ PATH + "vlan_has_two_properties/negative_both_missing/input");
+
+ Assert.assertNotNull(messages);
+ Assert.assertEquals(messages.size(), 0);
+
+ }
+
+
+ @Test
+ public void hasBothPropertiesPositive() {
+ HeatResourceValidator baseValidator = new HeatResourceValidator();
+ VirtualMachineInterfaceValidator resourceValidator = new VirtualMachineInterfaceValidator();
+ Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(baseValidator,
+ resourceValidator,
+ HeatResourcesTypes.CONTRAIL_V2_VIRTUAL_MACHINE_INTERFACE_RESOURCE_TYPE.getHeatResource(),
+ PATH + "vlan_has_two_properties/positive_test/input");
+
+ Assert.assertNotNull(messages);
+ Assert.assertEquals(messages.size(), 0);
+ }
} \ No newline at end of file
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/namingconvention/ContrailServiceInstanceNamingConventionValidatorTest.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/namingconvention/ContrailServiceInstanceNamingConventionValidatorTest.java
index d61d71839a..dd74f98ed6 100644
--- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/namingconvention/ContrailServiceInstanceNamingConventionValidatorTest.java
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/namingconvention/ContrailServiceInstanceNamingConventionValidatorTest.java
@@ -36,7 +36,7 @@ public class ContrailServiceInstanceNamingConventionValidatorTest {
@Test
public void testContrailServiceInstanceAvailabilityZoneNotAlignedWithNamingConvention() {
- Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator,
+ Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(baseValidator,
resourceValidator, HeatResourcesTypes.CONTRAIL_SERVICE_INSTANCE.getHeatResource(),
PATH + "notaligned");
Assert.assertNotNull(messages);
@@ -48,7 +48,7 @@ public class ContrailServiceInstanceNamingConventionValidatorTest {
@Test
public void testContrailServiceInstanceAvailabilityZoneAlignedWithNamingConvention() {
- Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator,
+ Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(baseValidator,
resourceValidator, HeatResourcesTypes.CONTRAIL_SERVICE_INSTANCE.getHeatResource(),
PATH + "aligned");
Assert.assertNotNull(messages);
@@ -56,7 +56,7 @@ public class ContrailServiceInstanceNamingConventionValidatorTest {
}
@Test
public void testContrailServiceInstanceAvailabilityZoneNotAlignedWithNamingConventionMissingParam() {
- Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator,
+ Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(baseValidator,
resourceValidator, HeatResourcesTypes.CONTRAIL_SERVICE_INSTANCE.getHeatResource(),
PATH + "missingparam");
Assert.assertNotNull(messages);
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/namingconvention/ContrailServiceTemplateNamingConventionValidatorTest.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/namingconvention/ContrailServiceTemplateNamingConventionValidatorTest.java
index f9e0765158..f04778c1b0 100644
--- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/namingconvention/ContrailServiceTemplateNamingConventionValidatorTest.java
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/namingconvention/ContrailServiceTemplateNamingConventionValidatorTest.java
@@ -36,7 +36,7 @@ public class ContrailServiceTemplateNamingConventionValidatorTest {
@Test
public void testContrailServiceTemplateImageAndFlavorNamesAlignedWithNamingConventionButDifferentVmType() {
- Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator,
+ Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(baseValidator,
resourceValidator, HeatResourcesTypes.CONTRAIL_SERVICE_TEMPLATE.getHeatResource(),
PATH + "imageandflavordifferentvmtype");
Assert.assertNotNull(messages);
@@ -49,7 +49,7 @@ public class ContrailServiceTemplateNamingConventionValidatorTest {
@Test
public void testContrailServiceTemplateImageAndFlavorNamesNotAlignedWithNamingConvention() {
- Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator,
+ Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(baseValidator,
resourceValidator, HeatResourcesTypes.CONTRAIL_SERVICE_TEMPLATE.getHeatResource(),
PATH + "/notaligned");
Assert.assertNotNull(messages);
@@ -63,7 +63,7 @@ public class ContrailServiceTemplateNamingConventionValidatorTest {
@Test
public void testContrailServiceTemplateImageAndFlavorNamesAlignedWithNamingConvention() {
- Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator,
+ Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(baseValidator,
resourceValidator, HeatResourcesTypes.CONTRAIL_SERVICE_TEMPLATE.getHeatResource(),
PATH + "aligned");
Assert.assertNotNull(messages);
@@ -72,7 +72,7 @@ public class ContrailServiceTemplateNamingConventionValidatorTest {
@Test
public void testContrailServiceTemplateMissingParam() {
- Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator,
+ Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(baseValidator,
resourceValidator, HeatResourcesTypes.CONTRAIL_SERVICE_TEMPLATE.getHeatResource(),
PATH + "missingparam");
Assert.assertNotNull(messages);
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/namingconvention/NeutronPortNamingConventionValidatorTest.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/namingconvention/NeutronPortNamingConventionValidatorTest.java
index 00f95ef383..8dad17bcd1 100644
--- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/namingconvention/NeutronPortNamingConventionValidatorTest.java
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/namingconvention/NeutronPortNamingConventionValidatorTest.java
@@ -30,18 +30,17 @@ import org.openecomp.sdc.validation.util.ValidationTestUtil;
public class NeutronPortNamingConventionValidatorTest {
NamingConventionGuideLineValidator baseValidator = new NamingConventionGuideLineValidator();
- NeutronPortNamingConventionValidator resourceValidator = new
- NeutronPortNamingConventionValidator();
- private static final String PATH = "/org/openecomp/validation/validators/guideLineValidator/heatPortNetworkNamingConvention/";
+ NeutronPortNamingConventionValidator resourceValidator = new NeutronPortNamingConventionValidator();
+ private static final String PATH = "/org/openecomp/validation/validators/guideLineValidator/heatPortNetworkNamingConvention/";
@Test
public void testHeatPortNetworkNamingConvention() {
- Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator,
+ Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(baseValidator,
resourceValidator, HeatResourcesTypes.NEUTRON_PORT_RESOURCE_TYPE.getHeatResource(),
PATH + "positive/");
Assert.assertNotNull(messages);
Assert.assertEquals(messages.size(), 0);
- messages = ValidationTestUtil.testValidator(baseValidator,
+ messages = new ValidationTestUtil().testValidator(baseValidator,
resourceValidator, HeatResourcesTypes.NEUTRON_PORT_RESOURCE_TYPE.getHeatResource(),
PATH + "negative/");
Assert.assertNotNull(messages);
@@ -53,13 +52,13 @@ public class NeutronPortNamingConventionValidatorTest {
@Test
public void testNeutronFixedIpName() {
- Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator,
+ Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(baseValidator,
resourceValidator, HeatResourcesTypes.NEUTRON_PORT_RESOURCE_TYPE.getHeatResource(),
PATH + "positiveFixedIP");
Assert.assertNotNull(messages);
Assert.assertEquals(messages.size(), 0);
- messages = ValidationTestUtil.testValidator(baseValidator,
+ messages = new ValidationTestUtil().testValidator(baseValidator,
resourceValidator, HeatResourcesTypes.NEUTRON_PORT_RESOURCE_TYPE.getHeatResource(),
PATH + "negativeFixedIP/");
Assert.assertNotNull(messages);
@@ -76,13 +75,13 @@ public class NeutronPortNamingConventionValidatorTest {
@Test
public void testMissingParam() {
- Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator,
- resourceValidator, HeatResourcesTypes.NEUTRON_PORT_RESOURCE_TYPE.getHeatResource(),
+ Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(new NamingConventionGuideLineValidator(),
+ new NeutronPortNamingConventionValidator(), HeatResourcesTypes.NEUTRON_PORT_RESOURCE_TYPE.getHeatResource(),
PATH + "missingparam/");
Assert.assertNotNull(messages);
- Assert.assertEquals(messages.size(), 1);
- Assert.assertEquals(messages.get("first.yaml").getErrorMessageList().size(), 1);
- Assert.assertEquals(messages.get("first.yaml").getErrorMessageList().get(0).getMessage(),
- "WARNING: [NNP2]: Missing get_param in network or network_id, Resource Id [port_resource_2]");
+ Assert.assertEquals(1, messages.size());
+ Assert.assertEquals(1, messages.get("first.yaml").getErrorMessageList().size());
+ Assert.assertEquals("WARNING: [NNP2]: Missing get_param in network or network_id, Resource Id [port_resource_2]",
+ messages.get("first.yaml").getErrorMessageList().get(0).getMessage());
}
}
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/namingconvention/NovaServerNamingConventionGuideLineValidatorTest.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/namingconvention/NovaServerNamingConventionGuideLineValidatorTest.java
index 01750c5f54..cfa3a86325 100644
--- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/namingconvention/NovaServerNamingConventionGuideLineValidatorTest.java
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/namingconvention/NovaServerNamingConventionGuideLineValidatorTest.java
@@ -36,13 +36,13 @@ public class NovaServerNamingConventionGuideLineValidatorTest {
private static final String PATH = "/org/openecomp/validation/validators/guideLineValidator/novaserverValidation/";
@Test
public void testHeatNovaServerMetaDataValidation() {
- Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator,
+ Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(baseValidator,
resourceValidator, HeatResourcesTypes.NOVA_SERVER_RESOURCE_TYPE.getHeatResource(),
PATH + "heatNovaServerMetaDataValidation/positive/");
Assert.assertNotNull(messages);
Assert.assertEquals(messages.size(), 0);
- messages = ValidationTestUtil.testValidator(baseValidator,
+ messages = new ValidationTestUtil().testValidator(baseValidator,
resourceValidator, HeatResourcesTypes.NOVA_SERVER_RESOURCE_TYPE.getHeatResource(),
PATH + "heatNovaServerMetaDataValidation/negative/");
Assert.assertNotNull(messages);
@@ -54,13 +54,13 @@ public class NovaServerNamingConventionGuideLineValidatorTest {
@Test
public void testNovaServerAvailabilityZoneName() {
- Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator,
+ Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(baseValidator,
resourceValidator, HeatResourcesTypes.NOVA_SERVER_RESOURCE_TYPE.getHeatResource(),
PATH + "heatNovaServerAvailabilityZoneName/positive");
Assert.assertNotNull(messages);
Assert.assertEquals(messages.size(), 0);
- messages = ValidationTestUtil.testValidator(baseValidator,
+ messages = new ValidationTestUtil().testValidator(baseValidator,
resourceValidator, HeatResourcesTypes.NOVA_SERVER_RESOURCE_TYPE.getHeatResource(),
PATH + "heatNovaServerAvailabilityZoneName/negative");
Assert.assertNotNull(messages);
@@ -74,7 +74,7 @@ public class NovaServerNamingConventionGuideLineValidatorTest {
@Test
public void testNovaImageAndFlavorNamesEmptyProperties() {
- Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator,
+ Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(baseValidator,
resourceValidator, HeatResourcesTypes.NOVA_SERVER_RESOURCE_TYPE.getHeatResource(),
PATH + "heatNovaServerImageAndFlavor/negativeEmptyProperties");
Assert.assertNotNull(messages);
@@ -86,13 +86,13 @@ public class NovaServerNamingConventionGuideLineValidatorTest {
@Test
public void testNovaImageAndFlavorNames() {
- Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator,
+ Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(baseValidator,
resourceValidator, HeatResourcesTypes.NOVA_SERVER_RESOURCE_TYPE.getHeatResource(),
PATH + "heatNovaServerImageAndFlavor/positive");
Assert.assertNotNull(messages);
Assert.assertEquals(messages.size(), 0);
- messages = ValidationTestUtil.testValidator(baseValidator,
+ messages = new ValidationTestUtil().testValidator(baseValidator,
resourceValidator, HeatResourcesTypes.NOVA_SERVER_RESOURCE_TYPE.getHeatResource(),
PATH + "heatNovaServerImageAndFlavor/negative");
Assert.assertNotNull(messages);
@@ -106,12 +106,12 @@ public class NovaServerNamingConventionGuideLineValidatorTest {
@Test
public void testNovaResourceNetworkUniqueRole() {
- Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator,
+ Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(baseValidator,
resourceValidator, HeatResourcesTypes.NOVA_SERVER_RESOURCE_TYPE.getHeatResource(),
PATH + "heatNovaNetworkUniqueRoleConvention/positive/");
Assert.assertNotNull(messages);
Assert.assertEquals(messages.size(), 0);
- messages = ValidationTestUtil.testValidator(baseValidator,
+ messages = new ValidationTestUtil().testValidator(baseValidator,
resourceValidator, HeatResourcesTypes.NOVA_SERVER_RESOURCE_TYPE.getHeatResource(),
PATH + "heatNovaNetworkUniqueRoleConvention/negative/");
Assert.assertNotNull(messages);
@@ -123,13 +123,13 @@ public class NovaServerNamingConventionGuideLineValidatorTest {
@Test
public void testNovaServerName() {
- Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator,
+ Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(baseValidator,
resourceValidator, HeatResourcesTypes.NOVA_SERVER_RESOURCE_TYPE.getHeatResource(),
PATH + "heatNovaServerNameValidation/positive");
Assert.assertNotNull(messages);
Assert.assertEquals(messages.size(), 0);
- messages = ValidationTestUtil.testValidator(baseValidator,
+ messages = new ValidationTestUtil().testValidator(baseValidator,
resourceValidator, HeatResourcesTypes.NOVA_SERVER_RESOURCE_TYPE.getHeatResource(),
PATH + "heatNovaServerNameValidation/negative/");
Assert.assertNotNull(messages);
@@ -141,7 +141,7 @@ public class NovaServerNamingConventionGuideLineValidatorTest {
@Test
public void testVMNameSyncInNova() {
- Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator,
+ Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(baseValidator,
resourceValidator, HeatResourcesTypes.NOVA_SERVER_RESOURCE_TYPE.getHeatResource(),
PATH + "input");
@@ -161,7 +161,7 @@ public class NovaServerNamingConventionGuideLineValidatorTest {
@Test
public void testAvailabilityZoneName() throws IOException {
- Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator,
+ Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(baseValidator,
resourceValidator, HeatResourcesTypes.NOVA_SERVER_RESOURCE_TYPE.getHeatResource(),
PATH + "availability_zone_name/input");
@@ -179,7 +179,7 @@ public class NovaServerNamingConventionGuideLineValidatorTest {
@Test
public void testHeatNovaServerVnfIDValidation() {
- Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator,
+ Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(baseValidator,
resourceValidator, HeatResourcesTypes.NOVA_SERVER_RESOURCE_TYPE.getHeatResource(),
"/org/openecomp/validation/validators/guideLineValidator/novaserverValidation/heatNovaServerMetaDataValidation/negativemissingvnfid/");
Assert.assertNotNull(messages);
@@ -190,7 +190,7 @@ public class NovaServerNamingConventionGuideLineValidatorTest {
@Test
public void testHeatNovaServerVfModuleValidation() {
- Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator,
+ Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(baseValidator,
resourceValidator, HeatResourcesTypes.NOVA_SERVER_RESOURCE_TYPE.getHeatResource(),
"/org/openecomp/validation/validators/guideLineValidator/novaserverValidation/heatNovaServerMetaDataValidation/negativemisningvfmodule/");
Assert.assertNotNull(messages);
@@ -200,7 +200,7 @@ public class NovaServerNamingConventionGuideLineValidatorTest {
@Test
public void testMissingParam() {
- Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator,
+ Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(baseValidator,
resourceValidator, HeatResourcesTypes.NOVA_SERVER_RESOURCE_TYPE.getHeatResource(),
PATH + "heatNovaNetworkUniqueRoleConvention/missingportNetwork/");
Assert.assertNotNull(messages);
@@ -217,7 +217,7 @@ public class NovaServerNamingConventionGuideLineValidatorTest {
@Test
public void testNovaResource() {
- Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator,
+ Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(baseValidator,
resourceValidator, HeatResourcesTypes.NOVA_SERVER_RESOURCE_TYPE.getHeatResource(),
PATH + "heatNovaNetworkUniqueRoleConvention/invalidresource/");
Assert.assertNotNull(messages);
@@ -227,7 +227,7 @@ public class NovaServerNamingConventionGuideLineValidatorTest {
@Test
public void testEnvFileContent() {
- Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator,
+ Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(baseValidator,
resourceValidator, HeatResourcesTypes.NOVA_SERVER_RESOURCE_TYPE.getHeatResource(),
PATH + "heatNovaNetworkUniqueRoleConvention/input/");
Assert.assertNotNull(messages);
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/namingconvention/VirtualMachineInterfaceGuidelineValidatorTest.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/namingconvention/VirtualMachineInterfaceGuidelineValidatorTest.java
index e660fbffd5..21b5ca6f5f 100644
--- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/namingconvention/VirtualMachineInterfaceGuidelineValidatorTest.java
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/namingconvention/VirtualMachineInterfaceGuidelineValidatorTest.java
@@ -34,7 +34,7 @@ public class VirtualMachineInterfaceGuidelineValidatorTest {
NamingConventionGuideLineValidator baseValidator = new NamingConventionGuideLineValidator();
VirtualMachineInterfaceGuidelineValidator resourceValidator = new
VirtualMachineInterfaceGuidelineValidator();
- Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator,
+ Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(baseValidator,
resourceValidator,
HeatResourcesTypes.CONTRAIL_V2_VIRTUAL_MACHINE_INTERFACE_RESOURCE_TYPE.getHeatResource(),
PATH + "modeled_through_resource_group/positive_test/input");
@@ -50,7 +50,7 @@ public class VirtualMachineInterfaceGuidelineValidatorTest {
NamingConventionGuideLineValidator baseValidator = new NamingConventionGuideLineValidator();
VirtualMachineInterfaceGuidelineValidator resourceValidator = new
VirtualMachineInterfaceGuidelineValidator();
- Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator,
+ Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(baseValidator,
resourceValidator,
HeatResourcesTypes.CONTRAIL_V2_VIRTUAL_MACHINE_INTERFACE_RESOURCE_TYPE.getHeatResource(),
PATH + "modeled_through_resource_group/negative_test/input");
@@ -71,7 +71,7 @@ public class VirtualMachineInterfaceGuidelineValidatorTest {
NamingConventionGuideLineValidator baseValidator = new NamingConventionGuideLineValidator();
VirtualMachineInterfaceGuidelineValidator resourceValidator = new
VirtualMachineInterfaceGuidelineValidator();
- Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator,
+ Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(baseValidator,
resourceValidator,
HeatResourcesTypes.CONTRAIL_V2_VIRTUAL_MACHINE_INTERFACE_RESOURCE_TYPE.getHeatResource(),
PATH + "modeled_through_resource_group/negative_test_non_string/input");
@@ -92,7 +92,7 @@ public class VirtualMachineInterfaceGuidelineValidatorTest {
NamingConventionGuideLineValidator baseValidator = new NamingConventionGuideLineValidator();
VirtualMachineInterfaceGuidelineValidator resourceValidator = new
VirtualMachineInterfaceGuidelineValidator();
- Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator,
+ Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(baseValidator,
resourceValidator,
HeatResourcesTypes.CONTRAIL_V2_VIRTUAL_MACHINE_INTERFACE_RESOURCE_TYPE.getHeatResource(),
PATH + "modeled_through_resource_group/negative_get_resource/input");
@@ -114,7 +114,7 @@ public class VirtualMachineInterfaceGuidelineValidatorTest {
NamingConventionGuideLineValidator baseValidator = new NamingConventionGuideLineValidator();
VirtualMachineInterfaceGuidelineValidator resourceValidator = new
VirtualMachineInterfaceGuidelineValidator();
- Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator,
+ Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(baseValidator,
resourceValidator,
HeatResourcesTypes.CONTRAIL_V2_VIRTUAL_MACHINE_INTERFACE_RESOURCE_TYPE.getHeatResource(),
PATH + "single_vlan_resource/positive_test/input");
@@ -130,7 +130,7 @@ public class VirtualMachineInterfaceGuidelineValidatorTest {
NamingConventionGuideLineValidator baseValidator = new NamingConventionGuideLineValidator();
VirtualMachineInterfaceGuidelineValidator resourceValidator = new
VirtualMachineInterfaceGuidelineValidator();
- Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator,
+ Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(baseValidator,
resourceValidator,
HeatResourcesTypes.CONTRAIL_V2_VIRTUAL_MACHINE_INTERFACE_RESOURCE_TYPE.getHeatResource(),
PATH + "single_vlan_resource/negative_test/two_vlans");
@@ -151,7 +151,7 @@ public class VirtualMachineInterfaceGuidelineValidatorTest {
NamingConventionGuideLineValidator baseValidator = new NamingConventionGuideLineValidator();
VirtualMachineInterfaceGuidelineValidator resourceValidator = new
VirtualMachineInterfaceGuidelineValidator();
- Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator,
+ Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(baseValidator,
resourceValidator,
HeatResourcesTypes.CONTRAIL_V2_VIRTUAL_MACHINE_INTERFACE_RESOURCE_TYPE.getHeatResource(),
PATH + "single_vlan_resource/negative_test/vlan_and_nova");
@@ -171,7 +171,7 @@ public class VirtualMachineInterfaceGuidelineValidatorTest {
NamingConventionGuideLineValidator baseValidator = new NamingConventionGuideLineValidator();
VirtualMachineInterfaceGuidelineValidator resourceValidator = new
VirtualMachineInterfaceGuidelineValidator();
- Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator,
+ Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(baseValidator,
resourceValidator,
HeatResourcesTypes.CONTRAIL_V2_VIRTUAL_MACHINE_INTERFACE_RESOURCE_TYPE.getHeatResource(),
PATH + "naming_convention/negative_test/input");
@@ -192,7 +192,7 @@ public class VirtualMachineInterfaceGuidelineValidatorTest {
NamingConventionGuideLineValidator baseValidator = new NamingConventionGuideLineValidator();
VirtualMachineInterfaceGuidelineValidator resourceValidator = new
VirtualMachineInterfaceGuidelineValidator();
- Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator,
+ Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(baseValidator,
resourceValidator,
HeatResourcesTypes.CONTRAIL_V2_VIRTUAL_MACHINE_INTERFACE_RESOURCE_TYPE.getHeatResource(),
PATH + "naming_convention/positive_test/input");
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/util/ValidationTestUtil.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/util/ValidationTestUtil.java
index 68ba5c911d..11ed22966c 100644
--- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/util/ValidationTestUtil.java
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/util/ValidationTestUtil.java
@@ -49,9 +49,9 @@ import org.openecomp.sdc.validation.base.ResourceBaseValidator;
*/
public class ValidationTestUtil {
- private ValidationTestUtil(){}
+ public ValidationTestUtil(){}
- public static GlobalValidationContext createGlobalContextFromPath(String path) {
+ public GlobalValidationContext createGlobalContextFromPath(String path) {
GlobalValidationContext globalValidationContext = new GlobalValidationContext();
Map<String, byte[]> contentMap = getContentMapByPath(path);
if (contentMap == null) {
@@ -62,7 +62,7 @@ public class ValidationTestUtil {
return globalValidationContext;
}
- private static Map<String, byte[]> getContentMapByPath(String path) {
+ private Map<String, byte[]> getContentMapByPath(String path) {
Map<String, byte[]> contentMap = new HashMap<>();
URL url = ValidationTestUtil.class.getResource(path);
File pathFile = new File(url.getFile());
@@ -89,8 +89,7 @@ public class ValidationTestUtil {
return contentMap;
}
- public static Map<String, MessageContainer> testValidator(Validator validator, String path) {
-
+ public Map<String, MessageContainer> testValidator(Validator validator, String path) {
GlobalValidationContext globalValidationContext = createGlobalContextFromPath(path);
validator.validate(globalValidationContext);
@@ -100,7 +99,7 @@ public class ValidationTestUtil {
}
- public static Map<String, MessageContainer> testValidator(ResourceBaseValidator baseValidator,
+ public Map<String, MessageContainer> testValidator(ResourceBaseValidator baseValidator,
ResourceValidator resourceValidator,
String resourceTypeToValidate, String path) {
@@ -117,7 +116,7 @@ public class ValidationTestUtil {
return globalContext.getContextMessageContainers();
}
- private static void validateFiles(ResourceBaseValidator baseValidator,
+ private void validateFiles(ResourceBaseValidator baseValidator,
ResourceValidator resourceValidator,
GlobalValidationContext globalContext,
Map<String, FileData> fileEnvMap,
@@ -144,7 +143,7 @@ public class ValidationTestUtil {
}
}
- private static void validateResources(String fileName, ResourceValidator resourceValidator,
+ private void validateResources(String fileName, ResourceValidator resourceValidator,
String resourceTypeToValidate, ValidationContext validationContext,
GlobalValidationContext globalValidationContext){
@@ -166,7 +165,7 @@ public class ValidationTestUtil {
(fileName, resourceEntry, globalValidationContext, validationContext));
}
- private static boolean isResourceNeedToBeTested(String currResource, String resourceToTest){
+ private boolean isResourceNeedToBeTested(String currResource, String resourceToTest){
if(Objects.isNull(resourceToTest)){
return HeatStructureUtil.isNestedResource(currResource);
}
@@ -174,14 +173,13 @@ public class ValidationTestUtil {
return currResource.equals(resourceToTest);
}
- public static void validateErrorMessage(String actualMessage, String expected, String... params) {
-
+ public void validateErrorMessage(String actualMessage, String expected, String... params) {
Assert.assertEquals(actualMessage.replace("\n", "").replace("\r", ""),
ErrorMessagesFormatBuilder.getErrorWithParameters(expected, params).replace("\n", "")
.replace("\r", ""));
}
- public static Map<String, Object> getResourceMap(String configFileName) throws IOException {
+ public Map<String, Object> getResourceMap(String configFileName) throws IOException {
URL mockResource = ValidationTestUtil.class.getResource(configFileName);
String json = IOUtils.toString(mockResource.openStream(), "UTF-8");
return JsonUtil.json2Object(json, Map.class);
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/guideLineValidator/heatPortNetworkNamingConvention/missingparam/first.yaml b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/guideLineValidator/heatPortNetworkNamingConvention/missingparam/first.yaml
index 0fd281d692..b1bfd9e6e3 100644
--- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/guideLineValidator/heatPortNetworkNamingConvention/missingparam/first.yaml
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/guideLineValidator/heatPortNetworkNamingConvention/missingparam/first.yaml
@@ -3,19 +3,10 @@ heat_template_version: 2013-05-23
description: heat expose volume resource
resources:
- port_resource_0:
- type: OS::Neutron::Port
- properties:
- network_id: { get_param: Internal1_net_id }
-resources:
- port_resource_1:
- type: OS::Neutron::Port
- properties:
- network_id: { get_param: Internal1_net_name }
-resources:
port_resource_2:
type: OS::Neutron::Port
properties:
+ # required to be 'not a map' to trigger error NNP2
network_id: Internal1_net_fqdn
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/guideLineValidator/heatPortNetworkNamingConvention/positive/first.yaml b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/guideLineValidator/heatPortNetworkNamingConvention/positive/first.yaml
index 12ee08952d..560aa61c68 100644
--- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/guideLineValidator/heatPortNetworkNamingConvention/positive/first.yaml
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/guideLineValidator/heatPortNetworkNamingConvention/positive/first.yaml
@@ -7,17 +7,6 @@ resources:
type: OS::Neutron::Port
properties:
network_id: { get_param: Internal1_net_id }
-resources:
- port_resource_1:
- type: OS::Neutron::Port
- properties:
- network_id: { get_param: Internal1_net_name }
-resources:
- port_resource_2:
- type: OS::Neutron::Port
- properties:
- network_id: { get_param: Internal1_net_fqdn }
-
outputs:
expose_resource_port_output_0:
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/guideLineValidator/vlan_validation/modeled_through_resource_group/negative_test/input/main.yml b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/guideLineValidator/vlan_validation/modeled_through_resource_group/negative_test/input/main.yml
index 2fc1d1614c..ea28e7fa4e 100644
--- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/guideLineValidator/vlan_validation/modeled_through_resource_group/negative_test/input/main.yml
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/guideLineValidator/vlan_validation/modeled_through_resource_group/negative_test/input/main.yml
@@ -65,17 +65,6 @@ resources:
- port: { get_resource: template_VMInt_OAM_lb_1 }
- port: { get_resource: cmaui_port_2 }
-
- type: OS::ContrailV2::VirtualMachineInterface
- properties:
- virtual_machine_interface_properties:
- {
- virtual_machine_interface_properties_service_interface_type: { get_param: lb_st_interface_type_oam },
- }
- virtual_network_refs: [{ get_resource: test_net1 }]
- port_tuple_refs: [{ get_param: template_PortTuple_LB1 }]
- security_group_refs: [{ get_param: oam_sec_group_name}]
-
cmaui_port_2:
type: OS::Neutron::Port
properties:
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/guideLineValidator/vlan_validation/modeled_through_resource_group/negative_test_non_string/input/main.yml b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/guideLineValidator/vlan_validation/modeled_through_resource_group/negative_test_non_string/input/main.yml
index 2fc1d1614c..ea28e7fa4e 100644
--- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/guideLineValidator/vlan_validation/modeled_through_resource_group/negative_test_non_string/input/main.yml
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/guideLineValidator/vlan_validation/modeled_through_resource_group/negative_test_non_string/input/main.yml
@@ -65,17 +65,6 @@ resources:
- port: { get_resource: template_VMInt_OAM_lb_1 }
- port: { get_resource: cmaui_port_2 }
-
- type: OS::ContrailV2::VirtualMachineInterface
- properties:
- virtual_machine_interface_properties:
- {
- virtual_machine_interface_properties_service_interface_type: { get_param: lb_st_interface_type_oam },
- }
- virtual_network_refs: [{ get_resource: test_net1 }]
- port_tuple_refs: [{ get_param: template_PortTuple_LB1 }]
- security_group_refs: [{ get_param: oam_sec_group_name}]
-
cmaui_port_2:
type: OS::Neutron::Port
properties:
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/heat_validator/vlan_resource_validation/vlan_multiple_parent_ports/negative_test/input/main.yml b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/heat_validator/vlan_resource_validation/vlan_multiple_parent_ports/negative_test/input/main.yml
index 2fc1d1614c..ea28e7fa4e 100644
--- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/heat_validator/vlan_resource_validation/vlan_multiple_parent_ports/negative_test/input/main.yml
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/heat_validator/vlan_resource_validation/vlan_multiple_parent_ports/negative_test/input/main.yml
@@ -65,17 +65,6 @@ resources:
- port: { get_resource: template_VMInt_OAM_lb_1 }
- port: { get_resource: cmaui_port_2 }
-
- type: OS::ContrailV2::VirtualMachineInterface
- properties:
- virtual_machine_interface_properties:
- {
- virtual_machine_interface_properties_service_interface_type: { get_param: lb_st_interface_type_oam },
- }
- virtual_network_refs: [{ get_resource: test_net1 }]
- port_tuple_refs: [{ get_param: template_PortTuple_LB1 }]
- security_group_refs: [{ get_param: oam_sec_group_name}]
-
cmaui_port_2:
type: OS::Neutron::Port
properties:
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/heat_validator/vlan_resource_validation/vlan_multiple_parent_ports/positive_test/input/main.yml b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/heat_validator/vlan_resource_validation/vlan_multiple_parent_ports/positive_test/input/main.yml
index 9b0c3ec0eb..ea28e7fa4e 100644
--- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/heat_validator/vlan_resource_validation/vlan_multiple_parent_ports/positive_test/input/main.yml
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/heat_validator/vlan_resource_validation/vlan_multiple_parent_ports/positive_test/input/main.yml
@@ -65,17 +65,6 @@ resources:
- port: { get_resource: template_VMInt_OAM_lb_1 }
- port: { get_resource: cmaui_port_2 }
-
- type: OS::ContrailV2::VirtualMachineInterface
- properties:
- virtual_machine_interface_properties:
- {
- virtual_machine_interface_properties_service_interface_type: { get_param: lb_st_interface_type_oam },
- }
- virtual_network_refs: [{ get_resource: test_net1 }]
- port_tuple_refs: [{ get_param: template_PortTuple_LB1 }]
- security_group_refs: [{ get_param: oam_sec_group_name}]
-
cmaui_port_2:
type: OS::Neutron::Port
properties:
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-sdk/pom.xml b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-sdk/pom.xml
index 54b6964bbc..4d2ec69003 100644
--- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-sdk/pom.xml
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-sdk/pom.xml
@@ -7,9 +7,8 @@
<parent>
<groupId>org.openecomp.sdc</groupId>
- <artifactId>openecomp-sdc-lib</artifactId>
+ <artifactId>openecomp-sdc-validation-lib</artifactId>
<version>1.8.1-SNAPSHOT</version>
- <relativePath>../..</relativePath>
</parent>
<dependencies>
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-sdk/src/main/java/org/openecomp/sdc/validation/base/ResourceBaseValidator.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-sdk/src/main/java/org/openecomp/sdc/validation/base/ResourceBaseValidator.java
index ba23c8b649..a15c7678f7 100644
--- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-sdk/src/main/java/org/openecomp/sdc/validation/base/ResourceBaseValidator.java
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-sdk/src/main/java/org/openecomp/sdc/validation/base/ResourceBaseValidator.java
@@ -56,7 +56,7 @@ public class ResourceBaseValidator implements Validator {
return MapUtils.unmodifiableMap(this.resourceTypeToImpl);
}
-@Override
+ @Override
public void init(Map<String, Object> properties) {
if (MapUtils.isEmpty(properties)) {
return;
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-sdk/src/test/java/org/openecomp/sdc/validation/base/ResourceBaseValidatorTest.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-sdk/src/test/java/org/openecomp/sdc/validation/base/ResourceBaseValidatorTest.java
index 35a8c00ee9..095df4f859 100644
--- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-sdk/src/test/java/org/openecomp/sdc/validation/base/ResourceBaseValidatorTest.java
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-sdk/src/test/java/org/openecomp/sdc/validation/base/ResourceBaseValidatorTest.java
@@ -19,97 +19,228 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import org.apache.commons.collections4.MapUtils;
+import org.apache.commons.io.IOUtils;
import org.junit.jupiter.api.Test;
+import org.openecomp.core.utilities.file.FileUtils;
+import org.openecomp.core.utilities.json.JsonUtil;
+import org.openecomp.core.validation.errors.ErrorMessagesFormatBuilder;
+import org.openecomp.core.validation.types.GlobalValidationContext;
import org.openecomp.core.validation.types.MessageContainer;
import org.openecomp.sdc.datatypes.configuration.ImplementationConfiguration;
+import org.openecomp.sdc.heat.datatypes.manifest.FileData;
+import org.openecomp.sdc.heat.datatypes.manifest.ManifestContent;
+import org.openecomp.sdc.heat.datatypes.model.HeatOrchestrationTemplate;
+import org.openecomp.sdc.heat.datatypes.model.Resource;
+import org.openecomp.sdc.heat.services.HeatStructureUtil;
+import org.openecomp.sdc.heat.services.manifest.ManifestUtil;
+import org.openecomp.sdc.validation.ResourceValidator;
+import org.openecomp.sdc.validation.ValidationContext;
+import org.openecomp.sdc.validation.Validator;
import org.openecomp.sdc.validation.type.ConfigConstants;
-import org.openecomp.sdc.validation.util.ValidationTestUtil;
+import org.openecomp.sdc.validation.util.ValidationUtil;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.net.URL;
+import java.util.*;
public class ResourceBaseValidatorTest {
-private String testValidator = "testValidator";
-
- @Test
- public void testInvalidResourceType(){
- ResourceBaseValidator resourceBaseValidator = new ResourceBaseValidator();
- Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(
- resourceBaseValidator, "/InvalidResourceType");
- assertEquals(messages.get("first.yaml").getErrorMessageList().get(0).getMessage(),
- "WARNING: [RBV1]: A resource has an invalid or unsupported type - null, " +
- "Resource ID [FSB2]");
- }
-
- @Test
- public void testInvalidHeatStructure(){
- ResourceBaseValidator resourceBaseValidator = new ResourceBaseValidator();
- Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(resourceBaseValidator,
- "/InvalidHeatStructure");
- assertEquals(messages.get("first.yaml").getErrorMessageList().get(0).getMessage(),
- "ERROR: [RBV2]: Invalid HEAT format problem - [while scanning for the next " +
- "token\n" + "found character '\\t(TAB)' that cannot start any token. " +
- "(Do not use \\t(TAB) for indentation)\n" +
- " in 'reader', line 10, column 1:\n" +
- " \t\t\tresources:\n" +
- " ^\n" +
- "]");
- }
-
- @Test
- public void testInitWithEmptyPropertiesMap() {
- ResourceBaseValidator resourceBaseValidator = new ResourceBaseValidator();
- Map<String, Object> properties = new HashMap<>();
- resourceBaseValidator.init(properties);
-
- assertTrue(MapUtils.isEmpty(resourceBaseValidator.getResourceTypeToImpl()));
- }
-
- @Test
- public void testInitPropertiesMap() {
- ResourceBaseValidator resourceBaseValidator = new ResourceBaseValidator();
- initProperties(resourceBaseValidator, getValidImplementationConfiguration());
-
- Map<String, ImplementationConfiguration> resourceTypeToImpl =
- resourceBaseValidator.getResourceTypeToImpl();
- assertTrue(MapUtils.isNotEmpty(resourceTypeToImpl));
- assertTrue(resourceTypeToImpl.containsKey(testValidator));
- }
-
- @Test
- public void testInitPropertiesWithString() {
- ResourceBaseValidator resourceBaseValidator = new ResourceBaseValidator();
- Map<String, Object> properties = new HashMap<>();
- properties.put(testValidator, "invalidValue");
-
- resourceBaseValidator.init(properties);
-
- assertTrue(MapUtils.isEmpty(resourceBaseValidator.getResourceTypeToImpl()));
- }
-
- @Test
- public void testInitPropertiesWithoutImplClass() {
- ResourceBaseValidator resourceBaseValidator = new ResourceBaseValidator();
- initProperties(resourceBaseValidator, new HashMap<>());
-
- assertTrue(MapUtils.isEmpty(resourceBaseValidator.getResourceTypeToImpl()));
- }
-
- public Map<String, Object> getValidImplementationConfiguration() {
- Map<String, Object> implConfiguration = new HashMap<>();
- implConfiguration.put(
- ConfigConstants.Impl_Class, "org.openecomp.sdc.validation.impl.validators.ForbiddenResourceGuideLineValidator");
- implConfiguration.put(ConfigConstants.Enable, true);
-
- return implConfiguration;
- }
-
- private void initProperties(ResourceBaseValidator resourceBaseValidator,
- Map<String, Object> implementationConfiguration) {
- Map<String, Object> properties =
- Collections.singletonMap(testValidator, implementationConfiguration);
-
- resourceBaseValidator.init(properties);
- }
+ private String testValidator = "testValidator";
+
+ @Test
+ public void testInvalidResourceType() {
+ ResourceBaseValidator resourceBaseValidator = new ResourceBaseValidator();
+ Map<String, MessageContainer> messages = testValidator(resourceBaseValidator, "/InvalidResourceType");
+ assertEquals(messages.get("first.yaml").getErrorMessageList().get(0).getMessage(),
+ "WARNING: [RBV1]: A resource has an invalid or unsupported type - null, Resource ID [FSB2]");
+ }
+
+ @Test
+ public void testInvalidHeatStructure() {
+ ResourceBaseValidator resourceBaseValidator = new ResourceBaseValidator();
+ Map<String, MessageContainer> messages = testValidator(resourceBaseValidator, "/InvalidHeatStructure");
+ assertEquals(messages.get("first.yaml").getErrorMessageList().get(0).getMessage(),
+ "ERROR: [RBV2]: Invalid HEAT format problem - [while scanning for the next " +
+ "token\n" + "found character '\\t(TAB)' that cannot start any token. " +
+ "(Do not use \\t(TAB) for indentation)\n" +
+ " in 'reader', line 10, column 1:\n" +
+ " \t\t\tresources:\n" +
+ " ^\n" +
+ "]");
+ }
+
+ @Test
+ public void testInitWithEmptyPropertiesMap() {
+ ResourceBaseValidator resourceBaseValidator = new ResourceBaseValidator();
+ Map<String, Object> properties = new HashMap<>();
+ resourceBaseValidator.init(properties);
+ assertTrue(MapUtils.isEmpty(resourceBaseValidator.getResourceTypeToImpl()));
+ }
+
+ @Test
+ public void testInitPropertiesMap() {
+ ResourceBaseValidator resourceBaseValidator = new ResourceBaseValidator();
+ initProperties(resourceBaseValidator, getValidImplementationConfiguration());
+
+ Map<String, ImplementationConfiguration> resourceTypeToImpl = resourceBaseValidator.getResourceTypeToImpl();
+ assertTrue(MapUtils.isNotEmpty(resourceTypeToImpl));
+ assertTrue(resourceTypeToImpl.containsKey(testValidator));
+ }
+
+ @Test
+ public void testInitPropertiesWithString() {
+ ResourceBaseValidator resourceBaseValidator = new ResourceBaseValidator();
+ Map<String, Object> properties = new HashMap<>();
+ properties.put(testValidator, "invalidValue");
+ resourceBaseValidator.init(properties);
+ assertTrue(MapUtils.isEmpty(resourceBaseValidator.getResourceTypeToImpl()));
+ }
+
+ @Test
+ public void testInitPropertiesWithoutImplClass() {
+ ResourceBaseValidator resourceBaseValidator = new ResourceBaseValidator();
+ initProperties(resourceBaseValidator, new HashMap<>());
+ assertTrue(MapUtils.isEmpty(resourceBaseValidator.getResourceTypeToImpl()));
+ }
+
+ public Map<String, Object> getValidImplementationConfiguration() {
+ Map<String, Object> implConfiguration = new HashMap<>();
+ implConfiguration.put(ConfigConstants.Impl_Class, "org.openecomp.sdc.validation.impl.validators.ForbiddenResourceGuideLineValidator");
+ implConfiguration.put(ConfigConstants.Enable, true);
+
+ return implConfiguration;
+ }
+
+ private void initProperties(ResourceBaseValidator resourceBaseValidator, Map<String, Object> implementationConfiguration) {
+ Map<String, Object> properties = Collections.singletonMap(testValidator, implementationConfiguration);
+ resourceBaseValidator.init(properties);
+ }
+
+ public GlobalValidationContext createGlobalContextFromPath(String path) {
+ GlobalValidationContext globalValidationContext = new GlobalValidationContext();
+ Map<String, byte[]> contentMap = getContentMapByPath(path);
+ if (contentMap == null) {
+ return null;
+ }
+ contentMap.forEach(globalValidationContext::addFileContext);
+
+ return globalValidationContext;
+ }
+
+ private Map<String, byte[]> getContentMapByPath(String path) {
+ Map<String, byte[]> contentMap = new HashMap<>();
+ URL url = ResourceBaseValidator.class.getResource(path);
+ File pathFile = new File(url.getFile());
+ File[] files;
+ if (pathFile.isDirectory()) {
+ files = pathFile.listFiles();
+ } else {
+ files = new File[]{pathFile};
+ }
+
+ if (files == null || files.length == 0) {
+ return null;
+ }
+
+ for (File file : files) {
+
+ try (FileInputStream fis = new FileInputStream(file)) {
+ contentMap.put(file.getName(), FileUtils.toByteArray(fis));
+ } catch (IOException e) {
+ throw new RuntimeException("Failed to read file: " + file, e);
+ }
+
+ }
+ return contentMap;
+ }
+
+ public Map<String, MessageContainer> testValidator(Validator validator, String path) {
+ GlobalValidationContext globalValidationContext = createGlobalContextFromPath(path);
+ validator.validate(globalValidationContext);
+
+ assert globalValidationContext != null;
+ return globalValidationContext.getContextMessageContainers();
+ }
+
+ public Map<String, MessageContainer> testValidator(ResourceBaseValidator baseValidator,
+ ResourceValidator resourceValidator,
+ String resourceTypeToValidate, String path) {
+
+ GlobalValidationContext globalContext = Objects.requireNonNull(
+ createGlobalContextFromPath(path), "Global validation context cannot be null");
+
+ ManifestContent manifestContent = ValidationUtil.validateManifest(globalContext);
+ Map<String, FileData.Type> fileTypeMap = ManifestUtil.getFileTypeMap(manifestContent);
+ Map<String, FileData> fileEnvMap = ManifestUtil.getFileAndItsEnv(manifestContent);
+
+ validateFiles(baseValidator, resourceValidator, globalContext, fileEnvMap, fileTypeMap,
+ resourceTypeToValidate);
+
+ return globalContext.getContextMessageContainers();
+ }
+
+ private void validateFiles(ResourceBaseValidator baseValidator,
+ ResourceValidator resourceValidator,
+ GlobalValidationContext globalContext,
+ Map<String, FileData> fileEnvMap,
+ Map<String, FileData.Type> fileTypeMap,
+ String resourceTypeToValidate) {
+
+ Collection<String> files = globalContext.getFiles();
+ for (String fileName : files) {
+ if (FileData.isHeatFile(fileTypeMap.get(fileName))) {
+ HeatOrchestrationTemplate heatOrchestrationTemplate =
+ ValidationUtil.checkHeatOrchestrationPreCondition(fileName, globalContext);
+
+ if (Objects.isNull(heatOrchestrationTemplate)) {
+ continue;
+ }
+
+ ValidationContext validationContext = baseValidator.createValidationContext(fileName,
+ fileEnvMap.get(fileName) == null ? null : fileEnvMap.get(fileName).getFile(),
+ heatOrchestrationTemplate, globalContext);
+
+ validateResources(fileName, resourceValidator, resourceTypeToValidate, validationContext,
+ globalContext);
+ }
+ }
+ }
+
+ private void validateResources(String fileName, ResourceValidator resourceValidator,
+ String resourceTypeToValidate, ValidationContext validationContext,
+ GlobalValidationContext globalValidationContext) {
+
+ HeatOrchestrationTemplate heatOrchestrationTemplate =
+ ValidationUtil.checkHeatOrchestrationPreCondition(fileName, globalValidationContext);
+
+ Map<String, Resource> resourcesMap =
+ Objects.requireNonNull(heatOrchestrationTemplate, "Orchestration template cannot be null").getResources();
+
+ if (MapUtils.isEmpty(resourcesMap)) {
+ return;
+ }
+
+ resourcesMap.entrySet()
+ .stream()
+ .filter(resourceEntry -> isResourceNeedToBeTested(resourceEntry.getValue().getType(), resourceTypeToValidate))
+ .forEach(resourceEntry ->
+ resourceValidator.validate
+ (fileName, resourceEntry, globalValidationContext, validationContext));
+ }
+
+ private boolean isResourceNeedToBeTested(String currResource, String resourceToTest) {
+ if (Objects.isNull(resourceToTest)) {
+ return HeatStructureUtil.isNestedResource(currResource);
+ }
+
+ return currResource.equals(resourceToTest);
+ }
+
+ public void validateErrorMessage(String actualMessage, String expected, String... params) {
+ assertEquals(actualMessage.replace("\n", "").replace("\r", ""),
+ ErrorMessagesFormatBuilder.getErrorWithParameters(expected, params).replace("\n", "")
+ .replace("\r", ""));
+ }
+
}