aboutsummaryrefslogtreecommitdiffstats
path: root/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test')
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/ContrailValidatorTest.java70
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/contrailvalidatorresources/invalidHeatStructure/MANIFEST.json12
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/contrailvalidatorresources/invalidHeatStructure/first.yaml0
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/contrailvalidatorresources/invalidHeatStructureParsingError/MANIFEST.json12
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/contrailvalidatorresources/invalidHeatStructureParsingError/first.yaml18
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/contrailvalidatorresources/parseException/MANIFEST.json17
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/contrailvalidatorresources/parseException/first.yaml22
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/contrailvalidatorresources/parseException/second.yaml19
8 files changed, 159 insertions, 11 deletions
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 30b7f68230..f921102957 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
@@ -36,32 +36,58 @@ import java.util.Map;
*/
public class ContrailValidatorTest {
+ private static final String RESOURCE_PATH = "/org/openecomp/validation/validators/contrailvalidatorresources";
private Validator validator = new ContrailValidator();
@Test
public void testWarningMessageExistWhenConrailV1AndV2ResourcesCollidesInSameHeatFile() {
Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(validator,
- "/org/openecomp/validation/validators/contrailvalidatorresources/collidesinsameheatfile/");
+ RESOURCE_PATH + "/collidesinsameheatfile/");
validateMessage(messages,
- "WARNING: HEAT Package includes both Contrail 2 and Contrail 3 resources. Contrail 2 resources can be found in file 'first.yaml' , resources :'jsa_net1' . Contrail 3 resources can be found in file 'first.yaml' , resources :'jsa_net2' ",
+ "WARNING: [CTL2]: HEAT Package includes both Contrail 2 and Contrail 3 " +
+ "resources. Contrail 2 resources can be found in file 'first.yaml' , resources :" +
+ "'jsa_net1' . Contrail 3 resources can be found in file 'first.yaml' , resources :" +
+ "'jsa_net2' ",
"first.yaml", 2);
}
@Test
+ public void testParseException(){
+ Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(validator,
+ RESOURCE_PATH + "/parseException/");
+ validateMessage(messages,
+ "ERROR: [CTL4]: 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" +
+ "]",
+ "first.yaml", 1);
+
+ }
+
+ @Test
public void testWarningMessageExistWhenConrailV1AndV2ResourcesCollidesInDifferentHeatFiles() {
Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(validator,
- "/org/openecomp/validation/validators/contrailvalidatorresources/collidesindifferentheatfiles/");
+ RESOURCE_PATH + "/collidesindifferentheatfiles/");
validateMessage(messages,
- "WARNING: HEAT Package includes both Contrail 2 and Contrail 3 resources. Contrail 2 resources can be found in file 'first.yaml' , resources :'jsa_net1', 'jsa_net3' . Contrail 3 resources can be found in file 'second.yaml' , resources :'jsa_net2', 'jsa_net4', file 'first.yaml' , resources :'jsa_net5' ",
+ "WARNING: [CTL2]: HEAT Package includes both Contrail 2 and Contrail 3 " +
+ "resources. Contrail 2 resources can be found in file 'first.yaml' , resources :" +
+ "'jsa_net1', 'jsa_net3' . Contrail 3 resources can be found in file 'second.yaml' , " +
+ "resources :'jsa_net2', 'jsa_net4', file 'first.yaml' , resources :'jsa_net5' ",
"first.yaml", 3);
}
@Test
public void testWarningMessageNotExistWhenConrailV1AndV2ResourcesCollidesInNonHeatFile() {
Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(validator,
- "/org/openecomp/validation/validators/contrailvalidatorresources/collidesinnontheatfiles/");
+ RESOURCE_PATH + "/collidesinnontheatfiles/");
validateMessage(messages,
- "WARNING: HEAT Package includes both Contrail 2 and Contrail 3 resources. Contrail 2 resources can be found in file 'first.yaml' , resources :'jsa_net1' . Contrail 3 resources can be found in file 'second.yaml' , resources :'jsa_net2' ",
+ "WARNING: [CTL2]: HEAT Package includes both Contrail 2 and Contrail 3 " +
+ "resources. Contrail 2 resources can be found in file 'first.yaml' , resources :" +
+ "'jsa_net1' . Contrail 3 resources can be found in file 'second.yaml' , " +
+ "resources :'jsa_net2' ",
"first.yaml", 2);
;
}
@@ -69,9 +95,10 @@ public class ContrailValidatorTest {
@Test
public void testWarningMessageNotExistWhenOnlyConrailV1Resources() {
Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(validator,
- "/org/openecomp/validation/validators/contrailvalidatorresources/notcollides/");
+ RESOURCE_PATH + "/notcollides/");
validateMessage(messages,
- "WARNING: Contrail 2.x deprecated resource is in use, Resource ID [jsa_net1]", "first.yaml",
+ "WARNING: [CTL3]: Contrail 2.x deprecated resource is in use, " +
+ "Resource ID [jsa_net1]", "first.yaml",
2);
}
@@ -79,13 +106,34 @@ public class ContrailValidatorTest {
@Test
public void testWarningMessageOnResourceWithContrailType() {
Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(validator,
- "/org/openecomp/validation/validators/contrailvalidatorresources/validatenocontrailresource/");
+ RESOURCE_PATH + "/validatenocontrailresource/");
validateMessage(messages,
- "WARNING: Contrail 2.x deprecated resource is in use, Resource ID [template_NetworkPolicy]",
+ "WARNING: [CTL3]: Contrail 2.x deprecated resource is in use, " +
+ "Resource ID [template_NetworkPolicy]",
"first.yaml", 1);
- ;
}
+ @Test
+ public void testInvalidHeatStructure(){
+ Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(validator,
+ RESOURCE_PATH + "/invalidHeatStructure/");
+ validateMessage(messages,
+ "ERROR: [CTL1]: Invalid HEAT format problem - [The file 'first.yaml' " +
+ "has no content]",
+ "first.yaml", 1);
+ }
+
+ @Test
+ public void testInvalidHeatStructuredueToParsingError(){
+ Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(validator,
+ RESOURCE_PATH + "/invalidHeatStructure/");
+ validateMessage(messages,
+ "ERROR: [CTL1]: Invalid HEAT format problem - [The file 'first.yaml' " +
+ "has no content]",
+ "first.yaml", 1);
+ }
+
+
private void validateMessage(Map<String, MessageContainer> messages, String expectedMessage,
String fileNameWithErrorToCheck, int sizeOfFileMessageList) {
Assert.assertEquals(messages.size(), 1);
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/contrailvalidatorresources/invalidHeatStructure/MANIFEST.json b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/contrailvalidatorresources/invalidHeatStructure/MANIFEST.json
new file mode 100644
index 0000000000..0e8bebb1d1
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/contrailvalidatorresources/invalidHeatStructure/MANIFEST.json
@@ -0,0 +1,12 @@
+{
+ "name": "validTest",
+ "description": "Valid Test",
+ "version": "1610",
+ "data": [
+ {
+ "file": "first.yaml",
+ "type": "HEAT",
+ "isBase": true
+ }
+ ]
+} \ No newline at end of file
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/contrailvalidatorresources/invalidHeatStructure/first.yaml b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/contrailvalidatorresources/invalidHeatStructure/first.yaml
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/contrailvalidatorresources/invalidHeatStructure/first.yaml
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/contrailvalidatorresources/invalidHeatStructureParsingError/MANIFEST.json b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/contrailvalidatorresources/invalidHeatStructureParsingError/MANIFEST.json
new file mode 100644
index 0000000000..0e8bebb1d1
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/contrailvalidatorresources/invalidHeatStructureParsingError/MANIFEST.json
@@ -0,0 +1,12 @@
+{
+ "name": "validTest",
+ "description": "Valid Test",
+ "version": "1610",
+ "data": [
+ {
+ "file": "first.yaml",
+ "type": "HEAT",
+ "isBase": true
+ }
+ ]
+} \ No newline at end of file
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/contrailvalidatorresources/invalidHeatStructureParsingError/first.yaml b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/contrailvalidatorresources/invalidHeatStructureParsingError/first.yaml
new file mode 100644
index 0000000000..a50ca86aa5
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/contrailvalidatorresources/invalidHeatStructureParsingError/first.yaml
@@ -0,0 +1,18 @@
+heat_template_version: 2013-05-23a
+description: cmaui server template for vMMSC
+
+parameters:
+ nems_traffic_name:
+ description: dummy
+ type: string
+
+resources:
+ jsa_net1:
+ type: OS::Contrail::VirtualNetwork
+ proaperties:
+ name: {get_param: nems_traffic_name}
+ jsa_net2:
+ taype: OS::ContrailV2::VirtualNetwork
+ propaerties:
+ name: {get_param: nems_traffic_name}
+
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/contrailvalidatorresources/parseException/MANIFEST.json b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/contrailvalidatorresources/parseException/MANIFEST.json
new file mode 100644
index 0000000000..15650ae299
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/contrailvalidatorresources/parseException/MANIFEST.json
@@ -0,0 +1,17 @@
+{
+ "name": "validTest",
+ "description": "Valid Test",
+ "version": "1610",
+ "data": [
+ {
+ "file": "first.yaml",
+ "type": "HEAT",
+ "isBase": true
+ },
+ {
+ "file": "second.yaml",
+ "type": "HEAT",
+ "isBase": false
+ }
+ ]
+} \ No newline at end of file
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/contrailvalidatorresources/parseException/first.yaml b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/contrailvalidatorresources/parseException/first.yaml
new file mode 100644
index 0000000000..24fe19170d
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/contrailvalidatorresources/parseException/first.yaml
@@ -0,0 +1,22 @@
+heat_template_version: 2013-05-23
+
+description: cmaui server template for vMMSC
+
+parameters:
+ nems_traffic_name:
+ description: dummy
+ type: string
+
+ resources:
+ jsa_net1:
+ type: OS::Contrail::VirtualNetwork
+ properties:
+ name: {get_param: }
+ jsa_net3:
+ type: OS::Contrail::VirtualNetwork
+ properties:
+ name: {get_param: nems_traffic_name}
+ jsa_net5:
+ type: OS::ContrailV2::VirtualNetwork
+ properties:
+ name: {get_param: nems_traffic_name}
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/contrailvalidatorresources/parseException/second.yaml b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/contrailvalidatorresources/parseException/second.yaml
new file mode 100644
index 0000000000..f8cadfee51
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/contrailvalidatorresources/parseException/second.yaml
@@ -0,0 +1,19 @@
+heat_template_version: 2013-05-23
+
+description: cmaui server template for vMMSC
+
+parameters:
+ nems_traffic_name:
+ description: dummy
+ type: string
+
+resources:
+ jsa_net2:
+ type: OS::ContrailV2::VirtualNetwork
+ properties:
+ name: {get_param: nems_traffic_name}
+ jsa_net4:
+ type: OS::ContrailV2::VirtualNetwork
+ properties:
+ name: {get_param: nems_traffic_name}
+