summaryrefslogtreecommitdiffstats
path: root/src/main
diff options
context:
space:
mode:
authorsebdet <sebastien.determe@intl.att.com>2018-12-07 17:48:10 +0100
committersebdet <sebastien.determe@intl.att.com>2018-12-07 17:48:10 +0100
commit9d1f89cff526052bd28a24d4ac33b1fd54d76983 (patch)
tree1e7f2598b46433953dd1ab13be88803b7df1860a /src/main
parentd72d0d05d74f4125e8f36beea096aa7769d19eab (diff)
Add unit tests
Add test to policyClient + guard policyAttributes Issue-ID: CLAMP-252 Change-Id: I344a631cc1dfd38e87f61b34dcb1bb3dbb00625a Signed-off-by: sebdet <sebastien.determe@intl.att.com>
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/org/onap/clamp/clds/client/req/policy/GuardPolicyAttributesConstructor.java34
-rw-r--r--src/main/java/org/onap/clamp/clds/client/req/policy/PolicyClient.java1
2 files changed, 24 insertions, 11 deletions
diff --git a/src/main/java/org/onap/clamp/clds/client/req/policy/GuardPolicyAttributesConstructor.java b/src/main/java/org/onap/clamp/clds/client/req/policy/GuardPolicyAttributesConstructor.java
index 0b4cbeab7..afef5919c 100644
--- a/src/main/java/org/onap/clamp/clds/client/req/policy/GuardPolicyAttributesConstructor.java
+++ b/src/main/java/org/onap/clamp/clds/client/req/policy/GuardPolicyAttributesConstructor.java
@@ -38,6 +38,18 @@ import org.onap.policy.api.AttributeType;
import org.onap.policy.api.RuleProvider;
public class GuardPolicyAttributesConstructor {
+ public static final String ACTOR = "actor";
+ public static final String RECIPE = "recipe";
+ public static final String TARGETS = "targets";
+ public static final String CLNAME = "clname";
+ public static final String MIN = "min";
+ public static final String MAX = "max";
+ public static final String LIMIT = "limit";
+ public static final String TIME_WINDOW = "timeWindow";
+ public static final String TIME_UNITS = "timeUnits";
+ public static final String GUARD_ACTIVE_START = "guardActiveStart";
+ public static final String GUARD_ACTIVE_END = "guardActiveEnd";
+
private static final EELFLogger logger = EELFManager.getInstance()
.getLogger(GuardPolicyAttributesConstructor.class);
@@ -63,20 +75,20 @@ public class GuardPolicyAttributesConstructor {
private static Map<String, String> prepareMatchingAttributes(PolicyItem policyItem, ModelProperties modelProp) {
logger.info("Preparing matching attributes for guard...");
Map<String, String> matchingAttributes = new HashMap<>();
- matchingAttributes.put("actor", policyItem.getActor());
- matchingAttributes.put("recipe", policyItem.getRecipe());
- matchingAttributes.put("targets", policyItem.getGuardTargets());
- matchingAttributes.put("clname", modelProp.getControlNameAndPolicyUniqueId());
+ matchingAttributes.put(ACTOR, policyItem.getActor());
+ matchingAttributes.put(RECIPE, policyItem.getRecipe());
+ matchingAttributes.put(TARGETS, policyItem.getGuardTargets());
+ matchingAttributes.put(CLNAME, modelProp.getControlNameAndPolicyUniqueId());
if (RuleProvider.GUARD_MIN_MAX.equals(RuleProvider.valueOf(policyItem.getGuardPolicyType()))) {
- matchingAttributes.put("min", policyItem.getMinGuard());
- matchingAttributes.put("max", policyItem.getMaxGuard());
+ matchingAttributes.put(MIN, policyItem.getMinGuard());
+ matchingAttributes.put(MAX, policyItem.getMaxGuard());
} else if (RuleProvider.GUARD_YAML.equals(RuleProvider.valueOf(policyItem.getGuardPolicyType()))) {
- matchingAttributes.put("limit", policyItem.getLimitGuard());
- matchingAttributes.put("timeWindow", policyItem.getTimeWindowGuard());
- matchingAttributes.put("timeUnits", policyItem.getTimeUnitsGuard());
+ matchingAttributes.put(LIMIT, policyItem.getLimitGuard());
+ matchingAttributes.put(TIME_WINDOW, policyItem.getTimeWindowGuard());
+ matchingAttributes.put(TIME_UNITS, policyItem.getTimeUnitsGuard());
}
- matchingAttributes.put("guardActiveStart", policyItem.getGuardActiveStart());
- matchingAttributes.put("guardActiveEnd", policyItem.getGuardActiveEnd());
+ matchingAttributes.put(GUARD_ACTIVE_START, policyItem.getGuardActiveStart());
+ matchingAttributes.put(GUARD_ACTIVE_END, policyItem.getGuardActiveEnd());
logger.info("Prepared: " + matchingAttributes);
return matchingAttributes;
diff --git a/src/main/java/org/onap/clamp/clds/client/req/policy/PolicyClient.java b/src/main/java/org/onap/clamp/clds/client/req/policy/PolicyClient.java
index 610bd4c1d..9f25ba9fd 100644
--- a/src/main/java/org/onap/clamp/clds/client/req/policy/PolicyClient.java
+++ b/src/main/java/org/onap/clamp/clds/client/req/policy/PolicyClient.java
@@ -534,6 +534,7 @@ public class PolicyClient {
deletePolicyParameters.setPolicyName(prop.getCurrentPolicyScopeAndPolicyName());
}
logger.info("Policy Name in delete policy method - " + deletePolicyParameters.getPolicyName());
+ logger.info("Deleting policy from PDP...");
deletePolicyParameters.setPolicyComponent("PDP");
deletePolicyParameters.setDeleteCondition(DeletePolicyCondition.ALL);
deletePolicyParameters.setPdpGroup(refProp.getStringValue("policy.pdp.group"));