2 * Copyright © 2016-2017 European Support Limited
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package org.openecomp.sdc.validation.impl.validators.heatresource;
19 import org.openecomp.core.validation.types.MessageContainer;
20 import org.openecomp.sdc.heat.datatypes.model.HeatResourcesTypes;
21 import org.openecomp.sdc.validation.impl.validators.HeatResourceValidator;
22 import org.openecomp.sdc.validation.util.ValidationTestUtil;
23 import org.testng.Assert;
24 import org.testng.annotations.Test;
29 * Created by TALIO on 2/28/2017.
31 public class ResourceGroupResourceValidatorTest {
33 private final HeatResourceValidator baseValidator = new HeatResourceValidator();
34 private final ResourceGroupResourceValidator resourceValidator = new ResourceGroupResourceValidator();
36 private static final String PATH = "/org/openecomp/validation/validators/heat_validator/";
38 public void testResourceGroupWithInvalidIndexVar() {
39 Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator,
40 resourceValidator, HeatResourcesTypes.RESOURCE_GROUP_RESOURCE_TYPE.getHeatResource(),
41 PATH + "resource_group_invalid_indexvar/negative_test/input");
43 Assert.assertNotNull(messages);
44 Assert.assertEquals(messages.size(), 1);
46 Assert.assertEquals(messages.get("hot-nimbus-psm_v1.0.yaml").getErrorMessageList().size(), 14);
48 messages.get("hot-nimbus-psm_v1.0.yaml").getErrorMessageList().get(0).getMessage(),
49 "WARNING: [HRR8]: OS::Heat::ResourceGroup resource with resource_def which is not pointing to nested heat file is not supported, Resource ID [resource_with_resources_group_1], resource_def type [yamlFile.yaml]");
51 messages.get("hot-nimbus-psm_v1.0.yaml").getErrorMessageList().get(1).getMessage(),
52 "ERROR: [HRR1]: Wrong value assigned to a ResourceGroup index_var property (functions are not allowed but only strings), Resource ID [resource_with_resources_group_1]");
54 messages.get("hot-nimbus-psm_v1.0.yaml").getErrorMessageList().get(2).getMessage(),
55 "WARNING: [HRR8]: OS::Heat::ResourceGroup resource with resource_def which is not pointing to nested heat file is not supported, Resource ID [resource_with_resources_group_2], resource_def type [yamlFile.yaml]");
57 messages.get("hot-nimbus-psm_v1.0.yaml").getErrorMessageList().get(3).getMessage(),
58 "WARNING: [HRR5]: Wrong value type assigned to a nested input parameter, nested resource [resource_with_resources_group_2], property name [index_boolean], nested file [yamlFile.yaml]");
60 messages.get("hot-nimbus-psm_v1.0.yaml").getErrorMessageList().get(4).getMessage(),
61 "WARNING: [HRR8]: OS::Heat::ResourceGroup resource with resource_def which is not pointing to nested heat file is not supported, Resource ID [resource_with_resources_group_3], resource_def type [yamlFile.yaml]");
63 messages.get("hot-nimbus-psm_v1.0.yaml").getErrorMessageList().get(5).getMessage(),
64 "WARNING: [HRR5]: Wrong value type assigned to a nested input parameter, nested resource [resource_with_resources_group_3], property name [index_boolean], nested file [yamlFile.yaml]");
66 messages.get("hot-nimbus-psm_v1.0.yaml").getErrorMessageList().get(6).getMessage(),
67 "WARNING: [HRR5]: Wrong value type assigned to a nested input parameter, nested resource [resource_with_resources_group_3], property name [index_number], nested file [yamlFile.yaml]");
69 messages.get("hot-nimbus-psm_v1.0.yaml").getErrorMessageList().get(7).getMessage(),
70 "WARNING: [HRR8]: OS::Heat::ResourceGroup resource with resource_def which is not pointing to nested heat file is not supported, Resource ID [resource_with_resources_group_4], resource_def type [yamlFile.yaml]");
72 messages.get("hot-nimbus-psm_v1.0.yaml").getErrorMessageList().get(8).getMessage(),
73 "WARNING: [HRR5]: Wrong value type assigned to a nested input parameter, nested resource [resource_with_resources_group_4], property name [index_boolean], nested file [yamlFile.yaml]");
75 messages.get("hot-nimbus-psm_v1.0.yaml").getErrorMessageList().get(9).getMessage(),
76 "WARNING: [HRR8]: OS::Heat::ResourceGroup resource with resource_def which is not pointing to nested heat file is not supported, Resource ID [resource_with_resources_group_5], resource_def type [yamlFile.yaml]");
78 messages.get("hot-nimbus-psm_v1.0.yaml").getErrorMessageList().get(10).getMessage(),
79 "WARNING: [HRR5]: Wrong value type assigned to a nested input parameter, nested resource [resource_with_resources_group_5], property name [index_boolean], nested file [yamlFile.yaml]");
81 messages.get("hot-nimbus-psm_v1.0.yaml").getErrorMessageList().get(11).getMessage(),
82 "WARNING: [HRR5]: Wrong value type assigned to a nested input parameter, nested resource [resource_with_resources_group_5], property name [index_number], nested file [yamlFile.yaml]");
84 messages.get("hot-nimbus-psm_v1.0.yaml").getErrorMessageList().get(12).getMessage(),
85 "WARNING: [HRR8]: OS::Heat::ResourceGroup resource with resource_def which is not pointing to nested heat file is not supported, Resource ID [resource_with_resources_group_6], resource_def type [yamlFile.yaml]");
87 messages.get("hot-nimbus-psm_v1.0.yaml").getErrorMessageList().get(13).getMessage(),
88 "ERROR: [HRR1]: Wrong value assigned to a ResourceGroup index_var property (functions are not allowed but only strings), Resource ID [resource_with_resources_group_6]");
92 public void testResourceGroupWithInvalidType() {
93 Map<String, MessageContainer> messages =ValidationTestUtil.testValidator(baseValidator,
94 resourceValidator, HeatResourcesTypes.RESOURCE_GROUP_RESOURCE_TYPE.getHeatResource(),
95 PATH + "resource_group_invalid_type/negative_test/input");
97 Assert.assertNotNull(messages);
98 Assert.assertEquals(messages.size(), 1);
100 Assert.assertEquals(messages.get("hot-nimbus-psm_v1.0.yaml").getErrorMessageList().size(), 3);
102 messages.get("hot-nimbus-psm_v1.0.yaml").getErrorMessageList().get(0).getMessage(),
103 "WARNING: [HRR7]: OS::Heat::ResourceGroup resource with resource_def which is not pointing to nested heat file is not supported, Resource ID [resource_with_resources_group_1], resource_def type [{get_param=pcrf_vnf_id}]");
105 messages.get("hot-nimbus-psm_v1.0.yaml").getErrorMessageList().get(1).getMessage(),
106 "WARNING: [HRR6]: A resource has an invalid or unsupported type - null, Resource ID [resource_with_resources_group_3]");
108 messages.get("hot-nimbus-psm_v1.0.yaml").getErrorMessageList().get(2).getMessage(),
109 "WARNING: [HRR8]: OS::Heat::ResourceGroup resource with resource_def which is not pointing to nested heat file is not supported, Resource ID [resource_with_resources_group_4], resource_def type [yamlFile.yaml]");
113 public void testResourcesGroupWithNested() {
114 Map<String, MessageContainer> messages =ValidationTestUtil.testValidator(baseValidator,
115 resourceValidator, HeatResourcesTypes.RESOURCE_GROUP_RESOURCE_TYPE.getHeatResource(),
116 PATH + "resources_group_with_nested/negative_test/input");
118 Assert.assertNotNull(messages);
119 Assert.assertEquals(messages.size(), 4);
121 Assert.assertEquals(messages.get("hot-nimbus-psm_v1.0.yaml").getErrorMessageList().size(), 2);
123 messages.get("hot-nimbus-psm_v1.0.yaml").getErrorMessageList().get(0).getMessage(),
124 "WARNING: [HRR8]: OS::Heat::ResourceGroup resource with resource_def which is not pointing to nested heat file is not supported, Resource ID [resource_with_resources_group], resource_def type [nested-from-resources-group.yaml]");
126 messages.get("hot-nimbus-psm_v1.0.yaml").getErrorMessageList().get(1).getMessage(),
127 "ERROR: [HRR4]: Referenced parameter not found in nested file - nested-from-resources-group.yaml, parameter name [resource_with_resources_group], Resource ID [property_not_in_nested]");
129 Assert.assertEquals(messages.get("nested-pps_v1.0.yaml").getErrorMessageList().size(), 2);
131 messages.get("nested-pps_v1.0.yaml").getErrorMessageList().get(1).getMessage(),
132 "ERROR: [HRR3]: Nested files loop - [nested-pps_v1.0.yaml -- nested-from-resources-group.yaml -- hot-nimbus-pps_v1.0.yaml -- nested-pps_v1.0.yaml]");
134 Assert.assertEquals(messages.get("nested-not-exist.yaml").getErrorMessageList().size(), 1);
136 messages.get("nested-not-exist.yaml").getErrorMessageList().get(0).getMessage(),
137 "ERROR: [HRR2]: Missing nested file - nested-not-exist.yaml");