From 9b2e29efa7cc069a119ef2e4894a93a7fc31b6f5 Mon Sep 17 00:00:00 2001 From: mojahidi Date: Mon, 20 Nov 2017 18:24:20 +0530 Subject: ContrailServiceTemplate validator This task is about updating error messages with error codes for ContrailServiceTemplateNamingConventionValidator validator Change-Id: I7d06d0cae2cd3c1ecc10d971db3e7c89bca585a9 Issue-ID:SDC-572 Signed-off-by: mojahidi --- ...rviceTemplateNamingConventionValidatorTest.java | 35 +++++++++++++++------- 1 file changed, 25 insertions(+), 10 deletions(-) (limited to 'openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java') diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/namingconvention/ContrailServiceTemplateNamingConventionValidatorTest.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/namingconvention/ContrailServiceTemplateNamingConventionValidatorTest.java index 1a04d94748..681c54b12e 100644 --- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/namingconvention/ContrailServiceTemplateNamingConventionValidatorTest.java +++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/namingconvention/ContrailServiceTemplateNamingConventionValidatorTest.java @@ -18,40 +18,55 @@ public class ContrailServiceTemplateNamingConventionValidatorTest { HeatResourceValidator baseValidator = new HeatResourceValidator(); ContrailServiceTemplateNamingConventionValidator resourceValidator = new ContrailServiceTemplateNamingConventionValidator(); + private static final String PATH="/org/openecomp/validation/validators/guideLineValidator/heatcontrailservicetemplateimageandflavor/"; @Test public void testContrailServiceTemplateImageAndFlavorNamesAlignedWithNamingConventionButDifferentVmType() { Map messages = ValidationTestUtil.testValidator(baseValidator, - resourceValidator, HeatResourcesTypes.CONTRAIL_SERVICE_TEMPLATE.getHeatResource(), - "/org/openecomp/validation/validators/guideLineValidator/heatcontrailservicetemplateimageandflavor/imageandflavordifferentvmtype"); + resourceValidator, HeatResourcesTypes.CONTRAIL_SERVICE_TEMPLATE.getHeatResource(), + PATH + "imageandflavordifferentvmtype"); Assert.assertNotNull(messages); Assert.assertEquals(messages.size(), 1); Assert.assertEquals( - messages.get(messages.keySet().iterator().next()).getErrorMessageList().size(), 1); + messages.get(messages.keySet().iterator().next()).getErrorMessageList().size(), 1); Assert.assertEquals(messages.get("first.yaml").getErrorMessageList().get(0).getMessage(), - "WARNING: Service Template naming convention in Image and Flavor properties is not consistent in Resource, Resource ID service_template"); + "WARNING: [NST1]: Service Template naming convention in Image and Flavor properties is not consistent in Resource, Resource ID service_template"); } @Test public void testContrailServiceTemplateImageAndFlavorNamesNotAlignedWithNamingConvention() { Map messages = ValidationTestUtil.testValidator(baseValidator, - resourceValidator, HeatResourcesTypes.CONTRAIL_SERVICE_TEMPLATE.getHeatResource(), - "/org/openecomp/validation/validators/guideLineValidator/heatcontrailservicetemplateimageandflavor/notaligned"); + resourceValidator, HeatResourcesTypes.CONTRAIL_SERVICE_TEMPLATE.getHeatResource(), + PATH + "/notaligned"); 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: Service Template 'image_name' Parameter Name not aligned with Guidelines, Parameter Name [st_imaage_name], Resource ID [service_template]. As a result, VF/VFC Profile may miss this information"); + "WARNING: [NST3]: Service Template 'image_name' Parameter Name not aligned with Guidelines, Parameter Name [st_imaage_name], Resource ID [service_template]. As a result, VF/VFC Profile may miss this information"); Assert.assertEquals(messages.get("first.yaml").getErrorMessageList().get(1).getMessage(), - "WARNING: Service Template 'flavor' Parameter Name not aligned with Guidelines, Parameter Name [st_flavaor_name], Resource ID [service_template]. As a result, VF/VFC Profile may miss this information"); + "WARNING: [NST3]: Service Template 'flavor' Parameter Name not aligned with Guidelines, Parameter Name [st_flavaor_name], Resource ID [service_template]. As a result, VF/VFC Profile may miss this information"); } @Test public void testContrailServiceTemplateImageAndFlavorNamesAlignedWithNamingConvention() { Map messages = ValidationTestUtil.testValidator(baseValidator, - resourceValidator, HeatResourcesTypes.CONTRAIL_SERVICE_TEMPLATE.getHeatResource(), - "/org/openecomp/validation/validators/guideLineValidator/heatcontrailservicetemplateimageandflavor/aligned"); + resourceValidator, HeatResourcesTypes.CONTRAIL_SERVICE_TEMPLATE.getHeatResource(), + PATH + "aligned"); Assert.assertNotNull(messages); Assert.assertEquals(messages.size(), 0); } + + @Test + public void testContrailServiceTemplateMissingParam() { + Map messages = ValidationTestUtil.testValidator(baseValidator, + resourceValidator, HeatResourcesTypes.CONTRAIL_SERVICE_TEMPLATE.getHeatResource(), + PATH + "missingparam"); + Assert.assertNotNull(messages); + Assert.assertEquals(messages.size(), 1); + Assert.assertEquals( + messages.get(messages.keySet().iterator().next()).getErrorMessageList().size(), 1); + Assert.assertEquals(messages.get("first.yaml").getErrorMessageList().get(0).getMessage(), + "WARNING: [NST2]: Missing get_param in image_name, Resource Id [service_template]"); + } + } -- cgit 1.2.3-korg