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/HeatValidatorTest.java114
1 files changed, 79 insertions, 35 deletions
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 471ed7df10..a523627081 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
@@ -34,12 +34,13 @@ import java.util.Map;
public class HeatValidatorTest {
+ private static final String RESOURCE_PATH = "/org/openecomp/validation/validators/heat_validator";
private Validator validator = new HeatValidator();
@Test
public void testInvalidHeatFormat() {
Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(validator,
- "/org/openecomp/validation/validators/heat_validator/invalid_heat_format/negative_test/input");
+ RESOURCE_PATH + "/invalid_heat_format/negative_test/input");
Assert.assertNotNull(messages);
Assert.assertEquals(messages.size(), 1);
@@ -47,21 +48,19 @@ public class HeatValidatorTest {
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(),
- "ERROR: 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" +
- "]");
+ "ERROR: [HOT12]: 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 testDependsOn() {
Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(validator,
- "/org/openecomp/validation/validators/heat_validator/depends_on_points_to_existing_resource/input");
+ RESOURCE_PATH + "/depends_on_points_to_existing_resource/input");
Assert.assertNotNull(messages);
Assert.assertEquals(messages.size(), 1);
@@ -69,17 +68,17 @@ public class HeatValidatorTest {
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(),
- "ERROR: a Missing resource in depend On, Missing Resource ID [resource_not_exist]");
+ "ERROR: [HOT8]: 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(),
- "ERROR: a Missing resource in depend On, Missing Resource ID [resource_3]");
+ "ERROR: [HOT7]: a Missing resource in depend On, Missing Resource ID [resource_3]");
}
@Test
public void testResourcesReferencesExistInHeat() throws IOException {
Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(new HeatValidator(),
- "/org/openecomp/validation/validators/heat_validator/resource_references_exist_in_heat/negative_test/input");
+ RESOURCE_PATH + "/resource_references_exist_in_heat/negative_test/input");
Assert.assertNotNull(messages);
Assert.assertEquals(messages.size(), 1);
@@ -87,17 +86,18 @@ public class HeatValidatorTest {
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(),
- "ERROR: Referenced resource - not_existing_resource not found");
+ "ERROR: [HOT16]: Referenced resource - not_existing_resource not found");
Assert.assertEquals(
messages.get("hot-nimbus-pps_v1.0.yaml").getErrorMessageList().get(1).getMessage(),
- "ERROR: invalid get_resource syntax is in use - null , get_resource function should get the resource id of the referenced resource");
+ "ERROR: [HOT13]: 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 = ValidationTestUtil.testValidator(new HeatValidator(),
- "/org/openecomp/validation/validators/heat_validator/get_resource_value_valid/negative_test/input");
+ RESOURCE_PATH + "/get_resource_value_valid/negative_test/input");
Assert.assertNotNull(messages);
Assert.assertEquals(messages.size(), 1);
@@ -105,27 +105,67 @@ public class HeatValidatorTest {
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(),
- "ERROR: invalid get_resource syntax is in use - [param_1, param_2] , get_resource function should get the resource id of the referenced resource");
+ "ERROR: [HOT13]: 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(),
- "ERROR: invalid get_resource syntax is in use - {get_param=param_1} , get_resource function should get the resource id of the referenced resource");
+ "ERROR: [HOT13]: 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(),
- "ERROR: invalid get_resource syntax is in use - null , get_resource function should get the resource id of the referenced resource");
+ "ERROR: [HOT13]: 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 = ValidationTestUtil.testValidator(new HeatValidator(),
- "/org/openecomp/validation/validators/heat_validator/two_resources_does_not_hold_same_id/positive_test/input");
+ RESOURCE_PATH + "/two_resources_does_not_hold_same_id/positive_test/input");
Assert.assertNotNull(messages);
Assert.assertEquals(messages.size(), 0);
}
@Test
+ public void testWithWrongFileExtension(){
+ Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(new HeatValidator(),
+ RESOURCE_PATH + "/wrongFileExtension");
+ Assert.assertNotNull(messages);
+ Assert.assertEquals(messages.get("single.aad").getErrorMessageList().get(0).getMessage(),
+ "ERROR: [HOT2]: Wrong ENV file extension - single.aad");
+ Assert.assertEquals(messages.get("single.ya").getErrorMessageList().get(0).getMessage(),
+ "ERROR: [HOT6]: Wrong HEAT file extension - single.ya");
+ }
+
+ @Test
+ public void testWithMissingManifestContent(){
+ Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(new HeatValidator(),
+ RESOURCE_PATH + "/missingManifestContent");
+ Assert.assertNotNull(messages);
+ Assert.assertEquals(messages.get("single.yaml").getErrorMessageList().get(0).getMessage(),
+ "ERROR: [HOT9]: Invalid HEAT format problem - [missing template version]");
+ Assert.assertEquals(messages.get("single.yaml").getErrorMessageList().get(1).getMessage(),
+ "WARNING: [HOT10]: Invalid HEAT format problem - " +
+ "[The heat file does not contain any resources]");
+ }
+
+ @Test
+ public void testWithInvalidHeatContent(){
+ Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(new HeatValidator(),
+ RESOURCE_PATH + "/invalidHeatContent");
+ Assert.assertNotNull(messages);
+ Assert.assertEquals(messages.get("single.yaml").getErrorMessageList().get(0).getMessage(),
+ "ERROR: [HOT9]: Invalid HEAT format problem - [missing template version]");
+ Assert.assertEquals(messages.get("single.yaml").getErrorMessageList().get(1).getMessage(),
+ "WARNING: [HOT10]: Invalid HEAT format problem - " +
+ "[The heat file does not contain any resources]");
+ Assert.assertEquals(messages.get("mount_iso_script.sh").getErrorMessageList().get(0).
+ getMessage(),"WARNING: [HOT11]: Artifact file is not referenced.");
+ }
+
+ @Test
public void negativeTestGetParamPointToExistingParameter() throws IOException {
Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(new HeatValidator(),
- "/org/openecomp/validation/validators/heat_validator/get_param_points_to_existing_parameter/negative_test/input");
+ RESOURCE_PATH + "/get_param_points_to_existing_parameter/negative_test/input");
Assert.assertNotNull(messages);
Assert.assertEquals(messages.size(), 1);
@@ -133,13 +173,14 @@ public class HeatValidatorTest {
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(),
- "ERROR: Referenced parameter - not_existing_param_1 - not found, used in resource [server_pcrf_psm_001]");
+ "ERROR: [HOT1]: 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 =ValidationTestUtil.testValidator(new HeatValidator(),
- "/org/openecomp/validation/validators/heat_validator/get_attr_from_nested/negative_test/input");
+ RESOURCE_PATH + "/get_attr_from_nested/negative_test/input");
Assert.assertNotNull(messages);
Assert.assertEquals(messages.size(), 1);
@@ -147,13 +188,14 @@ public class HeatValidatorTest {
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(),
- "ERROR: get_attr attribute not found, Attribute name [nested_output], Resource ID [server_pcrf_psm_001]");
+ "ERROR: [HOT17]: get_attr attribute not found, Attribute name [nested_output], " +
+ "Resource ID [server_pcrf_psm_001]");
}
@Test
public void testDefaultValueAlignWithType() throws IOException {
Map<String, MessageContainer> messages =ValidationTestUtil.testValidator(new HeatValidator(),
- "/org/openecomp/validation/validators/heat_validator/default_value_align_with_type/negative_test/input");
+ RESOURCE_PATH + "/default_value_align_with_type/negative_test/input");
Assert.assertNotNull(messages);
Assert.assertEquals(messages.size(), 1);
@@ -161,14 +203,15 @@ public class HeatValidatorTest {
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(),
- "ERROR: Parameter - pcrf_pps_image_name_1 default value not align with type number");
+ "ERROR: [HOT4]: Parameter - pcrf_pps_image_name_1 default value not align with " +
+ "type number");
}
@Test
public void testEnvParametersMatchDefinedHeatParameterTypes() throws IOException {
Map<String, MessageContainer> messages =ValidationTestUtil.testValidator(new HeatValidator(),
- "/org/openecomp/validation/validators/heat_validator/env_parameters_match_defined_types/negative_test/input");
+ RESOURCE_PATH + "/env_parameters_match_defined_types/negative_test/input");
Assert.assertNotNull(messages);
Assert.assertEquals(messages.size(), 1);
@@ -176,14 +219,14 @@ public class HeatValidatorTest {
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(),
- "ERROR: Parameter env value pcrf_pps_flavor_name not align with type");
+ "ERROR: [HOT5]: Parameter env value pcrf_pps_flavor_name not align with type");
}
@Test
public void testReferencedArtifactsExist() throws IOException {
Map<String, MessageContainer> messages =ValidationTestUtil.testValidator(new HeatValidator(),
- "/org/openecomp/validation/validators/heat_validator/referenced_artifacts_exist/negative_test/input");
+ RESOURCE_PATH + "/referenced_artifacts_exist/negative_test/input");
Assert.assertNotNull(messages);
Assert.assertEquals(messages.size(), 1);
@@ -191,14 +234,14 @@ public class HeatValidatorTest {
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(),
- "ERROR: Missing artifact - nimbus-ethernet");
+ "ERROR: [HOT15]: Missing artifact - nimbus-ethernet");
}
@Test
public void testEnvContentIsSubSetOfHeatParameters() throws IOException {
Map<String, MessageContainer> messages =ValidationTestUtil.testValidator(validator,
- "/org/openecomp/validation/validators/heat_validator/env_content_is_subset_of_heat/negative_test/input");
+ RESOURCE_PATH + "/env_content_is_subset_of_heat/negative_test/input");
Assert.assertNotNull(messages);
Assert.assertEquals(messages.size(), 1);
@@ -206,13 +249,14 @@ public class HeatValidatorTest {
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(),
- "ERROR: Env file hot-nimbus-pps_v1.0.env includes a parameter not in HEAT - mock_param");
+ "ERROR: [HOT3]: Env file hot-nimbus-pps_v1.0.env includes a parameter not in " +
+ "HEAT - mock_param");
}
@Test
public void testGetParamPseudoParameters() {
Map<String, MessageContainer> messages =ValidationTestUtil.testValidator(new HeatValidator(),
- "/org/openecomp/validation/validators/heat_validator/pseudo_parameters/input");
+ RESOURCE_PATH + "/pseudo_parameters/input");
Assert.assertNotNull(messages);
Assert.assertEquals(messages.size(), 0);
@@ -221,7 +265,7 @@ public class HeatValidatorTest {
@Test
public void testNoErrorWhenEmptyValueForParameterInEnv() {
Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(validator,
- "/org/openecomp/validation/validators/heat_validator/env_empty_value/input");
+ RESOURCE_PATH + "/env_empty_value/input");
Assert.assertNotNull(messages);
Assert.assertEquals(messages.size(), 0);