summaryrefslogtreecommitdiffstats
path: root/model/policy-model
diff options
context:
space:
mode:
authorwaqas.ikram <waqas.ikram@ericsson.com>2018-05-30 09:48:40 +0100
committerwaqas.ikram <waqas.ikram@ericsson.com>2018-05-30 16:29:30 +0100
commit8bad2ad828fad2f5f99a9a291ca0f5c51b62e4ca (patch)
tree7b02ec8dd5dcda881b9133169a753fc6671e44bf /model/policy-model
parent55d93a12cc5575c872724f48585304b5eec77fea (diff)
Fixing Sonar bugs and code smells
Change-Id: I661cd409d01320fe11a29b7ea72b9e8f70e72a6c Issue-ID: POLICY-856 Signed-off-by: waqas.ikram <waqas.ikram@ericsson.com>
Diffstat (limited to 'model/policy-model')
-rw-r--r--model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxPolicies.java23
1 files changed, 14 insertions, 9 deletions
diff --git a/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxPolicies.java b/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxPolicies.java
index 248e4fdae..1937edac0 100644
--- a/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxPolicies.java
+++ b/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxPolicies.java
@@ -225,19 +225,15 @@ public class AxPolicies extends AxConcept implements AxConceptGetter<AxPolicy> {
"policyMap may not be empty"));
} else {
for (final Entry<AxArtifactKey, AxPolicy> policyEntry : policyMap.entrySet()) {
- if (policyEntry.getKey().equals(AxArtifactKey.getNullKey())) {
+ final AxArtifactKey entryKey = policyEntry.getKey();
+ if (entryKey.equals(AxArtifactKey.getNullKey())) {
result.addValidationMessage(new AxValidationMessage(key, this.getClass(), ValidationResult.INVALID,
- "key on policy entry " + policyEntry.getKey() + " may not be the null key"));
+ "key on policy entry " + entryKey + " may not be the null key"));
} else if (policyEntry.getValue() == null) {
result.addValidationMessage(new AxValidationMessage(key, this.getClass(), ValidationResult.INVALID,
- "value on policy entry " + policyEntry.getKey() + " may not be null"));
+ "value on policy entry " + entryKey + " may not be null"));
} else {
- if (!policyEntry.getKey().equals(policyEntry.getValue().getKey())) {
- result.addValidationMessage(new AxValidationMessage(key, this.getClass(),
- ValidationResult.INVALID, "key on policy entry key " + policyEntry.getKey()
- + " does not equal policy value key " + policyEntry.getValue().getKey()));
- }
-
+ validate(result, policyEntry, entryKey);
result = policyEntry.getValue().validate(result);
}
}
@@ -246,6 +242,15 @@ public class AxPolicies extends AxConcept implements AxConceptGetter<AxPolicy> {
return result;
}
+ private void validate(final AxValidationResult result, final Entry<AxArtifactKey, AxPolicy> policyEntry,
+ final AxArtifactKey entryKey) {
+ if (!entryKey.equals(policyEntry.getValue().getKey())) {
+ result.addValidationMessage(
+ new AxValidationMessage(key, this.getClass(), ValidationResult.INVALID, "key on policy entry key "
+ + entryKey + " does not equal policy value key " + policyEntry.getValue().getKey()));
+ }
+ }
+
/*
* (non-Javadoc)
*