1 package org.openecomp.sdc.validation.impl.validators.validators;
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;
7 import java.io.IOException;
10 import org.testng.Assert;
11 import org.testng.annotations.Test;
13 public class EcompNamingConventionTest extends ValidatorBaseTest {
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");
20 Assert.assertNotNull(messages);
21 Assert.assertEquals(messages.size(), 2);
23 Assert.assertEquals(messages.get("hot-nimbus-pps_v1.0.yaml").getErrorMessageList().size(), 3);
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]");
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]");
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]");
37 public void testNovaServerName() throws IOException {
38 Map<String, MessageContainer> messages = runValidation(
39 "/openecomp/org/validation/validators/ecomp_naming_convention/nova_server_name/input");
41 Assert.assertNotNull(messages);
42 Assert.assertEquals(messages.size(), 2);
44 Assert.assertEquals(messages.get("hot-nimbus-pps_v1.0.yaml").getErrorMessageList().size(), 6);
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]");
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]");
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]");
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]");
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]");
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]");
67 public void testAvailabilityZoneName() throws IOException {
68 Map<String, MessageContainer> messages = runValidation(
69 "/openecomp/org/validation/validators/ecomp_naming_convention/availability_zone_name/input");
71 Assert.assertNotNull(messages);
72 Assert.assertEquals(messages.size(), 2);
74 Assert.assertEquals(messages.get("hot-nimbus-pps_v1.0.yaml").getErrorMessageList().size(), 2);
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]");
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]");
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");
89 Assert.assertNotNull(messages);
90 Assert.assertEquals(messages.size(), 2);
92 Assert.assertEquals(messages.get("hot-nimbus-pps_v1.0.yaml").getErrorMessageList().size(), 1);
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]");
100 public Map<String, MessageContainer> runValidation(String path) {
101 EcompGuideLineValidator ecompGuideLineValidator = new EcompGuideLineValidator();
102 return testValidator(ecompGuideLineValidator, path);