From 8052ce0a3916c4fb6387af169205274a5e78d4ee Mon Sep 17 00:00:00 2001 From: mojahidi Date: Wed, 22 Nov 2017 18:28:21 +0530 Subject: NeutronPortResourceValidator This task is about updating error messages with error codes for NeutronPortResourceValidator Change-Id: I6070dfc4543727a29c3625078a947d0059c92fb7 Issue-ID: SDC-572 Signed-off-by: mojahidi --- .../NeutronPortResourceValidatorTest.java | 41 +++++++++++++++++++--- 1 file changed, 36 insertions(+), 5 deletions(-) (limited to 'openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp') diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/heatresource/NeutronPortResourceValidatorTest.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/heatresource/NeutronPortResourceValidatorTest.java index 359803f473..83e06ee5b7 100644 --- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/heatresource/NeutronPortResourceValidatorTest.java +++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/heatresource/NeutronPortResourceValidatorTest.java @@ -18,18 +18,49 @@ public class NeutronPortResourceValidatorTest { HeatResourceValidator baseValidator = new HeatResourceValidator(); NeutronPortResourceValidator resourceValidator = new NeutronPortResourceValidator(); + private static final String PATH = "/org/openecomp/validation/validators/heat_validator/"; @Test - public void testOnlyOneNovaPointsToOnePort() throws IOException { + public void testMoreThanOneBindFromNovaToPort() throws IOException { Map messages = ValidationTestUtil.testValidator(baseValidator, - resourceValidator, HeatResourcesTypes.NEUTRON_PORT_RESOURCE_TYPE.getHeatResource(), - "/org/openecomp/validation/validators/heat_validator/one_nova_points_to_one_port/negative_test/input"); + resourceValidator, HeatResourcesTypes.NEUTRON_PORT_RESOURCE_TYPE.getHeatResource(), + PATH + "one_nova_points_to_one_port/negative_test/input"); Assert.assertNotNull(messages); Assert.assertEquals(messages.size(), 1); Assert.assertEquals(messages.get("hot-nimbus-psm_v1.0.yaml").getErrorMessageList().size(), 1); Assert.assertEquals( - messages.get("hot-nimbus-psm_v1.0.yaml").getErrorMessageList().get(0).getMessage(), - "ERROR: Resource Port oam1_int_port exceed allowed relations from NovaServer"); + messages.get("hot-nimbus-psm_v1.0.yaml").getErrorMessageList().get(0).getMessage(), + "ERROR: [HPR2]: Resource Port oam1_int_port exceed allowed relations from NovaServer"); + } + + @Test + public void testPortNotBindToAnyNovaServerHPR1() throws IOException { + Map messages = ValidationTestUtil.testValidator(baseValidator, + resourceValidator, HeatResourcesTypes.NOVA_SERVER_RESOURCE_TYPE.getHeatResource(), + PATH + "no_neutron_port/input"); + + Assert.assertNotNull(messages); + Assert.assertEquals(messages.size(), 1); + + Assert.assertEquals(messages.get("hot-nimbus-psm_v1.0.yaml").getErrorMessageList().size(), 1); + Assert.assertEquals( + messages.get("hot-nimbus-psm_v1.0.yaml").getErrorMessageList().get(0).getMessage(), + "WARNING: [HPR1]: Port not bind to any NOVA Server, Resource Id [nova_server_1]"); + } + + @Test + public void testPortNotBindToAnyNovaServerHPR3() throws IOException { + Map messages = ValidationTestUtil.testValidator(baseValidator, + resourceValidator, HeatResourcesTypes.NOVA_SERVER_RESOURCE_TYPE.getHeatResource(), + PATH + "port_no_bind_to_any_nova_server/input"); + + Assert.assertNotNull(messages); + Assert.assertEquals(messages.size(), 1); + + Assert.assertEquals(messages.get("hot-nimbus-psm_v1.0.yaml").getErrorMessageList().size(), 1); + Assert.assertEquals( + messages.get("hot-nimbus-psm_v1.0.yaml").getErrorMessageList().get(0).getMessage(), + "WARNING: [HPR3]: Port not bind to any NOVA Server, Resource Id [nova_server_1]"); } } -- cgit 1.2.3-korg