diff options
author | 2018-02-07 17:19:59 +0100 | |
---|---|---|
committer | 2018-02-19 17:16:48 +0000 | |
commit | 3a88d01cee90090f7bf012ea33fe73576e55192a (patch) | |
tree | fdb75a4385784a273250d753ac5a88388efc47d5 /openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org | |
parent | 38b4e81eab76202bcafdec7e0b6374679090ce7e (diff) |
Heat Validation - VirtualMachineInterface
Issue-ID: SDC-994
Change-Id: I0fd23862eebf65437ab0e1a1ad1d44c9a2944990
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/org')
1 files changed, 163 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/heatresource/VirtualMachineInterfaceValidatorTest.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/heatresource/VirtualMachineInterfaceValidatorTest.java new file mode 100644 index 0000000000..c82271e1c7 --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/heatresource/VirtualMachineInterfaceValidatorTest.java @@ -0,0 +1,163 @@ +package org.openecomp.sdc.validation.impl.validators.heatresource; + +import org.openecomp.core.validation.types.MessageContainer; +import org.openecomp.sdc.heat.datatypes.model.HeatResourcesTypes; +import org.openecomp.sdc.validation.impl.validators.HeatResourceValidator; +import org.openecomp.sdc.validation.util.ValidationTestUtil; +import org.testng.Assert; +import org.testng.annotations.Test; + +import java.util.Map; + +/** + * @author KATYR + * @since January 22, 2018 + */ + +public class VirtualMachineInterfaceValidatorTest { + private static final String PATH = + "/org/openecomp/validation/validators/heat_validator/vlan_resource_validation/"; + + + @Test + public void hasSingleParentPortNegative() { + HeatResourceValidator baseValidator = new HeatResourceValidator(); + VirtualMachineInterfaceValidator resourceValidator = new VirtualMachineInterfaceValidator(); + Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator, + resourceValidator, + HeatResourcesTypes.CONTRAIL_V2_VIRTUAL_MACHINE_INTERFACE_RESOURCE_TYPE.getHeatResource(), + PATH + "vlan_multiple_parent_ports/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(), + "ERROR: [VLAN1]: More than one parent port found, " + + "there should be only one parent port for a VLAN sub-interface ID [template_Vlan_2]"); + } + + @Test + public void hasSingleParentPortNegativeWithGetResource() { + HeatResourceValidator baseValidator = new HeatResourceValidator(); + VirtualMachineInterfaceValidator resourceValidator = new VirtualMachineInterfaceValidator(); + Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator, + resourceValidator, + HeatResourcesTypes.CONTRAIL_V2_VIRTUAL_MACHINE_INTERFACE_RESOURCE_TYPE.getHeatResource(), + PATH + "vlan_multiple_parent_ports/negative_get_resource/input"); + + Assert.assertNotNull(messages); + Assert.assertEquals(messages.size(), 0); + } + + + @Test + public void hasSingleParentPortPositive() { + HeatResourceValidator baseValidator = new HeatResourceValidator(); + VirtualMachineInterfaceValidator resourceValidator = new VirtualMachineInterfaceValidator(); + Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator, + resourceValidator, + HeatResourcesTypes.CONTRAIL_V2_VIRTUAL_MACHINE_INTERFACE_RESOURCE_TYPE.getHeatResource(), + PATH + "vlan_multiple_parent_ports/positive_test/input"); + + Assert.assertNotNull(messages); + Assert.assertEquals(messages.size(), 0); + + + } + + + @Test + public void hasBothPropertiesMissingTagNegative() { + HeatResourceValidator baseValidator = new HeatResourceValidator(); + VirtualMachineInterfaceValidator resourceValidator = new VirtualMachineInterfaceValidator(); + Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator, + resourceValidator, + HeatResourcesTypes.CONTRAIL_V2_VIRTUAL_MACHINE_INTERFACE_RESOURCE_TYPE.getHeatResource(), + PATH + "vlan_has_two_properties/negative_tag_missing/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: [VLAN2]: VLAN Tag property " + + "virtual_machine_interface_properties_sub_interface_vlan_tag " + + "is missing in VLAN Resource ID [template_Vlan_2]"); + } + + @Test + public void hasBothPropertiesMissingRefsNegative() { + HeatResourceValidator baseValidator = new HeatResourceValidator(); + VirtualMachineInterfaceValidator resourceValidator = new VirtualMachineInterfaceValidator(); + Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator, + resourceValidator, + HeatResourcesTypes.CONTRAIL_V2_VIRTUAL_MACHINE_INTERFACE_RESOURCE_TYPE.getHeatResource(), + PATH + "vlan_has_two_properties/negative_refs_missing/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: [VLAN2]: Parent port property virtual_machine_interface_refs is " + + "missing in VLAN Resource ID [template_Vlan_2]"); + } + + @Test + public void hasBothPropertiesBothMissingPositiveNotVLAN() { + HeatResourceValidator baseValidator = new HeatResourceValidator(); + VirtualMachineInterfaceValidator resourceValidator = new VirtualMachineInterfaceValidator(); + Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator, + resourceValidator, + HeatResourcesTypes.CONTRAIL_V2_VIRTUAL_MACHINE_INTERFACE_RESOURCE_TYPE.getHeatResource(), + PATH + "vlan_has_two_properties/negative_both_missing/input"); + + Assert.assertNotNull(messages); + Assert.assertEquals(messages.size(), 0); + + } + + + @Test + public void hasBothPropertiesPositive() { + HeatResourceValidator baseValidator = new HeatResourceValidator(); + VirtualMachineInterfaceValidator resourceValidator = new VirtualMachineInterfaceValidator(); + Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator, + resourceValidator, + HeatResourcesTypes.CONTRAIL_V2_VIRTUAL_MACHINE_INTERFACE_RESOURCE_TYPE.getHeatResource(), + PATH + "vlan_has_two_properties/positive_test/input"); + + Assert.assertNotNull(messages); + Assert.assertEquals(messages.size(), 0); + + + } + + @Test + public void hasSingleParentPortNegativeHasBothPropertiesNegative() { + HeatResourceValidator baseValidator = new HeatResourceValidator(); + VirtualMachineInterfaceValidator resourceValidator = new VirtualMachineInterfaceValidator(); + Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator, + resourceValidator, + HeatResourcesTypes.CONTRAIL_V2_VIRTUAL_MACHINE_INTERFACE_RESOURCE_TYPE.getHeatResource(), + PATH + "vlan_mixed/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: [VLAN2]: VLAN Tag property " + + "virtual_machine_interface_properties_sub_interface_vlan_tag is missing in " + + "VLAN Resource ID [template_Vlan_2]"); + + } + + +}
\ No newline at end of file |