summaryrefslogtreecommitdiffstats
path: root/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src
diff options
context:
space:
mode:
authormojahidi <mojahidul.islam@amdocs.com>2017-11-21 11:38:41 +0530
committermojahidi <mojahidul.islam@amdocs.com>2017-11-21 11:38:54 +0530
commit7bd878afa02d188e687a6958ae999807c2106392 (patch)
tree386429ce3dfa9bc95c766118b0aa54968289c9fd /openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src
parent66ed5840294585b55bc632944f19b859d389b3d2 (diff)
ContrailNetworkPolicy ResourceValidator
This task is about updating error messages with error codes for ContrailNetworkPolicyResourceValidator Change-Id: Ia011acd6c82b5fee5fdfd0bca27ef527d4b3b039 Issue-ID:SDC-572 Signed-off-by: mojahidi <mojahidul.islam@amdocs.com>
Diffstat (limited to 'openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src')
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/heatresource/ContrailNetworkPolicyResourceValidator.java55
-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.java24
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/heat_validator/network_policy_associated_with_attach_policy/negative/MANIFEST.json (renamed from openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/heat_validator/network_policy_associated_with_attach_policy/input/MANIFEST.json)0
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/heat_validator/network_policy_associated_with_attach_policy/negative/hot-nimbus-pps_v1.0.env (renamed from openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/heat_validator/network_policy_associated_with_attach_policy/input/hot-nimbus-pps_v1.0.env)0
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/heat_validator/network_policy_associated_with_attach_policy/negative/hot-nimbus-pps_v1.0.yaml51
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/heat_validator/network_policy_associated_with_attach_policy/positive/MANIFEST.json17
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/heat_validator/network_policy_associated_with_attach_policy/positive/hot-nimbus-pps_v1.0.env11
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/heat_validator/network_policy_associated_with_attach_policy/positive/hot-nimbus-pps_v1.0.yaml (renamed from openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/heat_validator/network_policy_associated_with_attach_policy/input/hot-nimbus-pps_v1.0.yaml)0
8 files changed, 128 insertions, 30 deletions
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/heatresource/ContrailNetworkPolicyResourceValidator.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/heatresource/ContrailNetworkPolicyResourceValidator.java
index 8ca5e69061..8aa5714f2c 100644
--- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/heatresource/ContrailNetworkPolicyResourceValidator.java
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/heatresource/ContrailNetworkPolicyResourceValidator.java
@@ -1,6 +1,7 @@
package org.openecomp.sdc.validation.impl.validators.heatresource;
import org.apache.commons.collections4.MapUtils;
+import org.openecomp.core.validation.ErrorMessageCode;
import org.openecomp.core.validation.errors.ErrorMessagesFormatBuilder;
import org.openecomp.core.validation.types.GlobalValidationContext;
import org.openecomp.sdc.common.errors.Messages;
@@ -23,12 +24,14 @@ import java.util.Map;
*/
public class ContrailNetworkPolicyResourceValidator implements ResourceValidator {
private static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage();
+ private static final ErrorMessageCode ERROR_CODE_HNP1 = new ErrorMessageCode("HNP1");
+ private static final ErrorMessageCode ERROR_CODE_HNP2 = new ErrorMessageCode("HNP2");
@Override
public void validate(String fileName, Map.Entry<String, Resource> resourceEntry,
GlobalValidationContext globalContext, ValidationContext validationContext) {
- validateNetworkPolicyIsUsed
- (fileName, resourceEntry, globalContext, (HeatResourceValidationContext)validationContext);
+ validateNetworkPolicyIsUsed(fileName, resourceEntry, globalContext,
+ (HeatResourceValidationContext) validationContext);
}
@@ -39,25 +42,25 @@ public class ContrailNetworkPolicyResourceValidator implements ResourceValidator
mdcDataDebugMessage.debugEntryMessage("file", fileName);
Map<String, Map<String, List<String>>> referencedNetworkAttachPoliciesResources =
- validationContext.getFileLevelResourceDependencies()
- .get(HeatResourcesTypes.CONTRAIL_NETWORK_RULE_RESOURCE_TYPE.getHeatResource());
+ validationContext.getFileLevelResourceDependencies()
+ .get(HeatResourcesTypes.CONTRAIL_NETWORK_RULE_RESOURCE_TYPE.getHeatResource());
if (MapUtils.isEmpty(referencedNetworkAttachPoliciesResources)) {
globalContext
- .addMessage(
- fileName,
- ErrorLevel.WARNING,
- ErrorMessagesFormatBuilder
- .getErrorWithParameters(
- Messages.RESOURCE_NOT_IN_USE.getErrorMessage(),
- ValidatorConstants.Network_Policy, resourceEntry.getKey()),
- LoggerTragetServiceName.VALIDATE_ATTACH_POLICY_IN_USE,
- LoggerErrorDescription.NETWORK_ATTACH_POLICY_NOT_IN_USE);
+ .addMessage(
+ fileName,
+ ErrorLevel.WARNING,
+ ErrorMessagesFormatBuilder
+ .getErrorWithParameters(ERROR_CODE_HNP1,
+ Messages.RESOURCE_NOT_IN_USE.getErrorMessage(),
+ ValidatorConstants.Network_Policy, resourceEntry.getKey()),
+ LoggerTragetServiceName.VALIDATE_ATTACH_POLICY_IN_USE,
+ LoggerErrorDescription.NETWORK_ATTACH_POLICY_NOT_IN_USE);
return;
}
- handleNetworkAttachPolicyReferences
- (fileName, resourceEntry, referencedNetworkAttachPoliciesResources, globalContext);
+ handleNetworkAttachPolicyReferences(fileName, resourceEntry,
+ referencedNetworkAttachPoliciesResources, globalContext);
mdcDataDebugMessage.debugExitMessage("file", fileName);
@@ -69,23 +72,23 @@ public class ContrailNetworkPolicyResourceValidator implements ResourceValidator
GlobalValidationContext globalContext) {
Map<String, List<String>> resourcesPointingToCurrNetworkAttachPolicy =
- pointedNetworkAttachPolicies.get(resourceEntry.getKey());
+ pointedNetworkAttachPolicies.get(resourceEntry.getKey());
if (isNetworkAttachPolicyNotInUse(resourcesPointingToCurrNetworkAttachPolicy)) {
globalContext
- .addMessage(
- fileName,
- ErrorLevel.WARNING,
- ErrorMessagesFormatBuilder
- .getErrorWithParameters(
- Messages.RESOURCE_NOT_IN_USE.getErrorMessage(),
- ValidatorConstants.Network_Policy, resourceEntry.getKey()),
- LoggerTragetServiceName.VALIDATE_ATTACH_POLICY_IN_USE,
- LoggerErrorDescription.NETWORK_ATTACH_POLICY_NOT_IN_USE);
+ .addMessage(
+ fileName,
+ ErrorLevel.WARNING,
+ ErrorMessagesFormatBuilder
+ .getErrorWithParameters(ERROR_CODE_HNP2,
+ Messages.RESOURCE_NOT_IN_USE.getErrorMessage(),
+ ValidatorConstants.Network_Policy, resourceEntry.getKey()),
+ LoggerTragetServiceName.VALIDATE_ATTACH_POLICY_IN_USE,
+ LoggerErrorDescription.NETWORK_ATTACH_POLICY_NOT_IN_USE);
}
}
private static boolean isNetworkAttachPolicyNotInUse(
- Map<String, List<String>> resourcesPointingToCurrNetworkAttachPolicy) {
+ Map<String, List<String>> resourcesPointingToCurrNetworkAttachPolicy) {
return MapUtils.isEmpty(resourcesPointingToCurrNetworkAttachPolicy);
}
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
index a03120c5d6..fd6f1d42bb 100644
--- 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
@@ -19,18 +19,34 @@ public class ContrailNetworkPolicyResourceValidatorTest {
ContrailNetworkPolicyResourceValidator resourceValidator = new
ContrailNetworkPolicyResourceValidator();
+ private static final String PATH = "/org/openecomp/validation/validators/heat_validator/network_policy_associated_with_attach_policy/";
@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");
+ , HeatResourcesTypes.CONTRAIL_NETWORK_RULE_RESOURCE_TYPE.getHeatResource(),
+ PATH + "positive");
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]");
+ messages.get("hot-nimbus-pps_v1.0.yaml").getErrorMessageList().get(0).getMessage(),
+ "WARNING: [HNP2]: NetworkPolicy not in use, Resource Id [not_used_server_pcrf_policy]");
+ }
+
+ @Test
+ public void testNonNetworkPolicyResource() throws IOException {
+ Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator, resourceValidator
+ , HeatResourcesTypes.CONTRAIL_VIRTUAL_NETWORK_RESOURCE_TYPE.getHeatResource(),
+ PATH + "negative");
+
+ 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: [HNP1]: NetworkPolicy not in use, Resource Id [server_pcrf_network]");
}
}
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/heat_validator/network_policy_associated_with_attach_policy/input/MANIFEST.json b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/heat_validator/network_policy_associated_with_attach_policy/negative/MANIFEST.json
index 1e719efb31..1e719efb31 100644
--- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/heat_validator/network_policy_associated_with_attach_policy/input/MANIFEST.json
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/heat_validator/network_policy_associated_with_attach_policy/negative/MANIFEST.json
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/heat_validator/network_policy_associated_with_attach_policy/input/hot-nimbus-pps_v1.0.env b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/heat_validator/network_policy_associated_with_attach_policy/negative/hot-nimbus-pps_v1.0.env
index 340be2b815..340be2b815 100644
--- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/heat_validator/network_policy_associated_with_attach_policy/input/hot-nimbus-pps_v1.0.env
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/heat_validator/network_policy_associated_with_attach_policy/negative/hot-nimbus-pps_v1.0.env
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/heat_validator/network_policy_associated_with_attach_policy/negative/hot-nimbus-pps_v1.0.yaml b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/heat_validator/network_policy_associated_with_attach_policy/negative/hot-nimbus-pps_v1.0.yaml
new file mode 100644
index 0000000000..d0bbe46ffe
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/heat_validator/network_policy_associated_with_attach_policy/negative/hot-nimbus-pps_v1.0.yaml
@@ -0,0 +1,51 @@
+heat_template_version: 2013-05-23
+
+description: heat template that creates PCRF Policy Server stack
+
+parameters:
+ pcrf_pps_server_names:
+ type: comma_delimited_list
+ label: PCRF PS server names
+ description: PCRF PS server names
+ pcrf_pps_image_name:
+ type: string
+ label: PCRF PS image name
+ description: PCRF PS image name
+ pcrf_pps_flavor_name:
+ type: string
+ label: PCRF PS flavor name
+ description: flavor name of PCRF PS instance
+ availabilityzone_name:
+ type: string
+ label: availabilityzone name
+ description: availabilityzone name
+ pcrf_cps_net_name:
+ type: string
+ label: CPS network name
+ description: CPS network name
+ pcrf_cps_net_ips:
+ type: comma_delimited_list
+ label: CPS network ips
+ description: CPS network ips
+ pcrf_cps_net_mask:
+ type: string
+ label: CPS network mask
+ description: CPS network mask
+ pcrf_security_group_name:
+ type: string
+ label: security group name
+ description: the name of security group
+ pcrf_vnf_id:
+ type: string
+ label: PCRF VNF Id
+ description: PCRF VNF Id
+
+resources:
+ server_pcrf_network:
+ type: OS::Contrail::VirtualNetwork
+ properties:
+ pcrf_pps_server_name: { get_param: [pcrf_pps_server_names, 0] }
+ pcrf_pps_image_name: { get_param: pcrf_pps_image_name }
+
+
+
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/heat_validator/network_policy_associated_with_attach_policy/positive/MANIFEST.json b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/heat_validator/network_policy_associated_with_attach_policy/positive/MANIFEST.json
new file mode 100644
index 0000000000..1e719efb31
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/heat_validator/network_policy_associated_with_attach_policy/positive/MANIFEST.json
@@ -0,0 +1,17 @@
+{
+ "name": "hot-mog",
+ "description": "HOT template to create hot mog server",
+ "version": "2013-05-23",
+ "data": [
+ {
+ "file": "hot-nimbus-pps_v1.0.yaml",
+ "type": "HEAT",
+ "data": [
+ {
+ "file": "hot-nimbus-pps_v1.0.env",
+ "type": "HEAT_ENV"
+ }
+ ]
+ }
+ ]
+} \ No newline at end of file
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/heat_validator/network_policy_associated_with_attach_policy/positive/hot-nimbus-pps_v1.0.env b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/heat_validator/network_policy_associated_with_attach_policy/positive/hot-nimbus-pps_v1.0.env
new file mode 100644
index 0000000000..340be2b815
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/heat_validator/network_policy_associated_with_attach_policy/positive/hot-nimbus-pps_v1.0.env
@@ -0,0 +1,11 @@
+parameters:
+ pcrf_pps_server_names: ZRDM1PCRF01PPS001,ZRDM1PCRF01PPS002,ZRDM1PCRF01PPS003,ZRDM1PCRF01PPS004,ZRDM1PCRF01PPS005,ZRDM1PCRF01PPS006
+ pcrf_pps_image_name: PCRF_8.995-ATTM1.0.3.qcow2
+ pcrf_pps_flavor_name: lc.3xlarge
+ availabilityzone_name: nova
+ pcrf_cps_net_name: Mobisupport-25193-I-INT1_int_pcrf_net_0
+ pcrf_cps_net_ips: 172.26.16.7,172.26.16.8,172.26.16.9,172.26.16.10,172.26.16.11,172.26.16.12
+ pcrf_cps_net_mask: 255.255.255.0
+ pcrf_security_group_name: nimbus_security_group
+ pcrf_vnf_id: 730797234b4a40aa99335157b02871cd
+
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/heat_validator/network_policy_associated_with_attach_policy/input/hot-nimbus-pps_v1.0.yaml b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/heat_validator/network_policy_associated_with_attach_policy/positive/hot-nimbus-pps_v1.0.yaml
index b2b91ec36d..b2b91ec36d 100644
--- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/heat_validator/network_policy_associated_with_attach_policy/input/hot-nimbus-pps_v1.0.yaml
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/heat_validator/network_policy_associated_with_attach_policy/positive/hot-nimbus-pps_v1.0.yaml