aboutsummaryrefslogtreecommitdiffstats
path: root/ECOMP-ControlloopPolicy
diff options
context:
space:
mode:
authorRavindra Bakkamanthala <rb7147@att.com>2017-06-05 22:42:02 -0400
committerRavindra Bakkamanthala <rb7147@att.com>2017-06-07 14:47:34 -0400
commitfc5c07705edc4dcb7083b39116a43844bb6a1490 (patch)
treeab5c7258197fc776fef8106413704a5f0a829160 /ECOMP-ControlloopPolicy
parentd9007d680d19734d5dc106479784c420236cca4b (diff)
Fixed the Policy API issues and Bugfixes
Change-Id: I6e8b54442421b6ebd0ff88426fc6e5f3a36b0690 Signed-off-by: Ravindra Bakkamanthala <rb7147@att.com>
Diffstat (limited to 'ECOMP-ControlloopPolicy')
-rw-r--r--ECOMP-ControlloopPolicy/src/main/java/org/openecomp/policy/controlloop/policy/guard/Constraint.java22
-rw-r--r--ECOMP-ControlloopPolicy/src/main/java/org/openecomp/policy/controlloop/policy/guard/ControlLoopGuard.java7
-rw-r--r--ECOMP-ControlloopPolicy/src/main/java/org/openecomp/policy/controlloop/policy/guard/GuardPolicy.java8
-rw-r--r--ECOMP-ControlloopPolicy/src/test/java/org/openecomp/policy/controlloop/compiler/ControlLoopGuardCompilerTest.java2
-rw-r--r--ECOMP-ControlloopPolicy/src/test/java/org/openecomp/policy/controlloop/policy/guard/ControlLoopGuardBuilderTest.java4
-rw-r--r--ECOMP-ControlloopPolicy/src/test/java/org/openecomp/policy/controlloop/policy/guard/ControlLoopGuardTest.java6
6 files changed, 29 insertions, 20 deletions
diff --git a/ECOMP-ControlloopPolicy/src/main/java/org/openecomp/policy/controlloop/policy/guard/Constraint.java b/ECOMP-ControlloopPolicy/src/main/java/org/openecomp/policy/controlloop/policy/guard/Constraint.java
index 85ddf066d..42a04e7b7 100644
--- a/ECOMP-ControlloopPolicy/src/main/java/org/openecomp/policy/controlloop/policy/guard/Constraint.java
+++ b/ECOMP-ControlloopPolicy/src/main/java/org/openecomp/policy/controlloop/policy/guard/Constraint.java
@@ -77,6 +77,13 @@ public class Constraint {
this.blacklist = new LinkedList<>(blacklist);
}
+
+ public Constraint(Map<String, String> time_in_range, List<String> blacklist) {
+ if (time_in_range != null) {
+ this.time_in_range = Collections.unmodifiableMap(time_in_range);
+ }
+ this.blacklist = new LinkedList<>(blacklist);
+ }
public Constraint(Integer num, String duration, List<String> blacklist) {
this.num = num;
@@ -84,6 +91,13 @@ public class Constraint {
this.blacklist = new LinkedList<>(blacklist);
}
+ public Constraint(Integer num, String duration, Map<String, String> time_in_range) {
+ this(num, duration);
+ if (time_in_range != null) {
+ this.time_in_range = Collections.unmodifiableMap(time_in_range);
+ }
+ }
+
public Constraint(Integer num, String duration, Map<String, String> time_in_range, List<String> blacklist) {
this(num, duration);
if (time_in_range != null) {
@@ -102,13 +116,7 @@ public class Constraint {
}
public boolean isValid() {
- if (num == null && duration != null) {
- return false;
- }
- if (duration == null && num != null) {
- return false;
- }
- return true;
+ return ((num == null && duration != null)|| (duration == null && num != null))? false : true;
}
@Override
diff --git a/ECOMP-ControlloopPolicy/src/main/java/org/openecomp/policy/controlloop/policy/guard/ControlLoopGuard.java b/ECOMP-ControlloopPolicy/src/main/java/org/openecomp/policy/controlloop/policy/guard/ControlLoopGuard.java
index cfc904823..3df2a0885 100644
--- a/ECOMP-ControlloopPolicy/src/main/java/org/openecomp/policy/controlloop/policy/guard/ControlLoopGuard.java
+++ b/ECOMP-ControlloopPolicy/src/main/java/org/openecomp/policy/controlloop/policy/guard/ControlLoopGuard.java
@@ -20,13 +20,12 @@
package org.openecomp.policy.controlloop.policy.guard;
import java.util.LinkedList;
-import java.util.List;
public class ControlLoopGuard {
private Guard guard;
- private List<GuardPolicy> guards;
+ private LinkedList<GuardPolicy> guards;
public ControlLoopGuard() {
//DO Nothing Empty Constructor
@@ -40,11 +39,11 @@ public class ControlLoopGuard {
this.guard = guard;
}
- public List<GuardPolicy> getGuards() {
+ public LinkedList<GuardPolicy> getGuards() {
return guards;
}
- public void setGuards(List<GuardPolicy> guards) {
+ public void setGuards(LinkedList<GuardPolicy> guards) {
this.guards = guards;
}
diff --git a/ECOMP-ControlloopPolicy/src/main/java/org/openecomp/policy/controlloop/policy/guard/GuardPolicy.java b/ECOMP-ControlloopPolicy/src/main/java/org/openecomp/policy/controlloop/policy/guard/GuardPolicy.java
index 7eb8af6d1..a4d56ff07 100644
--- a/ECOMP-ControlloopPolicy/src/main/java/org/openecomp/policy/controlloop/policy/guard/GuardPolicy.java
+++ b/ECOMP-ControlloopPolicy/src/main/java/org/openecomp/policy/controlloop/policy/guard/GuardPolicy.java
@@ -31,7 +31,7 @@ public class GuardPolicy {
private String description;
private String actor;
private String recipe;
- private List<Constraint> limit_constraints;
+ private LinkedList<Constraint> limit_constraints;
public GuardPolicy() {
//Do Nothing Empty Constructor.
@@ -77,11 +77,11 @@ public class GuardPolicy {
this.recipe = recipe;
}
- public List<Constraint> getLimit_constraints() {
- return limit_constraints;
+ public LinkedList<Constraint> getLimit_constraints() {
+ return limit_constraints;
}
- public void setLimit_constraints(List<Constraint> limit_constraints) {
+ public void setLimit_constraints(LinkedList<Constraint> limit_constraints) {
this.limit_constraints = limit_constraints;
}
diff --git a/ECOMP-ControlloopPolicy/src/test/java/org/openecomp/policy/controlloop/compiler/ControlLoopGuardCompilerTest.java b/ECOMP-ControlloopPolicy/src/test/java/org/openecomp/policy/controlloop/compiler/ControlLoopGuardCompilerTest.java
index 1e035edf4..e2701eefb 100644
--- a/ECOMP-ControlloopPolicy/src/test/java/org/openecomp/policy/controlloop/compiler/ControlLoopGuardCompilerTest.java
+++ b/ECOMP-ControlloopPolicy/src/test/java/org/openecomp/policy/controlloop/compiler/ControlLoopGuardCompilerTest.java
@@ -31,7 +31,7 @@ import org.junit.Test;
import org.openecomp.policy.controlloop.guard.compiler.ControlLoopGuardCompiler;
public class ControlLoopGuardCompilerTest {
-
+
@Test
public void testTest1() {
try {
diff --git a/ECOMP-ControlloopPolicy/src/test/java/org/openecomp/policy/controlloop/policy/guard/ControlLoopGuardBuilderTest.java b/ECOMP-ControlloopPolicy/src/test/java/org/openecomp/policy/controlloop/policy/guard/ControlLoopGuardBuilderTest.java
index 5df0266ec..3137a1232 100644
--- a/ECOMP-ControlloopPolicy/src/test/java/org/openecomp/policy/controlloop/policy/guard/ControlLoopGuardBuilderTest.java
+++ b/ECOMP-ControlloopPolicy/src/test/java/org/openecomp/policy/controlloop/policy/guard/ControlLoopGuardBuilderTest.java
@@ -142,12 +142,12 @@ public class ControlLoopGuardBuilderTest {
fail(e.getMessage());
}
}
-
+
@Test
public void test1() {
this.test("src/test/resources/v2.0.0-guard/policy_guard_OpenECOMP_demo_vDNS.yaml");
}
-
+
@Test
public void test2() {
this.test("src/test/resources/v2.0.0-guard/policy_guard_1707_appc.yaml");
diff --git a/ECOMP-ControlloopPolicy/src/test/java/org/openecomp/policy/controlloop/policy/guard/ControlLoopGuardTest.java b/ECOMP-ControlloopPolicy/src/test/java/org/openecomp/policy/controlloop/policy/guard/ControlLoopGuardTest.java
index a09fd2112..4575e594f 100644
--- a/ECOMP-ControlloopPolicy/src/test/java/org/openecomp/policy/controlloop/policy/guard/ControlLoopGuardTest.java
+++ b/ECOMP-ControlloopPolicy/src/test/java/org/openecomp/policy/controlloop/policy/guard/ControlLoopGuardTest.java
@@ -19,7 +19,9 @@
*/
package org.openecomp.policy.controlloop.policy.guard;
-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;
@@ -35,7 +37,7 @@ import org.yaml.snakeyaml.constructor.Constructor;
public class ControlLoopGuardTest {
-
+
@Test
public void testGuardvDNS() {
this.test("src/test/resources/v2.0.0-guard/policy_guard_OpenECOMP_demo_vDNS.yaml");