1 package org.openecomp.sdc.validation.impl.validators.heatresource;
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;
10 import java.io.IOException;
14 * Created by TALIO on 2/28/2017.
16 public class NovaServerResourceValidatorTest {
18 HeatResourceValidator baseValidator = new HeatResourceValidator();
19 NovaServerResourceValidator resourceValidator = new NovaServerResourceValidator();
22 public void testNovaPropertiesHasAssignedValue() throws IOException {
23 Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator,
24 resourceValidator, HeatResourcesTypes.NOVA_SERVER_RESOURCE_TYPE.getHeatResource(),
25 "/org/openecomp/validation/validators/heat_validator/nova_properties_has_assigned_value/negative_test/input");
27 Assert.assertNotNull(messages);
28 Assert.assertEquals(messages.size(), 1);
30 Assert.assertEquals(messages.get("hot-nimbus-psm_v1.0.yaml").getErrorMessageList().size(), 1);
32 messages.get("hot-nimbus-psm_v1.0.yaml").getErrorMessageList().get(0).getMessage(),
33 "ERROR: Missing both Image and Flavor in NOVA Server, Resource ID [nova_server_resource_missing_both]");
37 public void testServerGroupsPointedByServersDefinedCorrectly() throws IOException {
38 Map<String, MessageContainer> messages =ValidationTestUtil.testValidator(baseValidator,
39 resourceValidator, HeatResourcesTypes.NOVA_SERVER_RESOURCE_TYPE.getHeatResource(),
40 "/org/openecomp/validation/validators/heat_validator/server_groups_defined_correctly/negative_test/input");
42 Assert.assertNotNull(messages);
43 Assert.assertEquals(messages.size(), 1);
45 Assert.assertEquals(messages.get("hot-nimbus-pps_v1.0.yaml").getErrorMessageList().size(), 2);
47 messages.get("hot-nimbus-pps_v1.0.yaml").getErrorMessageList().get(0).getMessage(),
48 "ERROR: Missing server group definition - BE_Affinity_2, nova_server_1");
50 messages.get("hot-nimbus-pps_v1.0.yaml").getErrorMessageList().get(1).getMessage(),
51 "ERROR: Missing server group definition - BE_Affinity_2, nova_server_2");