Sorted out unit-test libraries in onboarding
[sdc.git] / openecomp-be / lib / openecomp-sdc-validation-lib / openecomp-sdc-validation-impl / src / test / java / org / openecomp / sdc / validation / impl / validators / heatresource / NeutronPortResourceValidatorTest.java
1 /*
2  * Copyright © 2016-2018 European Support Limited
3  *
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
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16
17 package org.openecomp.sdc.validation.impl.validators.heatresource;
18
19 import java.io.IOException;
20 import java.util.Map;
21 import org.junit.Assert;
22 import org.junit.Test;
23 import org.openecomp.core.validation.types.MessageContainer;
24 import org.openecomp.sdc.heat.datatypes.model.HeatResourcesTypes;
25 import org.openecomp.sdc.validation.impl.validators.HeatResourceValidator;
26 import org.openecomp.sdc.validation.util.ValidationTestUtil;
27
28 /**
29  * Created by TALIO on 2/28/2017.
30  */
31 public class NeutronPortResourceValidatorTest {
32
33   HeatResourceValidator baseValidator = new HeatResourceValidator();
34   NeutronPortResourceValidator resourceValidator = new NeutronPortResourceValidator();
35
36   private static final String PATH = "/org/openecomp/validation/validators/heat_validator/";
37   @Test
38   public void testMoreThanOneBindFromNovaToPort() throws IOException {
39     Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator,
40             resourceValidator, HeatResourcesTypes.NEUTRON_PORT_RESOURCE_TYPE.getHeatResource(),
41             PATH + "one_nova_points_to_one_port/negative_test/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             "ERROR: [HPR2]: Resource Port oam1_int_port exceed allowed relations from NovaServer");
50   }
51
52   @Test
53   public void testPortNotBindToAnyNovaServerHPR1() throws IOException {
54     Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator,
55             resourceValidator, HeatResourcesTypes.NOVA_SERVER_RESOURCE_TYPE.getHeatResource(),
56             PATH + "no_neutron_port/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: [HPR1]: Port not bind to any NOVA Server, Resource Id [nova_server_1]");
65   }
66
67   @Test
68   public void testPortNotBindToAnyNovaServerHPR3() throws IOException {
69     Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator,
70             resourceValidator, HeatResourcesTypes.NOVA_SERVER_RESOURCE_TYPE.getHeatResource(),
71             PATH + "port_no_bind_to_any_nova_server/input");
72
73     Assert.assertNotNull(messages);
74     Assert.assertEquals(messages.size(), 1);
75
76     Assert.assertEquals(messages.get("hot-nimbus-psm_v1.0.yaml").getErrorMessageList().size(), 1);
77     Assert.assertEquals(
78             messages.get("hot-nimbus-psm_v1.0.yaml").getErrorMessageList().get(0).getMessage(),
79             "WARNING: [HPR3]: Port not bind to any NOVA Server, Resource Id [nova_server_1]");
80   }
81 }