[SDC-29] Amdocs OnBoard 1707 initial commit.
[sdc.git] / openecomp-be / lib / openecomp-sdc-validation-lib / openecomp-sdc-validation-impl / src / test / java / org / openecomp / sdc / validation / impl / validators / heatresource / NestedResourceValidatorTest.java
1 package org.openecomp.sdc.validation.impl.validators.heatresource;
2
3 import org.openecomp.core.validation.types.MessageContainer;
4 import org.openecomp.sdc.validation.impl.validators.HeatResourceValidator;
5 import org.openecomp.sdc.validation.util.ValidationTestUtil;
6 import org.testng.Assert;
7 import org.testng.annotations.Test;
8
9 import java.io.IOException;
10 import java.util.Map;
11
12 /**
13  * Created by TALIO on 2/28/2017.
14  */
15 public class NestedResourceValidatorTest {
16
17   HeatResourceValidator baseValidator = new HeatResourceValidator();
18   NestedResourceValidator resourceValidator = new NestedResourceValidator();
19
20   @Test
21   public void testNoLoopsNesting() throws IOException {
22     Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator,
23         resourceValidator, null,
24         "/org/openecomp/validation/validators/heat_validator/no_loops_nesting/negative_test/input");
25
26     Assert.assertNotNull(messages);
27     Assert.assertEquals(messages.size(), 4);
28
29     Assert.assertEquals(messages.get("hot-nimbus-psm_v1.0.yaml").getErrorMessageList().size(), 1);
30     Assert.assertEquals(
31         messages.get("hot-nimbus-psm_v1.0.yaml").getErrorMessageList().get(0).getMessage(),
32         "ERROR: Nested files loop - [hot-nimbus-psm_v1.0.yaml -- nested-psm_v1.0.yaml -- nested-points-to-hot-nimbus-psm.yaml -- hot-nimbus-psm_v1.0.yaml]");
33
34     Assert.assertEquals(
35         messages.get("nested-points-to-hot-nimbus-psm.yaml").getErrorMessageList().size(), 2);
36     Assert.assertEquals(
37         messages.get("nested-points-to-hot-nimbus-psm.yaml").getErrorMessageList().get(0)
38             .getMessage(),
39         "ERROR: Nested files loop - [nested-points-to-hot-nimbus-psm.yaml -- hot-nimbus-psm_v1.0.yaml -- nested-psm_v1.0.yaml -- nested-points-to-hot-nimbus-psm.yaml]");
40     Assert.assertEquals(
41         messages.get("nested-points-to-hot-nimbus-psm.yaml").getErrorMessageList().get(1)
42             .getMessage(),
43         "ERROR: Nested files loop - [nested-points-to-hot-nimbus-psm.yaml -- nested-psm_v1.0.yaml -- nested-points-to-hot-nimbus-psm.yaml]");
44
45     Assert.assertEquals(messages.get("yaml-point-to-itself.yaml").getErrorMessageList().size(), 1);
46     Assert.assertEquals(
47         messages.get("yaml-point-to-itself.yaml").getErrorMessageList().get(0).getMessage(),
48         "ERROR: Nested files loop - [yaml-point-to-itself.yaml -- yaml-point-to-itself.yaml]");
49
50     Assert.assertEquals(messages.get("nested-psm_v1.0.yaml").getErrorMessageList().size(), 1);
51     Assert.assertEquals(
52         messages.get("nested-psm_v1.0.yaml").getErrorMessageList().get(0).getMessage(),
53         "ERROR: Nested files loop - [nested-psm_v1.0.yaml -- nested-points-to-hot-nimbus-psm.yaml -- hot-nimbus-psm_v1.0.yaml -- nested-psm_v1.0.yaml]");
54   }
55
56   @Test
57   public void testPropertiesMatchNestedParameters() throws IOException {
58     Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator,
59         resourceValidator, null,
60         "/org/openecomp/validation/validators/heat_validator/properties_match_nested_parameters/negative_test/input");
61
62     Assert.assertNotNull(messages);
63     Assert.assertEquals(messages.size(), 1);
64
65     Assert.assertEquals(messages.get("hot-nimbus-pps_v1.0.yaml").getErrorMessageList().size(), 1);
66     Assert.assertEquals(
67         messages.get("hot-nimbus-pps_v1.0.yaml").getErrorMessageList().get(0).getMessage(),
68         "ERROR: Referenced parameter not found in nested file - nested-pps_v1.0.yaml, parameter name [server_pcrf_pps_001], Resource ID [parameter_not_existing_in_nested]");
69   }
70 }