83e06ee5b710c80385d6d47fbd366b21cffb30e8
[sdc.git] /
1 package org.openecomp.sdc.validation.impl.validators.heatresource;
2
3 import org.openecomp.core.validation.types.MessageContainer;
4 import org.openecomp.sdc.heat.datatypes.model.HeatResourcesTypes;
5 import org.openecomp.sdc.validation.impl.validators.HeatResourceValidator;
6 import org.openecomp.sdc.validation.util.ValidationTestUtil;
7 import org.testng.Assert;
8 import org.testng.annotations.Test;
9
10 import java.io.IOException;
11 import java.util.Map;
12
13 /**
14  * Created by TALIO on 2/28/2017.
15  */
16 public class NeutronPortResourceValidatorTest {
17
18   HeatResourceValidator baseValidator = new HeatResourceValidator();
19   NeutronPortResourceValidator resourceValidator = new NeutronPortResourceValidator();
20
21   private static final String PATH = "/org/openecomp/validation/validators/heat_validator/";
22   @Test
23   public void testMoreThanOneBindFromNovaToPort() throws IOException {
24     Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator,
25             resourceValidator, HeatResourcesTypes.NEUTRON_PORT_RESOURCE_TYPE.getHeatResource(),
26             PATH + "one_nova_points_to_one_port/negative_test/input");
27
28     Assert.assertNotNull(messages);
29     Assert.assertEquals(messages.size(), 1);
30
31     Assert.assertEquals(messages.get("hot-nimbus-psm_v1.0.yaml").getErrorMessageList().size(), 1);
32     Assert.assertEquals(
33             messages.get("hot-nimbus-psm_v1.0.yaml").getErrorMessageList().get(0).getMessage(),
34             "ERROR: [HPR2]: Resource Port oam1_int_port exceed allowed relations from NovaServer");
35   }
36
37   @Test
38   public void testPortNotBindToAnyNovaServerHPR1() throws IOException {
39     Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator,
40             resourceValidator, HeatResourcesTypes.NOVA_SERVER_RESOURCE_TYPE.getHeatResource(),
41             PATH + "no_neutron_port/input");
42
43     Assert.assertNotNull(messages);
44     Assert.assertEquals(messages.size(), 1);
45
46     Assert.assertEquals(messages.get("hot-nimbus-psm_v1.0.yaml").getErrorMessageList().size(), 1);
47     Assert.assertEquals(
48             messages.get("hot-nimbus-psm_v1.0.yaml").getErrorMessageList().get(0).getMessage(),
49             "WARNING: [HPR1]: Port not bind to any NOVA Server, Resource Id [nova_server_1]");
50   }
51
52   @Test
53   public void testPortNotBindToAnyNovaServerHPR3() throws IOException {
54     Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator,
55             resourceValidator, HeatResourcesTypes.NOVA_SERVER_RESOURCE_TYPE.getHeatResource(),
56             PATH + "port_no_bind_to_any_nova_server/input");
57
58     Assert.assertNotNull(messages);
59     Assert.assertEquals(messages.size(), 1);
60
61     Assert.assertEquals(messages.get("hot-nimbus-psm_v1.0.yaml").getErrorMessageList().size(), 1);
62     Assert.assertEquals(
63             messages.get("hot-nimbus-psm_v1.0.yaml").getErrorMessageList().get(0).getMessage(),
64             "WARNING: [HPR3]: Port not bind to any NOVA Server, Resource Id [nova_server_1]");
65   }
66 }