2 * Copyright © 2016-2018 European Support Limited
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package org.openecomp.sdc.validation.impl.validators.namingconvention;
20 import org.junit.Assert;
21 import org.junit.Test;
22 import org.openecomp.core.validation.types.MessageContainer;
23 import org.openecomp.sdc.heat.datatypes.model.HeatResourcesTypes;
24 import org.openecomp.sdc.validation.impl.validators.NamingConventionGuideLineValidator;
25 import org.openecomp.sdc.validation.util.ValidationTestUtil;
28 * Created by TALIO on 2/28/2017.
30 public class NeutronPortNamingConventionValidatorTest {
32 NamingConventionGuideLineValidator baseValidator = new NamingConventionGuideLineValidator();
33 NeutronPortNamingConventionValidator resourceValidator = new
34 NeutronPortNamingConventionValidator();
35 private static final String PATH = "/org/openecomp/validation/validators/guideLineValidator/heatPortNetworkNamingConvention/";
37 public void testHeatPortNetworkNamingConvention() {
38 Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator,
39 resourceValidator, HeatResourcesTypes.NEUTRON_PORT_RESOURCE_TYPE.getHeatResource(),
41 Assert.assertNotNull(messages);
42 Assert.assertEquals(messages.size(), 0);
44 messages = ValidationTestUtil.testValidator(baseValidator,
45 resourceValidator, HeatResourcesTypes.NEUTRON_PORT_RESOURCE_TYPE.getHeatResource(),
47 Assert.assertNotNull(messages);
48 Assert.assertEquals(messages.size(), 1);
49 Assert.assertEquals(messages.get("first.yaml").getErrorMessageList().size(), 3);
50 Assert.assertEquals(messages.get("first.yaml").getErrorMessageList().get(0).getMessage(),
51 "WARNING: [NNP3]: Port 'Network' Parameter Name not aligned with Guidelines, Parameter Name [not_valid_network_name], Resource ID [port_resource]. As a result, VF/VFC Profile may miss this information");
55 public void testNeutronFixedIpName() {
56 Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator,
57 resourceValidator, HeatResourcesTypes.NEUTRON_PORT_RESOURCE_TYPE.getHeatResource(),
58 PATH + "positiveFixedIP");
59 Assert.assertNotNull(messages);
60 Assert.assertEquals(messages.size(), 0);
62 messages = ValidationTestUtil.testValidator(baseValidator,
63 resourceValidator, HeatResourcesTypes.NEUTRON_PORT_RESOURCE_TYPE.getHeatResource(),
64 PATH + "negativeFixedIP/");
65 Assert.assertNotNull(messages);
66 Assert.assertEquals(messages.size(), 1);
67 Assert.assertEquals(messages.get("first.yaml").getErrorMessageList().size(), 4);
68 Assert.assertEquals(messages.get("first.yaml").getErrorMessageList().get(0).getMessage(),
69 "WARNING: [NNP1]: Port 'Fixed_IPS' Parameter Name not aligned with Guidelines, Parameter Name [pcrf_net_v6_ip_a], Resource ID [port_resource_0]. As a result, VF/VFC Profile may miss this information");
70 Assert.assertEquals(messages.get("first.yaml").getErrorMessageList().get(1).getMessage(),
71 "WARNING: [NNP1]: Port 'Fixed_IPS' Parameter Name not aligned with Guidelines, Parameter Name [indx], Resource ID [port_resource_1]. As a result, VF/VFC Profile may miss this information");
73 Assert.assertEquals(messages.get("first.yaml").getErrorMessageList().get(2).getMessage(),
74 "WARNING: [NNP1]: Port 'Fixed_IPS' Parameter Name not aligned with Guidelines, Parameter Name [pcrf_net_ipz], Resource ID [port_resource_2]. As a result, VF/VFC Profile may miss this information");
76 Assert.assertEquals(messages.get("first.yaml").getErrorMessageList().get(3).getMessage(),
77 "WARNING: [NNP1]: Port 'Fixed_IPS' Parameter Name not aligned with Guidelines, Parameter Name [pcrf_net_v0_ip_3], Resource ID [port_resource_2]. As a result, VF/VFC Profile may miss this information");
81 public void testMissingParam() {
82 Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator,
83 resourceValidator, HeatResourcesTypes.NEUTRON_PORT_RESOURCE_TYPE.getHeatResource(),
84 PATH + "missingparam/");
85 Assert.assertNotNull(messages);
86 Assert.assertEquals(messages.size(), 1);
87 Assert.assertEquals(messages.get("first.yaml").getErrorMessageList().size(), 1);
88 Assert.assertEquals(messages.get("first.yaml").getErrorMessageList().get(0).getMessage(),
89 "WARNING: [NNP2]: Missing get_param in network or network_id, Resource Id [port_resource_2]");