summaryrefslogtreecommitdiffstats
path: root/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java
diff options
context:
space:
mode:
authorAviZi <avi.ziv@amdocs.com>2017-06-09 02:39:56 +0300
committerAviZi <avi.ziv@amdocs.com>2017-06-09 02:39:56 +0300
commit280f8015d06af1f41a3ef12e8300801c7a5e0d54 (patch)
tree9c1d3978c04cd28068f02073038c936bb49ca9e0 /openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java
parentfd3821dad11780d33c5373d74c957c442489945e (diff)
[SDC-29] Amdocs OnBoard 1707 initial commit.
Change-Id: Ie4d12a3f574008b792899b368a0902a8b46b5370 Signed-off-by: AviZi <avi.ziv@amdocs.com>
Diffstat (limited to 'openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java')
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/ContrailValidatorTest.java99
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/ErrorMessagesTest.java25
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/ForbiddenResourceGuideLineValidatorTest.java55
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/HeatValidatorTest.java230
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/ManifestValidatorTest.java142
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/SharedResourceGuideLineValidatorTest.java155
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/ValidatorBaseTest.java84
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/YamlValidatorTest.java (renamed from openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/validators/YamlValidatorTest.java)62
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/heatresource/ContrailNetworkPolicyResourceValidatorTest.java36
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/heatresource/NestedResourceValidatorTest.java70
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/heatresource/NeutronPortResourceValidatorTest.java35
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/heatresource/NeutronSecurityGroupResourceValidatorTest.java53
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/heatresource/NovaServerGroupResourceValidatorTest.java51
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/heatresource/NovaServerResourceValidatorTest.java53
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/heatresource/ResourceGroupResourceValidatorTest.java106
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/namingconvention/ContrailServiceInstanceNamingConventionValidatorTest.java41
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/namingconvention/ContrailServiceTemplateNamingConventionValidatorTest.java58
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/namingconvention/NeutronPortNamingConventionValidatorTest.java64
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/namingconvention/NovaServerNamingConventionGuideLineValidatorTest.java154
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/validators/EcompGuideLineValidatorTest.java281
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/validators/EcompNamingConventionTest.java104
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/validators/HeatValidatorTest.java356
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/validators/ManifestValidatorTest.java125
23 files changed, 1465 insertions, 974 deletions
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/ContrailValidatorTest.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/ContrailValidatorTest.java
new file mode 100644
index 0000000000..30b7f68230
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/ContrailValidatorTest.java
@@ -0,0 +1,99 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdc.validation.impl.validators;
+
+import org.openecomp.sdc.validation.Validator;
+import org.openecomp.core.validation.types.MessageContainer;
+import org.openecomp.sdc.datatypes.error.ErrorMessage;
+import org.openecomp.sdc.validation.util.ValidationTestUtil;
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author Avrahamg
+ * @since October 06, 2016
+ */
+public class ContrailValidatorTest {
+
+ private Validator validator = new ContrailValidator();
+
+ @Test
+ public void testWarningMessageExistWhenConrailV1AndV2ResourcesCollidesInSameHeatFile() {
+ Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(validator,
+ "/org/openecomp/validation/validators/contrailvalidatorresources/collidesinsameheatfile/");
+ validateMessage(messages,
+ "WARNING: HEAT Package includes both Contrail 2 and Contrail 3 resources. Contrail 2 resources can be found in file 'first.yaml' , resources :'jsa_net1' . Contrail 3 resources can be found in file 'first.yaml' , resources :'jsa_net2' ",
+ "first.yaml", 2);
+ }
+
+ @Test
+ public void testWarningMessageExistWhenConrailV1AndV2ResourcesCollidesInDifferentHeatFiles() {
+ Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(validator,
+ "/org/openecomp/validation/validators/contrailvalidatorresources/collidesindifferentheatfiles/");
+ validateMessage(messages,
+ "WARNING: HEAT Package includes both Contrail 2 and Contrail 3 resources. Contrail 2 resources can be found in file 'first.yaml' , resources :'jsa_net1', 'jsa_net3' . Contrail 3 resources can be found in file 'second.yaml' , resources :'jsa_net2', 'jsa_net4', file 'first.yaml' , resources :'jsa_net5' ",
+ "first.yaml", 3);
+ }
+
+ @Test
+ public void testWarningMessageNotExistWhenConrailV1AndV2ResourcesCollidesInNonHeatFile() {
+ Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(validator,
+ "/org/openecomp/validation/validators/contrailvalidatorresources/collidesinnontheatfiles/");
+ validateMessage(messages,
+ "WARNING: HEAT Package includes both Contrail 2 and Contrail 3 resources. Contrail 2 resources can be found in file 'first.yaml' , resources :'jsa_net1' . Contrail 3 resources can be found in file 'second.yaml' , resources :'jsa_net2' ",
+ "first.yaml", 2);
+ ;
+ }
+
+ @Test
+ public void testWarningMessageNotExistWhenOnlyConrailV1Resources() {
+ Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(validator,
+ "/org/openecomp/validation/validators/contrailvalidatorresources/notcollides/");
+ validateMessage(messages,
+ "WARNING: Contrail 2.x deprecated resource is in use, Resource ID [jsa_net1]", "first.yaml",
+ 2);
+ }
+
+
+ @Test
+ public void testWarningMessageOnResourceWithContrailType() {
+ Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(validator,
+ "/org/openecomp/validation/validators/contrailvalidatorresources/validatenocontrailresource/");
+ validateMessage(messages,
+ "WARNING: Contrail 2.x deprecated resource is in use, Resource ID [template_NetworkPolicy]",
+ "first.yaml", 1);
+ ;
+ }
+
+ private void validateMessage(Map<String, MessageContainer> messages, String expectedMessage,
+ String fileNameWithErrorToCheck, int sizeOfFileMessageList) {
+ Assert.assertEquals(messages.size(), 1);
+ List<ErrorMessage> errorMessageList =
+ messages.get(fileNameWithErrorToCheck).getErrorMessageList();
+ Assert.assertEquals(errorMessageList.size(), sizeOfFileMessageList);
+ Assert.assertEquals(errorMessageList.get(0).getMessage(), expectedMessage);
+ }
+
+
+}
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/ErrorMessagesTest.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/ErrorMessagesTest.java
index d762689049..345aad330d 100644
--- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/ErrorMessagesTest.java
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/ErrorMessagesTest.java
@@ -1,10 +1,31 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
package org.openecomp.sdc.validation.impl.validators;
-import org.openecomp.core.validation.errors.ErrorMessagesFormatBuilder;
-import org.openecomp.core.validation.errors.Messages;
import org.junit.Test;
+import org.openecomp.core.validation.errors.ErrorMessagesFormatBuilder;
+import org.openecomp.sdc.common.errors.Messages;
import org.testng.Assert;
+
public class ErrorMessagesTest {
@Test
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/ForbiddenResourceGuideLineValidatorTest.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/ForbiddenResourceGuideLineValidatorTest.java
new file mode 100644
index 0000000000..7cee77c54c
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/ForbiddenResourceGuideLineValidatorTest.java
@@ -0,0 +1,55 @@
+package org.openecomp.sdc.validation.impl.validators;
+
+import org.openecomp.sdc.validation.Validator;
+import org.openecomp.core.validation.types.MessageContainer;
+import org.openecomp.sdc.datatypes.configuration.ImplementationConfiguration;
+import org.openecomp.sdc.validation.util.ValidationTestUtil;
+import org.testng.Assert;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+import java.io.IOException;
+import java.util.Map;
+
+/**
+ * Created by TALIO on 2/16/2017.
+ */
+public class ForbiddenResourceGuideLineValidatorTest {
+
+ private static String mockConfigFileName =
+ "/org/openecomp/validation/configuration/mock_resource_validator_configuration.json";
+
+ ForbiddenResourceGuideLineValidator forbiddenResourceGuideLineValidator = new
+ ForbiddenResourceGuideLineValidator();
+
+ @BeforeClass
+ public void init() throws IOException {
+ Map<String, Object> resourcesMap = ValidationTestUtil.getResourceMap(mockConfigFileName);
+
+ Map<String, Object> resourceBaseValidatorMap =
+ (Map<String, Object>) resourcesMap.get("forbiddenResourceGuideLineValidator");
+ String implementationClass =
+ (String) resourceBaseValidatorMap.get("implementationClass");
+ Map<String, Object> properties =
+ (Map<String, Object>) resourceBaseValidatorMap.get("properties");
+
+ forbiddenResourceGuideLineValidator.init(properties);
+ }
+
+ @Test
+ public void testFloatingIpResourceType() {
+ Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(forbiddenResourceGuideLineValidator,
+ "/org/openecomp/validation/validators/attGuideLineValidator/heatFloatingIpResourceType/positive");
+ Assert.assertNotNull(messages);
+ Assert.assertEquals(messages.size(), 0);
+
+
+ messages = ValidationTestUtil.testValidator(forbiddenResourceGuideLineValidator,
+ "/org/openecomp/validation/validators/attGuideLineValidator/heatFloatingIpResourceType/negative");
+ Assert.assertNotNull(messages);
+ Assert.assertEquals(messages.size(), 1);
+ Assert.assertEquals(messages.get("first.yaml").getErrorMessageList().size(), 1);
+ Assert.assertEquals(messages.get("first.yaml").getErrorMessageList().get(0).getMessage(),
+ "WARNING: OS::Neutron::FloatingIP is in use, Resource ID [FSB2]");
+ }
+}
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/HeatValidatorTest.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/HeatValidatorTest.java
new file mode 100644
index 0000000000..471ed7df10
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/HeatValidatorTest.java
@@ -0,0 +1,230 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdc.validation.impl.validators;
+
+
+import org.openecomp.sdc.validation.Validator;
+import org.openecomp.core.validation.types.MessageContainer;
+import org.openecomp.sdc.validation.util.ValidationTestUtil;
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+import java.io.IOException;
+import java.util.Map;
+
+
+public class HeatValidatorTest {
+
+
+ private Validator validator = new HeatValidator();
+
+ @Test
+ public void testInvalidHeatFormat() {
+ Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(validator,
+ "/org/openecomp/validation/validators/heat_validator/invalid_heat_format/negative_test/input");
+
+ Assert.assertNotNull(messages);
+ Assert.assertEquals(messages.size(), 1);
+
+ Assert.assertEquals(messages.get("hot-nimbus-psm_v1.0.yaml").getErrorMessageList().size(), 1);
+ Assert.assertEquals(
+ messages.get("hot-nimbus-psm_v1.0.yaml").getErrorMessageList().get(0).getMessage(),
+ "ERROR: Invalid HEAT format problem - [Cannot create property=kuku for JavaBean=Resource{type='null', properties=null, metadata=null, depends_on=null, update_policy='null', deletion_policy='null'}\n" +
+ " in 'reader', line 25, column 5:\n" +
+ " kuku: kuku\n" +
+ " ^\n" +
+ "Unable to find property 'kuku' on class: org.openecomp.sdc.heat.datatypes.model.Resource\n" +
+ " in 'reader', line 25, column 11:\n" +
+ " kuku: kuku\n" +
+ " ^\n" +
+ "]");
+ }
+
+ @Test
+ public void testDependsOn() {
+ Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(validator,
+ "/org/openecomp/validation/validators/heat_validator/depends_on_points_to_existing_resource/input");
+
+ Assert.assertNotNull(messages);
+ Assert.assertEquals(messages.size(), 1);
+
+ Assert.assertEquals(messages.get("hot-nimbus-pps_v1.0.yaml").getErrorMessageList().size(), 2);
+ Assert.assertEquals(
+ messages.get("hot-nimbus-pps_v1.0.yaml").getErrorMessageList().get(0).getMessage(),
+ "ERROR: a Missing resource in depend On, Missing Resource ID [resource_not_exist]");
+ Assert.assertEquals(
+ messages.get("hot-nimbus-pps_v1.0.yaml").getErrorMessageList().get(1).getMessage(),
+ "ERROR: a Missing resource in depend On, Missing Resource ID [resource_3]");
+ }
+
+
+ @Test
+ public void testResourcesReferencesExistInHeat() throws IOException {
+ Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(new HeatValidator(),
+ "/org/openecomp/validation/validators/heat_validator/resource_references_exist_in_heat/negative_test/input");
+
+ Assert.assertNotNull(messages);
+ Assert.assertEquals(messages.size(), 1);
+
+ Assert.assertEquals(messages.get("hot-nimbus-pps_v1.0.yaml").getErrorMessageList().size(), 2);
+ Assert.assertEquals(
+ messages.get("hot-nimbus-pps_v1.0.yaml").getErrorMessageList().get(0).getMessage(),
+ "ERROR: Referenced resource - not_existing_resource not found");
+ Assert.assertEquals(
+ messages.get("hot-nimbus-pps_v1.0.yaml").getErrorMessageList().get(1).getMessage(),
+ "ERROR: invalid get_resource syntax is in use - null , get_resource function should get the resource id of the referenced resource");
+ }
+
+
+ @Test
+ public void testGetResourceValueIsValid() {
+ Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(new HeatValidator(),
+ "/org/openecomp/validation/validators/heat_validator/get_resource_value_valid/negative_test/input");
+
+ Assert.assertNotNull(messages);
+ Assert.assertEquals(messages.size(), 1);
+
+ Assert.assertEquals(messages.get("hot-nimbus-pps_v1.0.yaml").getErrorMessageList().size(), 3);
+ Assert.assertEquals(
+ messages.get("hot-nimbus-pps_v1.0.yaml").getErrorMessageList().get(0).getMessage(),
+ "ERROR: invalid get_resource syntax is in use - [param_1, param_2] , get_resource function should get the resource id of the referenced resource");
+ Assert.assertEquals(
+ messages.get("hot-nimbus-pps_v1.0.yaml").getErrorMessageList().get(1).getMessage(),
+ "ERROR: invalid get_resource syntax is in use - {get_param=param_1} , get_resource function should get the resource id of the referenced resource");
+ Assert.assertEquals(
+ messages.get("hot-nimbus-pps_v1.0.yaml").getErrorMessageList().get(2).getMessage(),
+ "ERROR: invalid get_resource syntax is in use - null , get_resource function should get the resource id of the referenced resource");
+ }
+
+ @Test
+ public void testTwoResourcesDoesNotHoldSameId() throws IOException {
+ Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(new HeatValidator(),
+ "/org/openecomp/validation/validators/heat_validator/two_resources_does_not_hold_same_id/positive_test/input");
+ Assert.assertNotNull(messages);
+ Assert.assertEquals(messages.size(), 0);
+ }
+
+ @Test
+ public void negativeTestGetParamPointToExistingParameter() throws IOException {
+ Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(new HeatValidator(),
+ "/org/openecomp/validation/validators/heat_validator/get_param_points_to_existing_parameter/negative_test/input");
+
+ Assert.assertNotNull(messages);
+ Assert.assertEquals(messages.size(), 1);
+
+ Assert.assertEquals(messages.get("hot-nimbus-psm_v1.0.yaml").getErrorMessageList().size(), 1);
+ Assert.assertEquals(
+ messages.get("hot-nimbus-psm_v1.0.yaml").getErrorMessageList().get(0).getMessage(),
+ "ERROR: Referenced parameter - not_existing_param_1 - not found, used in resource [server_pcrf_psm_001]");
+ }
+
+ @Test
+ public void testGetAttrFromNested() throws IOException {
+ Map<String, MessageContainer> messages =ValidationTestUtil.testValidator(new HeatValidator(),
+ "/org/openecomp/validation/validators/heat_validator/get_attr_from_nested/negative_test/input");
+
+ Assert.assertNotNull(messages);
+ Assert.assertEquals(messages.size(), 1);
+
+ Assert.assertEquals(messages.get("hot-nimbus-psm_v1.0.yaml").getErrorMessageList().size(), 1);
+ Assert.assertEquals(
+ messages.get("hot-nimbus-psm_v1.0.yaml").getErrorMessageList().get(0).getMessage(),
+ "ERROR: get_attr attribute not found, Attribute name [nested_output], Resource ID [server_pcrf_psm_001]");
+ }
+
+ @Test
+ public void testDefaultValueAlignWithType() throws IOException {
+ Map<String, MessageContainer> messages =ValidationTestUtil.testValidator(new HeatValidator(),
+ "/org/openecomp/validation/validators/heat_validator/default_value_align_with_type/negative_test/input");
+
+ Assert.assertNotNull(messages);
+ Assert.assertEquals(messages.size(), 1);
+
+ Assert.assertEquals(messages.get("hot-nimbus-pps_v1.0.yaml").getErrorMessageList().size(), 1);
+ Assert.assertEquals(
+ messages.get("hot-nimbus-pps_v1.0.yaml").getErrorMessageList().get(0).getMessage(),
+ "ERROR: Parameter - pcrf_pps_image_name_1 default value not align with type number");
+ }
+
+
+ @Test
+ public void testEnvParametersMatchDefinedHeatParameterTypes() throws IOException {
+ Map<String, MessageContainer> messages =ValidationTestUtil.testValidator(new HeatValidator(),
+ "/org/openecomp/validation/validators/heat_validator/env_parameters_match_defined_types/negative_test/input");
+
+ Assert.assertNotNull(messages);
+ Assert.assertEquals(messages.size(), 1);
+
+ Assert.assertEquals(messages.get("hot-nimbus-pps_v1.0.env").getErrorMessageList().size(), 1);
+ Assert.assertEquals(
+ messages.get("hot-nimbus-pps_v1.0.env").getErrorMessageList().get(0).getMessage(),
+ "ERROR: Parameter env value pcrf_pps_flavor_name not align with type");
+
+ }
+
+ @Test
+ public void testReferencedArtifactsExist() throws IOException {
+ Map<String, MessageContainer> messages =ValidationTestUtil.testValidator(new HeatValidator(),
+ "/org/openecomp/validation/validators/heat_validator/referenced_artifacts_exist/negative_test/input");
+
+ Assert.assertNotNull(messages);
+ Assert.assertEquals(messages.size(), 1);
+
+ Assert.assertEquals(messages.get("hot-nimbus-pps_v1.0.yaml").getErrorMessageList().size(), 1);
+ Assert.assertEquals(
+ messages.get("hot-nimbus-pps_v1.0.yaml").getErrorMessageList().get(0).getMessage(),
+ "ERROR: Missing artifact - nimbus-ethernet");
+
+ }
+
+ @Test
+ public void testEnvContentIsSubSetOfHeatParameters() throws IOException {
+ Map<String, MessageContainer> messages =ValidationTestUtil.testValidator(validator,
+ "/org/openecomp/validation/validators/heat_validator/env_content_is_subset_of_heat/negative_test/input");
+
+ Assert.assertNotNull(messages);
+ Assert.assertEquals(messages.size(), 1);
+
+ Assert.assertEquals(messages.get("hot-nimbus-pps_v1.0.env").getErrorMessageList().size(), 1);
+ Assert.assertEquals(
+ messages.get("hot-nimbus-pps_v1.0.env").getErrorMessageList().get(0).getMessage(),
+ "ERROR: Env file hot-nimbus-pps_v1.0.env includes a parameter not in HEAT - mock_param");
+ }
+
+ @Test
+ public void testGetParamPseudoParameters() {
+ Map<String, MessageContainer> messages =ValidationTestUtil.testValidator(new HeatValidator(),
+ "/org/openecomp/validation/validators/heat_validator/pseudo_parameters/input");
+
+ Assert.assertNotNull(messages);
+ Assert.assertEquals(messages.size(), 0);
+
+ }
+ @Test
+ public void testNoErrorWhenEmptyValueForParameterInEnv() {
+ Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(validator,
+ "/org/openecomp/validation/validators/heat_validator/env_empty_value/input");
+
+ Assert.assertNotNull(messages);
+ Assert.assertEquals(messages.size(), 0);
+ }
+
+}
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/ManifestValidatorTest.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/ManifestValidatorTest.java
new file mode 100644
index 0000000000..3d560934dd
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/ManifestValidatorTest.java
@@ -0,0 +1,142 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdc.validation.impl.validators;
+
+
+import org.openecomp.core.validation.types.MessageContainer;
+import org.openecomp.sdc.common.errors.Messages;
+import org.openecomp.sdc.common.utils.SdcCommon;
+import org.openecomp.sdc.validation.util.ValidationTestUtil;
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+import java.util.Map;
+
+
+public class ManifestValidatorTest {
+
+
+ private ManifestValidator validator = new ManifestValidator();
+
+ @Test
+ public void testValidManifest() {
+
+ Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(validator,
+ "/org/openecomp/validation/validators/manifestValidator/validFiles");
+ Assert.assertNotNull(messages);
+ Assert.assertNotNull(messages);
+ Assert.assertEquals(messages.size(), 0);
+ }
+
+ @Test
+ public void testManifestMissingFileInZip() {
+ Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(new ManifestValidator(),
+ "/org/openecomp/validation/validators/manifestValidator/missingFileInZip");
+ Assert.assertNotNull(messages);
+ Assert.assertEquals(messages.size(), 1);
+ Assert.assertTrue(messages.containsKey("singleVol.yaml"));
+ ValidationTestUtil.validateErrorMessage(messages.get("singleVol.yaml").getErrorMessageList().get(0).getMessage(),
+ "ERROR: " + Messages.MISSING_FILE_IN_ZIP.getErrorMessage());
+ }
+
+ @Test
+ public void testInvalidManifest() {
+ Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(new ManifestValidator(),
+ "/org/openecomp/validation/validators/manifestValidator/invalidManifest");
+ Assert.assertNotNull(messages);
+ Assert.assertNotNull(messages);
+ Assert.assertEquals(messages.size(), 1);
+ Assert.assertTrue(messages.containsKey(SdcCommon.MANIFEST_NAME));
+ ValidationTestUtil.validateErrorMessage(
+ messages.get(SdcCommon.MANIFEST_NAME).getErrorMessageList().get(0).getMessage(),
+ "ERROR: " + Messages.INVALID_MANIFEST_FILE.getErrorMessage(), SdcCommon.MANIFEST_NAME);
+
+ }
+
+ @Test
+ public void testMissingFileInManifest() {
+ Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(new ManifestValidator(),
+ "/org/openecomp/validation/validators/manifestValidator/missingFileInManifest");
+ Assert.assertNotNull(messages);
+ Assert.assertEquals(messages.size(), 1);
+ Assert.assertTrue(messages.containsKey("extraFile.env"));
+ ValidationTestUtil.validateErrorMessage(messages.get("extraFile.env").getErrorMessageList().get(0).getMessage(),
+ "WARNING: " + Messages.MISSING_FILE_IN_MANIFEST.getErrorMessage());
+
+ }
+
+ @Test
+ public void testInvalidFileTypeInManifest() {
+ Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(new ManifestValidator(),
+ "/org/openecomp/validation/validators/manifestValidator/invalidFileTypeInManifest");
+ Assert.assertNotNull(messages);
+ Assert.assertEquals(messages.size(), 4);
+ Assert.assertTrue(messages.containsKey("single.env.illegalSuffix"));
+ Assert.assertTrue(messages.containsKey("illegalTypeFile.yaml"));
+ Assert.assertTrue(messages.containsKey("single.yaml.illegalSuffix"));
+ Assert.assertTrue(messages.containsKey("singleVol.yaml.illegalSuffix"));
+ ValidationTestUtil.validateErrorMessage(
+ messages.get("single.env.illegalSuffix").getErrorMessageList().get(0).getMessage(),
+ "ERROR: " + Messages.WRONG_ENV_FILE_EXTENSION.getErrorMessage(),
+ "single.env.illegalSuffix");
+ ValidationTestUtil.validateErrorMessage(
+ messages.get("illegalTypeFile.yaml").getErrorMessageList().get(0).getMessage(),
+ "ERROR: " + Messages.INVALID_FILE_TYPE.getErrorMessage(), "illegalTypeFile.yaml");
+ ValidationTestUtil.validateErrorMessage(
+ messages.get("single.yaml.illegalSuffix").getErrorMessageList().get(0).getMessage(),
+ "ERROR: " + Messages.WRONG_HEAT_FILE_EXTENSION.getErrorMessage(),
+ "single.yaml.illegalSuffix");
+ ValidationTestUtil.validateErrorMessage(
+ messages.get("singleVol.yaml.illegalSuffix").getErrorMessageList().get(0).getMessage(),
+ "ERROR: " + Messages.WRONG_HEAT_FILE_EXTENSION.getErrorMessage(),
+ "singleVol.yaml.illegalSuffix");
+
+ }
+
+
+ @Test
+ public void testMissingFileInManifestAndInZip() {
+
+ Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(new ManifestValidator(),
+ "/org/openecomp/validation/validators/manifestValidator/missingFileInManifestAndInZip");
+ Assert.assertNotNull(messages);
+ Assert.assertEquals(messages.size(), 2);
+ Assert.assertTrue(messages.containsKey("extraFile.env"));
+ Assert.assertTrue(messages.containsKey("singleVol.yaml"));
+ ValidationTestUtil.validateErrorMessage(messages.get("extraFile.env").getErrorMessageList().get(0).getMessage(),
+ "WARNING: " + Messages.MISSING_FILE_IN_MANIFEST.getErrorMessage());
+ ValidationTestUtil.validateErrorMessage(messages.get("singleVol.yaml").getErrorMessageList().get(0).getMessage(),
+ "ERROR: " + Messages.MISSING_FILE_IN_ZIP.getErrorMessage());
+
+ }
+
+
+ @Test
+ public void testEnvInRoot() {
+ Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(new ManifestValidator(),
+ "/org/openecomp/validation/validators/manifestValidator/envInRoot");
+ Assert.assertNotNull(messages);
+ Assert.assertEquals(messages.size(), 1);
+ Assert.assertTrue(messages.containsKey("second.env"));
+ ValidationTestUtil.validateErrorMessage(messages.get("second.env").getErrorMessageList().get(0).getMessage(),
+ "ERROR: ENV file must be associated to a HEAT file");
+ }
+}
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/SharedResourceGuideLineValidatorTest.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/SharedResourceGuideLineValidatorTest.java
new file mode 100644
index 0000000000..7d994e4f13
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/SharedResourceGuideLineValidatorTest.java
@@ -0,0 +1,155 @@
+package org.openecomp.sdc.validation.impl.validators;
+
+import org.openecomp.sdc.validation.Validator;
+import org.openecomp.core.validation.types.MessageContainer;
+import org.openecomp.sdc.validation.util.ValidationTestUtil;
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+import java.util.Map;
+
+/**
+ * Created by TALIO on 2/15/2017.
+ */
+public class SharedResourceGuideLineValidatorTest {
+
+ Validator validator = new SharedResourceGuideLineValidator();
+
+ @Test
+ public void testBaseHeatExposeNetwork() {
+ Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(validator,
+ "/org/openecomp/validation/validators/attGuideLineValidator/baseHeatDoesNotExposeNetwork/positive/");
+ Assert.assertNotNull(messages);
+ Assert.assertEquals(messages.size(), 0);
+
+ messages = ValidationTestUtil.testValidator(validator,
+ "/org/openecomp/validation/validators/attGuideLineValidator/baseHeatDoesNotExposeNetwork/negative/");
+ Assert.assertNotNull(messages);
+ Assert.assertEquals(messages.size(), 1);
+ Assert.assertEquals(messages.get("first.yaml").getErrorMessageList().size(), 1);
+ Assert.assertEquals(messages.get("first.yaml").getErrorMessageList().get(0).getMessage(),
+ "WARNING: Resource is not defined as output and thus cannot be Shared, Resource ID [SecurityGroup_expose]");
+ }
+
+ @Test
+ public void testBaseHeatExposeNetworkAndVolume() {
+ Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(validator,
+ "/org/openecomp/validation/validators/attGuideLineValidator/baseHeatDoesNotExposeNetworkAndVolume/positive/");
+ Assert.assertNotNull(messages);
+ Assert.assertEquals(messages.size(), 0);
+
+ messages = ValidationTestUtil.testValidator(validator,
+ "/org/openecomp/validation/validators/attGuideLineValidator/baseHeatDoesNotExposeNetworkAndVolume/negative/");
+ Assert.assertNotNull(messages);
+ Assert.assertEquals(messages.size(), 1);
+ Assert.assertEquals(messages.get("first.yaml").getErrorMessageList().size(), 2);
+ Assert.assertEquals(messages.get("first.yaml").getErrorMessageList().get(0).getMessage(),
+ "WARNING: Resource is not defined as output and thus cannot be Shared, Resource ID [volume_expose]");
+ Assert.assertEquals(messages.get("first.yaml").getErrorMessageList().get(1).getMessage(),
+ "WARNING: Resource is not defined as output and thus cannot be Shared, Resource ID [net_expose]");
+ }
+
+ @Test
+ public void testBaseHeatExposeServerGroup() {
+ Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(validator,
+ "/org/openecomp/validation/validators/attGuideLineValidator/baseHeatDoesNotExposeServerGroup/positive/");
+ Assert.assertNotNull(messages);
+ Assert.assertEquals(messages.size(), 0);
+
+ messages = ValidationTestUtil.testValidator(validator,
+ "/org/openecomp/validation/validators/attGuideLineValidator/baseHeatDoesNotExposeServerGroup/negative/");
+ Assert.assertNotNull(messages);
+ Assert.assertEquals(messages.size(), 1);
+ Assert.assertEquals(messages.get("first.yaml").getErrorMessageList().size(), 1);
+ Assert.assertEquals(messages.get("first.yaml").getErrorMessageList().get(0).getMessage(),
+ "WARNING: Resource is not defined as output and thus cannot be Shared, Resource ID [ServerGroup_expose]");
+ }
+
+ @Test
+ public void testBaseHeatExposeSecurityGroup() {
+ Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(validator,
+ "/org/openecomp/validation/validators/attGuideLineValidator/baseHeatDoesNotExposeSecurityGroup/positive/");
+ Assert.assertNotNull(messages);
+ Assert.assertEquals(messages.size(), 0);
+
+ messages = ValidationTestUtil.testValidator(validator,
+ "/org/openecomp/validation/validators/attGuideLineValidator/baseHeatDoesNotExposeSecurityGroup/negative/");
+ Assert.assertNotNull(messages);
+ Assert.assertEquals(messages.size(), 1);
+ Assert.assertEquals(messages.get("first.yaml").getErrorMessageList().size(), 1);
+ Assert.assertEquals(messages.get("first.yaml").getErrorMessageList().get(0).getMessage(),
+ "WARNING: Resource is not defined as output and thus cannot be Shared, Resource ID [SecurityGroup_expose]");
+ }
+
+ @Test
+ public void testBaseHeatExposeVolume() {
+ Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(validator,
+ "/org/openecomp/validation/validators/attGuideLineValidator/baseHeatDoesNotExposeVolume/positive/");
+ Assert.assertNotNull(messages);
+ Assert.assertEquals(messages.size(), 0);
+
+ messages = ValidationTestUtil.testValidator(validator,
+ "/org/openecomp/validation/validators/attGuideLineValidator/baseHeatDoesNotExposeVolume/negative/");
+ Assert.assertNotNull(messages);
+ Assert.assertEquals(messages.size(), 1);
+ Assert.assertEquals(messages.get("first.yaml").getErrorMessageList().size(), 1);
+ Assert.assertEquals(messages.get("first.yaml").getErrorMessageList().get(0).getMessage(),
+ "WARNING: Resource is not defined as output and thus cannot be Shared, Resource ID [volume_expose]");
+ }
+
+ @Test
+ public void testHeatVolumeExpose() {
+ Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(validator,
+ "/org/openecomp/validation/validators/attGuideLineValidator/heatVolumeExpose/positive/");
+ Assert.assertNotNull(messages);
+ Assert.assertEquals(messages.size(), 0);
+
+ messages = ValidationTestUtil.testValidator(validator,
+ "/org/openecomp/validation/validators/attGuideLineValidator/heatVolumeExpose/negative/");
+ Assert.assertNotNull(messages);
+ Assert.assertEquals(messages.size(), 1);
+ Assert.assertEquals(messages.get("firstVol.yaml").getErrorMessageList().size(), 1);
+ Assert.assertEquals(messages.get("firstVol.yaml").getErrorMessageList().get(0).getMessage(),
+ "WARNING: Volume is not defined as output and thus cannot be attached volume_expose");
+
+ }
+
+ @Test
+ public void testResourceIsExposedByCallingGetResourceNotFromOutput() {
+ Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(validator,
+ "/org/openecomp/validation/validators/attGuideLineValidator/baseHeatExposeResourceUsingGetResource/positive");
+ Assert.assertNotNull(messages);
+ Assert.assertEquals(messages.size(), 0);
+
+
+ messages = ValidationTestUtil.testValidator(validator,
+ "/org/openecomp/validation/validators/attGuideLineValidator/baseHeatExposeResourceUsingGetResource/negative");
+ Assert.assertNotNull(messages);
+ Assert.assertEquals(messages.size(), 1);
+ Assert.assertEquals(messages.get("base_virc.yaml").getErrorMessageList().size(), 1);
+ Assert.assertEquals(messages.get("base_virc.yaml").getErrorMessageList().get(0).getMessage(),
+ "WARNING: Resource is not defined as output and thus cannot be Shared, Resource ID [virc_RSG]");
+ }
+
+ @Test
+ public void testMissingBaseHeat() {
+ Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(validator,
+ "/org/openecomp/validation/validators/attGuideLineValidator/missingBaseHeat/");
+ Assert.assertNotNull(messages);
+ Assert.assertEquals(messages.size(), 1);
+ Assert.assertEquals(messages.get("MANIFEST.json").getErrorMessageList().size(), 1);
+ Assert.assertEquals(messages.get("MANIFEST.json").getErrorMessageList().get(0).getMessage(),
+ "WARNING: Missing Base HEAT. Pay attention that without Base HEAT, there will be no shared resources");
+ }
+
+ @Test
+ public void testMultiBaseHeat() {
+ Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(validator,
+ "/org/openecomp/validation/validators/attGuideLineValidator/multiBaseHeat/");
+ Assert.assertNotNull(messages);
+ Assert.assertEquals(messages.size(), 1);
+ Assert.assertEquals(messages.get("MANIFEST.json").getErrorMessageList().size(), 1);
+ Assert.assertEquals(messages.get("MANIFEST.json").getErrorMessageList().get(0).getMessage(),
+ "WARNING: Multi Base HEAT. Expected only one. Files [second.yaml,first.yaml].");
+ }
+}
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/ValidatorBaseTest.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/ValidatorBaseTest.java
deleted file mode 100644
index f9c5bf423b..0000000000
--- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/ValidatorBaseTest.java
+++ /dev/null
@@ -1,84 +0,0 @@
-package org.openecomp.sdc.validation.impl.validators;
-
-import org.openecomp.core.utilities.file.FileUtils;
-import org.openecomp.core.validation.errors.ErrorMessagesFormatBuilder;
-import org.openecomp.core.validation.interfaces.Validator;
-import org.openecomp.core.validation.types.GlobalValidationContext;
-import org.openecomp.core.validation.types.MessageContainer;
-import org.testng.Assert;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.net.URL;
-import java.util.HashMap;
-import java.util.Map;
-
-public abstract class ValidatorBaseTest {
-
- private static GlobalValidationContext createGlobalContextFromPath(String path) {
- GlobalValidationContext globalValidationContext = new GlobalValidationContext();
- Map<String, byte[]> contentMap = getContentMapByPath(path);
- if (contentMap == null) {
- return null;
- }
- contentMap.entrySet().stream()
- .forEach(entry -> globalValidationContext.addFileContext(entry.getKey(), entry.getValue()));
-
- return globalValidationContext;
- }
-
-
- // New test base implementation
-
- private static Map<String, byte[]> getContentMapByPath(String path) {
- Map<String, byte[]> contentMap = new HashMap<>();
- byte[] fileContent;
- FileInputStream fis;
- URL url = ValidatorBaseTest.class.getResource(path);
- File pathFile = new File(url.getFile());
- File[] files;
- if (pathFile.isDirectory()) {
- files = pathFile.listFiles();
- } else {
- files = new File[]{pathFile};
- }
-
- if (files == null || files.length == 0) {
- return null;
- }
-
- for (File file : files) {
- try {
- fis = new FileInputStream(file);
- fileContent = FileUtils.toByteArray(fis);
- contentMap.put(file.getName(), fileContent);
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- return contentMap;
- }
-
- public abstract Map<String, MessageContainer> runValidation(String path);
-
- protected Map<String, MessageContainer> testValidator(Validator validator, String path) {
-
- GlobalValidationContext globalValidationContext = createGlobalContextFromPath(path);
- validator.validate(globalValidationContext);
-
- assert globalValidationContext != null;
- return globalValidationContext.getContextMessageContainers();
-
-
- }
-
- protected void validateErrorMessage(String actualMessage, String expected, String... params) {
- Assert.assertEquals(actualMessage.replace("\n", "").replace("\r", ""),
- ErrorMessagesFormatBuilder.getErrorWithParameters(expected, params).replace("\n", "")
- .replace("\r", ""));
-
- }
-
-
-}
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/validators/YamlValidatorTest.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/YamlValidatorTest.java
index abce8ec88c..32e847004c 100644
--- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/validators/YamlValidatorTest.java
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/YamlValidatorTest.java
@@ -1,22 +1,40 @@
-package org.openecomp.sdc.validation.impl.validators.validators;
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdc.validation.impl.validators;
-import org.openecomp.sdc.validation.impl.validators.ValidatorBaseTest;
-import org.openecomp.sdc.validation.impl.validators.YamlValidator;
-import org.openecomp.core.validation.errors.Messages;
import org.openecomp.core.validation.types.MessageContainer;
-
+import org.openecomp.sdc.common.errors.Messages;
+import org.openecomp.sdc.validation.util.ValidationTestUtil;
import org.testng.Assert;
import org.testng.annotations.Test;
import java.util.Map;
-public class YamlValidatorTest extends ValidatorBaseTest {
+public class YamlValidatorTest {
public Map<String, MessageContainer> runValidation(String path) {
YamlValidator validator = new YamlValidator();
- return testValidator(validator, path);
+ return ValidationTestUtil.testValidator(validator, path);
}
@@ -24,21 +42,21 @@ public class YamlValidatorTest extends ValidatorBaseTest {
public void testValidYaml() {
Map<String, MessageContainer> messages = runValidation(
- "/openecomp/org/validation/validators/yaml_validator/valid_yaml/input/validHeat.yaml");
+ "/org/openecomp/validation/validators/yaml_validator/valid_yaml/input/validHeat.yaml");
Assert.assertNotNull(messages);
Assert.assertEquals(messages.size(), 0);
}
-// @Test
+ @Test
public void testInvalidTabYaml() {
Map<String, MessageContainer> messages = runValidation(
- "/openecomp/org/validation/validators/yaml_validator/invalid_valid_yaml_structure/input/invalidYamlTab.yaml");
+ "/org/openecomp/validation/validators/yaml_validator/invalid_valid_yaml_structure/input/invalidYamlTab.yaml");
Assert.assertNotNull(messages);
Assert.assertEquals(messages.size(), 1);
- validateErrorMessage(
+ ValidationTestUtil.validateErrorMessage(
messages.get("invalidYamlTab.yaml").getErrorMessageList().get(0).getMessage(),
- Messages.INVALID_YAML_FORMAT_REASON.getErrorMessage(),
+ "ERROR: " + Messages.INVALID_YAML_FORMAT_REASON.getErrorMessage(),
"while scanning for the next tokenfound character '\\t(TAB)' that cannot start any token. (Do not use \\t(TAB) for indentation) in 'reader', line 14, column 5: \tadmin_state_up: true ^");
}
@@ -48,13 +66,13 @@ public class YamlValidatorTest extends ValidatorBaseTest {
public void testDuplicateKeyInYaml() {
Map<String, MessageContainer> messages =
- runValidation("/openecomp/org/validation/validators/yaml_validator/duplicateKey.yaml");
+ runValidation("/org/openecomp/validation/validators/yaml_validator/duplicateKey.yaml");
Assert.assertNotNull(messages);
Assert.assertEquals(messages.size(), 1);
Assert.assertTrue(messages.containsKey("duplicateKey.yaml"));
- validateErrorMessage(
+ ValidationTestUtil.validateErrorMessage(
messages.get("duplicateKey.yaml").getErrorMessageList().get(0).getMessage(),
- Messages.INVALID_YAML_FORMAT_REASON.getErrorMessage(),
+ "ERROR: " + Messages.INVALID_YAML_FORMAT_REASON.getErrorMessage(),
"while parsing MappingNode in 'reader', line 6, column 3: Key_1_unique: ^duplicate key: Key_2_not_unique in 'reader', line 31, column 1: ^");
}
@@ -62,14 +80,14 @@ public class YamlValidatorTest extends ValidatorBaseTest {
@Test
public void testInvalidYamlStructure() {
- Map<String, MessageContainer> messages =
- runValidation("/openecomp/org/validation/validators/yaml_validator/invalidYamlStructure.yaml");
+ Map<String, MessageContainer> messages = runValidation(
+ "/org/openecomp/validation/validators/yaml_validator/invalidYamlStructure.yaml");
Assert.assertNotNull(messages);
Assert.assertEquals(messages.size(), 1);
Assert.assertTrue(messages.containsKey("invalidYamlStructure.yaml"));
- validateErrorMessage(
+ ValidationTestUtil.validateErrorMessage(
messages.get("invalidYamlStructure.yaml").getErrorMessageList().get(0).getMessage(),
- Messages.INVALID_YAML_FORMAT_REASON.getErrorMessage(),
+ "ERROR: " + Messages.INVALID_YAML_FORMAT_REASON.getErrorMessage(),
"while parsing a block mapping in 'reader', line 8, column 7: admin_state_up: true ^expected <block end>, but found BlockEntry in 'reader', line 10, column 7: - shared: true ^");
}
@@ -77,12 +95,12 @@ public class YamlValidatorTest extends ValidatorBaseTest {
public void testEmptyYaml() {
Map<String, MessageContainer> messages =
- runValidation("/openecomp/org/validation/validators/yaml_validator/emptyYaml.yaml");
+ runValidation("/org/openecomp/validation/validators/yaml_validator/emptyYaml.yaml");
Assert.assertNotNull(messages);
Assert.assertEquals(messages.size(), 1);
Assert.assertTrue(messages.containsKey("emptyYaml.yaml"));
- validateErrorMessage(messages.get("emptyYaml.yaml").getErrorMessageList().get(0).getMessage(),
- Messages.INVALID_YAML_FORMAT_REASON.getErrorMessage(),
+ ValidationTestUtil.validateErrorMessage(messages.get("emptyYaml.yaml").getErrorMessageList().get(0).getMessage(),
+ "ERROR: " + Messages.INVALID_YAML_FORMAT_REASON.getErrorMessage(),
Messages.EMPTY_YAML_FILE.getErrorMessage());
}
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/heatresource/ContrailNetworkPolicyResourceValidatorTest.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/heatresource/ContrailNetworkPolicyResourceValidatorTest.java
new file mode 100644
index 0000000000..a03120c5d6
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/heatresource/ContrailNetworkPolicyResourceValidatorTest.java
@@ -0,0 +1,36 @@
+package org.openecomp.sdc.validation.impl.validators.heatresource;
+
+import org.openecomp.core.validation.types.MessageContainer;
+import org.openecomp.sdc.heat.datatypes.model.HeatResourcesTypes;
+import org.openecomp.sdc.validation.impl.validators.HeatResourceValidator;
+import org.openecomp.sdc.validation.util.ValidationTestUtil;
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+import java.io.IOException;
+import java.util.Map;
+
+/**
+ * Created by TALIO on 2/28/2017.
+ */
+public class ContrailNetworkPolicyResourceValidatorTest {
+
+ HeatResourceValidator baseValidator = new HeatResourceValidator();
+ ContrailNetworkPolicyResourceValidator resourceValidator = new
+ ContrailNetworkPolicyResourceValidator();
+
+ @Test
+ public void testNetworkPolicyAssociatedWithAttachPolicy() throws IOException {
+ Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator, resourceValidator
+ , HeatResourcesTypes.CONTRAIL_NETWORK_RULE_RESOURCE_TYPE.getHeatResource(),
+ "/org/openecomp/validation/validators/heat_validator/network_policy_associated_with_attach_policy/input");
+
+ Assert.assertNotNull(messages);
+ Assert.assertEquals(messages.size(), 1);
+
+ Assert.assertEquals(messages.get("hot-nimbus-pps_v1.0.yaml").getErrorMessageList().size(), 1);
+ Assert.assertEquals(
+ messages.get("hot-nimbus-pps_v1.0.yaml").getErrorMessageList().get(0).getMessage(),
+ "WARNING: NetworkPolicy not in use, Resource Id [not_used_server_pcrf_policy]");
+ }
+}
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/heatresource/NestedResourceValidatorTest.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/heatresource/NestedResourceValidatorTest.java
new file mode 100644
index 0000000000..96aa631a69
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/heatresource/NestedResourceValidatorTest.java
@@ -0,0 +1,70 @@
+package org.openecomp.sdc.validation.impl.validators.heatresource;
+
+import org.openecomp.core.validation.types.MessageContainer;
+import org.openecomp.sdc.validation.impl.validators.HeatResourceValidator;
+import org.openecomp.sdc.validation.util.ValidationTestUtil;
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+import java.io.IOException;
+import java.util.Map;
+
+/**
+ * Created by TALIO on 2/28/2017.
+ */
+public class NestedResourceValidatorTest {
+
+ HeatResourceValidator baseValidator = new HeatResourceValidator();
+ NestedResourceValidator resourceValidator = new NestedResourceValidator();
+
+ @Test
+ public void testNoLoopsNesting() throws IOException {
+ Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator,
+ resourceValidator, null,
+ "/org/openecomp/validation/validators/heat_validator/no_loops_nesting/negative_test/input");
+
+ Assert.assertNotNull(messages);
+ Assert.assertEquals(messages.size(), 4);
+
+ Assert.assertEquals(messages.get("hot-nimbus-psm_v1.0.yaml").getErrorMessageList().size(), 1);
+ Assert.assertEquals(
+ messages.get("hot-nimbus-psm_v1.0.yaml").getErrorMessageList().get(0).getMessage(),
+ "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]");
+
+ Assert.assertEquals(
+ messages.get("nested-points-to-hot-nimbus-psm.yaml").getErrorMessageList().size(), 2);
+ Assert.assertEquals(
+ messages.get("nested-points-to-hot-nimbus-psm.yaml").getErrorMessageList().get(0)
+ .getMessage(),
+ "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]");
+ Assert.assertEquals(
+ messages.get("nested-points-to-hot-nimbus-psm.yaml").getErrorMessageList().get(1)
+ .getMessage(),
+ "ERROR: Nested files loop - [nested-points-to-hot-nimbus-psm.yaml -- nested-psm_v1.0.yaml -- nested-points-to-hot-nimbus-psm.yaml]");
+
+ Assert.assertEquals(messages.get("yaml-point-to-itself.yaml").getErrorMessageList().size(), 1);
+ Assert.assertEquals(
+ messages.get("yaml-point-to-itself.yaml").getErrorMessageList().get(0).getMessage(),
+ "ERROR: Nested files loop - [yaml-point-to-itself.yaml -- yaml-point-to-itself.yaml]");
+
+ Assert.assertEquals(messages.get("nested-psm_v1.0.yaml").getErrorMessageList().size(), 1);
+ Assert.assertEquals(
+ messages.get("nested-psm_v1.0.yaml").getErrorMessageList().get(0).getMessage(),
+ "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]");
+ }
+
+ @Test
+ public void testPropertiesMatchNestedParameters() throws IOException {
+ Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator,
+ resourceValidator, null,
+ "/org/openecomp/validation/validators/heat_validator/properties_match_nested_parameters/negative_test/input");
+
+ Assert.assertNotNull(messages);
+ Assert.assertEquals(messages.size(), 1);
+
+ Assert.assertEquals(messages.get("hot-nimbus-pps_v1.0.yaml").getErrorMessageList().size(), 1);
+ Assert.assertEquals(
+ messages.get("hot-nimbus-pps_v1.0.yaml").getErrorMessageList().get(0).getMessage(),
+ "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]");
+ }
+}
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/heatresource/NeutronPortResourceValidatorTest.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/heatresource/NeutronPortResourceValidatorTest.java
new file mode 100644
index 0000000000..359803f473
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/heatresource/NeutronPortResourceValidatorTest.java
@@ -0,0 +1,35 @@
+package org.openecomp.sdc.validation.impl.validators.heatresource;
+
+import org.openecomp.core.validation.types.MessageContainer;
+import org.openecomp.sdc.heat.datatypes.model.HeatResourcesTypes;
+import org.openecomp.sdc.validation.impl.validators.HeatResourceValidator;
+import org.openecomp.sdc.validation.util.ValidationTestUtil;
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+import java.io.IOException;
+import java.util.Map;
+
+/**
+ * Created by TALIO on 2/28/2017.
+ */
+public class NeutronPortResourceValidatorTest {
+
+ HeatResourceValidator baseValidator = new HeatResourceValidator();
+ NeutronPortResourceValidator resourceValidator = new NeutronPortResourceValidator();
+
+ @Test
+ public void testOnlyOneNovaPointsToOnePort() throws IOException {
+ Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator,
+ resourceValidator, HeatResourcesTypes.NEUTRON_PORT_RESOURCE_TYPE.getHeatResource(),
+ "/org/openecomp/validation/validators/heat_validator/one_nova_points_to_one_port/negative_test/input");
+
+ Assert.assertNotNull(messages);
+ Assert.assertEquals(messages.size(), 1);
+
+ Assert.assertEquals(messages.get("hot-nimbus-psm_v1.0.yaml").getErrorMessageList().size(), 1);
+ Assert.assertEquals(
+ messages.get("hot-nimbus-psm_v1.0.yaml").getErrorMessageList().get(0).getMessage(),
+ "ERROR: Resource Port oam1_int_port exceed allowed relations from NovaServer");
+ }
+}
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/heatresource/NeutronSecurityGroupResourceValidatorTest.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/heatresource/NeutronSecurityGroupResourceValidatorTest.java
new file mode 100644
index 0000000000..b8e8d1ee19
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/heatresource/NeutronSecurityGroupResourceValidatorTest.java
@@ -0,0 +1,53 @@
+package org.openecomp.sdc.validation.impl.validators.heatresource;
+
+import org.openecomp.core.validation.types.MessageContainer;
+import org.openecomp.sdc.heat.datatypes.model.HeatResourcesTypes;
+import org.openecomp.sdc.validation.impl.validators.HeatResourceValidator;
+import org.openecomp.sdc.validation.util.ValidationTestUtil;
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+import java.io.IOException;
+import java.util.Map;
+
+/**
+ * Created by TALIO on 2/28/2017.
+ */
+public class NeutronSecurityGroupResourceValidatorTest {
+
+ HeatResourceValidator baseValidator = new HeatResourceValidator();
+ NeutronSecurityGroupResourceValidator resourceValidator = new
+ NeutronSecurityGroupResourceValidator();
+
+ @Test
+ public void testSecurityGroupBaseFileNoPorts() throws IOException {
+ Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator,
+ resourceValidator,
+ HeatResourcesTypes.NEUTRON_SECURITY_GROUP_RESOURCE_TYPE.getHeatResource(),
+ "/org/openecomp/validation/validators/heat_validator/security_group_base_file_no_ports/input");
+
+ Assert.assertNotNull(messages);
+ Assert.assertEquals(messages.size(), 1);
+
+ Assert.assertEquals(messages.get("baseFile.yaml").getErrorMessageList().size(), 1);
+ Assert.assertEquals(messages.get("baseFile.yaml").getErrorMessageList().get(0).getMessage(),
+ "WARNING: SecurityGroup not in use, Resource Id [jsa_security_group3]");
+ }
+
+ @Test
+ public void testSecurityGroupsCalledByPort() throws IOException {
+ Map<String, MessageContainer> messages =ValidationTestUtil.testValidator(baseValidator,
+ resourceValidator,
+ HeatResourcesTypes.NEUTRON_SECURITY_GROUP_RESOURCE_TYPE.getHeatResource(),
+ "/org/openecomp/validation/validators/heat_validator/security_group_called_by_port/input");
+
+ Assert.assertNotNull(messages);
+ Assert.assertEquals(messages.size(), 1);
+
+ Assert.assertEquals(messages.get("hot-nimbus-pps_v1.0.yaml").getErrorMessageList().size(), 1);
+ Assert.assertEquals(
+ messages.get("hot-nimbus-pps_v1.0.yaml").getErrorMessageList().get(0).getMessage(),
+ "WARNING: SecurityGroup not in use, Resource Id [not_used_security_group]");
+ }
+
+}
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/heatresource/NovaServerGroupResourceValidatorTest.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/heatresource/NovaServerGroupResourceValidatorTest.java
new file mode 100644
index 0000000000..b0e6ebf631
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/heatresource/NovaServerGroupResourceValidatorTest.java
@@ -0,0 +1,51 @@
+package org.openecomp.sdc.validation.impl.validators.heatresource;
+
+import org.openecomp.core.validation.types.MessageContainer;
+import org.openecomp.sdc.heat.datatypes.model.HeatResourcesTypes;
+import org.openecomp.sdc.validation.impl.validators.HeatResourceValidator;
+import org.openecomp.sdc.validation.util.ValidationTestUtil;
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+import java.io.IOException;
+import java.util.Map;
+
+/**
+ * Created by TALIO on 2/28/2017.
+ */
+public class NovaServerGroupResourceValidatorTest {
+
+ HeatResourceValidator baseValidator = new HeatResourceValidator();
+ NovaServerGroupResourceValidator resourceValidator = new NovaServerGroupResourceValidator();
+
+ @Test
+ public void testPolicyIsAffinityOrAntiAffinity() throws IOException {
+ Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator,
+ resourceValidator, HeatResourcesTypes.NOVA_SERVER_GROUP_RESOURCE_TYPE.getHeatResource(),
+ "/org/openecomp/validation/validators/heat_validator/policy_is_affinity_or_anti_affinity/negative_test/input");
+
+ Assert.assertNotNull(messages);
+ Assert.assertEquals(messages.size(), 1);
+
+ Assert.assertEquals(messages.get("hot-nimbus-psm_v1.0.yaml").getErrorMessageList().size(), 1);
+ Assert.assertEquals(
+ messages.get("hot-nimbus-psm_v1.0.yaml").getErrorMessageList().get(0).getMessage(),
+ "ERROR: Wrong policy in server group - pcrf_server_policies_1");
+ }
+
+ @Test
+ public void testServerGroupCalledByServer() throws IOException {
+ Map<String, MessageContainer> messages =ValidationTestUtil.testValidator(baseValidator,
+ resourceValidator, HeatResourcesTypes.NOVA_SERVER_GROUP_RESOURCE_TYPE.getHeatResource(),
+ "/org/openecomp/validation/validators/heat_validator/server_group_called_by_nova_server/input");
+
+ Assert.assertNotNull(messages);
+ Assert.assertEquals(messages.size(), 1);
+
+ Assert.assertEquals(messages.get("hot-nimbus-pps_v1.0.yaml").getErrorMessageList().size(), 1);
+ Assert.assertEquals(
+ messages.get("hot-nimbus-pps_v1.0.yaml").getErrorMessageList().get(0).getMessage(),
+ "WARNING: ServerGroup not in use, Resource Id [not_used_server_group]");
+
+ }
+}
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/heatresource/NovaServerResourceValidatorTest.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/heatresource/NovaServerResourceValidatorTest.java
new file mode 100644
index 0000000000..94bdf1e52f
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/heatresource/NovaServerResourceValidatorTest.java
@@ -0,0 +1,53 @@
+package org.openecomp.sdc.validation.impl.validators.heatresource;
+
+import org.openecomp.core.validation.types.MessageContainer;
+import org.openecomp.sdc.heat.datatypes.model.HeatResourcesTypes;
+import org.openecomp.sdc.validation.impl.validators.HeatResourceValidator;
+import org.openecomp.sdc.validation.util.ValidationTestUtil;
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+import java.io.IOException;
+import java.util.Map;
+
+/**
+ * Created by TALIO on 2/28/2017.
+ */
+public class NovaServerResourceValidatorTest {
+
+ HeatResourceValidator baseValidator = new HeatResourceValidator();
+ NovaServerResourceValidator resourceValidator = new NovaServerResourceValidator();
+
+ @Test
+ public void testNovaPropertiesHasAssignedValue() throws IOException {
+ Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator,
+ resourceValidator, HeatResourcesTypes.NOVA_SERVER_RESOURCE_TYPE.getHeatResource(),
+ "/org/openecomp/validation/validators/heat_validator/nova_properties_has_assigned_value/negative_test/input");
+
+ Assert.assertNotNull(messages);
+ Assert.assertEquals(messages.size(), 1);
+
+ Assert.assertEquals(messages.get("hot-nimbus-psm_v1.0.yaml").getErrorMessageList().size(), 1);
+ Assert.assertEquals(
+ messages.get("hot-nimbus-psm_v1.0.yaml").getErrorMessageList().get(0).getMessage(),
+ "ERROR: Missing both Image and Flavor in NOVA Server, Resource ID [nova_server_resource_missing_both]");
+ }
+
+ @Test
+ public void testServerGroupsPointedByServersDefinedCorrectly() throws IOException {
+ Map<String, MessageContainer> messages =ValidationTestUtil.testValidator(baseValidator,
+ resourceValidator, HeatResourcesTypes.NOVA_SERVER_RESOURCE_TYPE.getHeatResource(),
+ "/org/openecomp/validation/validators/heat_validator/server_groups_defined_correctly/negative_test/input");
+
+ Assert.assertNotNull(messages);
+ Assert.assertEquals(messages.size(), 1);
+
+ Assert.assertEquals(messages.get("hot-nimbus-pps_v1.0.yaml").getErrorMessageList().size(), 2);
+ Assert.assertEquals(
+ messages.get("hot-nimbus-pps_v1.0.yaml").getErrorMessageList().get(0).getMessage(),
+ "ERROR: Missing server group definition - BE_Affinity_2, nova_server_1");
+ Assert.assertEquals(
+ messages.get("hot-nimbus-pps_v1.0.yaml").getErrorMessageList().get(1).getMessage(),
+ "ERROR: Missing server group definition - BE_Affinity_2, nova_server_2");
+ }
+}
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/heatresource/ResourceGroupResourceValidatorTest.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/heatresource/ResourceGroupResourceValidatorTest.java
new file mode 100644
index 0000000000..4b255ae967
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/heatresource/ResourceGroupResourceValidatorTest.java
@@ -0,0 +1,106 @@
+package org.openecomp.sdc.validation.impl.validators.heatresource;
+
+import org.openecomp.core.validation.types.MessageContainer;
+import org.openecomp.sdc.heat.datatypes.model.HeatResourcesTypes;
+import org.openecomp.sdc.validation.impl.validators.HeatResourceValidator;
+import org.openecomp.sdc.validation.util.ValidationTestUtil;
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+import java.io.IOException;
+import java.util.Map;
+
+/**
+ * Created by TALIO on 2/28/2017.
+ */
+public class ResourceGroupResourceValidatorTest {
+
+ HeatResourceValidator baseValidator = new HeatResourceValidator();
+ ResourceGroupResourceValidator resourceValidator = new ResourceGroupResourceValidator();
+
+ @Test
+ public void testResourceGroupWithInvalidIndexVar() {
+ Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator,
+ resourceValidator, HeatResourcesTypes.RESOURCE_GROUP_RESOURCE_TYPE.getHeatResource(),
+ "/org/openecomp/validation/validators/heat_validator/resource_group_invalid_indexvar/negative_test/input");
+
+ Assert.assertNotNull(messages);
+ Assert.assertEquals(messages.size(), 1);
+
+ Assert.assertEquals(messages.get("hot-nimbus-psm_v1.0.yaml").getErrorMessageList().size(), 8);
+ Assert.assertEquals(
+ messages.get("hot-nimbus-psm_v1.0.yaml").getErrorMessageList().get(0).getMessage(),
+ "ERROR: Wrong value assigned to a ResourceGroup index_var property (functions are not allowed but only strings), Resource ID [resource_with_resources_group_1]");
+ Assert.assertEquals(
+ messages.get("hot-nimbus-psm_v1.0.yaml").getErrorMessageList().get(1).getMessage(),
+ "WARNING: Wrong value type assigned to a nested input parameter, nested resource [resource_with_resources_group_2], property name [index_boolean], nested file [yamlFile.yaml]");
+ Assert.assertEquals(
+ messages.get("hot-nimbus-psm_v1.0.yaml").getErrorMessageList().get(2).getMessage(),
+ "WARNING: Wrong value type assigned to a nested input parameter, nested resource [resource_with_resources_group_3], property name [index_boolean], nested file [yamlFile.yaml]");
+ Assert.assertEquals(
+ messages.get("hot-nimbus-psm_v1.0.yaml").getErrorMessageList().get(3).getMessage(),
+ "WARNING: Wrong value type assigned to a nested input parameter, nested resource [resource_with_resources_group_3], property name [index_number], nested file [yamlFile.yaml]");
+ Assert.assertEquals(
+ messages.get("hot-nimbus-psm_v1.0.yaml").getErrorMessageList().get(4).getMessage(),
+ "WARNING: Wrong value type assigned to a nested input parameter, nested resource [resource_with_resources_group_4], property name [index_boolean], nested file [yamlFile.yaml]");
+ Assert.assertEquals(
+ messages.get("hot-nimbus-psm_v1.0.yaml").getErrorMessageList().get(5).getMessage(),
+ "WARNING: Wrong value type assigned to a nested input parameter, nested resource [resource_with_resources_group_5], property name [index_boolean], nested file [yamlFile.yaml]");
+ Assert.assertEquals(
+ messages.get("hot-nimbus-psm_v1.0.yaml").getErrorMessageList().get(6).getMessage(),
+ "WARNING: Wrong value type assigned to a nested input parameter, nested resource [resource_with_resources_group_5], property name [index_number], nested file [yamlFile.yaml]");
+ Assert.assertEquals(
+ messages.get("hot-nimbus-psm_v1.0.yaml").getErrorMessageList().get(7).getMessage(),
+ "ERROR: Wrong value assigned to a ResourceGroup index_var property (functions are not allowed but only strings), Resource ID [resource_with_resources_group_6]");
+ }
+
+ @Test
+ public void testResourceGroupWithInvalidType() {
+ Map<String, MessageContainer> messages =ValidationTestUtil.testValidator(baseValidator,
+ resourceValidator, HeatResourcesTypes.RESOURCE_GROUP_RESOURCE_TYPE.getHeatResource(),
+ "/org/openecomp/validation/validators/heat_validator/resource_group_invalid_type/negative_test/input");
+
+ Assert.assertNotNull(messages);
+ Assert.assertEquals(messages.size(), 1);
+
+ Assert.assertEquals(messages.get("hot-nimbus-psm_v1.0.yaml").getErrorMessageList().size(), 3);
+ Assert.assertEquals(
+ messages.get("hot-nimbus-psm_v1.0.yaml").getErrorMessageList().get(0).getMessage(),
+ "WARNING: 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}]");
+ Assert.assertEquals(
+ messages.get("hot-nimbus-psm_v1.0.yaml").getErrorMessageList().get(1).getMessage(),
+ "WARNING: 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 [OS::Nova::Server]");
+ Assert.assertEquals(
+ messages.get("hot-nimbus-psm_v1.0.yaml").getErrorMessageList().get(2).getMessage(),
+ "WARNING: A resource has an invalid or unsupported type - null, Resource ID [resource_with_resources_group_3]");
+ }
+
+ @Test
+ public void testResourcesGroupWithNested() throws IOException {
+ Map<String, MessageContainer> messages =ValidationTestUtil.testValidator(baseValidator,
+ resourceValidator, HeatResourcesTypes.RESOURCE_GROUP_RESOURCE_TYPE.getHeatResource(),
+ "/org/openecomp/validation/validators/heat_validator/resources_group_with_nested/negative_test/input");
+
+ Assert.assertNotNull(messages);
+ Assert.assertEquals(messages.size(), 3);
+
+ Assert.assertEquals(messages.get("hot-nimbus-psm_v1.0.yaml").getErrorMessageList().size(), 2);
+ Assert.assertEquals(
+ messages.get("hot-nimbus-psm_v1.0.yaml").getErrorMessageList().get(0).getMessage(),
+ "ERROR: Referenced parameter not found in nested file - nested-from-resources-group.yaml, parameter name [resource_with_resources_group], Resource ID [property_not_in_nested]");
+ Assert.assertEquals(
+ messages.get("hot-nimbus-psm_v1.0.yaml").getErrorMessageList().get(1).getMessage(),
+ "WARNING: OS::Heat::ResourceGroup resource with resource_def which is not pointing to nested heat file is not supported, Resource ID [resource_without_resources_group], resource_def type [OS::Nova::Server]");
+
+ Assert.assertEquals(messages.get("nested-pps_v1.0.yaml").getErrorMessageList().size(), 1);
+ Assert.assertEquals(
+ messages.get("nested-pps_v1.0.yaml").getErrorMessageList().get(0).getMessage(),
+ "ERROR: Nested files loop - [nested-pps_v1.0.yaml -- nested-from-resources-group.yaml -- hot-nimbus-pps_v1.0.yaml -- nested-pps_v1.0.yaml]");
+
+ Assert.assertEquals(messages.get("nested-not-exist.yaml").getErrorMessageList().size(), 1);
+ Assert.assertEquals(
+ messages.get("nested-not-exist.yaml").getErrorMessageList().get(0).getMessage(),
+ "ERROR: Missing nested file - nested-not-exist.yaml");
+ }
+
+}
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/namingconvention/ContrailServiceInstanceNamingConventionValidatorTest.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/namingconvention/ContrailServiceInstanceNamingConventionValidatorTest.java
new file mode 100644
index 0000000000..2e61df2b16
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/namingconvention/ContrailServiceInstanceNamingConventionValidatorTest.java
@@ -0,0 +1,41 @@
+package org.openecomp.sdc.validation.impl.validators.namingconvention;
+
+import org.openecomp.core.validation.types.MessageContainer;
+import org.openecomp.sdc.heat.datatypes.model.HeatResourcesTypes;
+import org.openecomp.sdc.validation.impl.validators.HeatResourceValidator;
+import org.openecomp.sdc.validation.util.ValidationTestUtil;
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+import java.util.Map;
+
+/**
+ * Created by TALIO on 2/28/2017.
+ */
+public class ContrailServiceInstanceNamingConventionValidatorTest {
+
+ HeatResourceValidator baseValidator = new HeatResourceValidator();
+ ContrailServiceInstanceNamingConventionValidator resourceValidator = new
+ ContrailServiceInstanceNamingConventionValidator();
+
+ @Test
+ public void testContrailServiceInstanceAvailabilityZoneNotAlignedWithNamingConvention() {
+ Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator,
+ resourceValidator, HeatResourcesTypes.CONTRAIL_SERVICE_INSTANCE.getHeatResource(),
+ "/org/openecomp/validation/validators/attGuideLineValidator/heatcontrailserviceinstanceavailabilityzone/notaligned");
+ Assert.assertNotNull(messages);
+ Assert.assertEquals(messages.size(), 1);
+ Assert.assertEquals(messages.get("first.yaml").getErrorMessageList().size(), 1);
+ Assert.assertEquals(messages.get("first.yaml").getErrorMessageList().get(0).getMessage(),
+ "WARNING: Service Instance 'Availability Zone' Parameter Name not aligned with Guidelines, Parameter Name [availability_zone_1a], Resource ID [service_instance_1]. As a result, VF/VFC Profile may miss this information");
+ }
+
+ @Test
+ public void testContrailServiceInstanceAvailabilityZoneAlignedWithNamingConvention() {
+ Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator,
+ resourceValidator, HeatResourcesTypes.CONTRAIL_SERVICE_INSTANCE.getHeatResource(),
+ "/org/openecomp/validation/validators/attGuideLineValidator/heatcontrailserviceinstanceavailabilityzone/aligned");
+ Assert.assertNotNull(messages);
+ Assert.assertEquals(messages.size(), 0);
+ }
+}
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/namingconvention/ContrailServiceTemplateNamingConventionValidatorTest.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/namingconvention/ContrailServiceTemplateNamingConventionValidatorTest.java
new file mode 100644
index 0000000000..55a3f31b19
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/namingconvention/ContrailServiceTemplateNamingConventionValidatorTest.java
@@ -0,0 +1,58 @@
+package org.openecomp.sdc.validation.impl.validators.namingconvention;
+
+import org.openecomp.sdc.validation.impl.validators.HeatResourceValidator;
+
+import org.openecomp.core.validation.types.MessageContainer;
+import org.openecomp.sdc.heat.datatypes.model.HeatResourcesTypes;
+import org.openecomp.sdc.validation.impl.validators.HeatResourceValidator;
+import org.openecomp.sdc.validation.util.ValidationTestUtil;
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+import java.util.Map;
+
+/**
+ * Created by TALIO on 2/28/2017.
+ */
+public class ContrailServiceTemplateNamingConventionValidatorTest {
+
+ HeatResourceValidator baseValidator = new HeatResourceValidator();
+ ContrailServiceTemplateNamingConventionValidator resourceValidator = new
+ ContrailServiceTemplateNamingConventionValidator();
+
+ @Test
+ public void testContrailServiceTemplateImageAndFlavorNamesAlignedWithNamingConventionButDifferentVmType() {
+ Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator,
+ resourceValidator, HeatResourcesTypes.CONTRAIL_SERVICE_TEMPLATE.getHeatResource(),
+ "/org/openecomp/validation/validators/attGuideLineValidator/heatcontrailservicetemplateimageandflavor/imageandflavordifferentvmtype");
+ Assert.assertNotNull(messages);
+ Assert.assertEquals(messages.size(), 1);
+ Assert.assertEquals(
+ messages.get(messages.keySet().iterator().next()).getErrorMessageList().size(), 1);
+ Assert.assertEquals(messages.get("first.yaml").getErrorMessageList().get(0).getMessage(),
+ "WARNING: Service Template naming convention in Image and Flavor properties is not consistent in Resource, Resource ID service_template");
+ }
+
+ @Test
+ public void testContrailServiceTemplateImageAndFlavorNamesNotAlignedWithNamingConvention() {
+ Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator,
+ resourceValidator, HeatResourcesTypes.CONTRAIL_SERVICE_TEMPLATE.getHeatResource(),
+ "/org/openecomp/validation/validators/attGuideLineValidator/heatcontrailservicetemplateimageandflavor/notaligned");
+ Assert.assertNotNull(messages);
+ Assert.assertEquals(messages.size(), 1);
+ Assert.assertEquals(messages.get("first.yaml").getErrorMessageList().size(), 2);
+ Assert.assertEquals(messages.get("first.yaml").getErrorMessageList().get(0).getMessage(),
+ "WARNING: Service Template 'image_name' Parameter Name not aligned with Guidelines, Parameter Name [st_imaage_name], Resource ID [service_template]. As a result, VF/VFC Profile may miss this information");
+ Assert.assertEquals(messages.get("first.yaml").getErrorMessageList().get(1).getMessage(),
+ "WARNING: Service Template 'flavor' Parameter Name not aligned with Guidelines, Parameter Name [st_flavaor_name], Resource ID [service_template]. As a result, VF/VFC Profile may miss this information");
+ }
+
+ @Test
+ public void testContrailServiceTemplateImageAndFlavorNamesAlignedWithNamingConvention() {
+ Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator,
+ resourceValidator, HeatResourcesTypes.CONTRAIL_SERVICE_TEMPLATE.getHeatResource(),
+ "/org/openecomp/validation/validators/attGuideLineValidator/heatcontrailservicetemplateimageandflavor/aligned");
+ Assert.assertNotNull(messages);
+ Assert.assertEquals(messages.size(), 0);
+ }
+}
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/namingconvention/NeutronPortNamingConventionValidatorTest.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/namingconvention/NeutronPortNamingConventionValidatorTest.java
new file mode 100644
index 0000000000..8aedf8219c
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/namingconvention/NeutronPortNamingConventionValidatorTest.java
@@ -0,0 +1,64 @@
+package org.openecomp.sdc.validation.impl.validators.namingconvention;
+
+import org.openecomp.sdc.validation.impl.validators.NamingConventionGuideLineValidator;
+
+import org.openecomp.core.validation.types.MessageContainer;
+import org.openecomp.sdc.heat.datatypes.model.HeatResourcesTypes;
+import org.openecomp.sdc.validation.impl.validators.NamingConventionGuideLineValidator;
+import org.openecomp.sdc.validation.util.ValidationTestUtil;
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+import java.util.Map;
+
+/**
+ * Created by TALIO on 2/28/2017.
+ */
+public class NeutronPortNamingConventionValidatorTest {
+
+ NamingConventionGuideLineValidator baseValidator = new NamingConventionGuideLineValidator();
+ NeutronPortNamingConventionValidator resourceValidator = new
+ NeutronPortNamingConventionValidator();
+
+ @Test
+ public void testHeatPortNetworkNamingConvention() {
+ Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator,
+ resourceValidator, HeatResourcesTypes.NEUTRON_PORT_RESOURCE_TYPE.getHeatResource(),
+ "/org/openecomp/validation/validators/attGuideLineValidator/heatPortNetworkNamingConvention/positive/");
+ Assert.assertNotNull(messages);
+ Assert.assertEquals(messages.size(), 0);
+
+ messages = ValidationTestUtil.testValidator(baseValidator,
+ resourceValidator, HeatResourcesTypes.NEUTRON_PORT_RESOURCE_TYPE.getHeatResource(),
+ "/org/openecomp/validation/validators/attGuideLineValidator/heatPortNetworkNamingConvention/negative/");
+ Assert.assertNotNull(messages);
+ Assert.assertEquals(messages.size(), 1);
+ Assert.assertEquals(messages.get("first.yaml").getErrorMessageList().size(), 3);
+ Assert.assertEquals(messages.get("first.yaml").getErrorMessageList().get(0).getMessage(),
+ "WARNING: Port 'Network' Parameter Name not aligned with Guidelines, Parameter Name [not_valid_network_name], Resource ID [port_resource]. As a result, VF/VFC Profile may miss this information");
+ }
+
+ @Test
+ public void testNeutronFixedIpName() {
+ Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator,
+ resourceValidator, HeatResourcesTypes.NEUTRON_PORT_RESOURCE_TYPE.getHeatResource(),
+ "/org/openecomp/validation/validators/attGuideLineValidator/heatPortFixedIpNamingConvention/positive");
+ Assert.assertNotNull(messages);
+ Assert.assertEquals(messages.size(), 0);
+
+ messages = ValidationTestUtil.testValidator(baseValidator,
+ resourceValidator, HeatResourcesTypes.NEUTRON_PORT_RESOURCE_TYPE.getHeatResource(),
+ "/org/openecomp/validation/validators/attGuideLineValidator/heatPortFixedIpNamingConvention/negative/");
+ Assert.assertNotNull(messages);
+ Assert.assertEquals(messages.size(), 1);
+ Assert.assertEquals(messages.get("first.yaml").getErrorMessageList().size(), 4);
+ Assert.assertEquals(messages.get("first.yaml").getErrorMessageList().get(0).getMessage(),
+ "WARNING: Port 'Fixed_IPS' Parameter Name not aligned with Guidelines, Parameter Name [pcrf_net_v6_ip_a], Resource ID [port_resource_0]. As a result, VF/VFC Profile may miss this information");
+ Assert.assertEquals(messages.get("first.yaml").getErrorMessageList().get(1).getMessage(),
+ "WARNING: Port 'Fixed_IPS' Parameter Name not aligned with Guidelines, Parameter Name [indx], Resource ID [port_resource_1]. As a result, VF/VFC Profile may miss this information");
+ Assert.assertEquals(messages.get("first.yaml").getErrorMessageList().get(2).getMessage(),
+ "WARNING: Port 'Fixed_IPS' Parameter Name not aligned with Guidelines, Parameter Name [pcrf_net_ipz], Resource ID [port_resource_2]. As a result, VF/VFC Profile may miss this information");
+ Assert.assertEquals(messages.get("first.yaml").getErrorMessageList().get(3).getMessage(),
+ "WARNING: Port 'Fixed_IPS' Parameter Name not aligned with Guidelines, Parameter Name [pcrf_net_v0_ip_3], Resource ID [port_resource_2]. As a result, VF/VFC Profile may miss this information");
+ }
+}
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/namingconvention/NovaServerNamingConventionGuideLineValidatorTest.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/namingconvention/NovaServerNamingConventionGuideLineValidatorTest.java
new file mode 100644
index 0000000000..25b98bb6fb
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/namingconvention/NovaServerNamingConventionGuideLineValidatorTest.java
@@ -0,0 +1,154 @@
+package org.openecomp.sdc.validation.impl.validators.namingconvention;
+
+import org.openecomp.core.validation.types.MessageContainer;
+import org.openecomp.sdc.heat.datatypes.model.HeatResourcesTypes;
+import org.openecomp.sdc.validation.impl.validators.NamingConventionGuideLineValidator;
+import org.openecomp.sdc.validation.util.ValidationTestUtil;
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+import java.io.IOException;
+import java.util.Map;
+
+/**
+ * Created by TALIO on 2/28/2017.
+ */
+public class NovaServerNamingConventionGuideLineValidatorTest {
+
+ NamingConventionGuideLineValidator baseValidator = new NamingConventionGuideLineValidator();
+ NovaServerNamingConventionGuideLineValidator resourceValidator = new
+ NovaServerNamingConventionGuideLineValidator();
+
+ @Test
+ public void testHeatNovaServerMetaDataValidation() {
+ Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator,
+ resourceValidator, HeatResourcesTypes.NOVA_SERVER_RESOURCE_TYPE.getHeatResource(),
+ "/org/openecomp/validation/validators/attGuideLineValidator/heatNovaServerMetaDataValidation/positive/");
+ Assert.assertNotNull(messages);
+ Assert.assertEquals(messages.size(), 0);
+
+ messages = ValidationTestUtil.testValidator(baseValidator,
+ resourceValidator, HeatResourcesTypes.NOVA_SERVER_RESOURCE_TYPE.getHeatResource(),
+ "/org/openecomp/validation/validators/attGuideLineValidator/heatNovaServerMetaDataValidation/negative/");
+ Assert.assertNotNull(messages);
+ Assert.assertEquals(messages.size(), 1);
+ Assert.assertEquals(messages.get("first.yaml").getErrorMessageList().size(), 1);
+ Assert.assertEquals(messages.get("first.yaml").getErrorMessageList().get(0).getMessage(),
+ "WARNING: Missing VNF_ID in Metadata property, Resource ID [FSB2]");
+ }
+
+ @Test
+ public void testNovaServerAvailabilityZoneName() {
+ Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator,
+ resourceValidator, HeatResourcesTypes.NOVA_SERVER_RESOURCE_TYPE.getHeatResource(),
+ "/org/openecomp/validation/validators/attGuideLineValidator/heatNovaServerAvailabilityZoneName/positive");
+ Assert.assertNotNull(messages);
+ Assert.assertEquals(messages.size(), 0);
+
+ messages = ValidationTestUtil.testValidator(baseValidator,
+ resourceValidator, HeatResourcesTypes.NOVA_SERVER_RESOURCE_TYPE.getHeatResource(),
+ "/org/openecomp/validation/validators/attGuideLineValidator/heatNovaServerAvailabilityZoneName/negative");
+ Assert.assertNotNull(messages);
+ Assert.assertEquals(messages.size(), 1);
+ Assert.assertEquals(messages.get("first.yaml").getErrorMessageList().size(), 3);
+ Assert.assertEquals(messages.get("first.yaml").getErrorMessageList().get(0).getMessage(),
+ "WARNING: Server 'Availability Zone' Parameter Name not aligned with Guidelines, Parameter Name [availability_zone_a], Resource ID [FSB2]. As a result, VF/VFC Profile may miss this information");
+ Assert.assertEquals(messages.get("first.yaml").getErrorMessageList().get(1).getMessage(),
+ "WARNING: Server 'Availability Zone' Parameter Name not aligned with Guidelines, Parameter Name [availability_zone], Resource ID [FSB3]. As a result, VF/VFC Profile may miss this information");
+ }
+
+ @Test
+ public void testNovaImageAndFlavorNames() {
+ Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator,
+ resourceValidator, HeatResourcesTypes.NOVA_SERVER_RESOURCE_TYPE.getHeatResource(),
+ "/org/openecomp/validation/validators/attGuideLineValidator/heatNovaServerImageAndFlavor/positive");
+ Assert.assertNotNull(messages);
+ Assert.assertEquals(messages.size(), 0);
+
+ messages = ValidationTestUtil.testValidator(baseValidator,
+ resourceValidator, HeatResourcesTypes.NOVA_SERVER_RESOURCE_TYPE.getHeatResource(),
+ "/org/openecomp/validation/validators/attGuideLineValidator/heatNovaServerImageAndFlavor/negative");
+ Assert.assertNotNull(messages);
+ Assert.assertEquals(messages.size(), 1);
+ Assert.assertEquals(messages.get("first.yaml").getErrorMessageList().size(), 2);
+ Assert.assertEquals(messages.get("first.yaml").getErrorMessageList().get(0).getMessage(),
+ "WARNING: Server 'flavor' Parameter Name not aligned with Guidelines, Parameter Name [fsb2-flavor], Resource ID [FSB2]. As a result, VF/VFC Profile may miss this information");
+ Assert.assertEquals(messages.get("first.yaml").getErrorMessageList().get(1).getMessage(),
+ "WARNING: Server 'image' Parameter Name not aligned with Guidelines, Parameter Name [fsb2-image], Resource ID [FSB3]. As a result, VF/VFC Profile may miss this information");
+ }
+
+ @Test
+ public void testNovaResourceNetworkUniqueRole() {
+ Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator,
+ resourceValidator, HeatResourcesTypes.NOVA_SERVER_RESOURCE_TYPE.getHeatResource(),
+ "/org/openecomp/validation/validators/attGuideLineValidator/heatNovaNetworkUniqueRoleConvention/positive/");
+ Assert.assertNotNull(messages);
+ Assert.assertEquals(messages.size(), 0);
+
+ messages = ValidationTestUtil.testValidator(baseValidator,
+ resourceValidator, HeatResourcesTypes.NOVA_SERVER_RESOURCE_TYPE.getHeatResource(),
+ "/org/openecomp/validation/validators/attGuideLineValidator/heatNovaNetworkUniqueRoleConvention/negative/");
+ Assert.assertNotNull(messages);
+ Assert.assertEquals(messages.size(), 1);
+ Assert.assertEquals(messages.get("first.yaml").getErrorMessageList().size(), 1);
+ Assert.assertEquals(messages.get("first.yaml").getErrorMessageList().get(0).getMessage(),
+ "WARNING: A resource is connected twice to the same network role, Network Role [FSB2], Resource ID [Internal1]");
+ }
+
+ @Test
+ public void testNovaServerName() {
+ Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator,
+ resourceValidator, HeatResourcesTypes.NOVA_SERVER_RESOURCE_TYPE.getHeatResource(),
+ "/org/openecomp/validation/validators/attGuideLineValidator/heatNovaServerNameValidation/positive");
+ Assert.assertNotNull(messages);
+ Assert.assertEquals(messages.size(), 0);
+
+ messages = ValidationTestUtil.testValidator(baseValidator,
+ resourceValidator, HeatResourcesTypes.NOVA_SERVER_RESOURCE_TYPE.getHeatResource(),
+ "/org/openecomp/validation/validators/attGuideLineValidator/heatNovaServerNameValidation/negative/");
+ Assert.assertNotNull(messages);
+ Assert.assertEquals(messages.size(), 1);
+ Assert.assertEquals(messages.get("first.yaml").getErrorMessageList().size(), 2);
+ Assert.assertEquals(messages.get("first.yaml").getErrorMessageList().get(0).getMessage(),
+ "WARNING: Server 'name' Parameter Name not aligned with Guidelines, Parameter Name [pcrf_pps_server_4], Resource ID [FSB2]. As a result, VF/VFC Profile may miss this information");
+ }
+
+ @Test
+ public void testVMNameSyncInNova() {
+ Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator,
+ resourceValidator, HeatResourcesTypes.NOVA_SERVER_RESOURCE_TYPE.getHeatResource(),
+ "/org/openecomp/validation/validators/attGuideLineValidator/novaVMNameSync/input");
+
+ Assert.assertNotNull(messages);
+ Assert.assertEquals(messages.size(), 1);
+
+ Assert.assertEquals(messages.get("first.yaml").getErrorMessageList().size(), 4);
+ Assert.assertEquals(messages.get("first.yaml").getErrorMessageList().get(0).getMessage(),
+ "WARNING: Server 'name' Parameter Name not aligned with Guidelines, Parameter Name [CE_server_name], Resource ID [FSB2_legal_2]. As a result, VF/VFC Profile may miss this information");
+ Assert.assertEquals(messages.get("first.yaml").getErrorMessageList().get(1).getMessage(),
+ "WARNING: Server 'flavor' Parameter Name not aligned with Guidelines, Parameter Name [fsb_flavor_names], Resource ID [FSB2_legal_3]. As a result, VF/VFC Profile may miss this information");
+ Assert.assertEquals(messages.get("first.yaml").getErrorMessageList().get(2).getMessage(),
+ "WARNING: Nova Server naming convention in image, flavor and name properties is not consistent, Resource ID [FSB2_illegal_1]");
+ Assert.assertEquals(messages.get("first.yaml").getErrorMessageList().get(3).getMessage(),
+ "WARNING: Nova Server naming convention in image, flavor and name properties is not consistent, Resource ID [FSB2_illegal_2]");
+
+ }
+
+ @Test
+ public void testAvailabilityZoneName() throws IOException {
+ Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator,
+ resourceValidator, HeatResourcesTypes.NOVA_SERVER_RESOURCE_TYPE.getHeatResource(),
+ "/org/openecomp/validation/validators/att_naming_convention/availability_zone_name/input");
+
+ Assert.assertNotNull(messages);
+ Assert.assertEquals(messages.size(), 1);
+
+ Assert.assertEquals(messages.get("hot-nimbus-pps_v1.0.yaml").getErrorMessageList().size(), 2);
+ Assert.assertEquals(
+ messages.get("hot-nimbus-pps_v1.0.yaml").getErrorMessageList().get(0).getMessage(),
+ "WARNING: Server 'Availability Zone' Parameter Name not aligned with Guidelines, Parameter Name [availability_zone_name], Resource ID [availability_zone_illegal_name_1]. As a result, VF/VFC Profile may miss this information");
+ Assert.assertEquals(
+ messages.get("hot-nimbus-pps_v1.0.yaml").getErrorMessageList().get(1).getMessage(),
+ "WARNING: Server 'Availability Zone' Parameter Name not aligned with Guidelines, Parameter Name [availability_zone], Resource ID [availability_zone_illegal_name_2]. As a result, VF/VFC Profile may miss this information");
+ }
+}
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/validators/EcompGuideLineValidatorTest.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/validators/EcompGuideLineValidatorTest.java
deleted file mode 100644
index 44e9a3a580..0000000000
--- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/validators/EcompGuideLineValidatorTest.java
+++ /dev/null
@@ -1,281 +0,0 @@
-package org.openecomp.sdc.validation.impl.validators.validators;
-
-import org.openecomp.sdc.validation.impl.validators.EcompGuideLineValidator;
-
-import org.openecomp.sdc.validation.impl.validators.ValidatorBaseTest;
-import org.openecomp.core.validation.types.MessageContainer;
-
-import org.testng.Assert;
-import org.testng.annotations.Test;
-
-import java.util.Map;
-
-public class EcompGuideLineValidatorTest extends ValidatorBaseTest {
-
- @Test
- public void testMissingBaseHeat() {
- Map<String, MessageContainer> messages =
- runValidation("/openecomp/org/validation/validators/ecompGuideLineValidator/missingBaseHeat/");
- Assert.assertNotNull(messages);
- Assert.assertEquals(messages.size(), 1);
- Assert.assertEquals(messages.get("MANIFEST.json").getErrorMessageList().size(), 1);
- Assert.assertEquals(messages.get("MANIFEST.json").getErrorMessageList().get(0).getMessage(),
- "Missing Base HEAT. Pay attention that without Base HEAT, there will be no shared resources");
- }
-
- @Test
- public void testMultiBaseHeat() {
- Map<String, MessageContainer> messages =
- runValidation("/openecomp/org/validation/validators/ecompGuideLineValidator/multiBaseHeat/");
- Assert.assertNotNull(messages);
- Assert.assertEquals(messages.size(), 1);
- Assert.assertEquals(messages.get("MANIFEST.json").getErrorMessageList().size(), 1);
- Assert.assertEquals(messages.get("MANIFEST.json").getErrorMessageList().get(0).getMessage(),
- "Multi Base HEAT. Expected only one. Files [second.yaml,first.yaml].");
- }
-
- @Test
- public void testBaseHeatExposeVolume() {
- Map<String, MessageContainer> messages = runValidation(
- "/openecomp/org/validation/validators/ecompGuideLineValidator/baseHeatDoesNotExposeVolume/positive/");
- Assert.assertNotNull(messages);
- Assert.assertEquals(messages.size(), 0);
-
- messages = runValidation(
- "/openecomp/org/validation/validators/ecompGuideLineValidator/baseHeatDoesNotExposeVolume/negative/");
- Assert.assertNotNull(messages);
- Assert.assertEquals(messages.size(), 1);
- Assert.assertEquals(messages.get("first.yaml").getErrorMessageList().size(), 1);
- Assert.assertEquals(messages.get("first.yaml").getErrorMessageList().get(0).getMessage(),
- "Resource is not defined as output and thus cannot be Shared. resource id - volume_expose");
- }
-
- @Test
- public void testBaseHeatExposeServerGroup() {
- Map<String, MessageContainer> messages = runValidation(
- "/openecomp/org/validation/validators/ecompGuideLineValidator/baseHeatDoesNotExposeServerGroup/positive/");
- Assert.assertNotNull(messages);
- Assert.assertEquals(messages.size(), 0);
-
- messages = runValidation(
- "/openecomp/org/validation/validators/ecompGuideLineValidator/baseHeatDoesNotExposeServerGroup/negative/");
- Assert.assertNotNull(messages);
- Assert.assertEquals(messages.size(), 1);
- Assert.assertEquals(messages.get("first.yaml").getErrorMessageList().size(), 1);
- Assert.assertEquals(messages.get("first.yaml").getErrorMessageList().get(0).getMessage(),
- "Resource is not defined as output and thus cannot be Shared. resource id - ServerGroup_expose");
- }
-
- @Test
- public void testBaseHeatExposeSecurityGroup() {
- Map<String, MessageContainer> messages = runValidation(
- "/openecomp/org/validation/validators/ecompGuideLineValidator/baseHeatDoesNotExposeSecurityGroup/positive/");
- Assert.assertNotNull(messages);
- Assert.assertEquals(messages.size(), 0);
-
- messages = runValidation(
- "/openecomp/org/validation/validators/ecompGuideLineValidator/baseHeatDoesNotExposeSecurityGroup/negative/");
- Assert.assertNotNull(messages);
- Assert.assertEquals(messages.size(), 1);
- Assert.assertEquals(messages.get("first.yaml").getErrorMessageList().size(), 1);
- Assert.assertEquals(messages.get("first.yaml").getErrorMessageList().get(0).getMessage(),
- "Resource is not defined as output and thus cannot be Shared. resource id - SecurityGroup_expose");
- }
-
-
- @Test
- public void testBaseHeatExposeNetwork() {
- Map<String, MessageContainer> messages = runValidation(
- "/openecomp/org/validation/validators/ecompGuideLineValidator/baseHeatDoesNotExposeNetwork/positive/");
- Assert.assertNotNull(messages);
- Assert.assertEquals(messages.size(), 0);
-
- messages = runValidation(
- "/openecomp/org/validation/validators/ecompGuideLineValidator/baseHeatDoesNotExposeNetwork/negative/");
- Assert.assertNotNull(messages);
- Assert.assertEquals(messages.size(), 1);
- Assert.assertEquals(messages.get("first.yaml").getErrorMessageList().size(), 1);
- Assert.assertEquals(messages.get("first.yaml").getErrorMessageList().get(0).getMessage(),
- "Resource is not defined as output and thus cannot be Shared. resource id - SecurityGroup_expose");
- }
-
- @Test
- public void testBaseHeatExposeNetworkAndVolume() {
- Map<String, MessageContainer> messages = runValidation(
- "/openecomp/org/validation/validators/ecompGuideLineValidator/baseHeatDoesNotExposeNetworkAndVolume/positive/");
- Assert.assertNotNull(messages);
- Assert.assertEquals(messages.size(), 0);
-
- messages = runValidation(
- "/openecomp/org/validation/validators/ecompGuideLineValidator/baseHeatDoesNotExposeNetworkAndVolume/negative/");
- Assert.assertNotNull(messages);
- Assert.assertEquals(messages.size(), 1);
- Assert.assertEquals(messages.get("first.yaml").getErrorMessageList().size(), 2);
- Assert.assertEquals(messages.get("first.yaml").getErrorMessageList().get(0).getMessage(),
- "Resource is not defined as output and thus cannot be Shared. resource id - volume_expose");
- Assert.assertEquals(messages.get("first.yaml").getErrorMessageList().get(1).getMessage(),
- "Resource is not defined as output and thus cannot be Shared. resource id - net_expose");
- }
-
- @Test
- public void testNovaResourceNetworkUniqueRole() {
- Map<String, MessageContainer> messages = runValidation(
- "/openecomp/org/validation/validators/ecompGuideLineValidator/heatNovaNetworkUniqueRoleConvention/positive/");
- Assert.assertNotNull(messages);
- Assert.assertEquals(messages.size(), 0);
-
- messages = runValidation(
- "/openecomp/org/validation/validators/ecompGuideLineValidator/heatNovaNetworkUniqueRoleConvention/negative/");
- Assert.assertNotNull(messages);
- Assert.assertEquals(messages.size(), 1);
- Assert.assertEquals(messages.get("first.yaml").getErrorMessageList().size(), 1);
- Assert.assertEquals(messages.get("first.yaml").getErrorMessageList().get(0).getMessage(),
- "A resource is connected twice to the same network role Resource ID [FSB2] Network Role [Internal1].");
- }
-
- @Test
- public void testHeatVolumeExpose() {
- Map<String, MessageContainer> messages = runValidation(
- "/openecomp/org/validation/validators/ecompGuideLineValidator/heatVolumeExpose/positive/");
- Assert.assertNotNull(messages);
- Assert.assertEquals(messages.size(), 0);
-
- messages = runValidation(
- "/openecomp/org/validation/validators/ecompGuideLineValidator/heatVolumeExpose/negative/");
- Assert.assertNotNull(messages);
- Assert.assertEquals(messages.size(), 1);
- Assert.assertEquals(messages.get("firstVol.yaml").getErrorMessageList().size(), 1);
- Assert.assertEquals(messages.get("firstVol.yaml").getErrorMessageList().get(0).getMessage(),
- "Volume is not defined as output and thus cannot be attached volume_expose");
-
- }
-
- @Test
- public void testHeatPortNetworkNamingConvention() {
- Map<String, MessageContainer> messages = runValidation(
- "/openecomp/org/validation/validators/ecompGuideLineValidator/heatPortNetworkNamingConvention/positive/");
- Assert.assertNotNull(messages);
- Assert.assertEquals(messages.size(), 0);
-
- messages = runValidation(
- "/openecomp/org/validation/validators/ecompGuideLineValidator/heatPortNetworkNamingConvention/negative/");
- Assert.assertNotNull(messages);
- Assert.assertEquals(messages.size(), 1);
- Assert.assertEquals(messages.get("first.yaml").getErrorMessageList().size(), 3);
- Assert.assertEquals(messages.get("first.yaml").getErrorMessageList().get(0).getMessage(),
- "Network Parameter Name not aligned with Guidelines Parameter Name [not_valid_network_name] Resource ID [port_resource]");
- }
-
- @Test
- public void testHeatNovaServerMetaDataValidation() {
- Map<String, MessageContainer> messages = runValidation(
- "/openecomp/org/validation/validators/ecompGuideLineValidator/heatNovaServerMetaDataValidation/positive/");
- Assert.assertNotNull(messages);
- Assert.assertEquals(messages.size(), 0);
-
- messages = runValidation(
- "/openecomp/org/validation/validators/ecompGuideLineValidator/heatNovaServerMetaDataValidation/negative/");
- Assert.assertNotNull(messages);
- Assert.assertEquals(messages.size(), 1);
- Assert.assertEquals(messages.get("first.yaml").getErrorMessageList().size(), 1);
- Assert.assertEquals(messages.get("first.yaml").getErrorMessageList().get(0).getMessage(),
- "Missing VNF_ID Resource id [FSB2]");
- }
-
- @Test
- public void testNeutronFixedIpName() {
- Map<String, MessageContainer> messages = runValidation(
- "/openecomp/org/validation/validators/ecompGuideLineValidator/heatPortFixedIpNamingConvention/positive");
- Assert.assertNotNull(messages);
- Assert.assertEquals(messages.size(), 0);
-
- messages = runValidation(
- "/openecomp/org/validation/validators/ecompGuideLineValidator/heatPortFixedIpNamingConvention/negative/");
- Assert.assertNotNull(messages);
- Assert.assertEquals(messages.size(), 1);
- Assert.assertEquals(messages.get("first.yaml").getErrorMessageList().size(), 3);
- Assert.assertEquals(messages.get("first.yaml").getErrorMessageList().get(0).getMessage(),
- "Fixed_IPS not aligned with Guidelines, Resource ID [port_resource_0]");
- Assert.assertEquals(messages.get("first.yaml").getErrorMessageList().get(1).getMessage(),
- "Fixed_IPS not aligned with Guidelines, Resource ID [port_resource_1]");
- Assert.assertEquals(messages.get("first.yaml").getErrorMessageList().get(2).getMessage(),
- "Fixed_IPS not aligned with Guidelines, Resource ID [port_resource_2]");
- }
-
-
- @Test
- public void testNovaServerName() {
- Map<String, MessageContainer> messages = runValidation(
- "/openecomp/org/validation/validators/ecompGuideLineValidator/heatNovaServerNameValidation/positive");
- Assert.assertNotNull(messages);
- Assert.assertEquals(messages.size(), 0);
-
- messages = runValidation(
- "/openecomp/org/validation/validators/ecompGuideLineValidator/heatNovaServerNameValidation/negative/");
- Assert.assertNotNull(messages);
- Assert.assertEquals(messages.size(), 1);
- Assert.assertEquals(messages.get("first.yaml").getErrorMessageList().size(), 2);
- Assert.assertEquals(messages.get("first.yaml").getErrorMessageList().get(0).getMessage(),
- "Server Name not aligned with Guidelines, Resource ID [FSB2]");
- }
-
- @Test
- public void testAvailabilityZoneName() {
- Map<String, MessageContainer> messages = runValidation(
- "/openecomp/org/validation/validators/ecompGuideLineValidator/heatNovaServerAvailabilityZoneName/positive");
- Assert.assertNotNull(messages);
- Assert.assertEquals(messages.size(), 0);
-
- messages = runValidation(
- "/openecomp/org/validation/validators/ecompGuideLineValidator/heatNovaServerAvailabilityZoneName/negative");
- Assert.assertNotNull(messages);
- Assert.assertEquals(messages.size(), 1);
- Assert.assertEquals(messages.get("first.yaml").getErrorMessageList().size(), 3);
- Assert.assertEquals(messages.get("first.yaml").getErrorMessageList().get(0).getMessage(),
- "Server Availability Zone not aligned with Guidelines, Resource ID [FSB2]");
- Assert.assertEquals(messages.get("first.yaml").getErrorMessageList().get(1).getMessage(),
- "Server Availability Zone not aligned with Guidelines, Resource ID [FSB3]");
- }
-
- @Test
- public void testFloatingIpResourceType() {
- Map<String, MessageContainer> messages = runValidation(
- "/openecomp/org/validation/validators/ecompGuideLineValidator/heatFloatingIpResourceType/positive");
- Assert.assertNotNull(messages);
- Assert.assertEquals(messages.size(), 0);
-
-
- messages = runValidation(
- "/openecomp/org/validation/validators/ecompGuideLineValidator/heatFloatingIpResourceType/negative");
- Assert.assertNotNull(messages);
- Assert.assertEquals(messages.size(), 1);
- Assert.assertEquals(messages.get("first.yaml").getErrorMessageList().size(), 1);
- Assert.assertEquals(messages.get("first.yaml").getErrorMessageList().get(0).getMessage(),
- "OS::Neutron::FloatingIP is in use, Resource ID [FSB2]");
- }
-
- @Test
- public void testImageAndFlavorNames() {
- Map<String, MessageContainer> messages = runValidation(
- "/openecomp/org/validation/validators/ecompGuideLineValidator/heatNovaServerImageAndFlavor/positive");
- Assert.assertNotNull(messages);
- Assert.assertEquals(messages.size(), 0);
-
- messages = runValidation(
- "/openecomp/org/validation/validators/ecompGuideLineValidator/heatNovaServerImageAndFlavor/negative");
- Assert.assertNotNull(messages);
- Assert.assertEquals(messages.size(), 1);
- Assert.assertEquals(messages.get("first.yaml").getErrorMessageList().size(), 2);
- Assert.assertEquals(messages.get("first.yaml").getErrorMessageList().get(0).getMessage(),
- "Wrong flavor name format in NOVA Server, Resource ID [FSB2]");
- Assert.assertEquals(messages.get("first.yaml").getErrorMessageList().get(1).getMessage(),
- "Wrong image name format in NOVA Server, Resource ID [FSB3]");
- }
-
-
- @Override
- public Map<String, MessageContainer> runValidation(String path) {
- EcompGuideLineValidator validator = new EcompGuideLineValidator();
- return testValidator(validator, path);
- }
-} \ No newline at end of file
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/validators/EcompNamingConventionTest.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/validators/EcompNamingConventionTest.java
deleted file mode 100644
index e4203945aa..0000000000
--- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/validators/EcompNamingConventionTest.java
+++ /dev/null
@@ -1,104 +0,0 @@
-package org.openecomp.sdc.validation.impl.validators.validators;
-
-import org.openecomp.sdc.validation.impl.validators.EcompGuideLineValidator;
-import org.openecomp.sdc.validation.impl.validators.ValidatorBaseTest;
-import org.openecomp.core.validation.types.MessageContainer;
-
-import java.io.IOException;
-import java.util.Map;
-
-import org.testng.Assert;
-import org.testng.annotations.Test;
-
-public class EcompNamingConventionTest extends ValidatorBaseTest {
-
- @Test
- public void testNeutronFixedIpName() throws IOException {
- Map<String, MessageContainer> messages = runValidation(
- "/openecomp/org/validation/validators/ecomp_naming_convention/neutron_port_fixed_ip_name/input");
-
- Assert.assertNotNull(messages);
- Assert.assertEquals(messages.size(), 2);
-
- Assert.assertEquals(messages.get("hot-nimbus-pps_v1.0.yaml").getErrorMessageList().size(), 3);
- Assert.assertEquals(
- messages.get("hot-nimbus-pps_v1.0.yaml").getErrorMessageList().get(0).getMessage(),
- "Fixed_IPS not aligned with Guidelines, Resource ID [fixed_ip_illegal_name_1]");
- Assert.assertEquals(
- messages.get("hot-nimbus-pps_v1.0.yaml").getErrorMessageList().get(1).getMessage(),
- "Fixed_IPS not aligned with Guidelines, Resource ID [fixed_ip_illegal_name_2]");
- Assert.assertEquals(
- messages.get("hot-nimbus-pps_v1.0.yaml").getErrorMessageList().get(2).getMessage(),
- "Fixed_IPS not aligned with Guidelines, Resource ID [fixed_ip_illegal_name_3]");
- }
-
-
- @Test
- public void testNovaServerName() throws IOException {
- Map<String, MessageContainer> messages = runValidation(
- "/openecomp/org/validation/validators/ecomp_naming_convention/nova_server_name/input");
-
- Assert.assertNotNull(messages);
- Assert.assertEquals(messages.size(), 2);
-
- Assert.assertEquals(messages.get("hot-nimbus-pps_v1.0.yaml").getErrorMessageList().size(), 6);
- Assert.assertEquals(
- messages.get("hot-nimbus-pps_v1.0.yaml").getErrorMessageList().get(0).getMessage(),
- "Server Name not aligned with Guidelines, Resource ID [nova_server_ilegal_name_1]");
- Assert.assertEquals(
- messages.get("hot-nimbus-pps_v1.0.yaml").getErrorMessageList().get(1).getMessage(),
- "Server Name not aligned with Guidelines, Resource ID [nova_server_ilegal_name_2]");
- Assert.assertEquals(
- messages.get("hot-nimbus-pps_v1.0.yaml").getErrorMessageList().get(2).getMessage(),
- "Server Name not aligned with Guidelines, Resource ID [nova_server_ilegal_name_3]");
- Assert.assertEquals(
- messages.get("hot-nimbus-pps_v1.0.yaml").getErrorMessageList().get(3).getMessage(),
- "Server Name not aligned with Guidelines, Resource ID [nova_server_ilegal_name_4]");
- Assert.assertEquals(
- messages.get("hot-nimbus-pps_v1.0.yaml").getErrorMessageList().get(4).getMessage(),
- "Server Name not aligned with Guidelines, Resource ID [nova_server_ilegal_name_5]");
- Assert.assertEquals(
- messages.get("hot-nimbus-pps_v1.0.yaml").getErrorMessageList().get(5).getMessage(),
- "Missing get_param in nova server name, Resource Id [nova_server_ilegal_name_6]");
- }
-
-
- @Test
- public void testAvailabilityZoneName() throws IOException {
- Map<String, MessageContainer> messages = runValidation(
- "/openecomp/org/validation/validators/ecomp_naming_convention/availability_zone_name/input");
-
- Assert.assertNotNull(messages);
- Assert.assertEquals(messages.size(), 2);
-
- Assert.assertEquals(messages.get("hot-nimbus-pps_v1.0.yaml").getErrorMessageList().size(), 2);
- Assert.assertEquals(
- messages.get("hot-nimbus-pps_v1.0.yaml").getErrorMessageList().get(0).getMessage(),
- "Server Availability Zone not aligned with Guidelines, Resource ID [availability_zone_illegal_name_1]");
- Assert.assertEquals(
- messages.get("hot-nimbus-pps_v1.0.yaml").getErrorMessageList().get(1).getMessage(),
- "Server Availability Zone not aligned with Guidelines, Resource ID [availability_zone_illegal_name_2]");
- }
-
-
- @Test
- public void testFloatingIpResourceType() throws IOException {
- Map<String, MessageContainer> messages = runValidation(
- "/openecomp/org/validation/validators/ecomp_naming_convention/floating_ip_resource_type/input");
-
- Assert.assertNotNull(messages);
- Assert.assertEquals(messages.size(), 2);
-
- Assert.assertEquals(messages.get("hot-nimbus-pps_v1.0.yaml").getErrorMessageList().size(), 1);
- Assert.assertEquals(
- messages.get("hot-nimbus-pps_v1.0.yaml").getErrorMessageList().get(0).getMessage(),
- "OS::Neutron::FloatingIP is in use, Resource ID [floating_ip_type]");
- }
-
-
- @Override
- public Map<String, MessageContainer> runValidation(String path) {
- EcompGuideLineValidator ecompGuideLineValidator = new EcompGuideLineValidator();
- return testValidator(ecompGuideLineValidator, path);
- }
-} \ No newline at end of file
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/validators/HeatValidatorTest.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/validators/HeatValidatorTest.java
deleted file mode 100644
index 9ff375c1a3..0000000000
--- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/validators/HeatValidatorTest.java
+++ /dev/null
@@ -1,356 +0,0 @@
-package org.openecomp.sdc.validation.impl.validators.validators;
-
-import org.openecomp.sdc.validation.impl.validators.HeatValidator;
-import org.openecomp.sdc.validation.impl.validators.ValidatorBaseTest;
-import org.openecomp.core.validation.types.MessageContainer;
-
-import org.testng.Assert;
-import org.testng.annotations.Test;
-
-import java.io.IOException;
-import java.util.Map;
-
-public class HeatValidatorTest extends ValidatorBaseTest {
-
-
- @Test
- public void testInvalidHeatFormat(){
- Map<String, MessageContainer> messages = runValidation("/openecomp/org/validation/validators/heat_validator/invalid_heat_format/negative_test/input");
-
- Assert.assertNotNull(messages);
- Assert.assertEquals(messages.size(), 1);
-
- Assert.assertEquals(messages.get("hot-nimbus-psm_v1.0.yaml").getErrorMessageList().size(), 1);
- Assert.assertEquals(messages.get("hot-nimbus-psm_v1.0.yaml").getErrorMessageList().get(0).getMessage(), "Invalid HEAT format problem - [Cannot create property=kuku for JavaBean=Resource{type='null', properties=null, metadata=null, depends_on=null, update_policy='null', deletion_policy='null'}\n" +
- " in 'reader', line 25, column 5:\n" +
- " kuku: kuku\n" +
- " ^\n" +
- "Unable to find property 'kuku' on class: org.openecomp.sdc.heat.datatypes.model.Resource\n" +
- " in 'reader', line 25, column 11:\n" +
- " kuku: kuku\n" +
- " ^\n" +
- "]");
- }
-
-
- @Test
- public void testResourcesReferencesExistInHeat() throws IOException {
- Map<String, MessageContainer> messages = runValidation("/openecomp/org/validation/validators/heat_validator/resource_references_exist_in_heat/negative_test/input");
-
- Assert.assertNotNull(messages);
- Assert.assertEquals(messages.size(), 1);
-
- Assert.assertEquals(messages.get("hot-nimbus-pps_v1.0.yaml").getErrorMessageList().size(), 2);
- Assert.assertEquals(messages.get("hot-nimbus-pps_v1.0.yaml").getErrorMessageList().get(0).getMessage(), "Referenced resource - not_existing_resource not found");
- Assert.assertEquals(messages.get("hot-nimbus-pps_v1.0.yaml").getErrorMessageList().get(1).getMessage(), "invalid get_resource syntax is in use - null , get_resource function should get the resource id of the referenced resource");
- }
-
-
- @Test
- public void testGetResourceValueIsValid(){
- Map<String, MessageContainer> messages = runValidation("/openecomp/org/validation/validators/heat_validator/get_resource_value_valid/negative_test/input");
-
- Assert.assertNotNull(messages);
- Assert.assertEquals(messages.size(), 1);
-
- Assert.assertEquals(messages.get("hot-nimbus-pps_v1.0.yaml").getErrorMessageList().size(), 3);
- Assert.assertEquals(messages.get("hot-nimbus-pps_v1.0.yaml").getErrorMessageList().get(0).getMessage(), "invalid get_resource syntax is in use - [param_1, param_2] , get_resource function should get the resource id of the referenced resource");
- Assert.assertEquals(messages.get("hot-nimbus-pps_v1.0.yaml").getErrorMessageList().get(1).getMessage(), "invalid get_resource syntax is in use - {get_param=param_1} , get_resource function should get the resource id of the referenced resource");
- Assert.assertEquals(messages.get("hot-nimbus-pps_v1.0.yaml").getErrorMessageList().get(2).getMessage(), "invalid get_resource syntax is in use - null , get_resource function should get the resource id of the referenced resource");
- }
-
- @Test
- public void testTwoResourcesDoesNotHoldSameId() throws IOException {
- Map<String, MessageContainer> messages = runValidation("/openecomp/org/validation/validators/heat_validator/two_resources_does_not_hold_same_id/positive_test/input");
- Assert.assertNotNull(messages);
- Assert.assertEquals(messages.size(), 0);
- }
-
- @Test
- public void negativeTestGetParamPointToExistingParameter() throws IOException {
- Map<String, MessageContainer> messages = runValidation("/openecomp/org/validation/validators/heat_validator/get_param_points_to_existing_parameter/negative_test/input");
-
- Assert.assertNotNull(messages);
- Assert.assertEquals(messages.size(), 1);
-
- Assert.assertEquals(messages.get("hot-nimbus-psm_v1.0.yaml").getErrorMessageList().size(), 1);
- Assert.assertEquals(messages.get("hot-nimbus-psm_v1.0.yaml").getErrorMessageList().get(0).getMessage(), "Referenced parameter - not_existing_param_1 - not found, used in resource - server_pcrf_psm_001");
- }
-
- @Test
- public void testGetAttrFromNested() throws IOException {
- Map<String, MessageContainer> messages = runValidation("/openecomp/org/validation/validators/heat_validator/get_attr_from_nested/negative_test/input");
-
- Assert.assertNotNull(messages);
- Assert.assertEquals(messages.size(), 1);
-
- Assert.assertEquals(messages.get("hot-nimbus-psm_v1.0.yaml").getErrorMessageList().size(), 1);
- Assert.assertEquals(messages.get("hot-nimbus-psm_v1.0.yaml").getErrorMessageList().get(0).getMessage(), "get_attr attribute not found - nested_output in resource server_pcrf_psm_001");
- }
-
- @Test
- public void testPropertiesMatchNestedParameters() throws IOException {
- Map<String, MessageContainer> messages = runValidation("/openecomp/org/validation/validators/heat_validator/properties_match_nested_parameters/negative_test/input");
-
- Assert.assertNotNull(messages);
- Assert.assertEquals(messages.size(), 1);
-
- Assert.assertEquals(messages.get("hot-nimbus-pps_v1.0.yaml").getErrorMessageList().size(), 1);
- Assert.assertEquals(messages.get("hot-nimbus-pps_v1.0.yaml").getErrorMessageList().get(0).getMessage(), "Referenced parameter not found in nested file - nested-pps_v1.0.yaml, resource name - server_pcrf_pps_001, parameter name - parameter_not_existing_in_nested");
- }
-
- @Test
- public void testNovaPropertiesHasAssignedValue() throws IOException {
- Map<String, MessageContainer> messages = runValidation("/openecomp/org/validation/validators/heat_validator/nova_properties_has_assigned_value/negative_test/input");
-
- Assert.assertNotNull(messages);
- Assert.assertEquals(messages.size(), 1);
-
- Assert.assertEquals(messages.get("hot-nimbus-psm_v1.0.yaml").getErrorMessageList().size(), 1);
- Assert.assertEquals(messages.get("hot-nimbus-psm_v1.0.yaml").getErrorMessageList().get(0).getMessage(), "Missing both Image and Flavor in NOVA Server - nova_server_resource_missing_both");
- }
-
- @Test
- public void testNoLoopsNesting() throws IOException {
- Map<String, MessageContainer> messages = runValidation("/openecomp/org/validation/validators/heat_validator/no_loops_nesting/negative_test/input");
-
- Assert.assertNotNull(messages);
- Assert.assertEquals(messages.size(), 4);
-
- Assert.assertEquals(messages.get("hot-nimbus-psm_v1.0.yaml").getErrorMessageList().size(), 2);
- Assert.assertEquals(messages.get("hot-nimbus-psm_v1.0.yaml").getErrorMessageList().get(0).getMessage(), "A resource has an invalid or unsupported type - null, Resource ID [server_pcrf_psm_002]");
- Assert.assertEquals(messages.get("hot-nimbus-psm_v1.0.yaml").getErrorMessageList().get(1).getMessage(), "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]");
-
- Assert.assertEquals(messages.get("nested-points-to-hot-nimbus-psm.yaml").getErrorMessageList().size(), 2);
- Assert.assertEquals(messages.get("nested-points-to-hot-nimbus-psm.yaml").getErrorMessageList().get(0).getMessage(), "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]");
- Assert.assertEquals(messages.get("nested-points-to-hot-nimbus-psm.yaml").getErrorMessageList().get(1).getMessage(), "Nested files loop - [nested-points-to-hot-nimbus-psm.yaml -- nested-psm_v1.0.yaml -- nested-points-to-hot-nimbus-psm.yaml]");
-
- Assert.assertEquals(messages.get("yaml-point-to-itself.yaml").getErrorMessageList().size(), 1);
- Assert.assertEquals(messages.get("yaml-point-to-itself.yaml").getErrorMessageList().get(0).getMessage(), "Nested files loop - [yaml-point-to-itself.yaml -- yaml-point-to-itself.yaml]");
-
- Assert.assertEquals(messages.get("nested-psm_v1.0.yaml").getErrorMessageList().size(), 1);
- Assert.assertEquals(messages.get("nested-psm_v1.0.yaml").getErrorMessageList().get(0).getMessage(), "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]");
- }
-
- @Test
- public void testOnlyOneNovaPointsToOnePort() throws IOException {
- Map<String, MessageContainer> messages = runValidation("/openecomp/org/validation/validators/heat_validator/one_nova_points_to_one_port/negative_test/input");
-
- Assert.assertNotNull(messages);
- Assert.assertEquals(messages.size(), 1);
-
- Assert.assertEquals(messages.get("hot-nimbus-psm_v1.0.yaml").getErrorMessageList().size(), 1);
- Assert.assertEquals(messages.get("hot-nimbus-psm_v1.0.yaml").getErrorMessageList().get(0).getMessage(), "Resource Port oam1_int_port exceed allowed relations from NovaServer");
- }
-
- @Test
- public void testServerGroupsPointedByServersDefinedCorrectly() throws IOException {
- Map<String, MessageContainer> messages = runValidation("/openecomp/org/validation/validators/heat_validator/server_groups_defined_correctly/negative_test/input");
-
- Assert.assertNotNull(messages);
- Assert.assertEquals(messages.size(), 1);
-
- Assert.assertEquals(messages.get("hot-nimbus-pps_v1.0.yaml").getErrorMessageList().size(), 3);
- Assert.assertEquals(messages.get("hot-nimbus-pps_v1.0.yaml").getErrorMessageList().get(0).getMessage(), "Missing server group definition - BE_Affinity_2, nova_server_1");
- Assert.assertEquals(messages.get("hot-nimbus-pps_v1.0.yaml").getErrorMessageList().get(1).getMessage(), "Missing server group definition - BE_Affinity_2, nova_server_2");
- Assert.assertEquals(messages.get("hot-nimbus-pps_v1.0.yaml").getErrorMessageList().get(2).getMessage(), "Referenced resource - BE_Affinity_1 not found");
- }
-
-
- @Test
- public void testPolicyIsAffinityOrAntiAffinity() throws IOException {
- Map<String, MessageContainer> messages = runValidation("/openecomp/org/validation/validators/heat_validator/policy_is_affinity_or_anti_affinity/negative_test/input");
-
- Assert.assertNotNull(messages);
- Assert.assertEquals(messages.size(), 1);
-
- Assert.assertEquals(messages.get("hot-nimbus-psm_v1.0.yaml").getErrorMessageList().size(), 1);
- Assert.assertEquals(messages.get("hot-nimbus-psm_v1.0.yaml").getErrorMessageList().get(0).getMessage(), "Wrong policy in server group - pcrf_server_policies_1");
- }
-
-
- @Test
- public void testEnvContentIsSubSetOfHeatParameters() throws IOException {
- Map<String, MessageContainer> messages = runValidation("/openecomp/org/validation/validators/heat_validator/env_content_is_subset_of_heat/negative_test/input");
-
- Assert.assertNotNull(messages);
- Assert.assertEquals(messages.size(), 1);
-
- Assert.assertEquals(messages.get("hot-nimbus-pps_v1.0.env").getErrorMessageList().size(), 1);
- Assert.assertEquals(messages.get("hot-nimbus-pps_v1.0.env").getErrorMessageList().get(0).getMessage(), "Env file hot-nimbus-pps_v1.0.env includes a parameter not in HEAT - mock_param");
- }
-
- @Test
- public void testDefaultValueAlignWithType() throws IOException {
- Map<String, MessageContainer> messages = runValidation("/openecomp/org/validation/validators/heat_validator/default_value_align_with_type/negative_test/input");
-
- Assert.assertNotNull(messages);
- Assert.assertEquals(messages.size(), 1);
-
- Assert.assertEquals(messages.get("hot-nimbus-pps_v1.0.yaml").getErrorMessageList().size(), 1);
- Assert.assertEquals(messages.get("hot-nimbus-pps_v1.0.yaml").getErrorMessageList().get(0).getMessage(), "Parameter - pcrf_pps_image_name_1 default value not align with type number");
- }
-
-
- @Test
- public void testEnvParametersMatchDefinedHeatParameterTypes() throws IOException {
- Map<String, MessageContainer> messages = runValidation("/openecomp/org/validation/validators/heat_validator/env_parameters_match_defined_types/negative_test/input");
-
- Assert.assertNotNull(messages);
- Assert.assertEquals(messages.size(), 1);
-
- Assert.assertEquals(messages.get("hot-nimbus-pps_v1.0.env").getErrorMessageList().size(), 1);
- Assert.assertEquals(messages.get("hot-nimbus-pps_v1.0.env").getErrorMessageList().get(0).getMessage(), "Parameter env value pcrf_pps_flavor_name not align with type");
-
- }
-
- @Test
- public void testReferencedArtifactsExist() throws IOException {
- Map<String, MessageContainer> messages = runValidation("/openecomp/org/validation/validators/heat_validator/referenced_artifacts_exist/negative_test/input");
-
- Assert.assertNotNull(messages);
- Assert.assertEquals(messages.size(), 1);
-
- Assert.assertEquals(messages.get("hot-nimbus-pps_v1.0.yaml").getErrorMessageList().size(), 1);
- Assert.assertEquals(messages.get("hot-nimbus-pps_v1.0.yaml").getErrorMessageList().get(0).getMessage(), "Missing artifact - nimbus-ethernet");
-
- }
-
-
- @Test
- public void testResourcesGroupWithNested() throws IOException {
- Map<String, MessageContainer> messages = runValidation("/openecomp/org/validation/validators/heat_validator/resources_group_with_nested/negative_test/input");
-
- Assert.assertNotNull(messages);
- Assert.assertEquals(messages.size(), 3);
-
- Assert.assertEquals(messages.get("hot-nimbus-psm_v1.0.yaml").getErrorMessageList().size(), 2);
- Assert.assertEquals(messages.get("hot-nimbus-psm_v1.0.yaml").getErrorMessageList().get(0).getMessage(), "Referenced parameter not found in nested file - nested-from-resources-group.yaml, resource name - nested-from-resources-group.yaml, parameter name - property_not_in_nested");
- Assert.assertEquals(messages.get("hot-nimbus-psm_v1.0.yaml").getErrorMessageList().get(1).getMessage(), "OS::Heat::ResourceGroup resource with resource_def which is not pointing to nested heat file is not supported, Resource ID [resource_without_resources_group], resource_def type [OS::Nova::Server]");
-
- Assert.assertEquals(messages.get("nested-pps_v1.0.yaml").getErrorMessageList().size(), 1);
- Assert.assertEquals(messages.get("nested-pps_v1.0.yaml").getErrorMessageList().get(0).getMessage(), "Nested files loop - [nested-pps_v1.0.yaml -- nested-from-resources-group.yaml -- hot-nimbus-pps_v1.0.yaml -- nested-pps_v1.0.yaml]");
-
- Assert.assertEquals(messages.get("nested-not-exist.yaml").getErrorMessageList().size(), 1);
- Assert.assertEquals(messages.get("nested-not-exist.yaml").getErrorMessageList().get(0).getMessage(), "Missing nested file - nested-not-exist.yaml");
- }
-
-
- @Test
- public void testResourceGroupWithInvalidType(){
- Map<String, MessageContainer> messages = runValidation("/openecomp/org/validation/validators/heat_validator/resource_group_invalid_type/negative_test/input");
-
- Assert.assertNotNull(messages);
- Assert.assertEquals(messages.size(), 1);
-
- Assert.assertEquals(messages.get("hot-nimbus-psm_v1.0.yaml").getErrorMessageList().size(), 3);
- Assert.assertEquals(messages.get("hot-nimbus-psm_v1.0.yaml").getErrorMessageList().get(0).getMessage(), "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}]");
- Assert.assertEquals(messages.get("hot-nimbus-psm_v1.0.yaml").getErrorMessageList().get(1).getMessage(), "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 [OS::Nova::Server]");
- Assert.assertEquals(messages.get("hot-nimbus-psm_v1.0.yaml").getErrorMessageList().get(2).getMessage(), "A resource has an invalid or unsupported type - null, Resource ID [resource_with_resources_group_3]");
- }
-
-
- @Test
- public void testNetworkPolicyAssociatedWithAttachPolicy() throws IOException {
- Map<String, MessageContainer> messages = runValidation("/openecomp/org/validation/validators/heat_validator/network_policy_associated_with_attach_policy/input");
-
- Assert.assertNotNull(messages);
- Assert.assertEquals(messages.size(), 1);
-
- Assert.assertEquals(messages.get("hot-nimbus-pps_v1.0.yaml").getErrorMessageList().size(), 1);
- Assert.assertEquals(messages.get("hot-nimbus-pps_v1.0.yaml").getErrorMessageList().get(0).getMessage(), "NetworkPolicy not in use, Resource Id [not_used_server_pcrf_policy]");
- }
-
-
- @Test
- public void testSecurityGroupsCalledByPort() throws IOException {
- Map<String, MessageContainer> messages = runValidation("/openecomp/org/validation/validators/heat_validator/security_group_called_by_port/input");
-
- Assert.assertNotNull(messages);
- Assert.assertEquals(messages.size(), 1);
-
- Assert.assertEquals(messages.get("hot-nimbus-pps_v1.0.yaml").getErrorMessageList().size(), 2);
- Assert.assertEquals(messages.get("hot-nimbus-pps_v1.0.yaml").getErrorMessageList().get(0).getMessage(), "SecurityGroup not in use, Resource Id [not_used_security_group]");
- Assert.assertEquals(messages.get("hot-nimbus-pps_v1.0.yaml").getErrorMessageList().get(1).getMessage(), "Port not bind to any NOVA Server, Resource Id [attach_policy_resource]");
- }
-
-
- @Test
- public void testServerGroupCalledByServer() throws IOException {
- Map<String, MessageContainer> messages = runValidation("/openecomp/org/validation/validators/heat_validator/server_group_called_by_nova_server/input");
-
- Assert.assertNotNull(messages);
- Assert.assertEquals(messages.size(), 1);
-
- Assert.assertEquals(messages.get("hot-nimbus-pps_v1.0.yaml").getErrorMessageList().size(), 1);
- Assert.assertEquals(messages.get("hot-nimbus-pps_v1.0.yaml").getErrorMessageList().get(0).getMessage(), "ServerGroup not in use, Resource Id [not_used_server_group]");
-
- }
-
-
- @Test
- public void testSecurityGroupBaseFileNoPorts() throws IOException {
- Map<String, MessageContainer> messages = runValidation("/openecomp/org/validation/validators/heat_validator/security_group_base_file_no_ports/input");
-
- Assert.assertNotNull(messages);
- Assert.assertEquals(messages.size(), 1);
-
- Assert.assertEquals(messages.get("baseFile.yaml").getErrorMessageList().size(), 1);
- Assert.assertEquals(messages.get("baseFile.yaml").getErrorMessageList().get(0).getMessage(), "SecurityGroup not in use, Resource Id [shared_security_group_id3]");
- }
-
-
- @Test
- public void testDependsOn(){
- Map<String, MessageContainer> messages = runValidation("/openecomp/org/validation/validators/heat_validator/depends_on_points_to_existing_resource/input");
-
- Assert.assertNotNull(messages);
- Assert.assertEquals(messages.size(), 1);
-
- Assert.assertEquals(messages.get("hot-nimbus-pps_v1.0.yaml").getErrorMessageList().size(), 2);
- Assert.assertEquals(messages.get("hot-nimbus-pps_v1.0.yaml").getErrorMessageList().get(0).getMessage(), "a Missing resource in depend On Missing Resource ID [resource_not_exist]");
- Assert.assertEquals(messages.get("hot-nimbus-pps_v1.0.yaml").getErrorMessageList().get(1).getMessage(), "a Missing resource in depend On Missing Resource ID [resource_3]");
- }
-
-
- @Test
- public void testSharedResourcesValidation(){
- Map<String, MessageContainer> messages = runValidation("/openecomp/org/validation/validators/heat_validator/shared_resources/input");
-
- Assert.assertNotNull(messages);
- Assert.assertEquals(messages.size(), 1);
-
- Assert.assertEquals(messages.get("hot-nimbus-pps_v1.0.yaml").getErrorMessageList().size(), 2);
- Assert.assertEquals(messages.get("hot-nimbus-pps_v1.0.yaml").getErrorMessageList().get(0).getMessage(), "SecurityGroup not in use, Resource Id [not_used_security_group]");
- Assert.assertEquals(messages.get("hot-nimbus-pps_v1.0.yaml").getErrorMessageList().get(1).getMessage(), "Port not bind to any NOVA Server, Resource Id [attach_policy_resource]");
- }
-
-
- @Test
- public void testNoErrorWhenEmptyValueForParameterInEnv(){
- Map<String, MessageContainer> messages = runValidation("/openecomp/org/validation/validators/heat_validator/env_empty_value/input");
-
- Assert.assertNotNull(messages);
- Assert.assertEquals(messages.size(), 1);
-
- MessageContainer envMessages = messages.get("env_empty_value.env");
- Assert.assertNull(envMessages);
- }
-
-
- @Test
- public void testGetParamPseudoParameters(){
- Map<String, MessageContainer> messages = runValidation("/openecomp/org/validation/validators/heat_validator/pseudo_parameters/input");
-
- Assert.assertNotNull(messages);
- Assert.assertEquals(messages.size(), 0);
-
- }
-
-
- @Override
- public Map<String, MessageContainer> runValidation(String path) {
- HeatValidator heatValidator = new HeatValidator();
- return testValidator(heatValidator, path);
- }
-}
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/validators/ManifestValidatorTest.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/validators/ManifestValidatorTest.java
deleted file mode 100644
index 479a1fb83b..0000000000
--- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/validators/ManifestValidatorTest.java
+++ /dev/null
@@ -1,125 +0,0 @@
-package org.openecomp.sdc.validation.impl.validators.validators;
-
-
-import org.openecomp.sdc.common.utils.AsdcCommon;
-import org.openecomp.sdc.validation.impl.validators.ManifestValidator;
-import org.openecomp.sdc.validation.impl.validators.ValidatorBaseTest;
-import org.openecomp.core.validation.errors.Messages;
-import org.openecomp.core.validation.types.MessageContainer;
-
-import org.testng.Assert;
-import org.testng.annotations.Test;
-
-import java.util.Map;
-
-public class ManifestValidatorTest extends ValidatorBaseTest {
-
-
- @Test
- public void testValidManifest() {
- Map<String, MessageContainer> messages =
- runValidation("/openecomp/org/validation/validators/manifestValidator/validFiles");
- Assert.assertNotNull(messages);
- Assert.assertNotNull(messages);
- Assert.assertEquals(messages.size(), 0);
- }
-
- @Test
- public void testManifestMissingFileInZip() {
- Map<String, MessageContainer> messages =
- runValidation("/openecomp/org/validation/validators/manifestValidator/missingFileInZip");
- Assert.assertNotNull(messages);
- Assert.assertEquals(messages.size(), 1);
- Assert.assertTrue(messages.containsKey("singleVol.yaml"));
- validateErrorMessage(messages.get("singleVol.yaml").getErrorMessageList().get(0).getMessage(),
- Messages.MISSING_FILE_IN_ZIP.getErrorMessage());
- }
-
- @Test
- public void testInvalidManifest() {
- Map<String, MessageContainer> messages =
- runValidation("/openecomp/org/validation/validators/manifestValidator/invalidManifest");
- Assert.assertNotNull(messages);
- Assert.assertNotNull(messages);
- Assert.assertEquals(messages.size(), 1);
- Assert.assertTrue(messages.containsKey(AsdcCommon.MANIFEST_NAME));
- validateErrorMessage(
- messages.get(AsdcCommon.MANIFEST_NAME).getErrorMessageList().get(0).getMessage(),
- Messages.INVALID_MANIFEST_FILE.getErrorMessage(), AsdcCommon.MANIFEST_NAME);
-
- }
-
- @Test
- public void testMissingFileInManifest() {
- Map<String, MessageContainer> messages =
- runValidation("/openecomp/org/validation/validators/manifestValidator/missingFileInManifest");
- Assert.assertNotNull(messages);
- Assert.assertEquals(messages.size(), 1);
- Assert.assertTrue(messages.containsKey("extraFile.env"));
- validateErrorMessage(messages.get("extraFile.env").getErrorMessageList().get(0).getMessage(),
- Messages.MISSING_FILE_IN_MANIFEST.getErrorMessage());
-
- }
-
- @Test
- public void testInvalidFileTypeInManifest() {
- Map<String, MessageContainer> messages = runValidation(
- "/openecomp/org/validation/validators/manifestValidator/invalidFileTypeInManifest");
- Assert.assertNotNull(messages);
- Assert.assertEquals(messages.size(), 4);
- Assert.assertTrue(messages.containsKey("single.env.illegalSuffix"));
- Assert.assertTrue(messages.containsKey("illegalTypeFile.yaml"));
- Assert.assertTrue(messages.containsKey("single.yaml.illegalSuffix"));
- Assert.assertTrue(messages.containsKey("singleVol.yaml.illegalSuffix"));
- validateErrorMessage(
- messages.get("single.env.illegalSuffix").getErrorMessageList().get(0).getMessage(),
- Messages.WRONG_ENV_FILE_EXTENSION.getErrorMessage(), "single.env.illegalSuffix");
- validateErrorMessage(
- messages.get("illegalTypeFile.yaml").getErrorMessageList().get(0).getMessage(),
- Messages.INVALID_FILE_TYPE.getErrorMessage(), "illegalTypeFile.yaml");
- validateErrorMessage(
- messages.get("single.yaml.illegalSuffix").getErrorMessageList().get(0).getMessage(),
- Messages.WRONG_HEAT_FILE_EXTENSION.getErrorMessage(), "single.yaml.illegalSuffix");
- validateErrorMessage(
- messages.get("singleVol.yaml.illegalSuffix").getErrorMessageList().get(0).getMessage(),
- Messages.WRONG_HEAT_FILE_EXTENSION.getErrorMessage(), "singleVol.yaml.illegalSuffix");
-
- }
-
-
- @Test
- public void testMissingFileInManifestAndInZip() {
-
- Map<String, MessageContainer> messages = runValidation(
- "/openecomp/org/validation/validators/manifestValidator/missingFileInManifestAndInZip");
- Assert.assertNotNull(messages);
- Assert.assertEquals(messages.size(), 2);
- Assert.assertTrue(messages.containsKey("extraFile.env"));
- Assert.assertTrue(messages.containsKey("singleVol.yaml"));
- validateErrorMessage(messages.get("extraFile.env").getErrorMessageList().get(0).getMessage(),
- Messages.MISSING_FILE_IN_MANIFEST.getErrorMessage());
- validateErrorMessage(messages.get("singleVol.yaml").getErrorMessageList().get(0).getMessage(),
- Messages.MISSING_FILE_IN_ZIP.getErrorMessage());
-
- }
-
-
- @Test
- public void testEnvInRoot() {
- Map<String, MessageContainer> messages =
- runValidation("/openecomp/org/validation/validators/manifestValidator/envInRoot");
- Assert.assertNotNull(messages);
- Assert.assertEquals(messages.size(), 1);
- Assert.assertTrue(messages.containsKey("second.env"));
- validateErrorMessage(messages.get("second.env").getErrorMessageList().get(0).getMessage(),
- "ENV file must be associated to a HEAT file");
- }
-
- public Map<String, MessageContainer> runValidation(String path) {
- ManifestValidator manifestValidator = new ManifestValidator();
- return testValidator(manifestValidator, path);
-
- }
-
-
-}