Upgrade Vulnerable Direct Dependencies [snakeyaml]
[sdc.git] / openecomp-be / lib / openecomp-sdc-validation-lib / openecomp-sdc-validation-impl / src / test / java / org / openecomp / sdc / validation / impl / validators / namingconvention / ContrailServiceInstanceNamingConventionValidatorTest.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.namingconvention;
18
19 import java.util.Map;
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.HeatResourceValidator;
25 import org.openecomp.sdc.validation.util.ValidationTestUtil;
26
27 /**
28  * Created by TALIO on 2/28/2017.
29  */
30 public class ContrailServiceInstanceNamingConventionValidatorTest {
31
32   HeatResourceValidator baseValidator = new HeatResourceValidator();
33   ContrailServiceInstanceNamingConventionValidator resourceValidator = new
34       ContrailServiceInstanceNamingConventionValidator();
35   private static final String PATH = "/org/openecomp/validation/validators/guideLineValidator/heatcontrailserviceinstanceavailabilityzone/";
36
37   @Test
38   public void testContrailServiceInstanceAvailabilityZoneNotAlignedWithNamingConvention() {
39     Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(baseValidator,
40             resourceValidator, HeatResourcesTypes.CONTRAIL_SERVICE_INSTANCE.getHeatResource(),
41             PATH + "notaligned");
42     Assert.assertNotNull(messages);
43     Assert.assertEquals(messages.size(), 1);
44     Assert.assertEquals(messages.get("first.yaml").getErrorMessageList().size(), 1);
45     Assert.assertEquals(messages.get("first.yaml").getErrorMessageList().get(0).getMessage(),
46             "WARNING: [NSI1]: Service Instance 'Availability Zone' Parameter Name not aligned with Guidelines, Parameter Name [availability_zone_1a], Resource ID [service_instance_1]. As a result, VF/VFC Profile may miss this information");
47   }
48
49   @Test
50   public void testContrailServiceInstanceAvailabilityZoneAlignedWithNamingConvention() {
51     Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(baseValidator,
52             resourceValidator, HeatResourcesTypes.CONTRAIL_SERVICE_INSTANCE.getHeatResource(),
53             PATH + "aligned");
54     Assert.assertNotNull(messages);
55     Assert.assertEquals(messages.size(), 0);
56   }
57   @Test
58   public void testContrailServiceInstanceAvailabilityZoneNotAlignedWithNamingConventionMissingParam() {
59     Map<String, MessageContainer> messages = new ValidationTestUtil().testValidator(baseValidator,
60             resourceValidator, HeatResourcesTypes.CONTRAIL_SERVICE_INSTANCE.getHeatResource(),
61             PATH + "missingparam");
62     Assert.assertNotNull(messages);
63     Assert.assertEquals(messages.size(), 1);
64     Assert.assertEquals(messages.get("first.yaml").getErrorMessageList().size(), 1);
65     Assert.assertEquals(messages.get("first.yaml").getErrorMessageList().get(0).getMessage(),
66             "WARNING: [NSI2]: Missing get_param in availability_zone, Resource Id [service_instance_1]");
67   }
68 }