aboutsummaryrefslogtreecommitdiffstats
path: root/controlloop/common/policy-yaml/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'controlloop/common/policy-yaml/src/test')
-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
10 files changed, 164 insertions, 112 deletions
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));