diff options
author | katy.rotman <katy.rotman@amdocs.com> | 2018-02-21 13:14:21 +0200 |
---|---|---|
committer | Vitaly Emporopulo <Vitaliy.Emporopulo@amdocs.com> | 2018-03-04 10:00:26 +0000 |
commit | 7d5ccf3d6207008321595ec45149a370ba80ffe8 (patch) | |
tree | 3a1a3a1dcaa17e1c9925d6cb65ff8a7d2c2c0d43 /openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java | |
parent | 17ef2f46be5686d48d8e77b9b5a504456f169e3b (diff) |
VirtualMachineInterface guildeine validator
Issue-ID: SDC-994
Change-Id: Ia232a384c51facb61eaada66c2924957e68b8f0a
Signed-off-by: katy.rotman <katy.rotman@amdocs.com>
Diffstat (limited to 'openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java')
1 files changed, 189 insertions, 0 deletions
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/namingconvention/VirtualMachineInterfaceGuidelineValidatorTest.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/namingconvention/VirtualMachineInterfaceGuidelineValidatorTest.java new file mode 100644 index 0000000000..407adae932 --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/namingconvention/VirtualMachineInterfaceGuidelineValidatorTest.java @@ -0,0 +1,189 @@ +package org.openecomp.sdc.validation.impl.validators.namingconvention; + +import org.openecomp.core.validation.types.MessageContainer; +import org.openecomp.sdc.heat.datatypes.model.HeatResourcesTypes; +import org.openecomp.sdc.validation.impl.validators.NamingConventionGuideLineValidator; +import org.openecomp.sdc.validation.util.ValidationTestUtil; +import org.testng.Assert; +import org.testng.annotations.Test; + +import java.util.Map; + +public class VirtualMachineInterfaceGuidelineValidatorTest { + private static final String PATH = + "/org/openecomp/validation/validators/guideLineValidator/vlan_validation/"; + + @Test + public void modeledThroughResourceGroupPositive() { + + NamingConventionGuideLineValidator baseValidator = new NamingConventionGuideLineValidator(); + VirtualMachineInterfaceGuidelineValidator resourceValidator = new + VirtualMachineInterfaceGuidelineValidator(); + Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator, + resourceValidator, + HeatResourcesTypes.CONTRAIL_V2_VIRTUAL_MACHINE_INTERFACE_RESOURCE_TYPE.getHeatResource(), + PATH + "modeled_through_resource_group/positive_test/input"); + + Assert.assertNotNull(messages); + Assert.assertEquals(messages.size(), 0); + + } + + @Test + public void modeledThroughResourceGroupNegativeTwoValuesInList() { + + NamingConventionGuideLineValidator baseValidator = new NamingConventionGuideLineValidator(); + VirtualMachineInterfaceGuidelineValidator resourceValidator = new + VirtualMachineInterfaceGuidelineValidator(); + Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator, + resourceValidator, + HeatResourcesTypes.CONTRAIL_V2_VIRTUAL_MACHINE_INTERFACE_RESOURCE_TYPE.getHeatResource(), + PATH + "modeled_through_resource_group/negative_test/input"); + + Assert.assertNotNull(messages); + Assert.assertEquals(messages.size(), 1); + + Assert.assertEquals(messages.get("nested.yml").getErrorMessageList().size(), 1); + Assert.assertEquals( + messages.get("nested.yml").getErrorMessageList().get(0).getMessage(), + "WARNING: [VlANG1]: VLAN Resource will not be translated as the VLAN Sub-interface " + + "[template_vmi_Vlan_2] is not modeled as resource group"); + } + + @Test + public void modeledThroughResourceGroupNegativeNonStringGetParam() { + + NamingConventionGuideLineValidator baseValidator = new NamingConventionGuideLineValidator(); + VirtualMachineInterfaceGuidelineValidator resourceValidator = new + VirtualMachineInterfaceGuidelineValidator(); + Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator, + resourceValidator, + HeatResourcesTypes.CONTRAIL_V2_VIRTUAL_MACHINE_INTERFACE_RESOURCE_TYPE.getHeatResource(), + PATH + "modeled_through_resource_group/negative_test_non_string/input"); + + Assert.assertNotNull(messages); + Assert.assertEquals(messages.size(), 1); + + Assert.assertEquals(messages.get("nested.yml").getErrorMessageList().size(), 1); + Assert.assertEquals( + messages.get("nested.yml").getErrorMessageList().get(0).getMessage(), + "WARNING: [VlANG1]: VLAN Resource will not be translated as the VLAN Sub-interface " + + "[template_vmi_Vlan_2] is not modeled as resource group"); + } + + @Test + public void modeledThroughResourceGroupNegativeResource() { + + NamingConventionGuideLineValidator baseValidator = new NamingConventionGuideLineValidator(); + VirtualMachineInterfaceGuidelineValidator resourceValidator = new + VirtualMachineInterfaceGuidelineValidator(); + Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator, + resourceValidator, + HeatResourcesTypes.CONTRAIL_V2_VIRTUAL_MACHINE_INTERFACE_RESOURCE_TYPE.getHeatResource(), + PATH + "modeled_through_resource_group/negative_get_resource/input"); + + Assert.assertNotNull(messages); + Assert.assertEquals(messages.size(), 1); + + Assert.assertEquals(messages.get("nested.yml").getErrorMessageList().size(), 1); + Assert.assertEquals( + messages.get("nested.yml").getErrorMessageList().get(0).getMessage(), + "WARNING: [VlANG1]: VLAN Resource will not be translated as the VLAN Sub-interface " + + "[template_vmi_Vlan_2] is not modeled as resource group"); + } + + + @Test + public void vlanAloneInFilePositive() { + + NamingConventionGuideLineValidator baseValidator = new NamingConventionGuideLineValidator(); + VirtualMachineInterfaceGuidelineValidator resourceValidator = new + VirtualMachineInterfaceGuidelineValidator(); + Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator, + resourceValidator, + HeatResourcesTypes.CONTRAIL_V2_VIRTUAL_MACHINE_INTERFACE_RESOURCE_TYPE.getHeatResource(), + PATH + "single_vlan_resource/positive_test/input"); + + Assert.assertNotNull(messages); + Assert.assertEquals(messages.size(), 0); + + } + + @Test + public void vlanAloneInFileNegative_2vlans() { + + NamingConventionGuideLineValidator baseValidator = new NamingConventionGuideLineValidator(); + VirtualMachineInterfaceGuidelineValidator resourceValidator = new + VirtualMachineInterfaceGuidelineValidator(); + Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator, + resourceValidator, + HeatResourcesTypes.CONTRAIL_V2_VIRTUAL_MACHINE_INTERFACE_RESOURCE_TYPE.getHeatResource(), + PATH + "single_vlan_resource/negative_test/two_vlans"); + + Assert.assertNotNull(messages); + Assert.assertEquals(messages.size(), 1); + + Assert.assertEquals(messages.get("nested.yml").getErrorMessageList().size(), 1); + Assert.assertEquals( + messages.get("nested.yml").getErrorMessageList().get(0).getMessage(), + "ERROR: [VlANG2]: There should not be any Compute Server Node, Port, " + + "Parent Port in nested file [nested.yml]"); + } + + @Test + public void vlanAloneInFileNegative_vlanAndNova() { + + NamingConventionGuideLineValidator baseValidator = new NamingConventionGuideLineValidator(); + VirtualMachineInterfaceGuidelineValidator resourceValidator = new + VirtualMachineInterfaceGuidelineValidator(); + Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator, + resourceValidator, + HeatResourcesTypes.CONTRAIL_V2_VIRTUAL_MACHINE_INTERFACE_RESOURCE_TYPE.getHeatResource(), + PATH + "single_vlan_resource/negative_test/vlan_and_nova"); + + Assert.assertNotNull(messages); + Assert.assertEquals(messages.size(), 1); + + Assert.assertEquals(messages.get("nested.yml").getErrorMessageList().size(), 1); + Assert.assertEquals( + messages.get("nested.yml").getErrorMessageList().get(0).getMessage(), + "ERROR: [VlANG2]: There should not be any Compute Server Node, Port, " + + "Parent Port in nested file [nested.yml]"); + } + + @Test + public void namingConventionNegative(){ + NamingConventionGuideLineValidator baseValidator = new NamingConventionGuideLineValidator(); + VirtualMachineInterfaceGuidelineValidator resourceValidator = new + VirtualMachineInterfaceGuidelineValidator(); + Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator, + resourceValidator, + HeatResourcesTypes.CONTRAIL_V2_VIRTUAL_MACHINE_INTERFACE_RESOURCE_TYPE.getHeatResource(), + PATH + "naming_convention/negative_test/input"); + + Assert.assertNotNull(messages); + Assert.assertEquals(messages.size(), 1); + + Assert.assertEquals(messages.get("nested.yml").getErrorMessageList().size(), 2); + Assert.assertEquals( + messages.get("nested.yml").getErrorMessageList().get(1).getMessage(), + "WARNING: [VlANG3]: Network role associated with VLAN Sub-interface " + + "id[template_wrong_naming_Vlan_2] is not following the naming convention"); + + } + + @Test + public void namingConventionPositive(){ + NamingConventionGuideLineValidator baseValidator = new NamingConventionGuideLineValidator(); + VirtualMachineInterfaceGuidelineValidator resourceValidator = new + VirtualMachineInterfaceGuidelineValidator(); + Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator, + resourceValidator, + HeatResourcesTypes.CONTRAIL_V2_VIRTUAL_MACHINE_INTERFACE_RESOURCE_TYPE.getHeatResource(), + PATH + "naming_convention/positive_test/input"); + + Assert.assertNotNull(messages); + Assert.assertEquals(messages.size(), 0); + } + +}
\ No newline at end of file |