1 package org.openecomp.sdc.validation.impl.validators.heatresource;
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;
9 import java.io.IOException;
13 * Created by TALIO on 2/28/2017.
15 public class NestedResourceValidatorTest {
17 HeatResourceValidator baseValidator = new HeatResourceValidator();
18 NestedResourceValidator resourceValidator = new NestedResourceValidator();
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");
26 Assert.assertNotNull(messages);
27 Assert.assertEquals(messages.size(), 4);
29 Assert.assertEquals(messages.get("hot-nimbus-psm_v1.0.yaml").getErrorMessageList().size(), 1);
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]");
35 messages.get("nested-points-to-hot-nimbus-psm.yaml").getErrorMessageList().size(), 2);
37 messages.get("nested-points-to-hot-nimbus-psm.yaml").getErrorMessageList().get(0)
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]");
41 messages.get("nested-points-to-hot-nimbus-psm.yaml").getErrorMessageList().get(1)
43 "ERROR: Nested files loop - [nested-points-to-hot-nimbus-psm.yaml -- nested-psm_v1.0.yaml -- nested-points-to-hot-nimbus-psm.yaml]");
45 Assert.assertEquals(messages.get("yaml-point-to-itself.yaml").getErrorMessageList().size(), 1);
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]");
50 Assert.assertEquals(messages.get("nested-psm_v1.0.yaml").getErrorMessageList().size(), 1);
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]");
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");
62 Assert.assertNotNull(messages);
63 Assert.assertEquals(messages.size(), 1);
65 Assert.assertEquals(messages.get("hot-nimbus-pps_v1.0.yaml").getErrorMessageList().size(), 1);
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]");