push addional code
[sdc.git] / openecomp-be / lib / openecomp-sdc-validation-lib / openecomp-sdc-validation-impl / src / test / java / org / openecomp / sdc / validation / impl / validators / validators / EcompNamingConventionTest.java
1 package org.openecomp.sdc.validation.impl.validators.validators;
2
3 import org.openecomp.sdc.validation.impl.validators.EcompGuideLineValidator;
4 import org.openecomp.sdc.validation.impl.validators.ValidatorBaseTest;
5 import org.openecomp.core.validation.types.MessageContainer;
6
7 import java.io.IOException;
8 import java.util.Map;
9
10 import org.testng.Assert;
11 import org.testng.annotations.Test;
12
13 public class EcompNamingConventionTest extends ValidatorBaseTest {
14
15   @Test
16   public void testNeutronFixedIpName() throws IOException {
17     Map<String, MessageContainer> messages = runValidation(
18         "/openecomp/org/validation/validators/ecomp_naming_convention/neutron_port_fixed_ip_name/input");
19
20     Assert.assertNotNull(messages);
21     Assert.assertEquals(messages.size(), 2);
22
23     Assert.assertEquals(messages.get("hot-nimbus-pps_v1.0.yaml").getErrorMessageList().size(), 3);
24     Assert.assertEquals(
25         messages.get("hot-nimbus-pps_v1.0.yaml").getErrorMessageList().get(0).getMessage(),
26         "Fixed_IPS not aligned with Guidelines, Resource ID [fixed_ip_illegal_name_1]");
27     Assert.assertEquals(
28         messages.get("hot-nimbus-pps_v1.0.yaml").getErrorMessageList().get(1).getMessage(),
29         "Fixed_IPS not aligned with Guidelines, Resource ID [fixed_ip_illegal_name_2]");
30     Assert.assertEquals(
31         messages.get("hot-nimbus-pps_v1.0.yaml").getErrorMessageList().get(2).getMessage(),
32         "Fixed_IPS not aligned with Guidelines, Resource ID [fixed_ip_illegal_name_3]");
33   }
34
35
36   @Test
37   public void testNovaServerName() throws IOException {
38     Map<String, MessageContainer> messages = runValidation(
39         "/openecomp/org/validation/validators/ecomp_naming_convention/nova_server_name/input");
40
41     Assert.assertNotNull(messages);
42     Assert.assertEquals(messages.size(), 2);
43
44     Assert.assertEquals(messages.get("hot-nimbus-pps_v1.0.yaml").getErrorMessageList().size(), 6);
45     Assert.assertEquals(
46         messages.get("hot-nimbus-pps_v1.0.yaml").getErrorMessageList().get(0).getMessage(),
47         "Server Name not aligned with Guidelines, Resource ID [nova_server_ilegal_name_1]");
48     Assert.assertEquals(
49         messages.get("hot-nimbus-pps_v1.0.yaml").getErrorMessageList().get(1).getMessage(),
50         "Server Name not aligned with Guidelines, Resource ID [nova_server_ilegal_name_2]");
51     Assert.assertEquals(
52         messages.get("hot-nimbus-pps_v1.0.yaml").getErrorMessageList().get(2).getMessage(),
53         "Server Name not aligned with Guidelines, Resource ID [nova_server_ilegal_name_3]");
54     Assert.assertEquals(
55         messages.get("hot-nimbus-pps_v1.0.yaml").getErrorMessageList().get(3).getMessage(),
56         "Server Name not aligned with Guidelines, Resource ID [nova_server_ilegal_name_4]");
57     Assert.assertEquals(
58         messages.get("hot-nimbus-pps_v1.0.yaml").getErrorMessageList().get(4).getMessage(),
59         "Server Name not aligned with Guidelines, Resource ID [nova_server_ilegal_name_5]");
60     Assert.assertEquals(
61         messages.get("hot-nimbus-pps_v1.0.yaml").getErrorMessageList().get(5).getMessage(),
62         "Missing get_param in nova server name, Resource Id [nova_server_ilegal_name_6]");
63   }
64
65
66   @Test
67   public void testAvailabilityZoneName() throws IOException {
68     Map<String, MessageContainer> messages = runValidation(
69         "/openecomp/org/validation/validators/ecomp_naming_convention/availability_zone_name/input");
70
71     Assert.assertNotNull(messages);
72     Assert.assertEquals(messages.size(), 2);
73
74     Assert.assertEquals(messages.get("hot-nimbus-pps_v1.0.yaml").getErrorMessageList().size(), 2);
75     Assert.assertEquals(
76         messages.get("hot-nimbus-pps_v1.0.yaml").getErrorMessageList().get(0).getMessage(),
77         "Server Availability Zone not aligned with Guidelines, Resource ID [availability_zone_illegal_name_1]");
78     Assert.assertEquals(
79         messages.get("hot-nimbus-pps_v1.0.yaml").getErrorMessageList().get(1).getMessage(),
80         "Server Availability Zone not aligned with Guidelines, Resource ID [availability_zone_illegal_name_2]");
81   }
82
83
84   @Test
85   public void testFloatingIpResourceType() throws IOException {
86     Map<String, MessageContainer> messages = runValidation(
87         "/openecomp/org/validation/validators/ecomp_naming_convention/floating_ip_resource_type/input");
88
89     Assert.assertNotNull(messages);
90     Assert.assertEquals(messages.size(), 2);
91
92     Assert.assertEquals(messages.get("hot-nimbus-pps_v1.0.yaml").getErrorMessageList().size(), 1);
93     Assert.assertEquals(
94         messages.get("hot-nimbus-pps_v1.0.yaml").getErrorMessageList().get(0).getMessage(),
95         "OS::Neutron::FloatingIP is in use, Resource ID [floating_ip_type]");
96   }
97
98
99   @Override
100   public Map<String, MessageContainer> runValidation(String path) {
101     EcompGuideLineValidator ecompGuideLineValidator = new EcompGuideLineValidator();
102     return testValidator(ecompGuideLineValidator, path);
103   }
104 }