summaryrefslogtreecommitdiffstats
path: root/controlloop/common/policy-yaml/src
diff options
context:
space:
mode:
Diffstat (limited to 'controlloop/common/policy-yaml/src')
-rw-r--r--controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/compiler/ControlLoopCompiler.java4
-rw-r--r--controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/guard/compiler/ControlLoopGuardCompiler.java38
-rw-r--r--controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/ControlLoop.java9
-rw-r--r--controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/ControlLoopPolicy.java23
-rw-r--r--controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/FinalResult.java13
-rw-r--r--controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/OperationsAccumulateParams.java27
-rw-r--r--controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/Policy.java38
-rw-r--r--controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/PolicyResult.java8
-rw-r--r--controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/Target.java51
-rw-r--r--controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/builder/ControlLoopPolicyBuilder.java180
-rw-r--r--controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/builder/MessageLevel.java12
-rw-r--r--controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/builder/impl/ControlLoopPolicyBuilderImpl.java174
-rw-r--r--controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/guard/Constraint.java58
-rw-r--r--controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/guard/ControlLoopGuard.java27
-rw-r--r--controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/guard/Guard.java19
-rw-r--r--controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/guard/GuardPolicy.java20
-rw-r--r--controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/guard/MatchParameters.java35
-rw-r--r--controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/guard/builder/ControlLoopGuardBuilder.java51
-rw-r--r--controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/guard/builder/impl/ControlLoopGuardBuilderImpl.java32
-rw-r--r--controlloop/common/policy-yaml/src/test/java/org/onap/policy/controlloop/compiler/ControlLoopCompilerTest.java12
-rw-r--r--controlloop/common/policy-yaml/src/test/java/org/onap/policy/controlloop/compiler/ControlLoopGuardCompilerTest.java6
-rw-r--r--controlloop/common/policy-yaml/src/test/java/org/onap/policy/controlloop/policy/ControlLoopPolicyBuilderTest.java119
-rw-r--r--controlloop/common/policy-yaml/src/test/java/org/onap/policy/controlloop/policy/ControlLoopPolicyTest.java19
-rw-r--r--controlloop/common/policy-yaml/src/test/java/org/onap/policy/controlloop/policy/ControlLoopTest.java25
-rw-r--r--controlloop/common/policy-yaml/src/test/java/org/onap/policy/controlloop/policy/OperationsAccumulateParamsTest.java10
-rw-r--r--controlloop/common/policy-yaml/src/test/java/org/onap/policy/controlloop/policy/guard/ConstraintTest.java16
-rw-r--r--controlloop/common/policy-yaml/src/test/java/org/onap/policy/controlloop/policy/guard/ControlLoopGuardBuilderTest.java43
-rw-r--r--controlloop/common/policy-yaml/src/test/java/org/onap/policy/controlloop/policy/guard/ControlLoopGuardTest.java19
-rw-r--r--controlloop/common/policy-yaml/src/test/java/org/onap/policy/controlloop/policy/guard/GuardPolicyTest.java7
29 files changed, 678 insertions, 417 deletions
diff --git a/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/compiler/ControlLoopCompiler.java b/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/compiler/ControlLoopCompiler.java
index 27c9bf8cd..45ff1847b 100644
--- a/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/compiler/ControlLoopCompiler.java
+++ b/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/compiler/ControlLoopCompiler.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* policy-yaml
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 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.
@@ -101,7 +101,7 @@ public class ControlLoopCompiler implements Serializable {
&& callback != null) {
callback.onError("Missing controlLoopName");
}
- if ((!controlLoop.getVersion().contentEquals(ControlLoop.getVERSION())) && callback != null) {
+ if ((!controlLoop.getVersion().contentEquals(ControlLoop.getCompilerVersion())) && callback != null) {
callback.onError("Unsupported version for this compiler");
}
if (controlLoop.getTrigger_policy() == null || controlLoop.getTrigger_policy().length() < 1) {
diff --git a/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/guard/compiler/ControlLoopGuardCompiler.java b/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/guard/compiler/ControlLoopGuardCompiler.java
index 2897fde26..4cee39cb4 100644
--- a/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/guard/compiler/ControlLoopGuardCompiler.java
+++ b/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/guard/compiler/ControlLoopGuardCompiler.java
@@ -20,8 +20,8 @@
package org.onap.policy.controlloop.guard.compiler;
-
import java.io.InputStream;
+
import java.util.HashSet;
import java.util.List;
import java.util.Set;
@@ -43,24 +43,40 @@ public class ControlLoopGuardCompiler {
// Private Constructor
}
- public static ControlLoopGuard compile(ControlLoopGuard cLGuard,
+ /**
+ * Compile the control loop guard.
+ *
+ * @param clGuard the guard
+ * @param callback callback routine
+ * @return the guard object
+ * @throws CompilerException compilation exception
+ */
+ public static ControlLoopGuard compile(ControlLoopGuard clGuard,
ControlLoopCompilerCallback callback) throws CompilerException {
//
// Ensure ControlLoopGuard has at least one guard policies
//
- validateControlLoopGuard(cLGuard, callback);
+ validateControlLoopGuard(clGuard, callback);
//
// Ensure each guard policy has at least one constraints and all guard policies are unique
//
- validateGuardPolicies(cLGuard.getGuards(), callback);
+ validateGuardPolicies(clGuard.getGuards(), callback);
//
// Ensure constraints for each guard policy are unique
//
- validateConstraints(cLGuard.getGuards(), callback);
+ validateConstraints(clGuard.getGuards(), callback);
- return cLGuard;
+ return clGuard;
}
+ /**
+ * Compile the control loop guard.
+ *
+ * @param yamlSpecification yaml specification as a stream
+ * @param callback callback method
+ * @return guard object
+ * @throws CompilerException throws compile exception
+ */
public static ControlLoopGuard compile(InputStream yamlSpecification,
ControlLoopCompilerCallback callback) throws CompilerException {
Yaml yaml = new Yaml(new Constructor(ControlLoopGuard.class));
@@ -74,22 +90,22 @@ public class ControlLoopGuardCompiler {
return ControlLoopGuardCompiler.compile((ControlLoopGuard) obj, callback);
}
- private static void validateControlLoopGuard(ControlLoopGuard cLGuard,
+ private static void validateControlLoopGuard(ControlLoopGuard clGuard,
ControlLoopCompilerCallback callback) throws CompilerException {
- if (cLGuard == null) {
+ if (clGuard == null) {
if (callback != null) {
callback.onError("ControlLoop Guard cannot be null");
}
throw new CompilerException("ControlLoop Guard cannot be null");
}
- if (cLGuard.getGuard() == null && callback != null) {
+ if (clGuard.getGuard() == null && callback != null) {
callback.onError("Guard version cannot be null");
}
- if (cLGuard.getGuards() == null) {
+ if (clGuard.getGuards() == null) {
if (callback != null) {
callback.onError("ControlLoop Guard should have at least one guard policies");
}
- } else if (cLGuard.getGuards().isEmpty() && callback != null) {
+ } else if (clGuard.getGuards().isEmpty() && callback != null) {
callback.onError("ControlLoop Guard should have at least one guard policies");
}
}
diff --git a/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/ControlLoop.java b/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/ControlLoop.java
index fc835dd51..a8edf7a81 100644
--- a/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/ControlLoop.java
+++ b/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/ControlLoop.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* policy-yaml
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 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.
@@ -44,7 +44,7 @@ public class ControlLoop {
// Empty Constructor.
}
- public static String getVERSION() {
+ public static String getCompilerVersion() {
return ControlLoop.COMPILER_VERSION;
}
@@ -112,6 +112,11 @@ public class ControlLoop {
this.pnf = pnf;
}
+ /**
+ * Constructor.
+ *
+ * @param controlLoop copy object
+ */
public ControlLoop(ControlLoop controlLoop) {
this.controlLoopName = controlLoop.controlLoopName;
this.services = new LinkedList<>();
diff --git a/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/ControlLoopPolicy.java b/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/ControlLoopPolicy.java
index e0c5839b1..161fe1def 100644
--- a/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/ControlLoopPolicy.java
+++ b/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/ControlLoopPolicy.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* policy-yaml
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 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.
@@ -60,23 +60,30 @@ public class ControlLoopPolicy {
@Override
public boolean equals(Object obj) {
- if (this == obj)
+ if (this == obj) {
return true;
- if (obj == null)
+ }
+ if (obj == null) {
return false;
- if (getClass() != obj.getClass())
+ }
+ if (getClass() != obj.getClass()) {
return false;
+ }
ControlLoopPolicy other = (ControlLoopPolicy) obj;
if (controlLoop == null) {
- if (other.controlLoop != null)
+ if (other.controlLoop != null) {
return false;
- } else if (!controlLoop.equals(other.controlLoop))
+ }
+ } else if (!controlLoop.equals(other.controlLoop)) {
return false;
+ }
if (policies == null) {
- if (other.policies != null)
+ if (other.policies != null) {
return false;
- } else if (!policies.equals(other.policies))
+ }
+ } else if (!policies.equals(other.policies)) {
return false;
+ }
return true;
}
diff --git a/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/FinalResult.java b/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/FinalResult.java
index b9fdc2e6d..473b102e7 100644
--- a/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/FinalResult.java
+++ b/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/FinalResult.java
@@ -58,6 +58,12 @@ public enum FinalResult {
this.result = result;
}
+ /**
+ * Converts to a result object.
+ *
+ * @param result input string
+ * @return result object
+ */
public static FinalResult toResult(String result) {
if (result.equalsIgnoreCase(FINAL_SUCCESS.toString())) {
return FINAL_SUCCESS;
@@ -83,6 +89,13 @@ public enum FinalResult {
return null;
}
+ /**
+ * Check if the result really is a result.
+ *
+ * @param result string
+ * @param finalResult result object
+ * @return true if a result
+ */
public static boolean isResult(String result, FinalResult finalResult) {
FinalResult toResult = FinalResult.toResult(result);
if (toResult == null) {
diff --git a/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/OperationsAccumulateParams.java b/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/OperationsAccumulateParams.java
index 4d0f03a06..594c42023 100644
--- a/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/OperationsAccumulateParams.java
+++ b/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/OperationsAccumulateParams.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* policy-yaml
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 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.
@@ -24,9 +24,6 @@ import java.io.Serializable;
public class OperationsAccumulateParams implements Serializable {
- /**
- *
- */
private static final long serialVersionUID = -3597358159130168247L;
private String period;
@@ -75,25 +72,33 @@ public class OperationsAccumulateParams implements Serializable {
result = prime * result + ((limit == null) ? 0 : limit.hashCode());
return result;
}
+
@Override
public boolean equals(Object obj) {
- if (this == obj)
+ if (this == obj) {
return true;
- if (obj == null)
+ }
+ if (obj == null) {
return false;
- if (getClass() != obj.getClass())
+ }
+ if (getClass() != obj.getClass()) {
return false;
+ }
OperationsAccumulateParams other = (OperationsAccumulateParams) obj;
if (period == null) {
- if (other.period != null)
+ if (other.period != null) {
return false;
- } else if (!period.equals(other.period))
+ }
+ } else if (!period.equals(other.period)) {
return false;
+ }
if (limit == null) {
- if (other.limit != null)
+ if (other.limit != null) {
return false;
- } else if (!limit.equals(other.limit))
+ }
+ } else if (!limit.equals(other.limit)) {
return false;
+ }
return true;
}
diff --git a/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/Policy.java b/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/Policy.java
index 4e0a0c99b..8585b674b 100644
--- a/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/Policy.java
+++ b/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/Policy.java
@@ -180,6 +180,15 @@ public class Policy {
this.id = id;
}
+ /**
+ * Constructor.
+ *
+ * @param name name
+ * @param actor actor
+ * @param recipe recipe
+ * @param payload payload
+ * @param target target
+ */
public Policy(String name, String actor, String recipe, Map<String, String> payload, Target target) {
this.name = name;
this.actor = actor;
@@ -190,6 +199,17 @@ public class Policy {
}
}
+ /**
+ * Constructor.
+ *
+ * @param name name
+ * @param actor actor
+ * @param recipe recipe
+ * @param payload payload
+ * @param target target
+ * @param retries retries
+ * @param timeout timeout
+ */
public Policy(String name, String actor, String recipe, Map<String, String> payload, Target target,
Integer retries, Integer timeout) {
this(name, actor, recipe, payload, target);
@@ -197,6 +217,19 @@ public class Policy {
this.timeout = timeout;
}
+ /**
+ * Constructor.
+ *
+ * @param id id
+ * @param name name
+ * @param description description
+ * @param actor actor
+ * @param payload payload
+ * @param target target
+ * @param recipe recipe
+ * @param retries retries
+ * @param timeout timeout
+ */
public Policy(String id, String name, String description, String actor, Map<String, String> payload,
Target target, String recipe, Integer retries, Integer timeout) {
this(name, actor, recipe, payload, target, retries, timeout);
@@ -204,6 +237,11 @@ public class Policy {
this.description = description;
}
+ /**
+ * Constructor.
+ *
+ * @param policy copy object
+ */
public Policy(Policy policy) {
this.id = policy.id;
this.name = policy.name;
diff --git a/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/PolicyResult.java b/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/PolicyResult.java
index 574e14225..d9e1557d4 100644
--- a/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/PolicyResult.java
+++ b/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/PolicyResult.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* policy-yaml
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 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.
@@ -58,6 +58,12 @@ public enum PolicyResult {
return this.result;
}
+ /**
+ * Convert to a result.
+ *
+ * @param result result string
+ * @return Result object
+ */
public static PolicyResult toResult(String result) {
if (result.equalsIgnoreCase(SUCCESS.toString())) {
return SUCCESS;
diff --git a/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/Target.java b/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/Target.java
index bc5b934b2..61d1ae285 100644
--- a/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/Target.java
+++ b/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/Target.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* policy-yaml
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 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.
@@ -24,12 +24,9 @@ import java.io.Serializable;
public class Target implements Serializable {
- /**
- *
- */
private static final long serialVersionUID = 2180988443264988319L;
- private String resourceID;
+ private String resourceId;
private TargetType type;
public Target() {
@@ -37,11 +34,11 @@ public class Target implements Serializable {
}
public String getResourceID() {
- return resourceID;
+ return resourceId;
}
- public void setResourceID(String resourceID) {
- this.resourceID = resourceID;
+ public void setResourceID(String resourceId) {
+ this.resourceId = resourceId;
}
public TargetType getType() {
@@ -56,23 +53,23 @@ public class Target implements Serializable {
this.type = type;
}
- public Target(String resourceID) {
- this.resourceID = resourceID;
+ public Target(String resourceId) {
+ this.resourceId = resourceId;
}
- public Target(TargetType type, String resourceID) {
+ public Target(TargetType type, String resourceId) {
this.type = type;
- this.resourceID = resourceID;
+ this.resourceId = resourceId;
}
public Target(Target target) {
this.type = target.type;
- this.resourceID = target.resourceID;
+ this.resourceId = target.resourceId;
}
@Override
public String toString() {
- return "Target [type=" + type + ", resourceID=" + resourceID + "]";
+ return "Target [type=" + type + ", resourceId=" + resourceId + "]";
}
@Override
@@ -80,28 +77,36 @@ public class Target implements Serializable {
final int prime = 31;
int result = 1;
result = prime * result + ((type == null) ? 0 : type.hashCode());
- result = prime * result + ((resourceID == null) ? 0 : resourceID.hashCode());
+ result = prime * result + ((resourceId == null) ? 0 : resourceId.hashCode());
return result;
}
+
@Override
public boolean equals(Object obj) {
- if (this == obj)
+ if (this == obj) {
return true;
- if (obj == null)
+ }
+ if (obj == null) {
return false;
- if (getClass() != obj.getClass())
+ }
+ if (getClass() != obj.getClass()) {
return false;
+ }
Target other = (Target) obj;
if (type == null) {
- if (other.type != null)
+ if (other.type != null) {
return false;
- } else if (!type.equals(other.type))
+ }
+ } else if (!type.equals(other.type)) {
return false;
- if (resourceID == null) {
- if (other.resourceID != null)
+ }
+ if (resourceId == null) {
+ if (other.resourceId != null) {
return false;
- } else if (!resourceID.equals(other.resourceID))
+ }
+ } else if (!resourceId.equals(other.resourceId)) {
return false;
+ }
return true;
}
}
diff --git a/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/builder/ControlLoopPolicyBuilder.java b/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/builder/ControlLoopPolicyBuilder.java
index 4e034cb0e..9d00793b9 100644
--- a/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/builder/ControlLoopPolicyBuilder.java
+++ b/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/builder/ControlLoopPolicyBuilder.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* policy-yaml
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 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.
@@ -35,68 +35,79 @@ import org.onap.policy.sdc.Service;
public interface ControlLoopPolicyBuilder {
/**
- * Adds one or more services to the ControlLoop
+ * Adds one or more services to the ControlLoop.
*
- *
- * @param service
- * @return
- * @throws BuilderException
+ * @param services service to add
+ * @return builder object
+ * @throws BuilderException builder exception
*/
public ControlLoopPolicyBuilder addService(Service... services) throws BuilderException;
/**
- * @param services
- * @return
- * @throws BuilderException
+ * Remove service.
+ *
+ * @param services to remove
+ * @return builder object
+ * @throws BuilderException builder exception
*/
public ControlLoopPolicyBuilder removeService(Service... services) throws BuilderException;
/**
- * @return
- * @throws BuilderException
+ * Remove all the services.
+ *
+ * @return builder object
+ * @throws BuilderException builder exception
*/
public ControlLoopPolicyBuilder removeAllServices() throws BuilderException;
/**
- * Adds one or more resources to the ControlLoop
- *
+ * Adds one or more resources to the ControlLoop.
*
- * @param resource
- * @return
- * @throws BuilderException
+ * @return builder object
+ * @throws BuilderException builder exception
*/
public ControlLoopPolicyBuilder addResource(Resource... resources) throws BuilderException;
/**
- * @param resources
- * @return
- * @throws BuilderException
+ * Remove the resources.
+ *
+ * @param resources resources to be removed
+ * @return object
+ * @throws BuilderException builder exception
*/
public ControlLoopPolicyBuilder removeResource(Resource... resources) throws BuilderException;
/**
- * @return
- * @throws BuilderException
+ * Remove all resources.
+ *
+ * @return object
+ * @throws BuilderException builder exception
*/
public ControlLoopPolicyBuilder removeAllResources() throws BuilderException;
/**
- * @param pnf
- * @return
- * @throws BuilderException
+ * Set the PNF.
+ *
+ * @param pnf input pnf
+ * @return builder object
+ * @throws BuilderException builder exception
*/
public ControlLoopPolicyBuilder setPNF(Pnf pnf) throws BuilderException;
/**
- * @return
- * @throws BuilderException
+ * Remove PNF.
+ *
+ * @return the object
+ * @throws BuilderException builder exception
*/
public ControlLoopPolicyBuilder removePNF() throws BuilderException;
/**
- * @param abatement
- * @return
- * @throws BuilderException
+ * Set the abatement.
+ *
+ * @param abatement whether abatement is possible
+ * @return object
+ * @throws BuilderException builder exception
*/
public ControlLoopPolicyBuilder setAbatement(Boolean abatement) throws BuilderException;
@@ -105,9 +116,9 @@ public interface ControlLoopPolicyBuilder {
* Sets the overall timeout value for the Control Loop. If any operational policies have retries
* and timeouts, then this overall timeout value should exceed all those values.
*
- * @param timeout
- * @return
- * @throws BuilderException
+ * @param timeout timeout value
+ * @return control loop policy builder
+ * @throws BuilderException builder exception
*/
public ControlLoopPolicyBuilder setTimeout(Integer timeout) throws BuilderException;
@@ -124,38 +135,40 @@ public interface ControlLoopPolicyBuilder {
* Platform.
*
*
- * @param name
- * @param description
- * @param actor
- * @param target
- * @param recipe
- * @param retries
- * @param timeout
- * @return Policy
- * @throws BuilderException
+ * @param name name
+ * @param description description
+ * @param actor actor
+ * @param target target
+ * @param recipe recipe
+ * @param retries retries
+ * @param timeout timeout
+ * @return Policy object
+ * @throws BuilderException builder exception
*/
public Policy setTriggerPolicy(String name, String description, String actor, Target target, String recipe,
Map<String, String> payload, Integer retries, Integer timeout) throws BuilderException;
/**
- *
* Changes the trigger policy to point to another existing Policy.
*
- *
- * @param id
- * @return ControlLoop
- * @throws BuilderException
+ * @param id the id
+ * @return ControlLoop object
+ * @throws BuilderException build exception
*/
public ControlLoop setTriggerPolicy(String id) throws BuilderException;
/**
- * @return
+ * Is an open loop.
+ *
+ * @return true or false
*/
public boolean isOpenLoop();
/**
- * @return
- * @throws BuilderException
+ * Get the trigger policy.
+ *
+ * @return the policy object
+ * @throws BuilderException if there is a builder exception
*/
public Policy getTriggerPolicy() throws BuilderException;
@@ -170,35 +183,33 @@ public interface ControlLoopPolicyBuilder {
/**
* Creates a policy that is chained to the result of another Policy.
*
- *
- * @param name
- * @param description
- * @param actor
- * @param target
- * @param recipe
- * @param retries
- * @param timeout
- * @param policyID
- * @param results
- * @return
- * @throws BuilderException
+ * @param name name
+ * @param description description
+ * @param actor actor
+ * @param target target
+ * @param recipe recipe
+ * @param retries retries
+ * @param timeout timeout
+ * @param policyId id
+ * @param results results
+ * @return Policy that was set
+ * @throws BuilderException builder exception
*/
public Policy setPolicyForPolicyResult(String name, String description, String actor, Target target, String recipe,
- Map<String, String> payload, Integer retries, Integer timeout, String policyID, PolicyResult... results)
+ Map<String, String> payload, Integer retries, Integer timeout, String policyId, PolicyResult... results)
throws BuilderException;
/**
* Sets the policy result(s) to an existing Operational Policy.
*
- *
- * @param policyResultID
- * @param policyID
- * @param results
- * @return
- * @throws BuilderException
+ * @param policyResultId result ID
+ * @param policyId id
+ * @param results results
+ * @return Policy that was set
+ * @throws BuilderException builder exception
*/
- public Policy setPolicyForPolicyResult(String policyResultID, String policyID, PolicyResult... results)
+ public Policy setPolicyForPolicyResult(String policyResultId, String policyId, PolicyResult... results)
throws BuilderException;
/**
@@ -207,17 +218,16 @@ public interface ControlLoopPolicyBuilder {
* their result reset to the appropriate default FINAL_* result.
*
*
- * @param policyID
- * @return
- * @throws BuilderException
+ * @param policyID id for the policy
+ * @return true if removed else false
+ * @throws BuilderException builder exception
*/
public boolean removePolicy(String policyID) throws BuilderException;
/**
* Resets a policy's results to defualt FINAL_* codes.
*
- *
- * @return Policy
+ * @return Policy object
* @throws BuilderException - Policy does not exist
*/
public Policy resetPolicyResults(String policyID) throws BuilderException;
@@ -230,7 +240,7 @@ public interface ControlLoopPolicyBuilder {
public ControlLoopPolicyBuilder removeAllPolicies();
/**
- * Adds an operationsAccumulateParams to an existing operational policy
+ * Adds an operationsAccumulateParams to an existing operational policy.
*
* @return Policy
* @throws BuilderException - Policy does not exist
@@ -280,7 +290,7 @@ public interface ControlLoopPolicyBuilder {
* @param services - Zero or more services associated with this resource. Should come from
* ASDC, but if not available use serviceName to distinguish.
* @return ControlLoopPolicyBuilder object
- * @throws BuilderException
+ * @throws BuilderException builder exception
*/
public static ControlLoopPolicyBuilder buildControlLoop(String controlLoopName, Integer timeout,
Resource resource, Service... services) throws BuilderException {
@@ -288,12 +298,14 @@ public interface ControlLoopPolicyBuilder {
}
/**
- * @param controlLoopName
- * @param timeout
- * @param service
- * @param resources
- * @return
- * @throws BuilderException
+ * Build the control loop.
+ *
+ * @param controlLoopName control loop id
+ * @param timeout timeout
+ * @param service service
+ * @param resources resources
+ * @return builder object
+ * @throws BuilderException builder exception
*/
public static ControlLoopPolicyBuilder buildControlLoop(String controlLoopName, Integer timeout,
Service service, Resource... resources) throws BuilderException {
@@ -301,12 +313,14 @@ public interface ControlLoopPolicyBuilder {
}
/**
+ * Build control loop.
+ *
* @param controlLoopName - Per Closed Loop AID v1.0, unique string for the closed loop.
* @param timeout - Overall timeout for the Closed Loop to execute.
* @param pnf - Physical Network Function. Should come from AIC, but if not available use
* well-known name to distinguish. Eg. eNodeB
* @return ControlLoopPolicyBuilder object
- * @throws BuilderException
+ * @throws BuilderException builder exception
*/
public static ControlLoopPolicyBuilder buildControlLoop(String controlLoopName, Integer timeout, Pnf pnf)
throws BuilderException {
diff --git a/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/builder/MessageLevel.java b/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/builder/MessageLevel.java
index ffd63d691..bfe6fc080 100644
--- a/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/builder/MessageLevel.java
+++ b/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/builder/MessageLevel.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* policy-yaml
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 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.
@@ -21,10 +21,8 @@
package org.onap.policy.controlloop.policy.builder;
public enum MessageLevel {
- INFO,
- WARNING,
- ERROR,
- EXCEPTION
- ;
-
+ INFO,
+ WARNING,
+ ERROR,
+ EXCEPTION;
}
diff --git a/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/builder/impl/ControlLoopPolicyBuilderImpl.java b/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/builder/impl/ControlLoopPolicyBuilderImpl.java
index adbf12748..ba434356a 100644
--- a/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/builder/impl/ControlLoopPolicyBuilderImpl.java
+++ b/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/builder/impl/ControlLoopPolicyBuilderImpl.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* policy-yaml
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 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.
@@ -54,6 +54,12 @@ public class ControlLoopPolicyBuilderImpl implements ControlLoopPolicyBuilder {
private static Logger logger = LoggerFactory.getLogger(ControlLoopPolicyBuilderImpl.class.getName());
private ControlLoopPolicy controlLoopPolicy;
+ /**
+ * Constructor.
+ *
+ * @param controlLoopName control loop id
+ * @param timeout timeout value
+ */
public ControlLoopPolicyBuilderImpl(String controlLoopName, Integer timeout) {
controlLoopPolicy = new ControlLoopPolicy();
ControlLoop controlLoop = new ControlLoop();
@@ -62,6 +68,15 @@ public class ControlLoopPolicyBuilderImpl implements ControlLoopPolicyBuilder {
controlLoopPolicy.setControlLoop(controlLoop);
}
+ /**
+ * Constructor.
+ *
+ * @param controlLoopName control loop id
+ * @param timeout timeout value
+ * @param resource resource
+ * @param services services
+ * @throws BuilderException builder exception
+ */
public ControlLoopPolicyBuilderImpl(String controlLoopName, Integer timeout, Resource resource, Service... services)
throws BuilderException {
this(controlLoopName, timeout);
@@ -74,6 +89,15 @@ public class ControlLoopPolicyBuilderImpl implements ControlLoopPolicyBuilder {
this.setPNF(pnf);
}
+ /**
+ * Constructor.
+ *
+ * @param controlLoopName control loop id
+ * @param timeout timeout
+ * @param service service
+ * @param resources resources
+ * @throws BuilderException builder exception
+ */
public ControlLoopPolicyBuilderImpl(String controlLoopName, Integer timeout, Service service, Resource[] resources)
throws BuilderException {
this(controlLoopName, timeout);
@@ -137,7 +161,7 @@ public class ControlLoopPolicyBuilderImpl implements ControlLoopPolicyBuilder {
if (resource == null) {
throw new BuilderException("Resource must not be null");
}
- if (resource.getResourceUUID() == null && Strings.isNullOrEmpty(resource.getResourceName())) {
+ if (resource.getResourceUuid() == null && Strings.isNullOrEmpty(resource.getResourceName())) {
throw new BuilderException("Invalid resource - need either resourceUUID or resourceName");
}
if (controlLoopPolicy.getControlLoop().getResources() == null) {
@@ -192,15 +216,29 @@ public class ControlLoopPolicyBuilderImpl implements ControlLoopPolicyBuilder {
}
@Override
+ public ControlLoop setTriggerPolicy(String id) throws BuilderException {
+ if (id == null) {
+ throw new BuilderException("Id must not be null");
+ }
+ Policy trigger = this.findPolicy(id);
+ if (trigger == null) {
+ throw new BuilderException(UNKNOWN_POLICY + id);
+ } else {
+ this.controlLoopPolicy.getControlLoop().setTrigger_policy(id);
+ }
+ return new ControlLoop(this.controlLoopPolicy.getControlLoop());
+ }
+
+ @Override
public Policy setPolicyForPolicyResult(String name, String description, String actor, Target target, String recipe,
- Map<String, String> payload, Integer retries, Integer timeout, String policyID, PolicyResult... results)
+ Map<String, String> payload, Integer retries, Integer timeout, String policyId, PolicyResult... results)
throws BuilderException {
//
// Find the existing policy
//
- Policy existingPolicy = this.findPolicy(policyID);
+ Policy existingPolicy = this.findPolicy(policyId);
if (existingPolicy == null) {
- throw new BuilderException(UNKNOWN_POLICY + policyID);
+ throw new BuilderException(UNKNOWN_POLICY + policyId);
}
//
// Create the new Policy
@@ -244,6 +282,49 @@ public class ControlLoopPolicyBuilderImpl implements ControlLoopPolicyBuilder {
return new Policy(newPolicy);
}
+ @Override
+ public Policy setPolicyForPolicyResult(String policyResultId, String policyId, PolicyResult... results)
+ throws BuilderException {
+ //
+ // Find the existing policy
+ //
+ Policy existingPolicy = this.findPolicy(policyId);
+ if (existingPolicy == null) {
+ throw new BuilderException(policyId + " does not exist");
+ }
+ if (this.findPolicy(policyResultId) == null) {
+ throw new BuilderException("Operational policy " + policyResultId + " does not exist");
+ }
+ //
+ // Connect the results
+ //
+ for (PolicyResult result : results) {
+ switch (result) {
+ case FAILURE:
+ existingPolicy.setFailure(policyResultId);
+ break;
+ case FAILURE_EXCEPTION:
+ existingPolicy.setFailure_exception(policyResultId);
+ break;
+ case FAILURE_RETRIES:
+ existingPolicy.setFailure_retries(policyResultId);
+ break;
+ case FAILURE_TIMEOUT:
+ existingPolicy.setFailure_timeout(policyResultId);
+ break;
+ case FAILURE_GUARD:
+ existingPolicy.setFailure_guard(policyResultId);
+ break;
+ case SUCCESS:
+ existingPolicy.setSuccess(policyResultId);
+ break;
+ default:
+ throw new BuilderException("Invalid PolicyResult " + result);
+ }
+ }
+ return new Policy(this.findPolicy(policyResultId));
+ }
+
private class BuilderCompilerCallback implements ControlLoopCompilerCallback {
private ResultsImpl results = new ResultsImpl();
@@ -318,7 +399,7 @@ public class ControlLoopPolicyBuilderImpl implements ControlLoopPolicyBuilder {
if (resource == null) {
throw new BuilderException("Resource must not be null");
}
- if (resource.getResourceUUID() == null && Strings.isNullOrEmpty(resource.getResourceName())) {
+ if (resource.getResourceUuid() == null && Strings.isNullOrEmpty(resource.getResourceName())) {
throw new BuilderException("Invalid resource - need either a resourceUUID or resourceName");
}
boolean removed = controlLoopPolicy.getControlLoop().getResources().remove(resource);
@@ -345,20 +426,6 @@ public class ControlLoopPolicyBuilderImpl implements ControlLoopPolicyBuilder {
}
@Override
- public ControlLoop setTriggerPolicy(String id) throws BuilderException {
- if (id == null) {
- throw new BuilderException("Id must not be null");
- }
- Policy trigger = this.findPolicy(id);
- if (trigger == null) {
- throw new BuilderException(UNKNOWN_POLICY + id);
- } else {
- this.controlLoopPolicy.getControlLoop().setTrigger_policy(id);
- }
- return new ControlLoop(this.controlLoopPolicy.getControlLoop());
- }
-
- @Override
public boolean isOpenLoop() {
return this.controlLoopPolicy.getControlLoop().getTrigger_policy()
.equals(FinalResult.FINAL_OPENLOOP.toString());
@@ -379,61 +446,18 @@ public class ControlLoopPolicyBuilderImpl implements ControlLoopPolicyBuilder {
}
@Override
- public Policy setPolicyForPolicyResult(String policyResultID, String policyID, PolicyResult... results)
- throws BuilderException {
- //
- // Find the existing policy
- //
- Policy existingPolicy = this.findPolicy(policyID);
- if (existingPolicy == null) {
- throw new BuilderException(policyID + " does not exist");
- }
- if (this.findPolicy(policyResultID) == null) {
- throw new BuilderException("Operational policy " + policyResultID + " does not exist");
- }
- //
- // Connect the results
- //
- for (PolicyResult result : results) {
- switch (result) {
- case FAILURE:
- existingPolicy.setFailure(policyResultID);
- break;
- case FAILURE_EXCEPTION:
- existingPolicy.setFailure_exception(policyResultID);
- break;
- case FAILURE_RETRIES:
- existingPolicy.setFailure_retries(policyResultID);
- break;
- case FAILURE_TIMEOUT:
- existingPolicy.setFailure_timeout(policyResultID);
- break;
- case FAILURE_GUARD:
- existingPolicy.setFailure_guard(policyResultID);
- break;
- case SUCCESS:
- existingPolicy.setSuccess(policyResultID);
- break;
- default:
- throw new BuilderException("Invalid PolicyResult " + result);
- }
- }
- return new Policy(this.findPolicy(policyResultID));
- }
-
- @Override
- public boolean removePolicy(String policyID) throws BuilderException {
- Policy existingPolicy = this.findPolicy(policyID);
+ public boolean removePolicy(String policyId) throws BuilderException {
+ Policy existingPolicy = this.findPolicy(policyId);
if (existingPolicy == null) {
- throw new BuilderException(UNKNOWN_POLICY + policyID);
+ throw new BuilderException(UNKNOWN_POLICY + policyId);
}
//
// Check if the policy to remove is trigger_policy
//
- if (this.controlLoopPolicy.getControlLoop().getTrigger_policy().equals(policyID)) {
+ if (this.controlLoopPolicy.getControlLoop().getTrigger_policy().equals(policyId)) {
this.controlLoopPolicy.getControlLoop().setTrigger_policy(FinalResult.FINAL_OPENLOOP.toString());
} else {
- updateChainedPoliciesForPolicyRemoval(policyID);
+ updateChainedPoliciesForPolicyRemoval(policyId);
}
//
// remove the policy
@@ -443,7 +467,7 @@ public class ControlLoopPolicyBuilderImpl implements ControlLoopPolicyBuilder {
private void updateChainedPoliciesForPolicyRemoval(String idOfPolicyBeingRemoved) {
for (Policy policy : this.controlLoopPolicy.getPolicies()) {
- int index = this.controlLoopPolicy.getPolicies().indexOf(policy);
+ final int index = this.controlLoopPolicy.getPolicies().indexOf(policy);
if (policy.getSuccess().equals(idOfPolicyBeingRemoved)) {
policy.setSuccess(FinalResult.FINAL_SUCCESS.toString());
}
@@ -467,10 +491,10 @@ public class ControlLoopPolicyBuilderImpl implements ControlLoopPolicyBuilder {
}
@Override
- public Policy resetPolicyResults(String policyID) throws BuilderException {
- Policy existingPolicy = this.findPolicy(policyID);
+ public Policy resetPolicyResults(String policyId) throws BuilderException {
+ Policy existingPolicy = this.findPolicy(policyId);
if (existingPolicy == null) {
- throw new BuilderException(UNKNOWN_POLICY + policyID);
+ throw new BuilderException(UNKNOWN_POLICY + policyId);
}
//
// reset policy results
@@ -498,11 +522,11 @@ public class ControlLoopPolicyBuilderImpl implements ControlLoopPolicyBuilder {
}
@Override
- public Policy addOperationsAccumulateParams(String policyID, OperationsAccumulateParams operationsAccumulateParams)
+ public Policy addOperationsAccumulateParams(String policyId, OperationsAccumulateParams operationsAccumulateParams)
throws BuilderException {
- Policy existingPolicy = this.findPolicy(policyID);
+ Policy existingPolicy = this.findPolicy(policyId);
if (existingPolicy == null) {
- throw new BuilderException(UNKNOWN_POLICY + policyID);
+ throw new BuilderException(UNKNOWN_POLICY + policyId);
}
//
// Add operationsAccumulateParams to existingPolicy
diff --git a/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/guard/Constraint.java b/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/guard/Constraint.java
index e53f3e40f..6931de430 100644
--- a/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/guard/Constraint.java
+++ b/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/guard/Constraint.java
@@ -75,9 +75,15 @@ public class Constraint {
this.blacklist = blacklist;
}
+ /**
+ * Constructor.
+ *
+ * @param freqLimitPerTarget frequency limit
+ * @param timeWindow time window
+ */
public Constraint(Integer freqLimitPerTarget, Map<String, String> timeWindow) {
this.freqLimitPerTarget = freqLimitPerTarget;
- if(timeWindow!=null){
+ if (timeWindow != null) {
this.timeWindow = Collections.unmodifiableMap(timeWindow);
}
}
@@ -86,12 +92,26 @@ public class Constraint {
this.blacklist = new LinkedList<>(blacklist);
}
+ /**
+ * Constructor.
+ *
+ * @param freqLimitPerTarget frequency limit
+ * @param timeWindow time window
+ * @param blacklist blacklist
+ */
public Constraint(Integer freqLimitPerTarget, Map<String, String> timeWindow, List<String> blacklist) {
this.freqLimitPerTarget = freqLimitPerTarget;
this.timeWindow = Collections.unmodifiableMap(timeWindow);
this.blacklist = new LinkedList<>(blacklist);
}
+ /**
+ * Constructor.
+ *
+ * @param freqLimitPerTarget frequency limit
+ * @param timeWindow time window
+ * @param activeTimeRange active time range
+ */
public Constraint(Integer freqLimitPerTarget, Map<String, String> timeWindow, Map<String, String> activeTimeRange) {
this(freqLimitPerTarget, timeWindow);
if (activeTimeRange != null) {
@@ -99,17 +119,30 @@ public class Constraint {
}
}
+ /**
+ * Constructor.
+ *
+ * @param freqLimitPerTarget frequency limit
+ * @param timeWindow the time window
+ * @param activeTimeRange active time range
+ * @param blacklist incoming blacklist
+ */
public Constraint(Integer freqLimitPerTarget, Map<String, String> timeWindow, Map<String, String> activeTimeRange,
List<String> blacklist) {
this(freqLimitPerTarget, timeWindow);
if (activeTimeRange != null) {
this.activeTimeRange = Collections.unmodifiableMap(activeTimeRange);
}
- if(blacklist != null){
+ if (blacklist != null) {
this.blacklist = new LinkedList<>(blacklist);
}
}
+ /**
+ * Constructor.
+ *
+ * @param constraint objec to copy
+ */
public Constraint(Constraint constraint) {
this.freqLimitPerTarget = constraint.freqLimitPerTarget;
this.timeWindow = constraint.timeWindow;
@@ -143,23 +176,26 @@ public class Constraint {
@Override
public boolean equals(Object obj) {
- if (this == obj)
+ if (this == obj) {
return true;
- if (obj == null)
+ }
+ if (obj == null) {
return false;
- if (getClass() != obj.getClass())
+ }
+ if (getClass() != obj.getClass()) {
return false;
+ }
Constraint other = (Constraint) obj;
return equalsMayBeNull(freqLimitPerTarget, other.freqLimitPerTarget)
- && equalsMayBeNull(timeWindow, other.timeWindow)
- && equalsMayBeNull(activeTimeRange, other.activeTimeRange)
- && equalsMayBeNull(blacklist, other.blacklist);
+ && equalsMayBeNull(timeWindow, other.timeWindow)
+ && equalsMayBeNull(activeTimeRange, other.activeTimeRange)
+ && equalsMayBeNull(blacklist, other.blacklist);
}
- private boolean equalsMayBeNull(final Object obj1, final Object obj2){
- if ( obj1 == null ) {
+ private boolean equalsMayBeNull(final Object obj1, final Object obj2) {
+ if (obj1 == null) {
return obj2 == null;
}
- return obj1.equals(obj2);
+ return obj1.equals(obj2);
}
}
diff --git a/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/guard/ControlLoopGuard.java b/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/guard/ControlLoopGuard.java
index 6fb0ca9f0..66ac3e612 100644
--- a/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/guard/ControlLoopGuard.java
+++ b/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/guard/ControlLoopGuard.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* policy-yaml
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 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.
@@ -48,9 +48,9 @@ public class ControlLoopGuard {
this.guards = guards;
}
- public ControlLoopGuard(ControlLoopGuard cLGuard) {
+ public ControlLoopGuard(ControlLoopGuard clGuard) {
this.guard = new Guard();
- this.guards = new LinkedList<>(cLGuard.guards);
+ this.guards = new LinkedList<>(clGuard.guards);
}
@Override
@@ -69,23 +69,30 @@ public class ControlLoopGuard {
@Override
public boolean equals(Object obj) {
- if (this == obj)
+ if (this == obj) {
return true;
- if (obj == null)
+ }
+ if (obj == null) {
return false;
- if (getClass() != obj.getClass())
+ }
+ if (getClass() != obj.getClass()) {
return false;
+ }
ControlLoopGuard other = (ControlLoopGuard) obj;
if (guard == null) {
- if (other.guard != null)
+ if (other.guard != null) {
return false;
- } else if (!guard.equals(other.guard))
+ }
+ } else if (!guard.equals(other.guard)) {
return false;
+ }
if (guards == null) {
- if (other.guards != null)
+ if (other.guards != null) {
return false;
- } else if (!guards.equals(other.guards))
+ }
+ } else if (!guards.equals(other.guards)) {
return false;
+ }
return true;
}
diff --git a/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/guard/Guard.java b/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/guard/Guard.java
index 291004611..dcce13597 100644
--- a/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/guard/Guard.java
+++ b/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/guard/Guard.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* policy-yaml
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 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.
@@ -42,6 +42,7 @@ public class Guard {
public String toString() {
return "Guard [version=" + version + "]";
}
+
@Override
public int hashCode() {
final int prime = 31;
@@ -49,20 +50,26 @@ public class Guard {
result = prime * result + ((version == null) ? 0 : version.hashCode());
return result;
}
+
@Override
public boolean equals(Object obj) {
- if (this == obj)
+ if (this == obj) {
return true;
- if (obj == null)
+ }
+ if (obj == null) {
return false;
- if (getClass() != obj.getClass())
+ }
+ if (getClass() != obj.getClass()) {
return false;
+ }
Guard other = (Guard) obj;
if (version == null) {
- if (other.version != null)
+ if (other.version != null) {
return false;
- } else if (!version.equals(other.version))
+ }
+ } else if (!version.equals(other.version)) {
return false;
+ }
return true;
}
}
diff --git a/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/guard/GuardPolicy.java b/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/guard/GuardPolicy.java
index 759a0533d..799c5fcd7 100644
--- a/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/guard/GuardPolicy.java
+++ b/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/guard/GuardPolicy.java
@@ -85,12 +85,27 @@ public class GuardPolicy {
this.matchParameters = matchParameters;
}
+ /**
+ * Constructor.
+ *
+ * @param id id
+ * @param name name
+ * @param description description
+ * @param matchParameters match parameters
+ */
public GuardPolicy(String id, String name, String description, MatchParameters matchParameters) {
this(name, matchParameters);
this.id = id;
this.description = description;
}
+ /**
+ * Constructor.
+ *
+ * @param name name
+ * @param matchParameters match parameters
+ * @param limitConstraints limit constraints
+ */
public GuardPolicy(String name, MatchParameters matchParameters, List<Constraint> limitConstraints) {
this(name, matchParameters);
if (limitConstraints != null) {
@@ -110,6 +125,11 @@ public class GuardPolicy {
this.id = id;
}
+ /**
+ * Constructor.
+ *
+ * @param policy copy object
+ */
public GuardPolicy(GuardPolicy policy) {
this.id = policy.id;
this.name = policy.name;
diff --git a/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/guard/MatchParameters.java b/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/guard/MatchParameters.java
index 445e00f38..1bf10734d 100644
--- a/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/guard/MatchParameters.java
+++ b/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/guard/MatchParameters.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* policy-yaml
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 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.
@@ -71,6 +71,13 @@ public class MatchParameters {
this.recipe = recipe;
}
+ /**
+ * Constructor.
+ *
+ * @param actor actor
+ * @param recipe recipe
+ * @param targets targets
+ */
public MatchParameters(String actor, String recipe, List<String> targets) {
this(actor, recipe);
if (targets != null) {
@@ -83,6 +90,11 @@ public class MatchParameters {
this.controlLoopName = controlLoopName;
}
+ /**
+ * Constructor.
+ *
+ * @param matchParameters match parameters
+ */
public MatchParameters(MatchParameters matchParameters) {
this.controlLoopName = matchParameters.controlLoopName;
@@ -112,24 +124,27 @@ public class MatchParameters {
@Override
public boolean equals(Object obj) {
- if (this == obj)
+ if (this == obj) {
return true;
- if (obj == null)
+ }
+ if (obj == null) {
return false;
- if (getClass() != obj.getClass())
+ }
+ if (getClass() != obj.getClass()) {
return false;
+ }
MatchParameters other = (MatchParameters) obj;
return equalsMayBeNull(actor, other.actor)
- && equalsMayBeNull(controlLoopName, other.controlLoopName)
- && equalsMayBeNull(recipe, other.recipe)
- && equalsMayBeNull(targets, other.targets);
+ && equalsMayBeNull(controlLoopName, other.controlLoopName)
+ && equalsMayBeNull(recipe, other.recipe)
+ && equalsMayBeNull(targets, other.targets);
}
- private boolean equalsMayBeNull(final Object obj1, final Object obj2){
- if ( obj1 == null ) {
+ private boolean equalsMayBeNull(final Object obj1, final Object obj2) {
+ if (obj1 == null) {
return obj2 == null;
}
- return obj1.equals(obj2);
+ return obj1.equals(obj2);
}
}
diff --git a/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/guard/builder/ControlLoopGuardBuilder.java b/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/guard/builder/ControlLoopGuardBuilder.java
index 77651dcbf..850b487a7 100644
--- a/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/guard/builder/ControlLoopGuardBuilder.java
+++ b/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/guard/builder/ControlLoopGuardBuilder.java
@@ -31,64 +31,57 @@ import org.onap.policy.controlloop.policy.guard.builder.impl.ControlLoopGuardBui
public interface ControlLoopGuardBuilder {
/**
- * Adds one or more guard policies to the Control Loop Guard
+ * Adds one or more guard policies to the Control Loop Guard.
*
- *
- * @param policies
- * @return
- * @throws BuilderException
+ * @param policies policies to add
+ * @return builder object
+ * @throws BuilderException builder exception
*/
public ControlLoopGuardBuilder addGuardPolicy(GuardPolicy... policies) throws BuilderException;
/**
- * Removes one or more guard policies from the Control Loop Guard
- *
+ * Removes one or more guard policies from the Control Loop Guard.
*
- * @param policies
- * @return
- * @throws BuilderException
+ * @param policies policies to add
+ * @return builder object
+ * @throws BuilderException builder exception
*/
public ControlLoopGuardBuilder removeGuardPolicy(GuardPolicy... policies) throws BuilderException;
/**
- * Removes all guard policies from the Control Loop Guard
- *
+ * Removes all guard policies from the Control Loop Guard.
*
- * @param
- * @return
- * @throws BuilderException
+ * @return builder object
+ * @throws BuilderException builder exception
*/
public ControlLoopGuardBuilder removeAllGuardPolicies() throws BuilderException;
/**
- * Adds one or more time limit constraints to the guard policy
- *
+ * Adds one or more time limit constraints to the guard policy.
*
* @param id (guard policy id)
- * @param constraints
- * @return
- * @throws BuilderException
+ * @param constraints the constraints to add
+ * @return builder object
+ * @throws BuilderException builder exception
*/
public ControlLoopGuardBuilder addLimitConstraint(String id, Constraint... constraints) throws BuilderException;
/**
- * Removes one or more time limit constraints from the guard policy
- *
+ * Removes one or more time limit constraints from the guard policy.
*
* @param id (guard policy id)
- * @param constraints
- * @return
- * @throws BuilderException
+ * @param constraints constraints to remove
+ * @return builder object
+ * @throws BuilderException builder exception
*/
public ControlLoopGuardBuilder removeLimitConstraint(String id, Constraint... constraints) throws BuilderException;
/**
- * Removes all time limit constraints from the guard policy
- *
+ * Removes all time limit constraints from the guard policy.
*
* @param id (guard policy id)
- * @return
- * @throws BuilderException
+ * @return builder object
+ * @throws BuilderException builder exception
*/
public ControlLoopGuardBuilder removeAllLimitConstraints(String id) throws BuilderException;
diff --git a/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/guard/builder/impl/ControlLoopGuardBuilderImpl.java b/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/guard/builder/impl/ControlLoopGuardBuilderImpl.java
index b4d251e7f..f995ba4c6 100644
--- a/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/guard/builder/impl/ControlLoopGuardBuilderImpl.java
+++ b/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/guard/builder/impl/ControlLoopGuardBuilderImpl.java
@@ -46,11 +46,11 @@ public class ControlLoopGuardBuilderImpl implements ControlLoopGuardBuilder {
private static final String THE_ID_OF_TARGET_GUARD_POLICY_MUST_NOT_BE_NULL =
"The id of target guard policy must not be null";
private static Logger logger = LoggerFactory.getLogger(ControlLoopGuardBuilderImpl.class.getName());
- private ControlLoopGuard cLGuard;
+ private ControlLoopGuard clGuard;
public ControlLoopGuardBuilderImpl(Guard guard) {
- cLGuard = new ControlLoopGuard();
- cLGuard.setGuard(guard);
+ clGuard = new ControlLoopGuard();
+ clGuard.setGuard(guard);
}
@Override
@@ -62,10 +62,10 @@ public class ControlLoopGuardBuilderImpl implements ControlLoopGuardBuilder {
if (!policy.isValid()) {
throw new BuilderException("Invalid guard policy - some required fields are missing");
}
- if (cLGuard.getGuards() == null) {
- cLGuard.setGuards(new LinkedList<>());
+ if (clGuard.getGuards() == null) {
+ clGuard.setGuards(new LinkedList<>());
}
- cLGuard.getGuards().add(policy);
+ clGuard.getGuards().add(policy);
}
return this;
}
@@ -75,14 +75,14 @@ public class ControlLoopGuardBuilderImpl implements ControlLoopGuardBuilder {
if (policies == null) {
throw new BuilderException("GuardPolicy must not be null");
}
- if (cLGuard.getGuards() == null) {
+ if (clGuard.getGuards() == null) {
throw new BuilderException("No existing guard policies to remove");
}
for (GuardPolicy policy : policies) {
if (!policy.isValid()) {
throw new BuilderException("Invalid guard policy - some required fields are missing");
}
- boolean removed = cLGuard.getGuards().remove(policy);
+ boolean removed = clGuard.getGuards().remove(policy);
if (!removed) {
throw new BuilderException("Unknown guard policy: " + policy.getName());
}
@@ -92,7 +92,7 @@ public class ControlLoopGuardBuilderImpl implements ControlLoopGuardBuilder {
@Override
public ControlLoopGuardBuilder removeAllGuardPolicies() throws BuilderException {
- cLGuard.getGuards().clear();
+ clGuard.getGuards().clear();
return this;
}
@@ -112,7 +112,7 @@ public class ControlLoopGuardBuilderImpl implements ControlLoopGuardBuilder {
private boolean addLimitConstraints(String id, Constraint... constraints) throws BuilderException {
boolean exist = false;
- for (GuardPolicy policy: cLGuard.getGuards()) {
+ for (GuardPolicy policy: clGuard.getGuards()) {
//
// We could have only one guard policy matching the id
//
@@ -149,7 +149,7 @@ public class ControlLoopGuardBuilderImpl implements ControlLoopGuardBuilder {
private boolean removeConstraints(String id, Constraint... constraints) throws BuilderException {
boolean exist = false;
- for (GuardPolicy policy: cLGuard.getGuards()) {
+ for (GuardPolicy policy: clGuard.getGuards()) {
//
// We could have only one guard policy matching the id
//
@@ -172,14 +172,14 @@ public class ControlLoopGuardBuilderImpl implements ControlLoopGuardBuilder {
@Override
public ControlLoopGuardBuilder removeAllLimitConstraints(String id) throws BuilderException {
- if (cLGuard.getGuards() == null || cLGuard.getGuards().isEmpty()) {
+ if (clGuard.getGuards() == null || clGuard.getGuards().isEmpty()) {
throw new BuilderException("No guard policies exist");
}
if (id == null) {
throw new BuilderException(THE_ID_OF_TARGET_GUARD_POLICY_MUST_NOT_BE_NULL);
}
boolean exist = false;
- for (GuardPolicy policy: cLGuard.getGuards()) {
+ for (GuardPolicy policy: clGuard.getGuards()) {
if (policy.getId().equals(id)) {
exist = true;
policy.getLimit_constraints().clear();
@@ -211,7 +211,7 @@ public class ControlLoopGuardBuilderImpl implements ControlLoopGuardBuilder {
@Override
public ControlLoopGuard getControlLoopGuard() {
- return new ControlLoopGuard(this.cLGuard);
+ return new ControlLoopGuard(this.clGuard);
}
@@ -224,7 +224,7 @@ public class ControlLoopGuardBuilderImpl implements ControlLoopGuardBuilder {
options.setDefaultFlowStyle(FlowStyle.BLOCK);
options.setPrettyFlow(true);
Yaml yaml = new Yaml(options);
- String dumpedYaml = yaml.dump(cLGuard);
+ String dumpedYaml = yaml.dump(clGuard);
//
// This is our callback class for our compiler
//
@@ -233,7 +233,7 @@ public class ControlLoopGuardBuilderImpl implements ControlLoopGuardBuilder {
// Compile it
//
try {
- ControlLoopGuardCompiler.compile(cLGuard, callback);
+ ControlLoopGuardCompiler.compile(clGuard, callback);
} catch (CompilerException e) {
logger.error(e.getMessage() + e);
callback.results.addMessage(new MessageImpl(e.getMessage(), MessageLevel.EXCEPTION));
diff --git a/controlloop/common/policy-yaml/src/test/java/org/onap/policy/controlloop/compiler/ControlLoopCompilerTest.java b/controlloop/common/policy-yaml/src/test/java/org/onap/policy/controlloop/compiler/ControlLoopCompilerTest.java
index b69343862..56b695b96 100644
--- a/controlloop/common/policy-yaml/src/test/java/org/onap/policy/controlloop/compiler/ControlLoopCompilerTest.java
+++ b/controlloop/common/policy-yaml/src/test/java/org/onap/policy/controlloop/compiler/ControlLoopCompilerTest.java
@@ -20,7 +20,9 @@
package org.onap.policy.controlloop.compiler;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
import java.io.File;
import java.io.FileInputStream;
@@ -166,6 +168,14 @@ public class ControlLoopCompilerTest {
return test(testFile, null);
}
+ /**
+ * Does the actual test.
+ *
+ * @param testFile test file
+ * @param controlLoopCompilerCallback callback method
+ * @return the policy object
+ * @throws Exception exception
+ */
public ControlLoopPolicy test(String testFile,
ControlLoopCompilerCallback controlLoopCompilerCallback) throws Exception {
try (InputStream is = new FileInputStream(new File(testFile))) {
diff --git a/controlloop/common/policy-yaml/src/test/java/org/onap/policy/controlloop/compiler/ControlLoopGuardCompilerTest.java b/controlloop/common/policy-yaml/src/test/java/org/onap/policy/controlloop/compiler/ControlLoopGuardCompilerTest.java
index 54c4eccff..28e59d9ad 100644
--- a/controlloop/common/policy-yaml/src/test/java/org/onap/policy/controlloop/compiler/ControlLoopGuardCompilerTest.java
+++ b/controlloop/common/policy-yaml/src/test/java/org/onap/policy/controlloop/compiler/ControlLoopGuardCompilerTest.java
@@ -88,6 +88,12 @@ public class ControlLoopGuardCompilerTest {
}
}
+ /**
+ * Does the actual test.
+ *
+ * @param testFile input test file
+ * @throws Exception exception thrown
+ */
public void test(String testFile) throws Exception {
try (InputStream is = new FileInputStream(new File(testFile))) {
ControlLoopGuardCompiler.compile(is, null);
diff --git a/controlloop/common/policy-yaml/src/test/java/org/onap/policy/controlloop/policy/ControlLoopPolicyBuilderTest.java b/controlloop/common/policy-yaml/src/test/java/org/onap/policy/controlloop/policy/ControlLoopPolicyBuilderTest.java
index 3133273f9..90ce96b62 100644
--- a/controlloop/common/policy-yaml/src/test/java/org/onap/policy/controlloop/policy/ControlLoopPolicyBuilderTest.java
+++ b/controlloop/common/policy-yaml/src/test/java/org/onap/policy/controlloop/policy/ControlLoopPolicyBuilderTest.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* policy-yaml unit test
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 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.
@@ -69,30 +69,30 @@ public class ControlLoopPolicyBuilderTest {
//
// Test add services
//
- Service vSCP = new Service("vSCP");
- Service vUSP = new Service("vUSP");
- Service vTrinity = new Service("Trinity");
- builder = builder.addService(vSCP, vUSP, vTrinity);
+ Service scp = new Service("vSCP");
+ Service usp = new Service("vUSP");
+ Service trinity = new Service("Trinity");
+ builder = builder.addService(scp, usp, trinity);
assertTrue(builder.getControlLoop().getServices().size() == 3);
//
// Test remove services
//
- builder = builder.removeService(vSCP);
+ builder = builder.removeService(scp);
assertTrue(builder.getControlLoop().getServices().size() == 2);
builder = builder.removeAllServices();
assertTrue(builder.getControlLoop().getServices().size() == 0);
//
// Test add resources
//
- Resource vCTS = new Resource("vCTS", ResourceType.VF);
- Resource vCOM = new Resource("vCTS", ResourceType.VF);
- Resource vRAR = new Resource("vCTS", ResourceType.VF);
- builder = builder.addResource(vCTS, vCOM, vRAR);
+ Resource cts = new Resource("vCTS", ResourceType.VF);
+ Resource com = new Resource("vCTS", ResourceType.VF);
+ Resource rar = new Resource("vCTS", ResourceType.VF);
+ builder = builder.addResource(cts, com, rar);
assertTrue(builder.getControlLoop().getResources().size() == 3);
//
// Test remove resources
//
- builder = builder.removeResource(vCTS);
+ builder = builder.removeResource(cts);
assertTrue(builder.getControlLoop().getResources().size() == 2);
builder = builder.removeAllResources();
assertTrue(builder.getControlLoop().getResources().size() == 0);
@@ -120,12 +120,12 @@ public class ControlLoopPolicyBuilderTest {
}
@Test
- public void testAddServiceWithUUID() throws BuilderException {
+ public void testAddServiceWithUuid() throws BuilderException {
ControlLoopPolicyBuilder builder =
ControlLoopPolicyBuilder.Factory.buildControlLoop(UUID.randomUUID().toString(), 2400);
UUID uuid = UUID.randomUUID();
- Service serviceWithUUID = new Service(uuid);
- builder.addService(serviceWithUUID);
+ Service serviceWithUuid = new Service(uuid);
+ builder.addService(serviceWithUuid);
assertTrue(builder.getControlLoop().getServices().size() == 1);
}
@@ -149,15 +149,15 @@ public class ControlLoopPolicyBuilderTest {
}
@Test
- public void testAddAndRemoveResourceWithUUID() throws BuilderException {
+ public void testAddAndRemoveResourceWithUuid() throws BuilderException {
ControlLoopPolicyBuilder builder =
ControlLoopPolicyBuilder.Factory.buildControlLoop(UUID.randomUUID().toString(), 2400);
UUID uuid = UUID.randomUUID();
- Resource resourceWithUUID = new Resource(uuid);
- builder.addResource(resourceWithUUID);
+ Resource resourceWithUuid = new Resource(uuid);
+ builder.addResource(resourceWithUuid);
assertTrue(builder.getControlLoop().getResources().size() == 1);
- builder.removeResource(resourceWithUUID);
+ builder.removeResource(resourceWithUuid);
assertTrue(builder.getControlLoop().getResources().size() == 0);
}
@@ -207,11 +207,11 @@ public class ControlLoopPolicyBuilderTest {
@Test
public void testControlLoopWithInitialResourceAndServices() {
try {
- Resource vCTS = new Resource("vCTS", ResourceType.VF);
- Service vSCP = new Service("vSCP");
- Service vUSP = new Service("vUSP");
+ Resource cts = new Resource("vCTS", ResourceType.VF);
+ Service scp = new Service("vSCP");
+ Service usp = new Service("vUSP");
ControlLoopPolicyBuilder builder = ControlLoopPolicyBuilder.Factory
- .buildControlLoop(UUID.randomUUID().toString(), 2400, vCTS, vSCP, vUSP);
+ .buildControlLoop(UUID.randomUUID().toString(), 2400, cts, scp, usp);
assertTrue(builder.getControlLoop().getResources().size() == 1);
assertTrue(builder.getControlLoop().getServices().size() == 2);
} catch (BuilderException e) {
@@ -222,11 +222,11 @@ public class ControlLoopPolicyBuilderTest {
@Test
public void testControlLoopWithInitialResourcesAndService() {
try {
- Resource vCTS = new Resource("vCTS", ResourceType.VF);
- Resource vCOM = new Resource("vCTS", ResourceType.VF);
- Service vSCP = new Service("vSCP");
+ Resource cts = new Resource("vCTS", ResourceType.VF);
+ Resource com = new Resource("vCTS", ResourceType.VF);
+ Service scp = new Service("vSCP");
ControlLoopPolicyBuilder builder = ControlLoopPolicyBuilder.Factory
- .buildControlLoop(UUID.randomUUID().toString(), 2400, vSCP, vCTS, vCOM);
+ .buildControlLoop(UUID.randomUUID().toString(), 2400, scp, cts, com);
assertTrue(builder.getControlLoop().getServices().size() == 1);
assertTrue(builder.getControlLoop().getResources().size() == 2);
} catch (BuilderException e) {
@@ -459,7 +459,7 @@ public class ControlLoopPolicyBuilderTest {
//
// Create another policy and chain it to the results of trigger policy
//
- Policy onRestartFailurePolicy2 =
+ final Policy onRestartFailurePolicy2 =
builder.setPolicyForPolicyResult("Rebuild VM", "If the restart fails, rebuild it.", "APPC",
new Target(TargetType.VM), "Rebuild", null, 2, 600, triggerPolicy.getId(),
PolicyResult.FAILURE, PolicyResult.FAILURE_RETRIES, PolicyResult.FAILURE_TIMEOUT);
@@ -475,25 +475,25 @@ public class ControlLoopPolicyBuilderTest {
//
// Test set the policy results to an existing operational policy
//
- onRestartFailurePolicy2 =
+ Policy onRestartFailurePolicy3 =
builder.setPolicyForPolicyResult(onRestartFailurePolicy2.getId(), triggerPolicy.getId(),
PolicyResult.FAILURE, PolicyResult.FAILURE_RETRIES, PolicyResult.FAILURE_TIMEOUT);
- assertTrue(builder.getTriggerPolicy().getFailure().equals(onRestartFailurePolicy2.getId()));
- assertTrue(builder.getTriggerPolicy().getFailure_retries().equals(onRestartFailurePolicy2.getId()));
- assertTrue(builder.getTriggerPolicy().getFailure_timeout().equals(onRestartFailurePolicy2.getId()));
+ assertTrue(builder.getTriggerPolicy().getFailure().equals(onRestartFailurePolicy3.getId()));
+ assertTrue(builder.getTriggerPolicy().getFailure_retries().equals(onRestartFailurePolicy3.getId()));
+ assertTrue(builder.getTriggerPolicy().getFailure_timeout().equals(onRestartFailurePolicy3.getId()));
//
// Test set the policy result for success to an existing operational policy
//
- onRestartFailurePolicy2 =
+ Policy onRestartFailurePolicy4 =
builder.setPolicyForPolicyResult(onRestartFailurePolicy2.getId(), triggerPolicy.getId(),
PolicyResult.FAILURE, PolicyResult.FAILURE_EXCEPTION, PolicyResult.FAILURE_GUARD,
PolicyResult.FAILURE_RETRIES, PolicyResult.FAILURE_TIMEOUT, PolicyResult.SUCCESS);
- assertTrue(builder.getTriggerPolicy().getFailure().equals(onRestartFailurePolicy2.getId()));
- assertTrue(builder.getTriggerPolicy().getFailure_exception().equals(onRestartFailurePolicy2.getId()));
- assertTrue(builder.getTriggerPolicy().getFailure_guard().equals(onRestartFailurePolicy2.getId()));
- assertTrue(builder.getTriggerPolicy().getFailure_retries().equals(onRestartFailurePolicy2.getId()));
- assertTrue(builder.getTriggerPolicy().getFailure_timeout().equals(onRestartFailurePolicy2.getId()));
- assertTrue(builder.getTriggerPolicy().getSuccess().equals(onRestartFailurePolicy2.getId()));
+ assertTrue(builder.getTriggerPolicy().getFailure().equals(onRestartFailurePolicy4.getId()));
+ assertTrue(builder.getTriggerPolicy().getFailure_exception().equals(onRestartFailurePolicy4.getId()));
+ assertTrue(builder.getTriggerPolicy().getFailure_guard().equals(onRestartFailurePolicy4.getId()));
+ assertTrue(builder.getTriggerPolicy().getFailure_retries().equals(onRestartFailurePolicy4.getId()));
+ assertTrue(builder.getTriggerPolicy().getFailure_timeout().equals(onRestartFailurePolicy4.getId()));
+ assertTrue(builder.getTriggerPolicy().getSuccess().equals(onRestartFailurePolicy4.getId()));
//
// Test remove all existing operational policies
@@ -588,30 +588,30 @@ public class ControlLoopPolicyBuilderTest {
//
// Set the first invalid trigger policy
//
- Policy policy1 = builder.setTriggerPolicy("Restart the VM",
+ final Policy policy1 = builder.setTriggerPolicy("Restart the VM",
"Upon getting the trigger event, restart the VM", null, null, "Instantiate", null, 2, 300);
Results results = builder.buildSpecification();
//
// Check that ERRORs are in results for invalid policy arguments
//
- boolean invalid_actor = false;
- boolean invalid_recipe = false;
- boolean invalid_target = false;
+ boolean invalidActor = false;
+ boolean invalidRecipe = false;
+ boolean invalidTarget = false;
for (Message m : results.getMessages()) {
if (m.getMessage().equals("Policy actor is null") && m.getLevel() == MessageLevel.ERROR) {
- invalid_actor = true;
+ invalidActor = true;
}
if (m.getMessage().equals("Policy recipe is invalid") && m.getLevel() == MessageLevel.ERROR) {
- invalid_recipe = true;
+ invalidRecipe = true;
}
if (m.getMessage().equals("Policy target is null") && m.getLevel() == MessageLevel.ERROR) {
- invalid_target = true;
+ invalidTarget = true;
}
}
//
- assertTrue(invalid_actor);
- assertTrue(invalid_recipe);
- assertTrue(invalid_target);
+ assertTrue(invalidActor);
+ assertTrue(invalidRecipe);
+ assertTrue(invalidTarget);
//
// Remove the invalid policy
//
@@ -622,12 +622,12 @@ public class ControlLoopPolicyBuilderTest {
//
// Set a valid trigger policy
//
- policy1 = builder.setTriggerPolicy("Rebuild VM", "If the restart fails, rebuild it.", "APPC",
+ Policy policy1a = builder.setTriggerPolicy("Rebuild VM", "If the restart fails, rebuild it.", "APPC",
new Target(TargetType.VM), "Rebuild", null, 1, 600);
//
// Set a second valid trigger policy
//
- Policy policy2 =
+ final Policy policy2 =
builder.setTriggerPolicy("Restart the VM", "Upon getting the trigger event, restart the VM", "APPC",
new Target(TargetType.VM), "Restart", null, 2, 300);
//
@@ -636,7 +636,7 @@ public class ControlLoopPolicyBuilderTest {
results = builder.buildSpecification();
boolean unreachable = false;
for (Message m : results.getMessages()) {
- if (m.getMessage().equals("Policy " + policy1.getId() + " is not reachable.")
+ if (m.getMessage().equals("Policy " + policy1a.getId() + " is not reachable.")
&& m.getLevel() == MessageLevel.WARNING) {
unreachable = true;
break;
@@ -644,21 +644,21 @@ public class ControlLoopPolicyBuilderTest {
}
assertTrue(unreachable);
//
- // Set policy1 for the failure results of policy2
+ // Set policy1a for the failure results of policy2
//
- policy1 = builder.setPolicyForPolicyResult(policy1.getId(), policy2.getId(), PolicyResult.FAILURE,
+ policy1a = builder.setPolicyForPolicyResult(policy1a.getId(), policy2.getId(), PolicyResult.FAILURE,
PolicyResult.FAILURE_RETRIES, PolicyResult.FAILURE_TIMEOUT);
results = builder.buildSpecification();
- boolean invalid_timeout = false;
+ boolean invalidTimeout = false;
for (Message m : results.getMessages()) {
if (m.getMessage()
.equals("controlLoop overall timeout is less than the sum of operational policy timeouts.")
&& m.getLevel() == MessageLevel.ERROR) {
- invalid_timeout = true;
+ invalidTimeout = true;
break;
}
}
- assertTrue(invalid_timeout);
+ assertTrue(invalidTimeout);
//
// Remove policy2 (revert controlLoop back to open loop)
//
@@ -684,7 +684,7 @@ public class ControlLoopPolicyBuilderTest {
@Test
- public void test() {
+ public void test1() {
this.test("src/test/resources/v1.0.0/policy_Test.yaml");
}
@@ -707,6 +707,11 @@ public class ControlLoopPolicyBuilderTest {
}
}
+ /**
+ * Does the actual test.
+ *
+ * @param testFile input file
+ */
public void test(String testFile) {
try (InputStream is = new FileInputStream(new File(testFile))) {
//
diff --git a/controlloop/common/policy-yaml/src/test/java/org/onap/policy/controlloop/policy/ControlLoopPolicyTest.java b/controlloop/common/policy-yaml/src/test/java/org/onap/policy/controlloop/policy/ControlLoopPolicyTest.java
index 6212b17f4..fcfe1dcfe 100644
--- a/controlloop/common/policy-yaml/src/test/java/org/onap/policy/controlloop/policy/ControlLoopPolicyTest.java
+++ b/controlloop/common/policy-yaml/src/test/java/org/onap/policy/controlloop/policy/ControlLoopPolicyTest.java
@@ -20,7 +20,9 @@
package org.onap.policy.controlloop.policy;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
import java.io.File;
import java.io.FileInputStream;
@@ -41,7 +43,7 @@ public class ControlLoopPolicyTest {
private static final Logger logger = LoggerFactory.getLogger(ControlLoopPolicyTest.class);
@Test
- public void test() {
+ public void test1() {
this.test("src/test/resources/v1.0.0/policy_Test.yaml");
}
@@ -56,26 +58,31 @@ public class ControlLoopPolicyTest {
}
@Test
- public void testvDNS() {
+ public void testvdns() {
this.test("src/test/resources/v2.0.0/policy_ONAP_demo_vDNS.yaml");
}
@Test
public void testvFirewall() {
// Chenfei to fix this.
- // this.test("src/test/resources/v2.0.0/policy_ONAP_demo_vFirewall.yaml");
+ // this.test("src/test/resources/v2.0.0/policy_ONAP_demo_vFirewall.yaml");
}
@Test
- public void testvCPE() {
+ public void testvcpe() {
this.test("src/test/resources/v2.0.0/policy_ONAP_UseCase_vCPE.yaml");
}
@Test
- public void testVOLTE() {
+ public void testvolte() {
this.test("src/test/resources/v2.0.0/policy_ONAP_UseCase_VOLTE.yaml");
}
+ /**
+ * Does the actual test.
+ *
+ * @param testFile input file
+ */
public void test(String testFile) {
try (InputStream is = new FileInputStream(new File(testFile))) {
//
diff --git a/controlloop/common/policy-yaml/src/test/java/org/onap/policy/controlloop/policy/ControlLoopTest.java b/controlloop/common/policy-yaml/src/test/java/org/onap/policy/controlloop/policy/ControlLoopTest.java
index cc5a903ad..daab1a26b 100644
--- a/controlloop/common/policy-yaml/src/test/java/org/onap/policy/controlloop/policy/ControlLoopTest.java
+++ b/controlloop/common/policy-yaml/src/test/java/org/onap/policy/controlloop/policy/ControlLoopTest.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2018 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.
@@ -108,18 +109,18 @@ public class ControlLoopTest {
ControlLoop controlLoop2 = new ControlLoop();
controlLoop2.setControlLoopName(controlLoopName);
controlLoop2.setVersion(version);
- Service controlLoop2_service1 = new Service("service1");
- Service controlLoop2_service2 = new Service("service2");
- List<Service> controlLoop2_services = new ArrayList<>();
- controlLoop2_services.add(controlLoop2_service1);
- controlLoop2_services.add(controlLoop2_service2);
- controlLoop2.setServices(controlLoop2_services);
- Resource controlLoop2_resource1 = new Resource("resource1", ResourceType.VF);
- Resource controlLoop2_resource2 = new Resource("resource2", ResourceType.VFC);
- List<Resource> controlLoop2_resources = new ArrayList<>();
- controlLoop2_resources.add(controlLoop2_resource1);
- controlLoop2_resources.add(controlLoop2_resource2);
- controlLoop2.setResources(controlLoop2_resources);
+ Service controlLoop2Service1 = new Service("service1");
+ Service controlLoop2Service2 = new Service("service2");
+ List<Service> controlLoop2Services = new ArrayList<>();
+ controlLoop2Services.add(controlLoop2Service1);
+ controlLoop2Services.add(controlLoop2Service2);
+ controlLoop2.setServices(controlLoop2Services);
+ Resource controlLoop2Resource1 = new Resource("resource1", ResourceType.VF);
+ Resource controlLoop2Resource2 = new Resource("resource2", ResourceType.VFC);
+ List<Resource> controlLoop2Resources = new ArrayList<>();
+ controlLoop2Resources.add(controlLoop2Resource1);
+ controlLoop2Resources.add(controlLoop2Resource2);
+ controlLoop2.setResources(controlLoop2Resources);
controlLoop2.setPnf(pnf);
controlLoop2.setTrigger_policy(triggerPolicy);
controlLoop2.setTimeout(timeout);
diff --git a/controlloop/common/policy-yaml/src/test/java/org/onap/policy/controlloop/policy/OperationsAccumulateParamsTest.java b/controlloop/common/policy-yaml/src/test/java/org/onap/policy/controlloop/policy/OperationsAccumulateParamsTest.java
index adf85af3a..9e68a7389 100644
--- a/controlloop/common/policy-yaml/src/test/java/org/onap/policy/controlloop/policy/OperationsAccumulateParamsTest.java
+++ b/controlloop/common/policy-yaml/src/test/java/org/onap/policy/controlloop/policy/OperationsAccumulateParamsTest.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2018 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.
@@ -18,7 +19,10 @@
package org.onap.policy.controlloop.policy;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
import org.junit.Test;
@@ -78,8 +82,8 @@ public class OperationsAccumulateParamsTest {
@Test
public void testEqualsAndHashCode() {
- String period = "15m";
- Integer limit = 10;
+ final String period = "15m";
+ final Integer limit = 10;
OperationsAccumulateParams operationsAccumulateParams1 = new OperationsAccumulateParams();
OperationsAccumulateParams operationsAccumulateParams2 = new OperationsAccumulateParams();
diff --git a/controlloop/common/policy-yaml/src/test/java/org/onap/policy/controlloop/policy/guard/ConstraintTest.java b/controlloop/common/policy-yaml/src/test/java/org/onap/policy/controlloop/policy/guard/ConstraintTest.java
index 14e46b6bf..2d497ac4b 100644
--- a/controlloop/common/policy-yaml/src/test/java/org/onap/policy/controlloop/policy/guard/ConstraintTest.java
+++ b/controlloop/common/policy-yaml/src/test/java/org/onap/policy/controlloop/policy/guard/ConstraintTest.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2018 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.
@@ -18,7 +19,10 @@
package org.onap.policy.controlloop.policy.guard;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
import java.util.ArrayList;
import java.util.HashMap;
@@ -62,7 +66,7 @@ public class ConstraintTest {
activeTimeRange.put("timeWindowKey", "timeWindowValue");
Constraint constraint = new Constraint();
constraint.setActive_time_range(activeTimeRange);;
- assertEquals(activeTimeRange, constraint.getActive_time_range());
+ assertEquals(activeTimeRange, constraint.getActive_time_range());
}
@Test
@@ -71,7 +75,7 @@ public class ConstraintTest {
blacklist.add("blacklist item");
Constraint constraint = new Constraint();
constraint.setBlacklist(blacklist);
- assertEquals(blacklist, constraint.getBlacklist());
+ assertEquals(blacklist, constraint.getBlacklist());
}
@Test
@@ -164,7 +168,7 @@ public class ConstraintTest {
@Test
public void testIsValid() {
Integer freqLimitPerTarget = 10;
- Map<String, String> timeWindow = new HashMap<>();
+ final Map<String, String> timeWindow = new HashMap<>();
Constraint constraint = new Constraint();
assertTrue(constraint.isValid());
@@ -197,8 +201,8 @@ public class ConstraintTest {
@Test
public void testEquals() {
Integer freqLimitPerTarget = 10;
- Map<String, String> timeWindow = new HashMap<>();
- Map<String, String> activeTimeRange = new HashMap<>();
+ final Map<String, String> timeWindow = new HashMap<>();
+ final Map<String, String> activeTimeRange = new HashMap<>();
List<String> blacklist = new ArrayList<>();
blacklist.add("blacklist item");
diff --git a/controlloop/common/policy-yaml/src/test/java/org/onap/policy/controlloop/policy/guard/ControlLoopGuardBuilderTest.java b/controlloop/common/policy-yaml/src/test/java/org/onap/policy/controlloop/policy/guard/ControlLoopGuardBuilderTest.java
index 45e9c4202..782f6d5e8 100644
--- a/controlloop/common/policy-yaml/src/test/java/org/onap/policy/controlloop/policy/guard/ControlLoopGuardBuilderTest.java
+++ b/controlloop/common/policy-yaml/src/test/java/org/onap/policy/controlloop/policy/guard/ControlLoopGuardBuilderTest.java
@@ -59,15 +59,15 @@ public class ControlLoopGuardBuilderTest {
// Assert there is no guard policies yet
//
Results results = builder.buildSpecification();
- boolean no_guard_policies = false;
+ boolean noGuardPolicies = false;
for (Message m : results.getMessages()) {
if (m.getMessage().equals("ControlLoop Guard should have at least one guard policies")
&& m.getLevel() == MessageLevel.ERROR) {
- no_guard_policies = true;
+ noGuardPolicies = true;
break;
}
}
- assertTrue(no_guard_policies);
+ assertTrue(noGuardPolicies);
//
// Add a guard policy without limit constraint
//
@@ -83,28 +83,28 @@ public class ControlLoopGuardBuilderTest {
// Assert there is no limit constraint associated with the only guard policy
//
results = builder.buildSpecification();
- boolean no_constraint = false;
+ boolean noConstraint = false;
for (Message m : results.getMessages()) {
if (m.getMessage().equals("Guard policy guardpolicy1 does not have any limit constraint")
&& m.getLevel() == MessageLevel.ERROR) {
- no_constraint = true;
+ noConstraint = true;
break;
}
}
- assertTrue(no_constraint);
+ assertTrue(noConstraint);
//
// Add a constraint to policy1
//
- Map<String, String> active_time_range = new HashMap<String, String>();
- active_time_range.put("start", "00:00:00-05:00");
- active_time_range.put("end", "23:59:59-05:00");
+ Map<String, String> activeTimeRange = new HashMap<String, String>();
+ activeTimeRange.put("start", "00:00:00-05:00");
+ activeTimeRange.put("end", "23:59:59-05:00");
List<String> blacklist = new LinkedList<String>();
blacklist.add("eNodeB_common_id1");
blacklist.add("eNodeB_common_id2");
- Map<String, String> time_window = new HashMap<String, String>();
- time_window.put("value", "10");
- time_window.put("units", "minute");
- Constraint cons = new Constraint(5, time_window, active_time_range, blacklist);
+ Map<String, String> timeWindow = new HashMap<String, String>();
+ timeWindow.put("value", "10");
+ timeWindow.put("units", "minute");
+ Constraint cons = new Constraint(5, timeWindow, activeTimeRange, blacklist);
builder = builder.addLimitConstraint(policy1.getId(), cons);
//
// Add a duplicate constraint to policy1
@@ -114,15 +114,15 @@ public class ControlLoopGuardBuilderTest {
// Assert there are duplicate constraints associated with the only guard policy
//
results = builder.buildSpecification();
- boolean duplicate_constraint = false;
+ boolean duplicateConstraint = false;
for (Message m : results.getMessages()) {
if (m.getMessage().equals("Guard policy guardpolicy1 has duplicate limit constraints")
&& m.getLevel() == MessageLevel.WARNING) {
- duplicate_constraint = true;
+ duplicateConstraint = true;
break;
}
}
- assertTrue(duplicate_constraint);
+ assertTrue(duplicateConstraint);
//
// Remove the duplicate constraint
//
@@ -136,15 +136,15 @@ public class ControlLoopGuardBuilderTest {
// Assert there are duplicate guard policies
//
results = builder.buildSpecification();
- boolean duplicate_guard_policy = false;
+ boolean duplicateGuardPolicy = false;
for (Message m : results.getMessages()) {
if (m.getMessage().equals("There are duplicate guard policies")
&& m.getLevel() == MessageLevel.WARNING) {
- duplicate_guard_policy = true;
+ duplicateGuardPolicy = true;
break;
}
}
- assertTrue(duplicate_guard_policy);
+ assertTrue(duplicateGuardPolicy);
//
// Remove the duplicate guard policy
//
@@ -170,6 +170,11 @@ public class ControlLoopGuardBuilderTest {
this.test("src/test/resources/v2.0.0-guard/policy_guard_appc_restart.yaml");
}
+ /**
+ * Do the actual test.
+ *
+ * @param testFile input test file
+ */
public void test(String testFile) {
try (InputStream is = new FileInputStream(new File(testFile))) {
//
diff --git a/controlloop/common/policy-yaml/src/test/java/org/onap/policy/controlloop/policy/guard/ControlLoopGuardTest.java b/controlloop/common/policy-yaml/src/test/java/org/onap/policy/controlloop/policy/guard/ControlLoopGuardTest.java
index 81c76c76a..1a5b5e92a 100644
--- a/controlloop/common/policy-yaml/src/test/java/org/onap/policy/controlloop/policy/guard/ControlLoopGuardTest.java
+++ b/controlloop/common/policy-yaml/src/test/java/org/onap/policy/controlloop/policy/guard/ControlLoopGuardTest.java
@@ -20,7 +20,11 @@
package org.onap.policy.controlloop.policy.guard;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
import java.io.File;
import java.io.FileInputStream;
@@ -42,17 +46,17 @@ public class ControlLoopGuardTest {
private static final Logger logger = LoggerFactory.getLogger(ControlLoopGuardTest.class);
@Test
- public void testGuardvDNS() {
+ public void testGuardvdns() {
this.test("src/test/resources/v2.0.0-guard/policy_guard_ONAP_demo_vDNS.yaml");
}
@Test
- public void testGuardvUSP() {
+ public void testGuardvusp() {
this.test("src/test/resources/v2.0.0-guard/policy_guard_appc_restart.yaml");
}
@Test
- public void testConstructorControlLoopGuard(){
+ public void testConstructorControlLoopGuard() {
Guard guard1 = new Guard();
GuardPolicy guardPolicy1 = new GuardPolicy();
GuardPolicy guardPolicy2 = new GuardPolicy();
@@ -71,7 +75,7 @@ public class ControlLoopGuardTest {
@Test
public void testEqualsAndHashCode() {
- Guard guard1 = new Guard();
+ final Guard guard1 = new Guard();
GuardPolicy guardPolicy1 = new GuardPolicy();
GuardPolicy guardPolicy2 = new GuardPolicy();
LinkedList<GuardPolicy> guardPolicies = new LinkedList<>();
@@ -115,6 +119,11 @@ public class ControlLoopGuardTest {
assertFalse(controlLoopGuard.equals(""));
}
+ /**
+ * Does the actual test.
+ *
+ * @param testFile input file
+ */
public void test(String testFile) {
try (InputStream is = new FileInputStream(new File(testFile))) {
//
diff --git a/controlloop/common/policy-yaml/src/test/java/org/onap/policy/controlloop/policy/guard/GuardPolicyTest.java b/controlloop/common/policy-yaml/src/test/java/org/onap/policy/controlloop/policy/guard/GuardPolicyTest.java
index d80fecf2b..7019595b3 100644
--- a/controlloop/common/policy-yaml/src/test/java/org/onap/policy/controlloop/policy/guard/GuardPolicyTest.java
+++ b/controlloop/common/policy-yaml/src/test/java/org/onap/policy/controlloop/policy/guard/GuardPolicyTest.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2018 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.
@@ -211,9 +212,9 @@ public class GuardPolicyTest {
@Test
public void testEquals() {
- String id = "guard id";
- String name = "guard name";
- String description = "guard description";
+ final String id = "guard id";
+ final String name = "guard name";
+ final String description = "guard description";
GuardPolicy guardPolicy1 = new GuardPolicy(id);
GuardPolicy guardPolicy2 = new GuardPolicy();
assertFalse(guardPolicy1.equals(guardPolicy2));