b8e8d1ee196ee47ab2d38aa60a1314d0870dc24b
[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
22   @Test
23   public void testSecurityGroupBaseFileNoPorts() throws IOException {
24     Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator,
25         resourceValidator,
26         HeatResourcesTypes.NEUTRON_SECURITY_GROUP_RESOURCE_TYPE.getHeatResource(),
27         "/org/openecomp/validation/validators/heat_validator/security_group_base_file_no_ports/input");
28
29     Assert.assertNotNull(messages);
30     Assert.assertEquals(messages.size(), 1);
31
32     Assert.assertEquals(messages.get("baseFile.yaml").getErrorMessageList().size(), 1);
33     Assert.assertEquals(messages.get("baseFile.yaml").getErrorMessageList().get(0).getMessage(),
34         "WARNING: SecurityGroup not in use, Resource Id [jsa_security_group3]");
35   }
36
37   @Test
38   public void testSecurityGroupsCalledByPort() throws IOException {
39     Map<String, MessageContainer> messages =ValidationTestUtil.testValidator(baseValidator,
40         resourceValidator,
41         HeatResourcesTypes.NEUTRON_SECURITY_GROUP_RESOURCE_TYPE.getHeatResource(),
42         "/org/openecomp/validation/validators/heat_validator/security_group_called_by_port/input");
43
44     Assert.assertNotNull(messages);
45     Assert.assertEquals(messages.size(), 1);
46
47     Assert.assertEquals(messages.get("hot-nimbus-pps_v1.0.yaml").getErrorMessageList().size(), 1);
48     Assert.assertEquals(
49         messages.get("hot-nimbus-pps_v1.0.yaml").getErrorMessageList().get(0).getMessage(),
50         "WARNING: SecurityGroup not in use, Resource Id [not_used_security_group]");
51   }
52
53 }