summaryrefslogtreecommitdiffstats
path: root/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java
diff options
context:
space:
mode:
authorAbhai Singh <Abhai.Singh@amdocs.com>2017-11-20 18:27:50 +0530
committerVitaly Emporopulo <Vitaliy.Emporopulo@amdocs.com>2017-11-20 16:17:18 +0000
commit66ed5840294585b55bc632944f19b859d389b3d2 (patch)
tree1e870df0ce3985b3287d053abf620ebee99e18f6 /openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java
parent746d3c490eaf8c92ca6125be97371720f4c8f7c9 (diff)
Adding error codes to HEAT Validator
Added error code to SharedResourceGuideLineValidator Issue-Id :SDC-572 Change-Id: I20c014a1aeb488788bc1faeb05a89ff920258275 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/SharedResourceGuideLineValidatorTest.java78
1 files changed, 52 insertions, 26 deletions
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/SharedResourceGuideLineValidatorTest.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/SharedResourceGuideLineValidatorTest.java
index 5994c23642..e7c2d37d32 100644
--- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/SharedResourceGuideLineValidatorTest.java
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/SharedResourceGuideLineValidatorTest.java
@@ -13,143 +13,169 @@ import java.util.Map;
*/
public class SharedResourceGuideLineValidatorTest {
+ private static final String RESOURCE_PATH = "/org/openecomp/validation/validators/guideLineValidator";
Validator validator = new SharedResourceGuideLineValidator();
@Test
public void testBaseHeatExposeNetwork() {
Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(validator,
- "/org/openecomp/validation/validators/guideLineValidator/baseHeatDoesNotExposeNetwork/positive/");
+ RESOURCE_PATH + "/baseHeatDoesNotExposeNetwork/positive/");
Assert.assertNotNull(messages);
Assert.assertEquals(messages.size(), 0);
messages = ValidationTestUtil.testValidator(validator,
- "/org/openecomp/validation/validators/guideLineValidator/baseHeatDoesNotExposeNetwork/negative/");
+ RESOURCE_PATH + "/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(),
- "WARNING: Resource is not defined as output and thus cannot be Shared, Resource ID [SecurityGroup_expose]");
+ "WARNING: [SRG1]: Resource is not defined as output and thus cannot be Shared, Resource ID [SecurityGroup_expose]");
+ }
+
+ @Test
+ public void testParseException(){
+ Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(validator,
+ RESOURCE_PATH + "/baseHeatDoesNotExposeNetwork/parseException/");
+ Assert.assertEquals(messages.size(), 1);
+ Assert.assertEquals(messages.get("first.yaml").getErrorMessageList().size(), 1);
+ Assert.assertEquals(messages.get("first.yaml").getErrorMessageList().get(0).getMessage(),
+ "ERROR: [SRG5]: 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 5, column 1:\n" +
+ " \t\t\tresources:\n" +
+ " ^\n" +
+ "]");
+ }
+
+ @Test
+ public void testInvalidGetResource(){
+ Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(validator,
+ RESOURCE_PATH + "/" +
+ "baseHeatDoesNotExposeNetworkInvalidGetResource");
+ Assert.assertEquals(messages.get("first.yaml").getErrorMessageList().get(0).getMessage(),
+ "WARNING: [SRG1]: Resource is not defined as output and thus cannot be Shared, Resource ID [net_expose]");
+
}
@Test
public void testBaseHeatExposeNetworkAndVolume() {
Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(validator,
- "/org/openecomp/validation/validators/guideLineValidator/baseHeatDoesNotExposeNetworkAndVolume/positive/");
+ RESOURCE_PATH + "/baseHeatDoesNotExposeNetworkAndVolume/positive/");
Assert.assertNotNull(messages);
Assert.assertEquals(messages.size(), 0);
messages = ValidationTestUtil.testValidator(validator,
- "/org/openecomp/validation/validators/guideLineValidator/baseHeatDoesNotExposeNetworkAndVolume/negative/");
+ RESOURCE_PATH + "/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(),
- "WARNING: Resource is not defined as output and thus cannot be Shared, Resource ID [volume_expose]");
+ "WARNING: [SRG1]: 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(),
- "WARNING: Resource is not defined as output and thus cannot be Shared, Resource ID [net_expose]");
+ "WARNING: [SRG1]: Resource is not defined as output and thus cannot be Shared, Resource ID [net_expose]");
}
@Test
public void testBaseHeatExposeServerGroup() {
Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(validator,
- "/org/openecomp/validation/validators/guideLineValidator/baseHeatDoesNotExposeServerGroup/positive/");
+ RESOURCE_PATH + "/baseHeatDoesNotExposeServerGroup/positive/");
Assert.assertNotNull(messages);
Assert.assertEquals(messages.size(), 0);
messages = ValidationTestUtil.testValidator(validator,
- "/org/openecomp/validation/validators/guideLineValidator/baseHeatDoesNotExposeServerGroup/negative/");
+ RESOURCE_PATH + "/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(),
- "WARNING: Resource is not defined as output and thus cannot be Shared, Resource ID [ServerGroup_expose]");
+ "WARNING: [SRG1]: Resource is not defined as output and thus cannot be Shared, Resource ID [ServerGroup_expose]");
}
@Test
public void testBaseHeatExposeSecurityGroup() {
Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(validator,
- "/org/openecomp/validation/validators/guideLineValidator/baseHeatDoesNotExposeSecurityGroup/positive/");
+ RESOURCE_PATH + "/baseHeatDoesNotExposeSecurityGroup/positive/");
Assert.assertNotNull(messages);
Assert.assertEquals(messages.size(), 0);
messages = ValidationTestUtil.testValidator(validator,
- "/org/openecomp/validation/validators/guideLineValidator/baseHeatDoesNotExposeSecurityGroup/negative/");
+ RESOURCE_PATH + "/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(),
- "WARNING: Resource is not defined as output and thus cannot be Shared, Resource ID [SecurityGroup_expose]");
+ "WARNING: [SRG1]: Resource is not defined as output and thus cannot be Shared, Resource ID [SecurityGroup_expose]");
}
@Test
public void testBaseHeatExposeVolume() {
Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(validator,
- "/org/openecomp/validation/validators/guideLineValidator/baseHeatDoesNotExposeVolume/positive/");
+ RESOURCE_PATH + "/baseHeatDoesNotExposeVolume/positive/");
Assert.assertNotNull(messages);
Assert.assertEquals(messages.size(), 0);
messages = ValidationTestUtil.testValidator(validator,
- "/org/openecomp/validation/validators/guideLineValidator/baseHeatDoesNotExposeVolume/negative/");
+ RESOURCE_PATH + "/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(),
- "WARNING: Resource is not defined as output and thus cannot be Shared, Resource ID [volume_expose]");
+ "WARNING: [SRG1]: Resource is not defined as output and thus cannot be Shared, Resource ID [volume_expose]");
}
@Test
public void testHeatVolumeExpose() {
Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(validator,
- "/org/openecomp/validation/validators/guideLineValidator/heatVolumeExpose/positive/");
+ RESOURCE_PATH + "/heatVolumeExpose/positive/");
Assert.assertNotNull(messages);
Assert.assertEquals(messages.size(), 0);
messages = ValidationTestUtil.testValidator(validator,
- "/org/openecomp/validation/validators/guideLineValidator/heatVolumeExpose/negative/");
+ RESOURCE_PATH + "/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(),
- "WARNING: Volume is not defined as output and thus cannot be attached volume_expose");
+ "WARNING: [SRG2]: Volume is not defined as output and thus cannot be attached volume_expose");
}
@Test
public void testResourceIsExposedByCallingGetResourceNotFromOutput() {
Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(validator,
- "/org/openecomp/validation/validators/guideLineValidator/baseHeatExposeResourceUsingGetResource/positive");
+ RESOURCE_PATH + "/baseHeatExposeResourceUsingGetResource/positive");
Assert.assertNotNull(messages);
Assert.assertEquals(messages.size(), 0);
messages = ValidationTestUtil.testValidator(validator,
- "/org/openecomp/validation/validators/guideLineValidator/baseHeatExposeResourceUsingGetResource/negative");
+ RESOURCE_PATH + "/baseHeatExposeResourceUsingGetResource/negative");
Assert.assertNotNull(messages);
Assert.assertEquals(messages.size(), 1);
Assert.assertEquals(messages.get("base_virc.yaml").getErrorMessageList().size(), 1);
Assert.assertEquals(messages.get("base_virc.yaml").getErrorMessageList().get(0).getMessage(),
- "WARNING: Resource is not defined as output and thus cannot be Shared, Resource ID [virc_RSG]");
+ "WARNING: [SRG1]: Resource is not defined as output and thus cannot be Shared, Resource ID [virc_RSG]");
}
@Test
public void testMissingBaseHeat() {
Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(validator,
- "/org/openecomp/validation/validators/guideLineValidator/missingBaseHeat/");
+ RESOURCE_PATH + "/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(),
- "WARNING: Missing Base HEAT. Pay attention that without Base HEAT, there will be no shared resources");
+ "WARNING: [SRG3]: Missing Base HEAT. Pay attention that without Base HEAT, there will be no shared resources");
}
@Test
public void testMultiBaseHeat() {
Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(validator,
- "/org/openecomp/validation/validators/guideLineValidator/multiBaseHeat/");
+ RESOURCE_PATH + "/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(),
- "WARNING: Multi Base HEAT. Expected only one. Files [second.yaml,first.yaml].");
+ "WARNING: [SRG4]: Multi Base HEAT. Expected only one. Files [second.yaml,first.yaml].");
}
}