diff options
author | Abhai Singh <Abhai.Singh@amdocs.com> | 2017-11-21 11:51:29 +0530 |
---|---|---|
committer | Avi Gaffa <avi.gaffa@amdocs.com> | 2017-11-22 09:39:00 +0000 |
commit | 83a7d1bdcfb13cbb303ffafc032680fcc7827565 (patch) | |
tree | 46139a18399216224392f278689050448999d650 /openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java | |
parent | 9f459654bdd58ad7bbf303fa5f5446acddd2de8e (diff) |
Adding error codes to HEAT Validator
Added error code to ContrailValidator
Issue-Id :SDC-572
Change-Id: Ib0cb270d9c6222677373b2660c77cdd1aaa15367
Signed-off-by: Abhai Singh <Abhai.Singh@amdocs.com>
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/ContrailValidatorTest.java | 70 |
1 files changed, 59 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); |