2 * Copyright © 2016-2018 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 java.io.IOException;
21 import org.junit.Assert;
22 import org.junit.Test;
23 import org.openecomp.core.validation.types.MessageContainer;
24 import org.openecomp.sdc.heat.datatypes.model.HeatResourcesTypes;
25 import org.openecomp.sdc.validation.impl.validators.HeatResourceValidator;
26 import org.openecomp.sdc.validation.util.ValidationTestUtil;
29 * Created by TALIO on 2/28/2017.
31 public class NovaServerGroupResourceValidatorTest {
33 HeatResourceValidator baseValidator = new HeatResourceValidator();
34 NovaServerGroupResourceValidator resourceValidator = new NovaServerGroupResourceValidator();
35 private static final String PATH = "/org/openecomp/validation/validators/heat_validator/";
37 public void testPolicyIsAffinityOrAntiAffinity() throws IOException {
38 Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator,
39 resourceValidator, HeatResourcesTypes.NOVA_SERVER_GROUP_RESOURCE_TYPE.getHeatResource(),
40 PATH + "policy_is_affinity_or_anti_affinity/negative_test/input");
42 Assert.assertNotNull(messages);
43 Assert.assertEquals(messages.size(), 1);
45 Assert.assertEquals(messages.get("hot-nimbus-psm_v1.0.yaml").getErrorMessageList().size(), 1);
47 messages.get("hot-nimbus-psm_v1.0.yaml").getErrorMessageList().get(0).getMessage(),
48 "ERROR: [HNG1]: Wrong policy in server group - pcrf_server_policies_1");
52 public void testServerGroupCalledByServer() throws IOException {
53 Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator,
54 resourceValidator, HeatResourcesTypes.NOVA_SERVER_GROUP_RESOURCE_TYPE.getHeatResource(),
55 PATH + "server_group_called_by_nova_server/input");
57 Assert.assertNotNull(messages);
58 Assert.assertEquals(messages.size(), 1);
60 Assert.assertEquals(messages.get("hot-nimbus-pps_v1.0.yaml").getErrorMessageList().size(), 1);
62 messages.get("hot-nimbus-pps_v1.0.yaml").getErrorMessageList().get(0).getMessage(),
63 "WARNING: [HNG3]: ServerGroup not in use, Resource Id [not_used_server_group]");
68 public void testNonServerGroup() throws IOException {
69 Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator,
70 resourceValidator, HeatResourcesTypes.NOVA_SERVER_RESOURCE_TYPE.getHeatResource(),
71 PATH + "server_group_called_by_nova_server_negative/input");
73 Assert.assertNotNull(messages);
74 Assert.assertEquals(messages.size(), 1);
76 Assert.assertEquals(messages.get("hot-nimbus-pps_v1.0.yaml").getErrorMessageList().size(), 1);
78 messages.get("hot-nimbus-pps_v1.0.yaml").getErrorMessageList().get(0).getMessage(),
79 "WARNING: [HNG2]: ServerGroup not in use, Resource Id [nova_server]");