fd6f1d42bba978e108c57d3d4b38dd0170cbc68c
[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 ContrailNetworkPolicyResourceValidatorTest {
17
18   HeatResourceValidator baseValidator = new HeatResourceValidator();
19   ContrailNetworkPolicyResourceValidator resourceValidator = new
20       ContrailNetworkPolicyResourceValidator();
21
22   private static final String PATH = "/org/openecomp/validation/validators/heat_validator/network_policy_associated_with_attach_policy/";
23   @Test
24   public void testNetworkPolicyAssociatedWithAttachPolicy() throws IOException {
25     Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator, resourceValidator
26             , HeatResourcesTypes.CONTRAIL_NETWORK_RULE_RESOURCE_TYPE.getHeatResource(),
27             PATH + "positive");
28
29     Assert.assertNotNull(messages);
30     Assert.assertEquals(messages.size(), 1);
31
32     Assert.assertEquals(messages.get("hot-nimbus-pps_v1.0.yaml").getErrorMessageList().size(), 1);
33     Assert.assertEquals(
34             messages.get("hot-nimbus-pps_v1.0.yaml").getErrorMessageList().get(0).getMessage(),
35             "WARNING: [HNP2]: NetworkPolicy not in use, Resource Id [not_used_server_pcrf_policy]");
36   }
37
38   @Test
39   public void testNonNetworkPolicyResource() throws IOException {
40     Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator, resourceValidator
41             , HeatResourcesTypes.CONTRAIL_VIRTUAL_NETWORK_RESOURCE_TYPE.getHeatResource(),
42             PATH + "negative");
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: [HNP1]: NetworkPolicy not in use, Resource Id [server_pcrf_network]");
51   }
52 }