summaryrefslogtreecommitdiffstats
path: root/controlloop/common/eventmanager/src/test/java
diff options
context:
space:
mode:
authorLiam Fallon <liam.fallon@ericsson.com>2018-01-18 10:55:53 +0000
committerLiam Fallon <liam.fallon@ericsson.com>2018-01-18 11:06:22 +0000
commitb2a9a8adbcf036780bf47c5c94dbf65a088ab540 (patch)
treef594ceccac054e76a67e83de0712cf3896d0c8c7 /controlloop/common/eventmanager/src/test/java
parentbdf5640a2c68a0899363503dafa0f7cb1557e4a6 (diff)
Fix Tech Debt/JUnit on control loop event POJOs
Mainly making fields private, fixing field and methods to follow Java guidelines, and adding getter and setter methods. Unit test added for all classes in org.onap.policy.controlloop Issue-ID: POLICY-455 Change-Id: I445b7cfaf9eb921a230bbb72b06ff4455fe003ce Signed-off-by: Liam Fallon <liam.fallon@ericsson.com>
Diffstat (limited to 'controlloop/common/eventmanager/src/test/java')
-rw-r--r--controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManagerTest.java74
-rw-r--r--controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManagerTest.java26
2 files changed, 50 insertions, 50 deletions
diff --git a/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManagerTest.java b/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManagerTest.java
index bc832a907..d4083150d 100644
--- a/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManagerTest.java
+++ b/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManagerTest.java
@@ -59,15 +59,15 @@ public class ControlLoopEventManagerTest {
private static VirtualControlLoopEvent onset;
static {
onset = new VirtualControlLoopEvent();
- onset.closedLoopControlName = "ControlLoop-vUSP";
- onset.requestID = UUID.randomUUID();
- onset.target = "VM_NAME";
- onset.closedLoopAlarmStart = Instant.now();
- onset.AAI = new HashMap<String, String>();
- onset.AAI.put("cloud-region.identity-url", "foo");
- onset.AAI.put("vserver.selflink", "bar");
- onset.AAI.put("generic-vnf.vnf-id", "83f674e8-7555-44d7-9a39-bdc3770b0491");
- onset.closedLoopEventStatus = ControlLoopEventStatus.ONSET;
+ onset.setClosedLoopControlName("ControlLoop-vUSP");
+ onset.setRequestID(UUID.randomUUID());
+ onset.setTarget("VM_NAME");
+ onset.setClosedLoopAlarmStart(Instant.now());
+ onset.setAAI(new HashMap<String, String>());
+ onset.getAAI().put("cloud-region.identity-url", "foo");
+ onset.getAAI().put("vserver.selflink", "bar");
+ onset.getAAI().put("generic-vnf.vnf-id", "83f674e8-7555-44d7-9a39-bdc3770b0491");
+ onset.setClosedLoopEventStatus(ControlLoopEventStatus.ONSET);
}
@BeforeClass
@@ -90,7 +90,7 @@ public class ControlLoopEventManagerTest {
@Test
public void testAAIVnfInfo() {
final Util.Pair<ControlLoopPolicy, String> pair = Util.loadYaml("src/test/resources/test.yaml");
- onset.closedLoopControlName = pair.a.getControlLoop().getControlLoopName();
+ onset.setClosedLoopControlName(pair.a.getControlLoop().getControlLoopName());
try {
AAIGETVnfResponse response = getQueryByVnfID2(PolicyEngine.manager.getEnvironmentProperty("aai.url") + "/aai/v11/network/generic-vnfs/generic-vnf/",
PolicyEngine.manager.getEnvironmentProperty("aai.username"),
@@ -107,7 +107,7 @@ public class ControlLoopEventManagerTest {
@Test
public void testAAIVnfInfo2() {
final Util.Pair<ControlLoopPolicy, String> pair = Util.loadYaml("src/test/resources/test.yaml");
- onset.closedLoopControlName = pair.a.getControlLoop().getControlLoopName();
+ onset.setClosedLoopControlName(pair.a.getControlLoop().getControlLoopName());
try {
AAIGETVnfResponse response = getQueryByVnfName2(PolicyEngine.manager.getEnvironmentProperty("aai.url") + "/aai/v11/network/generic-vnfs/generic-vnf?vnf-name=",
PolicyEngine.manager.getEnvironmentProperty("aai.username"),
@@ -124,7 +124,7 @@ public class ControlLoopEventManagerTest {
@Test
public void testAAIVserver() {
final Util.Pair<ControlLoopPolicy, String> pair = Util.loadYaml("src/test/resources/test.yaml");
- onset.closedLoopControlName = pair.a.getControlLoop().getControlLoopName();
+ onset.setClosedLoopControlName(pair.a.getControlLoop().getControlLoopName());
try {
AAIGETVserverResponse response = getQueryByVserverName2(PolicyEngine.manager.getEnvironmentProperty("aai.url") + "/aai/v11/nodes/vservers?vserver-name=",
PolicyEngine.manager.getEnvironmentProperty("aai.username"),
@@ -144,7 +144,7 @@ public class ControlLoopEventManagerTest {
// Load up the policy
//
final Util.Pair<ControlLoopPolicy, String> pair = Util.loadYaml("src/test/resources/test.yaml");
- onset.closedLoopControlName = pair.a.getControlLoop().getControlLoopName();
+ onset.setClosedLoopControlName(pair.a.getControlLoop().getControlLoopName());
try {
logger.info("testIsClosedLoopDisabled --");
@@ -179,12 +179,12 @@ public class ControlLoopEventManagerTest {
@Test
public void abatemetCheckEventSyntaxTest() {
VirtualControlLoopEvent event = new VirtualControlLoopEvent();
- event.closedLoopControlName = "abatementAAI";
- event.requestID = UUID.randomUUID();
- event.target = "generic-vnf.vnf-id";
- event.closedLoopAlarmStart = Instant.now();
- event.closedLoopEventStatus = ControlLoopEventStatus.ABATED;
- ControlLoopEventManager manager = new ControlLoopEventManager(event.closedLoopControlName, event.requestID);
+ event.setClosedLoopControlName("abatementAAI");
+ event.setRequestID(UUID.randomUUID());
+ event.setTarget("generic-vnf.vnf-id");
+ event.setClosedLoopAlarmStart(Instant.now());
+ event.setClosedLoopEventStatus(ControlLoopEventStatus.ABATED);
+ ControlLoopEventManager manager = new ControlLoopEventManager(event.getClosedLoopControlName(), event.getRequestID());
assertNull(manager.getVnfResponse());
assertNull(manager.getVserverResponse());
try {
@@ -198,8 +198,8 @@ public class ControlLoopEventManagerTest {
assertNull(manager.getVserverResponse());
- event.AAI = new HashMap<>();
- event.AAI.put("generic-vnf.vnf-name", "abatementTest");
+ event.setAAI(new HashMap<>());
+ event.getAAI().put("generic-vnf.vnf-name", "abatementTest");
try {
manager.checkEventSyntax(event);
} catch (ControlLoopException e) {
@@ -215,19 +215,19 @@ public class ControlLoopEventManagerTest {
public void subsequentOnsetTest() {
UUID requestId = UUID.randomUUID();
VirtualControlLoopEvent event = new VirtualControlLoopEvent();
- event.closedLoopControlName = "TwoOnsetTest";
- event.requestID = requestId;
- event.target = "generic-vnf.vnf-id";
- event.closedLoopAlarmStart = Instant.now();
- event.closedLoopEventStatus = ControlLoopEventStatus.ONSET;
- event.AAI = new HashMap<>();
- event.AAI.put("generic-vnf.vnf-name", "onsetOne");
+ event.setClosedLoopControlName("TwoOnsetTest");
+ event.setRequestID(requestId);
+ event.setTarget("generic-vnf.vnf-id");
+ event.setClosedLoopAlarmStart(Instant.now());
+ event.setClosedLoopEventStatus(ControlLoopEventStatus.ONSET);
+ event.setAAI(new HashMap<>());
+ event.getAAI().put("generic-vnf.vnf-name", "onsetOne");
- ControlLoopEventManager manager = new ControlLoopEventManager(event.closedLoopControlName, event.requestID);
+ ControlLoopEventManager manager = new ControlLoopEventManager(event.getClosedLoopControlName(), event.getRequestID());
VirtualControlLoopNotification notification = manager.activate(event);
assertNotNull(notification);
- assertEquals(ControlLoopNotificationType.ACTIVE, notification.notification);
+ assertEquals(ControlLoopNotificationType.ACTIVE, notification.getNotification());
ControlLoopEventManager.NEW_EVENT_STATUS status = null;
try {
@@ -244,13 +244,13 @@ public class ControlLoopEventManagerTest {
assertNull(manager.getVserverResponse());
VirtualControlLoopEvent event2 = new VirtualControlLoopEvent();
- event2.closedLoopControlName = "TwoOnsetTest";
- event2.requestID = requestId;
- event2.target = "generic-vnf.vnf-id";
- event2.closedLoopAlarmStart = Instant.now();
- event2.closedLoopEventStatus = ControlLoopEventStatus.ONSET;
- event2.AAI = new HashMap<>();
- event2.AAI.put("generic-vnf.vnf-name", "onsetTwo");
+ event2.setClosedLoopControlName("TwoOnsetTest");
+ event2.setRequestID(requestId);
+ event2.setTarget("generic-vnf.vnf-id");
+ event2.setClosedLoopAlarmStart(Instant.now());
+ event2.setClosedLoopEventStatus(ControlLoopEventStatus.ONSET);
+ event2.setAAI(new HashMap<>());
+ event2.getAAI().put("generic-vnf.vnf-name", "onsetTwo");
try {
diff --git a/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManagerTest.java b/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManagerTest.java
index 1714d3e26..76020b0c9 100644
--- a/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManagerTest.java
+++ b/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManagerTest.java
@@ -58,13 +58,13 @@ public class ControlLoopOperationManagerTest {
private static VirtualControlLoopEvent onset;
static {
onset = new VirtualControlLoopEvent();
- onset.requestID = UUID.randomUUID();
- onset.target = "generic-vnf.vnf-name";
- onset.target_type = ControlLoopTargetType.VNF;
- onset.closedLoopAlarmStart = Instant.now();
- onset.AAI = new HashMap<>();
- onset.AAI.put("generic-vnf.vnf-name", "testTriggerSource");
- onset.closedLoopEventStatus = ControlLoopEventStatus.ONSET;
+ onset.setRequestID(UUID.randomUUID());
+ onset.setTarget("generic-vnf.vnf-name");
+ onset.setTargetType(ControlLoopTargetType.VNF);
+ onset.setClosedLoopAlarmStart(Instant.now());
+ onset.setAAI(new HashMap<>());
+ onset.getAAI().put("generic-vnf.vnf-name", "testTriggerSource");
+ onset.setClosedLoopEventStatus(ControlLoopEventStatus.ONSET);
/* Set environment properties */
PolicyEngine.manager.setEnvironmentProperty("aai.url", "http://localhost:6666");
@@ -92,7 +92,7 @@ public class ControlLoopOperationManagerTest {
// Load up the policy
//
final Util.Pair<ControlLoopPolicy, String> pair = Util.loadYaml("src/test/resources/test.yaml");
- onset.closedLoopControlName = pair.a.getControlLoop().getControlLoopName();
+ onset.setClosedLoopControlName(pair.a.getControlLoop().getControlLoopName());
try {
//
// Create a processor
@@ -101,11 +101,11 @@ public class ControlLoopOperationManagerTest {
//
// create the manager
//
- ControlLoopEventManager eventManager = new ControlLoopEventManager(onset.closedLoopControlName, onset.requestID);
+ ControlLoopEventManager eventManager = new ControlLoopEventManager(onset.getClosedLoopControlName(), onset.getRequestID());
VirtualControlLoopNotification notification = eventManager.activate(onset);
assertNotNull(notification);
- assertEquals(ControlLoopNotificationType.ACTIVE, notification.notification);
+ assertEquals(ControlLoopNotificationType.ACTIVE, notification.getNotification());
ControlLoopEventManager.NEW_EVENT_STATUS status = null;
try {
@@ -221,7 +221,7 @@ public class ControlLoopOperationManagerTest {
// Load up the policy
//
final Util.Pair<ControlLoopPolicy, String> pair = Util.loadYaml("src/test/resources/test.yaml");
- onset.closedLoopControlName = pair.a.getControlLoop().getControlLoopName();
+ onset.setClosedLoopControlName(pair.a.getControlLoop().getControlLoopName());
try {
//
// Create a processor
@@ -230,11 +230,11 @@ public class ControlLoopOperationManagerTest {
//
// create the manager
//
- ControlLoopEventManager eventManager = new ControlLoopEventManager(onset.closedLoopControlName, onset.requestID);
+ ControlLoopEventManager eventManager = new ControlLoopEventManager(onset.getClosedLoopControlName(), onset.getRequestID());
VirtualControlLoopNotification notification = eventManager.activate(onset);
assertNotNull(notification);
- assertEquals(ControlLoopNotificationType.ACTIVE, notification.notification);
+ assertEquals(ControlLoopNotificationType.ACTIVE, notification.getNotification());
ControlLoopEventManager.NEW_EVENT_STATUS status = null;
try {