8b83669037244f0a535fef0199e81d690ba01b26
[sdc.git] /
1 package org.openecomp.sdc.validation.impl.validators.heatresource;
2
3 import org.openecomp.core.validation.types.MessageContainer;
4 import org.openecomp.sdc.heat.datatypes.model.HeatResourcesTypes;
5 import org.openecomp.sdc.validation.impl.validators.HeatResourceValidator;
6 import org.openecomp.sdc.validation.util.ValidationTestUtil;
7 import org.testng.Assert;
8 import org.testng.annotations.Test;
9
10 import java.io.IOException;
11 import java.util.Map;
12
13 /**
14  * Created by TALIO on 2/28/2017.
15  */
16 public class NeutronSecurityGroupResourceValidatorTest {
17
18   HeatResourceValidator baseValidator = new HeatResourceValidator();
19   NeutronSecurityGroupResourceValidator resourceValidator = new
20       NeutronSecurityGroupResourceValidator();
21   private static final String PATH = "/org/openecomp/validation/validators/heat_validator/";
22
23   @Test
24   public void testSecurityGroupBaseFileNoPorts() throws IOException {
25     Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator,
26             resourceValidator,
27             HeatResourcesTypes.NEUTRON_SECURITY_GROUP_RESOURCE_TYPE.getHeatResource(),
28             PATH + "security_group_base_file_no_ports/input");
29
30     Assert.assertNotNull(messages);
31     Assert.assertEquals(messages.size(), 1);
32
33     Assert.assertEquals(messages.get("baseFile.yaml").getErrorMessageList().size(), 1);
34     Assert.assertEquals(messages.get("baseFile.yaml").getErrorMessageList().get(0).getMessage(),
35             "WARNING: [HSG1]: SecurityGroup not in use, Resource Id [jsa_security_group3]");
36   }
37
38   @Test
39   public void testSecurityGroupsCalledByPort() throws IOException {
40     Map<String, MessageContainer> messages =ValidationTestUtil.testValidator(baseValidator,
41             resourceValidator,
42             HeatResourcesTypes.NEUTRON_SECURITY_GROUP_RESOURCE_TYPE.getHeatResource(),
43             PATH + "security_group_called_by_port/input");
44
45     Assert.assertNotNull(messages);
46     Assert.assertEquals(messages.size(), 1);
47
48     Assert.assertEquals(messages.get("hot-nimbus-pps_v1.0.yaml").getErrorMessageList().size(), 1);
49     Assert.assertEquals(
50             messages.get("hot-nimbus-pps_v1.0.yaml").getErrorMessageList().get(0).getMessage(),
51             "WARNING: [HSG1]: SecurityGroup not in use, Resource Id [not_used_security_group]");
52   }
53
54 }