summaryrefslogtreecommitdiffstats
path: root/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java
diff options
context:
space:
mode:
Diffstat (limited to 'openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java')
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/ErrorMessagesTest.java25
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/ValidatorBaseTest.java84
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/validators/EcompGuideLineValidatorTest.java281
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/validators/EcompNamingConventionTest.java104
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/validators/HeatValidatorTest.java356
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/validators/ManifestValidatorTest.java125
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/validators/YamlValidatorTest.java89
7 files changed, 1064 insertions, 0 deletions
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/ErrorMessagesTest.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/ErrorMessagesTest.java
new file mode 100644
index 0000000000..d762689049
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/ErrorMessagesTest.java
@@ -0,0 +1,25 @@
+package org.openecomp.sdc.validation.impl.validators;
+
+import org.openecomp.core.validation.errors.ErrorMessagesFormatBuilder;
+import org.openecomp.core.validation.errors.Messages;
+import org.junit.Test;
+import org.testng.Assert;
+
+public class ErrorMessagesTest {
+
+ @Test
+ public void testErrorFormatWithOneParam() {
+ String error1 = ErrorMessagesFormatBuilder
+ .getErrorWithParameters(Messages.MISSING_FILE_NAME_IN_MANIFEST.getErrorMessage(),
+ "file.yaml");
+ Assert.assertNotNull(error1);
+ }
+
+ @Test
+ public void testErrorFormatWithTwoParams() {
+ String error1 = ErrorMessagesFormatBuilder
+ .getErrorWithParameters(Messages.REFERENCED_PARAMETER_NOT_FOUND.getErrorMessage(), "param",
+ "res");
+ Assert.assertNotNull(error1);
+ }
+}
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/ValidatorBaseTest.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/ValidatorBaseTest.java
new file mode 100644
index 0000000000..f9c5bf423b
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/ValidatorBaseTest.java
@@ -0,0 +1,84 @@
+package org.openecomp.sdc.validation.impl.validators;
+
+import org.openecomp.core.utilities.file.FileUtils;
+import org.openecomp.core.validation.errors.ErrorMessagesFormatBuilder;
+import org.openecomp.core.validation.interfaces.Validator;
+import org.openecomp.core.validation.types.GlobalValidationContext;
+import org.openecomp.core.validation.types.MessageContainer;
+import org.testng.Assert;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.net.URL;
+import java.util.HashMap;
+import java.util.Map;
+
+public abstract class ValidatorBaseTest {
+
+ private static GlobalValidationContext createGlobalContextFromPath(String path) {
+ GlobalValidationContext globalValidationContext = new GlobalValidationContext();
+ Map<String, byte[]> contentMap = getContentMapByPath(path);
+ if (contentMap == null) {
+ return null;
+ }
+ contentMap.entrySet().stream()
+ .forEach(entry -> globalValidationContext.addFileContext(entry.getKey(), entry.getValue()));
+
+ return globalValidationContext;
+ }
+
+
+ // New test base implementation
+
+ private static Map<String, byte[]> getContentMapByPath(String path) {
+ Map<String, byte[]> contentMap = new HashMap<>();
+ byte[] fileContent;
+ FileInputStream fis;
+ URL url = ValidatorBaseTest.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 {
+ fis = new FileInputStream(file);
+ fileContent = FileUtils.toByteArray(fis);
+ contentMap.put(file.getName(), fileContent);
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ return contentMap;
+ }
+
+ public abstract Map<String, MessageContainer> runValidation(String path);
+
+ protected Map<String, MessageContainer> testValidator(Validator validator, String path) {
+
+ GlobalValidationContext globalValidationContext = createGlobalContextFromPath(path);
+ validator.validate(globalValidationContext);
+
+ assert globalValidationContext != null;
+ return globalValidationContext.getContextMessageContainers();
+
+
+ }
+
+ protected void validateErrorMessage(String actualMessage, String expected, String... params) {
+ Assert.assertEquals(actualMessage.replace("\n", "").replace("\r", ""),
+ ErrorMessagesFormatBuilder.getErrorWithParameters(expected, params).replace("\n", "")
+ .replace("\r", ""));
+
+ }
+
+
+}
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/validators/EcompGuideLineValidatorTest.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/validators/EcompGuideLineValidatorTest.java
new file mode 100644
index 0000000000..44e9a3a580
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/validators/EcompGuideLineValidatorTest.java
@@ -0,0 +1,281 @@
+package org.openecomp.sdc.validation.impl.validators.validators;
+
+import org.openecomp.sdc.validation.impl.validators.EcompGuideLineValidator;
+
+import org.openecomp.sdc.validation.impl.validators.ValidatorBaseTest;
+import org.openecomp.core.validation.types.MessageContainer;
+
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+import java.util.Map;
+
+public class EcompGuideLineValidatorTest extends ValidatorBaseTest {
+
+ @Test
+ public void testMissingBaseHeat() {
+ Map<String, MessageContainer> messages =
+ runValidation("/openecomp/org/validation/validators/ecompGuideLineValidator/missingBaseHeat/");
+ Assert.assertNotNull(messages);
+ Assert.assertEquals(messages.size(), 1);
+ Assert.assertEquals(messages.get("MANIFEST.json").getErrorMessageList().size(), 1);
+ Assert.assertEquals(messages.get("MANIFEST.json").getErrorMessageList().get(0).getMessage(),
+ "Missing Base HEAT. Pay attention that without Base HEAT, there will be no shared resources");
+ }
+
+ @Test
+ public void testMultiBaseHeat() {
+ Map<String, MessageContainer> messages =
+ runValidation("/openecomp/org/validation/validators/ecompGuideLineValidator/multiBaseHeat/");
+ Assert.assertNotNull(messages);
+ Assert.assertEquals(messages.size(), 1);
+ Assert.assertEquals(messages.get("MANIFEST.json").getErrorMessageList().size(), 1);
+ Assert.assertEquals(messages.get("MANIFEST.json").getErrorMessageList().get(0).getMessage(),
+ "Multi Base HEAT. Expected only one. Files [second.yaml,first.yaml].");
+ }
+
+ @Test
+ public void testBaseHeatExposeVolume() {
+ Map<String, MessageContainer> messages = runValidation(
+ "/openecomp/org/validation/validators/ecompGuideLineValidator/baseHeatDoesNotExposeVolume/positive/");
+ Assert.assertNotNull(messages);
+ Assert.assertEquals(messages.size(), 0);
+
+ messages = runValidation(
+ "/openecomp/org/validation/validators/ecompGuideLineValidator/baseHeatDoesNotExposeVolume/negative/");
+ 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(),
+ "Resource is not defined as output and thus cannot be Shared. resource id - volume_expose");
+ }
+
+ @Test
+ public void testBaseHeatExposeServerGroup() {
+ Map<String, MessageContainer> messages = runValidation(
+ "/openecomp/org/validation/validators/ecompGuideLineValidator/baseHeatDoesNotExposeServerGroup/positive/");
+ Assert.assertNotNull(messages);
+ Assert.assertEquals(messages.size(), 0);
+
+ messages = runValidation(
+ "/openecomp/org/validation/validators/ecompGuideLineValidator/baseHeatDoesNotExposeServerGroup/negative/");
+ 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(),
+ "Resource is not defined as output and thus cannot be Shared. resource id - ServerGroup_expose");
+ }
+
+ @Test
+ public void testBaseHeatExposeSecurityGroup() {
+ Map<String, MessageContainer> messages = runValidation(
+ "/openecomp/org/validation/validators/ecompGuideLineValidator/baseHeatDoesNotExposeSecurityGroup/positive/");
+ Assert.assertNotNull(messages);
+ Assert.assertEquals(messages.size(), 0);
+
+ messages = runValidation(
+ "/openecomp/org/validation/validators/ecompGuideLineValidator/baseHeatDoesNotExposeSecurityGroup/negative/");
+ 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(),
+ "Resource is not defined as output and thus cannot be Shared. resource id - SecurityGroup_expose");
+ }
+
+
+ @Test
+ public void testBaseHeatExposeNetwork() {
+ Map<String, MessageContainer> messages = runValidation(
+ "/openecomp/org/validation/validators/ecompGuideLineValidator/baseHeatDoesNotExposeNetwork/positive/");
+ Assert.assertNotNull(messages);
+ Assert.assertEquals(messages.size(), 0);
+
+ messages = runValidation(
+ "/openecomp/org/validation/validators/ecompGuideLineValidator/baseHeatDoesNotExposeNetwork/negative/");
+ 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(),
+ "Resource is not defined as output and thus cannot be Shared. resource id - SecurityGroup_expose");
+ }
+
+ @Test
+ public void testBaseHeatExposeNetworkAndVolume() {
+ Map<String, MessageContainer> messages = runValidation(
+ "/openecomp/org/validation/validators/ecompGuideLineValidator/baseHeatDoesNotExposeNetworkAndVolume/positive/");
+ Assert.assertNotNull(messages);
+ Assert.assertEquals(messages.size(), 0);
+
+ messages = runValidation(
+ "/openecomp/org/validation/validators/ecompGuideLineValidator/baseHeatDoesNotExposeNetworkAndVolume/negative/");
+ Assert.assertNotNull(messages);
+ Assert.assertEquals(messages.size(), 1);
+ Assert.assertEquals(messages.get("first.yaml").getErrorMessageList().size(), 2);
+ Assert.assertEquals(messages.get("first.yaml").getErrorMessageList().get(0).getMessage(),
+ "Resource is not defined as output and thus cannot be Shared. resource id - volume_expose");
+ Assert.assertEquals(messages.get("first.yaml").getErrorMessageList().get(1).getMessage(),
+ "Resource is not defined as output and thus cannot be Shared. resource id - net_expose");
+ }
+
+ @Test
+ public void testNovaResourceNetworkUniqueRole() {
+ Map<String, MessageContainer> messages = runValidation(
+ "/openecomp/org/validation/validators/ecompGuideLineValidator/heatNovaNetworkUniqueRoleConvention/positive/");
+ Assert.assertNotNull(messages);
+ Assert.assertEquals(messages.size(), 0);
+
+ messages = runValidation(
+ "/openecomp/org/validation/validators/ecompGuideLineValidator/heatNovaNetworkUniqueRoleConvention/negative/");
+ 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(),
+ "A resource is connected twice to the same network role Resource ID [FSB2] Network Role [Internal1].");
+ }
+
+ @Test
+ public void testHeatVolumeExpose() {
+ Map<String, MessageContainer> messages = runValidation(
+ "/openecomp/org/validation/validators/ecompGuideLineValidator/heatVolumeExpose/positive/");
+ Assert.assertNotNull(messages);
+ Assert.assertEquals(messages.size(), 0);
+
+ messages = runValidation(
+ "/openecomp/org/validation/validators/ecompGuideLineValidator/heatVolumeExpose/negative/");
+ Assert.assertNotNull(messages);
+ Assert.assertEquals(messages.size(), 1);
+ Assert.assertEquals(messages.get("firstVol.yaml").getErrorMessageList().size(), 1);
+ Assert.assertEquals(messages.get("firstVol.yaml").getErrorMessageList().get(0).getMessage(),
+ "Volume is not defined as output and thus cannot be attached volume_expose");
+
+ }
+
+ @Test
+ public void testHeatPortNetworkNamingConvention() {
+ Map<String, MessageContainer> messages = runValidation(
+ "/openecomp/org/validation/validators/ecompGuideLineValidator/heatPortNetworkNamingConvention/positive/");
+ Assert.assertNotNull(messages);
+ Assert.assertEquals(messages.size(), 0);
+
+ messages = runValidation(
+ "/openecomp/org/validation/validators/ecompGuideLineValidator/heatPortNetworkNamingConvention/negative/");
+ Assert.assertNotNull(messages);
+ Assert.assertEquals(messages.size(), 1);
+ Assert.assertEquals(messages.get("first.yaml").getErrorMessageList().size(), 3);
+ Assert.assertEquals(messages.get("first.yaml").getErrorMessageList().get(0).getMessage(),
+ "Network Parameter Name not aligned with Guidelines Parameter Name [not_valid_network_name] Resource ID [port_resource]");
+ }
+
+ @Test
+ public void testHeatNovaServerMetaDataValidation() {
+ Map<String, MessageContainer> messages = runValidation(
+ "/openecomp/org/validation/validators/ecompGuideLineValidator/heatNovaServerMetaDataValidation/positive/");
+ Assert.assertNotNull(messages);
+ Assert.assertEquals(messages.size(), 0);
+
+ messages = runValidation(
+ "/openecomp/org/validation/validators/ecompGuideLineValidator/heatNovaServerMetaDataValidation/negative/");
+ 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(),
+ "Missing VNF_ID Resource id [FSB2]");
+ }
+
+ @Test
+ public void testNeutronFixedIpName() {
+ Map<String, MessageContainer> messages = runValidation(
+ "/openecomp/org/validation/validators/ecompGuideLineValidator/heatPortFixedIpNamingConvention/positive");
+ Assert.assertNotNull(messages);
+ Assert.assertEquals(messages.size(), 0);
+
+ messages = runValidation(
+ "/openecomp/org/validation/validators/ecompGuideLineValidator/heatPortFixedIpNamingConvention/negative/");
+ Assert.assertNotNull(messages);
+ Assert.assertEquals(messages.size(), 1);
+ Assert.assertEquals(messages.get("first.yaml").getErrorMessageList().size(), 3);
+ Assert.assertEquals(messages.get("first.yaml").getErrorMessageList().get(0).getMessage(),
+ "Fixed_IPS not aligned with Guidelines, Resource ID [port_resource_0]");
+ Assert.assertEquals(messages.get("first.yaml").getErrorMessageList().get(1).getMessage(),
+ "Fixed_IPS not aligned with Guidelines, Resource ID [port_resource_1]");
+ Assert.assertEquals(messages.get("first.yaml").getErrorMessageList().get(2).getMessage(),
+ "Fixed_IPS not aligned with Guidelines, Resource ID [port_resource_2]");
+ }
+
+
+ @Test
+ public void testNovaServerName() {
+ Map<String, MessageContainer> messages = runValidation(
+ "/openecomp/org/validation/validators/ecompGuideLineValidator/heatNovaServerNameValidation/positive");
+ Assert.assertNotNull(messages);
+ Assert.assertEquals(messages.size(), 0);
+
+ messages = runValidation(
+ "/openecomp/org/validation/validators/ecompGuideLineValidator/heatNovaServerNameValidation/negative/");
+ Assert.assertNotNull(messages);
+ Assert.assertEquals(messages.size(), 1);
+ Assert.assertEquals(messages.get("first.yaml").getErrorMessageList().size(), 2);
+ Assert.assertEquals(messages.get("first.yaml").getErrorMessageList().get(0).getMessage(),
+ "Server Name not aligned with Guidelines, Resource ID [FSB2]");
+ }
+
+ @Test
+ public void testAvailabilityZoneName() {
+ Map<String, MessageContainer> messages = runValidation(
+ "/openecomp/org/validation/validators/ecompGuideLineValidator/heatNovaServerAvailabilityZoneName/positive");
+ Assert.assertNotNull(messages);
+ Assert.assertEquals(messages.size(), 0);
+
+ messages = runValidation(
+ "/openecomp/org/validation/validators/ecompGuideLineValidator/heatNovaServerAvailabilityZoneName/negative");
+ Assert.assertNotNull(messages);
+ Assert.assertEquals(messages.size(), 1);
+ Assert.assertEquals(messages.get("first.yaml").getErrorMessageList().size(), 3);
+ Assert.assertEquals(messages.get("first.yaml").getErrorMessageList().get(0).getMessage(),
+ "Server Availability Zone not aligned with Guidelines, Resource ID [FSB2]");
+ Assert.assertEquals(messages.get("first.yaml").getErrorMessageList().get(1).getMessage(),
+ "Server Availability Zone not aligned with Guidelines, Resource ID [FSB3]");
+ }
+
+ @Test
+ public void testFloatingIpResourceType() {
+ Map<String, MessageContainer> messages = runValidation(
+ "/openecomp/org/validation/validators/ecompGuideLineValidator/heatFloatingIpResourceType/positive");
+ Assert.assertNotNull(messages);
+ Assert.assertEquals(messages.size(), 0);
+
+
+ messages = runValidation(
+ "/openecomp/org/validation/validators/ecompGuideLineValidator/heatFloatingIpResourceType/negative");
+ 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(),
+ "OS::Neutron::FloatingIP is in use, Resource ID [FSB2]");
+ }
+
+ @Test
+ public void testImageAndFlavorNames() {
+ Map<String, MessageContainer> messages = runValidation(
+ "/openecomp/org/validation/validators/ecompGuideLineValidator/heatNovaServerImageAndFlavor/positive");
+ Assert.assertNotNull(messages);
+ Assert.assertEquals(messages.size(), 0);
+
+ messages = runValidation(
+ "/openecomp/org/validation/validators/ecompGuideLineValidator/heatNovaServerImageAndFlavor/negative");
+ Assert.assertNotNull(messages);
+ Assert.assertEquals(messages.size(), 1);
+ Assert.assertEquals(messages.get("first.yaml").getErrorMessageList().size(), 2);
+ Assert.assertEquals(messages.get("first.yaml").getErrorMessageList().get(0).getMessage(),
+ "Wrong flavor name format in NOVA Server, Resource ID [FSB2]");
+ Assert.assertEquals(messages.get("first.yaml").getErrorMessageList().get(1).getMessage(),
+ "Wrong image name format in NOVA Server, Resource ID [FSB3]");
+ }
+
+
+ @Override
+ public Map<String, MessageContainer> runValidation(String path) {
+ EcompGuideLineValidator validator = new EcompGuideLineValidator();
+ return testValidator(validator, path);
+ }
+} \ 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/validators/EcompNamingConventionTest.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/validators/EcompNamingConventionTest.java
new file mode 100644
index 0000000000..e4203945aa
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/validators/EcompNamingConventionTest.java
@@ -0,0 +1,104 @@
+package org.openecomp.sdc.validation.impl.validators.validators;
+
+import org.openecomp.sdc.validation.impl.validators.EcompGuideLineValidator;
+import org.openecomp.sdc.validation.impl.validators.ValidatorBaseTest;
+import org.openecomp.core.validation.types.MessageContainer;
+
+import java.io.IOException;
+import java.util.Map;
+
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+public class EcompNamingConventionTest extends ValidatorBaseTest {
+
+ @Test
+ public void testNeutronFixedIpName() throws IOException {
+ Map<String, MessageContainer> messages = runValidation(
+ "/openecomp/org/validation/validators/ecomp_naming_convention/neutron_port_fixed_ip_name/input");
+
+ Assert.assertNotNull(messages);
+ Assert.assertEquals(messages.size(), 2);
+
+ Assert.assertEquals(messages.get("hot-nimbus-pps_v1.0.yaml").getErrorMessageList().size(), 3);
+ Assert.assertEquals(
+ messages.get("hot-nimbus-pps_v1.0.yaml").getErrorMessageList().get(0).getMessage(),
+ "Fixed_IPS not aligned with Guidelines, Resource ID [fixed_ip_illegal_name_1]");
+ Assert.assertEquals(
+ messages.get("hot-nimbus-pps_v1.0.yaml").getErrorMessageList().get(1).getMessage(),
+ "Fixed_IPS not aligned with Guidelines, Resource ID [fixed_ip_illegal_name_2]");
+ Assert.assertEquals(
+ messages.get("hot-nimbus-pps_v1.0.yaml").getErrorMessageList().get(2).getMessage(),
+ "Fixed_IPS not aligned with Guidelines, Resource ID [fixed_ip_illegal_name_3]");
+ }
+
+
+ @Test
+ public void testNovaServerName() throws IOException {
+ Map<String, MessageContainer> messages = runValidation(
+ "/openecomp/org/validation/validators/ecomp_naming_convention/nova_server_name/input");
+
+ Assert.assertNotNull(messages);
+ Assert.assertEquals(messages.size(), 2);
+
+ Assert.assertEquals(messages.get("hot-nimbus-pps_v1.0.yaml").getErrorMessageList().size(), 6);
+ Assert.assertEquals(
+ messages.get("hot-nimbus-pps_v1.0.yaml").getErrorMessageList().get(0).getMessage(),
+ "Server Name not aligned with Guidelines, Resource ID [nova_server_ilegal_name_1]");
+ Assert.assertEquals(
+ messages.get("hot-nimbus-pps_v1.0.yaml").getErrorMessageList().get(1).getMessage(),
+ "Server Name not aligned with Guidelines, Resource ID [nova_server_ilegal_name_2]");
+ Assert.assertEquals(
+ messages.get("hot-nimbus-pps_v1.0.yaml").getErrorMessageList().get(2).getMessage(),
+ "Server Name not aligned with Guidelines, Resource ID [nova_server_ilegal_name_3]");
+ Assert.assertEquals(
+ messages.get("hot-nimbus-pps_v1.0.yaml").getErrorMessageList().get(3).getMessage(),
+ "Server Name not aligned with Guidelines, Resource ID [nova_server_ilegal_name_4]");
+ Assert.assertEquals(
+ messages.get("hot-nimbus-pps_v1.0.yaml").getErrorMessageList().get(4).getMessage(),
+ "Server Name not aligned with Guidelines, Resource ID [nova_server_ilegal_name_5]");
+ Assert.assertEquals(
+ messages.get("hot-nimbus-pps_v1.0.yaml").getErrorMessageList().get(5).getMessage(),
+ "Missing get_param in nova server name, Resource Id [nova_server_ilegal_name_6]");
+ }
+
+
+ @Test
+ public void testAvailabilityZoneName() throws IOException {
+ Map<String, MessageContainer> messages = runValidation(
+ "/openecomp/org/validation/validators/ecomp_naming_convention/availability_zone_name/input");
+
+ Assert.assertNotNull(messages);
+ Assert.assertEquals(messages.size(), 2);
+
+ Assert.assertEquals(messages.get("hot-nimbus-pps_v1.0.yaml").getErrorMessageList().size(), 2);
+ Assert.assertEquals(
+ messages.get("hot-nimbus-pps_v1.0.yaml").getErrorMessageList().get(0).getMessage(),
+ "Server Availability Zone not aligned with Guidelines, Resource ID [availability_zone_illegal_name_1]");
+ Assert.assertEquals(
+ messages.get("hot-nimbus-pps_v1.0.yaml").getErrorMessageList().get(1).getMessage(),
+ "Server Availability Zone not aligned with Guidelines, Resource ID [availability_zone_illegal_name_2]");
+ }
+
+
+ @Test
+ public void testFloatingIpResourceType() throws IOException {
+ Map<String, MessageContainer> messages = runValidation(
+ "/openecomp/org/validation/validators/ecomp_naming_convention/floating_ip_resource_type/input");
+
+ Assert.assertNotNull(messages);
+ Assert.assertEquals(messages.size(), 2);
+
+ Assert.assertEquals(messages.get("hot-nimbus-pps_v1.0.yaml").getErrorMessageList().size(), 1);
+ Assert.assertEquals(
+ messages.get("hot-nimbus-pps_v1.0.yaml").getErrorMessageList().get(0).getMessage(),
+ "OS::Neutron::FloatingIP is in use, Resource ID [floating_ip_type]");
+ }
+
+
+ @Override
+ public Map<String, MessageContainer> runValidation(String path) {
+ EcompGuideLineValidator ecompGuideLineValidator = new EcompGuideLineValidator();
+ return testValidator(ecompGuideLineValidator, path);
+ }
+} \ 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/validators/HeatValidatorTest.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/validators/HeatValidatorTest.java
new file mode 100644
index 0000000000..9ff375c1a3
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/validators/HeatValidatorTest.java
@@ -0,0 +1,356 @@
+package org.openecomp.sdc.validation.impl.validators.validators;
+
+import org.openecomp.sdc.validation.impl.validators.HeatValidator;
+import org.openecomp.sdc.validation.impl.validators.ValidatorBaseTest;
+import org.openecomp.core.validation.types.MessageContainer;
+
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+import java.io.IOException;
+import java.util.Map;
+
+public class HeatValidatorTest extends ValidatorBaseTest {
+
+
+ @Test
+ public void testInvalidHeatFormat(){
+ Map<String, MessageContainer> messages = runValidation("/openecomp/org/validation/validators/heat_validator/invalid_heat_format/negative_test/input");
+
+ Assert.assertNotNull(messages);
+ Assert.assertEquals(messages.size(), 1);
+
+ Assert.assertEquals(messages.get("hot-nimbus-psm_v1.0.yaml").getErrorMessageList().size(), 1);
+ Assert.assertEquals(messages.get("hot-nimbus-psm_v1.0.yaml").getErrorMessageList().get(0).getMessage(), "Invalid HEAT format problem - [Cannot create property=kuku for JavaBean=Resource{type='null', properties=null, metadata=null, depends_on=null, update_policy='null', deletion_policy='null'}\n" +
+ " in 'reader', line 25, column 5:\n" +
+ " kuku: kuku\n" +
+ " ^\n" +
+ "Unable to find property 'kuku' on class: org.openecomp.sdc.heat.datatypes.model.Resource\n" +
+ " in 'reader', line 25, column 11:\n" +
+ " kuku: kuku\n" +
+ " ^\n" +
+ "]");
+ }
+
+
+ @Test
+ public void testResourcesReferencesExistInHeat() throws IOException {
+ Map<String, MessageContainer> messages = runValidation("/openecomp/org/validation/validators/heat_validator/resource_references_exist_in_heat/negative_test/input");
+
+ Assert.assertNotNull(messages);
+ Assert.assertEquals(messages.size(), 1);
+
+ Assert.assertEquals(messages.get("hot-nimbus-pps_v1.0.yaml").getErrorMessageList().size(), 2);
+ Assert.assertEquals(messages.get("hot-nimbus-pps_v1.0.yaml").getErrorMessageList().get(0).getMessage(), "Referenced resource - not_existing_resource not found");
+ Assert.assertEquals(messages.get("hot-nimbus-pps_v1.0.yaml").getErrorMessageList().get(1).getMessage(), "invalid get_resource syntax is in use - null , get_resource function should get the resource id of the referenced resource");
+ }
+
+
+ @Test
+ public void testGetResourceValueIsValid(){
+ Map<String, MessageContainer> messages = runValidation("/openecomp/org/validation/validators/heat_validator/get_resource_value_valid/negative_test/input");
+
+ Assert.assertNotNull(messages);
+ Assert.assertEquals(messages.size(), 1);
+
+ Assert.assertEquals(messages.get("hot-nimbus-pps_v1.0.yaml").getErrorMessageList().size(), 3);
+ Assert.assertEquals(messages.get("hot-nimbus-pps_v1.0.yaml").getErrorMessageList().get(0).getMessage(), "invalid get_resource syntax is in use - [param_1, param_2] , get_resource function should get the resource id of the referenced resource");
+ Assert.assertEquals(messages.get("hot-nimbus-pps_v1.0.yaml").getErrorMessageList().get(1).getMessage(), "invalid get_resource syntax is in use - {get_param=param_1} , get_resource function should get the resource id of the referenced resource");
+ Assert.assertEquals(messages.get("hot-nimbus-pps_v1.0.yaml").getErrorMessageList().get(2).getMessage(), "invalid get_resource syntax is in use - null , get_resource function should get the resource id of the referenced resource");
+ }
+
+ @Test
+ public void testTwoResourcesDoesNotHoldSameId() throws IOException {
+ Map<String, MessageContainer> messages = runValidation("/openecomp/org/validation/validators/heat_validator/two_resources_does_not_hold_same_id/positive_test/input");
+ Assert.assertNotNull(messages);
+ Assert.assertEquals(messages.size(), 0);
+ }
+
+ @Test
+ public void negativeTestGetParamPointToExistingParameter() throws IOException {
+ Map<String, MessageContainer> messages = runValidation("/openecomp/org/validation/validators/heat_validator/get_param_points_to_existing_parameter/negative_test/input");
+
+ Assert.assertNotNull(messages);
+ Assert.assertEquals(messages.size(), 1);
+
+ Assert.assertEquals(messages.get("hot-nimbus-psm_v1.0.yaml").getErrorMessageList().size(), 1);
+ Assert.assertEquals(messages.get("hot-nimbus-psm_v1.0.yaml").getErrorMessageList().get(0).getMessage(), "Referenced parameter - not_existing_param_1 - not found, used in resource - server_pcrf_psm_001");
+ }
+
+ @Test
+ public void testGetAttrFromNested() throws IOException {
+ Map<String, MessageContainer> messages = runValidation("/openecomp/org/validation/validators/heat_validator/get_attr_from_nested/negative_test/input");
+
+ Assert.assertNotNull(messages);
+ Assert.assertEquals(messages.size(), 1);
+
+ Assert.assertEquals(messages.get("hot-nimbus-psm_v1.0.yaml").getErrorMessageList().size(), 1);
+ Assert.assertEquals(messages.get("hot-nimbus-psm_v1.0.yaml").getErrorMessageList().get(0).getMessage(), "get_attr attribute not found - nested_output in resource server_pcrf_psm_001");
+ }
+
+ @Test
+ public void testPropertiesMatchNestedParameters() throws IOException {
+ Map<String, MessageContainer> messages = runValidation("/openecomp/org/validation/validators/heat_validator/properties_match_nested_parameters/negative_test/input");
+
+ Assert.assertNotNull(messages);
+ Assert.assertEquals(messages.size(), 1);
+
+ Assert.assertEquals(messages.get("hot-nimbus-pps_v1.0.yaml").getErrorMessageList().size(), 1);
+ Assert.assertEquals(messages.get("hot-nimbus-pps_v1.0.yaml").getErrorMessageList().get(0).getMessage(), "Referenced parameter not found in nested file - nested-pps_v1.0.yaml, resource name - server_pcrf_pps_001, parameter name - parameter_not_existing_in_nested");
+ }
+
+ @Test
+ public void testNovaPropertiesHasAssignedValue() throws IOException {
+ Map<String, MessageContainer> messages = runValidation("/openecomp/org/validation/validators/heat_validator/nova_properties_has_assigned_value/negative_test/input");
+
+ Assert.assertNotNull(messages);
+ Assert.assertEquals(messages.size(), 1);
+
+ Assert.assertEquals(messages.get("hot-nimbus-psm_v1.0.yaml").getErrorMessageList().size(), 1);
+ Assert.assertEquals(messages.get("hot-nimbus-psm_v1.0.yaml").getErrorMessageList().get(0).getMessage(), "Missing both Image and Flavor in NOVA Server - nova_server_resource_missing_both");
+ }
+
+ @Test
+ public void testNoLoopsNesting() throws IOException {
+ Map<String, MessageContainer> messages = runValidation("/openecomp/org/validation/validators/heat_validator/no_loops_nesting/negative_test/input");
+
+ Assert.assertNotNull(messages);
+ Assert.assertEquals(messages.size(), 4);
+
+ Assert.assertEquals(messages.get("hot-nimbus-psm_v1.0.yaml").getErrorMessageList().size(), 2);
+ Assert.assertEquals(messages.get("hot-nimbus-psm_v1.0.yaml").getErrorMessageList().get(0).getMessage(), "A resource has an invalid or unsupported type - null, Resource ID [server_pcrf_psm_002]");
+ Assert.assertEquals(messages.get("hot-nimbus-psm_v1.0.yaml").getErrorMessageList().get(1).getMessage(), "Nested files loop - [hot-nimbus-psm_v1.0.yaml -- nested-psm_v1.0.yaml -- nested-points-to-hot-nimbus-psm.yaml -- hot-nimbus-psm_v1.0.yaml]");
+
+ Assert.assertEquals(messages.get("nested-points-to-hot-nimbus-psm.yaml").getErrorMessageList().size(), 2);
+ Assert.assertEquals(messages.get("nested-points-to-hot-nimbus-psm.yaml").getErrorMessageList().get(0).getMessage(), "Nested files loop - [nested-points-to-hot-nimbus-psm.yaml -- hot-nimbus-psm_v1.0.yaml -- nested-psm_v1.0.yaml -- nested-points-to-hot-nimbus-psm.yaml]");
+ Assert.assertEquals(messages.get("nested-points-to-hot-nimbus-psm.yaml").getErrorMessageList().get(1).getMessage(), "Nested files loop - [nested-points-to-hot-nimbus-psm.yaml -- nested-psm_v1.0.yaml -- nested-points-to-hot-nimbus-psm.yaml]");
+
+ Assert.assertEquals(messages.get("yaml-point-to-itself.yaml").getErrorMessageList().size(), 1);
+ Assert.assertEquals(messages.get("yaml-point-to-itself.yaml").getErrorMessageList().get(0).getMessage(), "Nested files loop - [yaml-point-to-itself.yaml -- yaml-point-to-itself.yaml]");
+
+ Assert.assertEquals(messages.get("nested-psm_v1.0.yaml").getErrorMessageList().size(), 1);
+ Assert.assertEquals(messages.get("nested-psm_v1.0.yaml").getErrorMessageList().get(0).getMessage(), "Nested files loop - [nested-psm_v1.0.yaml -- nested-points-to-hot-nimbus-psm.yaml -- hot-nimbus-psm_v1.0.yaml -- nested-psm_v1.0.yaml]");
+ }
+
+ @Test
+ public void testOnlyOneNovaPointsToOnePort() throws IOException {
+ Map<String, MessageContainer> messages = runValidation("/openecomp/org/validation/validators/heat_validator/one_nova_points_to_one_port/negative_test/input");
+
+ Assert.assertNotNull(messages);
+ Assert.assertEquals(messages.size(), 1);
+
+ Assert.assertEquals(messages.get("hot-nimbus-psm_v1.0.yaml").getErrorMessageList().size(), 1);
+ Assert.assertEquals(messages.get("hot-nimbus-psm_v1.0.yaml").getErrorMessageList().get(0).getMessage(), "Resource Port oam1_int_port exceed allowed relations from NovaServer");
+ }
+
+ @Test
+ public void testServerGroupsPointedByServersDefinedCorrectly() throws IOException {
+ Map<String, MessageContainer> messages = runValidation("/openecomp/org/validation/validators/heat_validator/server_groups_defined_correctly/negative_test/input");
+
+ Assert.assertNotNull(messages);
+ Assert.assertEquals(messages.size(), 1);
+
+ Assert.assertEquals(messages.get("hot-nimbus-pps_v1.0.yaml").getErrorMessageList().size(), 3);
+ Assert.assertEquals(messages.get("hot-nimbus-pps_v1.0.yaml").getErrorMessageList().get(0).getMessage(), "Missing server group definition - BE_Affinity_2, nova_server_1");
+ Assert.assertEquals(messages.get("hot-nimbus-pps_v1.0.yaml").getErrorMessageList().get(1).getMessage(), "Missing server group definition - BE_Affinity_2, nova_server_2");
+ Assert.assertEquals(messages.get("hot-nimbus-pps_v1.0.yaml").getErrorMessageList().get(2).getMessage(), "Referenced resource - BE_Affinity_1 not found");
+ }
+
+
+ @Test
+ public void testPolicyIsAffinityOrAntiAffinity() throws IOException {
+ Map<String, MessageContainer> messages = runValidation("/openecomp/org/validation/validators/heat_validator/policy_is_affinity_or_anti_affinity/negative_test/input");
+
+ Assert.assertNotNull(messages);
+ Assert.assertEquals(messages.size(), 1);
+
+ Assert.assertEquals(messages.get("hot-nimbus-psm_v1.0.yaml").getErrorMessageList().size(), 1);
+ Assert.assertEquals(messages.get("hot-nimbus-psm_v1.0.yaml").getErrorMessageList().get(0).getMessage(), "Wrong policy in server group - pcrf_server_policies_1");
+ }
+
+
+ @Test
+ public void testEnvContentIsSubSetOfHeatParameters() throws IOException {
+ Map<String, MessageContainer> messages = runValidation("/openecomp/org/validation/validators/heat_validator/env_content_is_subset_of_heat/negative_test/input");
+
+ Assert.assertNotNull(messages);
+ Assert.assertEquals(messages.size(), 1);
+
+ Assert.assertEquals(messages.get("hot-nimbus-pps_v1.0.env").getErrorMessageList().size(), 1);
+ Assert.assertEquals(messages.get("hot-nimbus-pps_v1.0.env").getErrorMessageList().get(0).getMessage(), "Env file hot-nimbus-pps_v1.0.env includes a parameter not in HEAT - mock_param");
+ }
+
+ @Test
+ public void testDefaultValueAlignWithType() throws IOException {
+ Map<String, MessageContainer> messages = runValidation("/openecomp/org/validation/validators/heat_validator/default_value_align_with_type/negative_test/input");
+
+ Assert.assertNotNull(messages);
+ Assert.assertEquals(messages.size(), 1);
+
+ Assert.assertEquals(messages.get("hot-nimbus-pps_v1.0.yaml").getErrorMessageList().size(), 1);
+ Assert.assertEquals(messages.get("hot-nimbus-pps_v1.0.yaml").getErrorMessageList().get(0).getMessage(), "Parameter - pcrf_pps_image_name_1 default value not align with type number");
+ }
+
+
+ @Test
+ public void testEnvParametersMatchDefinedHeatParameterTypes() throws IOException {
+ Map<String, MessageContainer> messages = runValidation("/openecomp/org/validation/validators/heat_validator/env_parameters_match_defined_types/negative_test/input");
+
+ Assert.assertNotNull(messages);
+ Assert.assertEquals(messages.size(), 1);
+
+ Assert.assertEquals(messages.get("hot-nimbus-pps_v1.0.env").getErrorMessageList().size(), 1);
+ Assert.assertEquals(messages.get("hot-nimbus-pps_v1.0.env").getErrorMessageList().get(0).getMessage(), "Parameter env value pcrf_pps_flavor_name not align with type");
+
+ }
+
+ @Test
+ public void testReferencedArtifactsExist() throws IOException {
+ Map<String, MessageContainer> messages = runValidation("/openecomp/org/validation/validators/heat_validator/referenced_artifacts_exist/negative_test/input");
+
+ Assert.assertNotNull(messages);
+ Assert.assertEquals(messages.size(), 1);
+
+ Assert.assertEquals(messages.get("hot-nimbus-pps_v1.0.yaml").getErrorMessageList().size(), 1);
+ Assert.assertEquals(messages.get("hot-nimbus-pps_v1.0.yaml").getErrorMessageList().get(0).getMessage(), "Missing artifact - nimbus-ethernet");
+
+ }
+
+
+ @Test
+ public void testResourcesGroupWithNested() throws IOException {
+ Map<String, MessageContainer> messages = runValidation("/openecomp/org/validation/validators/heat_validator/resources_group_with_nested/negative_test/input");
+
+ Assert.assertNotNull(messages);
+ Assert.assertEquals(messages.size(), 3);
+
+ Assert.assertEquals(messages.get("hot-nimbus-psm_v1.0.yaml").getErrorMessageList().size(), 2);
+ Assert.assertEquals(messages.get("hot-nimbus-psm_v1.0.yaml").getErrorMessageList().get(0).getMessage(), "Referenced parameter not found in nested file - nested-from-resources-group.yaml, resource name - nested-from-resources-group.yaml, parameter name - property_not_in_nested");
+ Assert.assertEquals(messages.get("hot-nimbus-psm_v1.0.yaml").getErrorMessageList().get(1).getMessage(), "OS::Heat::ResourceGroup resource with resource_def which is not pointing to nested heat file is not supported, Resource ID [resource_without_resources_group], resource_def type [OS::Nova::Server]");
+
+ Assert.assertEquals(messages.get("nested-pps_v1.0.yaml").getErrorMessageList().size(), 1);
+ Assert.assertEquals(messages.get("nested-pps_v1.0.yaml").getErrorMessageList().get(0).getMessage(), "Nested files loop - [nested-pps_v1.0.yaml -- nested-from-resources-group.yaml -- hot-nimbus-pps_v1.0.yaml -- nested-pps_v1.0.yaml]");
+
+ Assert.assertEquals(messages.get("nested-not-exist.yaml").getErrorMessageList().size(), 1);
+ Assert.assertEquals(messages.get("nested-not-exist.yaml").getErrorMessageList().get(0).getMessage(), "Missing nested file - nested-not-exist.yaml");
+ }
+
+
+ @Test
+ public void testResourceGroupWithInvalidType(){
+ Map<String, MessageContainer> messages = runValidation("/openecomp/org/validation/validators/heat_validator/resource_group_invalid_type/negative_test/input");
+
+ Assert.assertNotNull(messages);
+ Assert.assertEquals(messages.size(), 1);
+
+ Assert.assertEquals(messages.get("hot-nimbus-psm_v1.0.yaml").getErrorMessageList().size(), 3);
+ Assert.assertEquals(messages.get("hot-nimbus-psm_v1.0.yaml").getErrorMessageList().get(0).getMessage(), "OS::Heat::ResourceGroup resource with resource_def which is not pointing to nested heat file is not supported, Resource ID [resource_with_resources_group_1], resource_def type [{get_param=pcrf_vnf_id}]");
+ Assert.assertEquals(messages.get("hot-nimbus-psm_v1.0.yaml").getErrorMessageList().get(1).getMessage(), "OS::Heat::ResourceGroup resource with resource_def which is not pointing to nested heat file is not supported, Resource ID [resource_with_resources_group_2], resource_def type [OS::Nova::Server]");
+ Assert.assertEquals(messages.get("hot-nimbus-psm_v1.0.yaml").getErrorMessageList().get(2).getMessage(), "A resource has an invalid or unsupported type - null, Resource ID [resource_with_resources_group_3]");
+ }
+
+
+ @Test
+ public void testNetworkPolicyAssociatedWithAttachPolicy() throws IOException {
+ Map<String, MessageContainer> messages = runValidation("/openecomp/org/validation/validators/heat_validator/network_policy_associated_with_attach_policy/input");
+
+ Assert.assertNotNull(messages);
+ Assert.assertEquals(messages.size(), 1);
+
+ Assert.assertEquals(messages.get("hot-nimbus-pps_v1.0.yaml").getErrorMessageList().size(), 1);
+ Assert.assertEquals(messages.get("hot-nimbus-pps_v1.0.yaml").getErrorMessageList().get(0).getMessage(), "NetworkPolicy not in use, Resource Id [not_used_server_pcrf_policy]");
+ }
+
+
+ @Test
+ public void testSecurityGroupsCalledByPort() throws IOException {
+ Map<String, MessageContainer> messages = runValidation("/openecomp/org/validation/validators/heat_validator/security_group_called_by_port/input");
+
+ Assert.assertNotNull(messages);
+ Assert.assertEquals(messages.size(), 1);
+
+ Assert.assertEquals(messages.get("hot-nimbus-pps_v1.0.yaml").getErrorMessageList().size(), 2);
+ Assert.assertEquals(messages.get("hot-nimbus-pps_v1.0.yaml").getErrorMessageList().get(0).getMessage(), "SecurityGroup not in use, Resource Id [not_used_security_group]");
+ Assert.assertEquals(messages.get("hot-nimbus-pps_v1.0.yaml").getErrorMessageList().get(1).getMessage(), "Port not bind to any NOVA Server, Resource Id [attach_policy_resource]");
+ }
+
+
+ @Test
+ public void testServerGroupCalledByServer() throws IOException {
+ Map<String, MessageContainer> messages = runValidation("/openecomp/org/validation/validators/heat_validator/server_group_called_by_nova_server/input");
+
+ Assert.assertNotNull(messages);
+ Assert.assertEquals(messages.size(), 1);
+
+ Assert.assertEquals(messages.get("hot-nimbus-pps_v1.0.yaml").getErrorMessageList().size(), 1);
+ Assert.assertEquals(messages.get("hot-nimbus-pps_v1.0.yaml").getErrorMessageList().get(0).getMessage(), "ServerGroup not in use, Resource Id [not_used_server_group]");
+
+ }
+
+
+ @Test
+ public void testSecurityGroupBaseFileNoPorts() throws IOException {
+ Map<String, MessageContainer> messages = runValidation("/openecomp/org/validation/validators/heat_validator/security_group_base_file_no_ports/input");
+
+ Assert.assertNotNull(messages);
+ Assert.assertEquals(messages.size(), 1);
+
+ Assert.assertEquals(messages.get("baseFile.yaml").getErrorMessageList().size(), 1);
+ Assert.assertEquals(messages.get("baseFile.yaml").getErrorMessageList().get(0).getMessage(), "SecurityGroup not in use, Resource Id [shared_security_group_id3]");
+ }
+
+
+ @Test
+ public void testDependsOn(){
+ Map<String, MessageContainer> messages = runValidation("/openecomp/org/validation/validators/heat_validator/depends_on_points_to_existing_resource/input");
+
+ Assert.assertNotNull(messages);
+ Assert.assertEquals(messages.size(), 1);
+
+ Assert.assertEquals(messages.get("hot-nimbus-pps_v1.0.yaml").getErrorMessageList().size(), 2);
+ Assert.assertEquals(messages.get("hot-nimbus-pps_v1.0.yaml").getErrorMessageList().get(0).getMessage(), "a Missing resource in depend On Missing Resource ID [resource_not_exist]");
+ Assert.assertEquals(messages.get("hot-nimbus-pps_v1.0.yaml").getErrorMessageList().get(1).getMessage(), "a Missing resource in depend On Missing Resource ID [resource_3]");
+ }
+
+
+ @Test
+ public void testSharedResourcesValidation(){
+ Map<String, MessageContainer> messages = runValidation("/openecomp/org/validation/validators/heat_validator/shared_resources/input");
+
+ Assert.assertNotNull(messages);
+ Assert.assertEquals(messages.size(), 1);
+
+ Assert.assertEquals(messages.get("hot-nimbus-pps_v1.0.yaml").getErrorMessageList().size(), 2);
+ Assert.assertEquals(messages.get("hot-nimbus-pps_v1.0.yaml").getErrorMessageList().get(0).getMessage(), "SecurityGroup not in use, Resource Id [not_used_security_group]");
+ Assert.assertEquals(messages.get("hot-nimbus-pps_v1.0.yaml").getErrorMessageList().get(1).getMessage(), "Port not bind to any NOVA Server, Resource Id [attach_policy_resource]");
+ }
+
+
+ @Test
+ public void testNoErrorWhenEmptyValueForParameterInEnv(){
+ Map<String, MessageContainer> messages = runValidation("/openecomp/org/validation/validators/heat_validator/env_empty_value/input");
+
+ Assert.assertNotNull(messages);
+ Assert.assertEquals(messages.size(), 1);
+
+ MessageContainer envMessages = messages.get("env_empty_value.env");
+ Assert.assertNull(envMessages);
+ }
+
+
+ @Test
+ public void testGetParamPseudoParameters(){
+ Map<String, MessageContainer> messages = runValidation("/openecomp/org/validation/validators/heat_validator/pseudo_parameters/input");
+
+ Assert.assertNotNull(messages);
+ Assert.assertEquals(messages.size(), 0);
+
+ }
+
+
+ @Override
+ public Map<String, MessageContainer> runValidation(String path) {
+ HeatValidator heatValidator = new HeatValidator();
+ return testValidator(heatValidator, path);
+ }
+}
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/validators/ManifestValidatorTest.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/validators/ManifestValidatorTest.java
new file mode 100644
index 0000000000..479a1fb83b
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/validators/ManifestValidatorTest.java
@@ -0,0 +1,125 @@
+package org.openecomp.sdc.validation.impl.validators.validators;
+
+
+import org.openecomp.sdc.common.utils.AsdcCommon;
+import org.openecomp.sdc.validation.impl.validators.ManifestValidator;
+import org.openecomp.sdc.validation.impl.validators.ValidatorBaseTest;
+import org.openecomp.core.validation.errors.Messages;
+import org.openecomp.core.validation.types.MessageContainer;
+
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+import java.util.Map;
+
+public class ManifestValidatorTest extends ValidatorBaseTest {
+
+
+ @Test
+ public void testValidManifest() {
+ Map<String, MessageContainer> messages =
+ runValidation("/openecomp/org/validation/validators/manifestValidator/validFiles");
+ Assert.assertNotNull(messages);
+ Assert.assertNotNull(messages);
+ Assert.assertEquals(messages.size(), 0);
+ }
+
+ @Test
+ public void testManifestMissingFileInZip() {
+ Map<String, MessageContainer> messages =
+ runValidation("/openecomp/org/validation/validators/manifestValidator/missingFileInZip");
+ Assert.assertNotNull(messages);
+ Assert.assertEquals(messages.size(), 1);
+ Assert.assertTrue(messages.containsKey("singleVol.yaml"));
+ validateErrorMessage(messages.get("singleVol.yaml").getErrorMessageList().get(0).getMessage(),
+ Messages.MISSING_FILE_IN_ZIP.getErrorMessage());
+ }
+
+ @Test
+ public void testInvalidManifest() {
+ Map<String, MessageContainer> messages =
+ runValidation("/openecomp/org/validation/validators/manifestValidator/invalidManifest");
+ Assert.assertNotNull(messages);
+ Assert.assertNotNull(messages);
+ Assert.assertEquals(messages.size(), 1);
+ Assert.assertTrue(messages.containsKey(AsdcCommon.MANIFEST_NAME));
+ validateErrorMessage(
+ messages.get(AsdcCommon.MANIFEST_NAME).getErrorMessageList().get(0).getMessage(),
+ Messages.INVALID_MANIFEST_FILE.getErrorMessage(), AsdcCommon.MANIFEST_NAME);
+
+ }
+
+ @Test
+ public void testMissingFileInManifest() {
+ Map<String, MessageContainer> messages =
+ runValidation("/openecomp/org/validation/validators/manifestValidator/missingFileInManifest");
+ Assert.assertNotNull(messages);
+ Assert.assertEquals(messages.size(), 1);
+ Assert.assertTrue(messages.containsKey("extraFile.env"));
+ validateErrorMessage(messages.get("extraFile.env").getErrorMessageList().get(0).getMessage(),
+ Messages.MISSING_FILE_IN_MANIFEST.getErrorMessage());
+
+ }
+
+ @Test
+ public void testInvalidFileTypeInManifest() {
+ Map<String, MessageContainer> messages = runValidation(
+ "/openecomp/org/validation/validators/manifestValidator/invalidFileTypeInManifest");
+ Assert.assertNotNull(messages);
+ Assert.assertEquals(messages.size(), 4);
+ Assert.assertTrue(messages.containsKey("single.env.illegalSuffix"));
+ Assert.assertTrue(messages.containsKey("illegalTypeFile.yaml"));
+ Assert.assertTrue(messages.containsKey("single.yaml.illegalSuffix"));
+ Assert.assertTrue(messages.containsKey("singleVol.yaml.illegalSuffix"));
+ validateErrorMessage(
+ messages.get("single.env.illegalSuffix").getErrorMessageList().get(0).getMessage(),
+ Messages.WRONG_ENV_FILE_EXTENSION.getErrorMessage(), "single.env.illegalSuffix");
+ validateErrorMessage(
+ messages.get("illegalTypeFile.yaml").getErrorMessageList().get(0).getMessage(),
+ Messages.INVALID_FILE_TYPE.getErrorMessage(), "illegalTypeFile.yaml");
+ validateErrorMessage(
+ messages.get("single.yaml.illegalSuffix").getErrorMessageList().get(0).getMessage(),
+ Messages.WRONG_HEAT_FILE_EXTENSION.getErrorMessage(), "single.yaml.illegalSuffix");
+ validateErrorMessage(
+ messages.get("singleVol.yaml.illegalSuffix").getErrorMessageList().get(0).getMessage(),
+ Messages.WRONG_HEAT_FILE_EXTENSION.getErrorMessage(), "singleVol.yaml.illegalSuffix");
+
+ }
+
+
+ @Test
+ public void testMissingFileInManifestAndInZip() {
+
+ Map<String, MessageContainer> messages = runValidation(
+ "/openecomp/org/validation/validators/manifestValidator/missingFileInManifestAndInZip");
+ Assert.assertNotNull(messages);
+ Assert.assertEquals(messages.size(), 2);
+ Assert.assertTrue(messages.containsKey("extraFile.env"));
+ Assert.assertTrue(messages.containsKey("singleVol.yaml"));
+ validateErrorMessage(messages.get("extraFile.env").getErrorMessageList().get(0).getMessage(),
+ Messages.MISSING_FILE_IN_MANIFEST.getErrorMessage());
+ validateErrorMessage(messages.get("singleVol.yaml").getErrorMessageList().get(0).getMessage(),
+ Messages.MISSING_FILE_IN_ZIP.getErrorMessage());
+
+ }
+
+
+ @Test
+ public void testEnvInRoot() {
+ Map<String, MessageContainer> messages =
+ runValidation("/openecomp/org/validation/validators/manifestValidator/envInRoot");
+ Assert.assertNotNull(messages);
+ Assert.assertEquals(messages.size(), 1);
+ Assert.assertTrue(messages.containsKey("second.env"));
+ validateErrorMessage(messages.get("second.env").getErrorMessageList().get(0).getMessage(),
+ "ENV file must be associated to a HEAT file");
+ }
+
+ public Map<String, MessageContainer> runValidation(String path) {
+ ManifestValidator manifestValidator = new ManifestValidator();
+ return testValidator(manifestValidator, path);
+
+ }
+
+
+}
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/validators/YamlValidatorTest.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/validators/YamlValidatorTest.java
new file mode 100644
index 0000000000..abce8ec88c
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/validators/YamlValidatorTest.java
@@ -0,0 +1,89 @@
+package org.openecomp.sdc.validation.impl.validators.validators;
+
+
+import org.openecomp.sdc.validation.impl.validators.ValidatorBaseTest;
+import org.openecomp.sdc.validation.impl.validators.YamlValidator;
+import org.openecomp.core.validation.errors.Messages;
+import org.openecomp.core.validation.types.MessageContainer;
+
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+import java.util.Map;
+
+public class YamlValidatorTest extends ValidatorBaseTest {
+
+
+ public Map<String, MessageContainer> runValidation(String path) {
+ YamlValidator validator = new YamlValidator();
+ return testValidator(validator, path);
+
+ }
+
+ @Test
+ public void testValidYaml() {
+
+ Map<String, MessageContainer> messages = runValidation(
+ "/openecomp/org/validation/validators/yaml_validator/valid_yaml/input/validHeat.yaml");
+ Assert.assertNotNull(messages);
+ Assert.assertEquals(messages.size(), 0);
+ }
+
+// @Test
+ public void testInvalidTabYaml() {
+
+ Map<String, MessageContainer> messages = runValidation(
+ "/openecomp/org/validation/validators/yaml_validator/invalid_valid_yaml_structure/input/invalidYamlTab.yaml");
+ Assert.assertNotNull(messages);
+ Assert.assertEquals(messages.size(), 1);
+ validateErrorMessage(
+ messages.get("invalidYamlTab.yaml").getErrorMessageList().get(0).getMessage(),
+ 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("/openecomp/org/validation/validators/yaml_validator/duplicateKey.yaml");
+ Assert.assertNotNull(messages);
+ Assert.assertEquals(messages.size(), 1);
+ Assert.assertTrue(messages.containsKey("duplicateKey.yaml"));
+ validateErrorMessage(
+ messages.get("duplicateKey.yaml").getErrorMessageList().get(0).getMessage(),
+ 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("/openecomp/org/validation/validators/yaml_validator/invalidYamlStructure.yaml");
+ Assert.assertNotNull(messages);
+ Assert.assertEquals(messages.size(), 1);
+ Assert.assertTrue(messages.containsKey("invalidYamlStructure.yaml"));
+ validateErrorMessage(
+ messages.get("invalidYamlStructure.yaml").getErrorMessageList().get(0).getMessage(),
+ 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("/openecomp/org/validation/validators/yaml_validator/emptyYaml.yaml");
+ Assert.assertNotNull(messages);
+ Assert.assertEquals(messages.size(), 1);
+ Assert.assertTrue(messages.containsKey("emptyYaml.yaml"));
+ validateErrorMessage(messages.get("emptyYaml.yaml").getErrorMessageList().get(0).getMessage(),
+ Messages.INVALID_YAML_FORMAT_REASON.getErrorMessage(),
+ Messages.EMPTY_YAML_FILE.getErrorMessage());
+ }
+
+}