summaryrefslogtreecommitdiffstats
path: root/controlloop/common/actors
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/actors
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/actors')
-rw-r--r--controlloop/common/actors/actor.appc/src/main/java/org/onap/policy/controlloop/actor/appc/APPCActorServiceProvider.java4
-rw-r--r--controlloop/common/actors/actor.appc/src/test/java/org/onap/policy/controlloop/actor/appc/AppcServiceProviderTest.java32
-rw-r--r--controlloop/common/actors/actor.appclcm/src/main/java/org/onap/policy/controlloop/actor/appclcm/AppcLcmActorServiceProvider.java8
-rw-r--r--controlloop/common/actors/actor.appclcm/src/test/java/org/onap/policy/controlloop/actor/appclcm/AppcLcmServiceProviderTest.java40
-rw-r--r--controlloop/common/actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/SOActorServiceProvider.java6
-rw-r--r--controlloop/common/actors/actor.vfc/src/main/java/org/onap/policy/controlloop/actor/vfc/VFCActorServiceProvider.java18
6 files changed, 54 insertions, 54 deletions
diff --git a/controlloop/common/actors/actor.appc/src/main/java/org/onap/policy/controlloop/actor/appc/APPCActorServiceProvider.java b/controlloop/common/actors/actor.appc/src/main/java/org/onap/policy/controlloop/actor/appc/APPCActorServiceProvider.java
index 41a99496c..c0bbfe8f3 100644
--- a/controlloop/common/actors/actor.appc/src/main/java/org/onap/policy/controlloop/actor/appc/APPCActorServiceProvider.java
+++ b/controlloop/common/actors/actor.appc/src/main/java/org/onap/policy/controlloop/actor/appc/APPCActorServiceProvider.java
@@ -94,8 +94,8 @@ public class APPCActorServiceProvider implements Actor {
*/
Request request = new Request();
request.setCommonHeader(new CommonHeader());
- request.getCommonHeader().setRequestID(onset.requestID);
- request.getCommonHeader().setSubRequestID(operation.subRequestId);
+ request.getCommonHeader().setRequestID(onset.getRequestID());
+ request.getCommonHeader().setSubRequestID(operation.getSubRequestId());
request.setAction(policy.getRecipe().substring(0, 1).toUpperCase()
+ policy.getRecipe().substring(1));
diff --git a/controlloop/common/actors/actor.appc/src/test/java/org/onap/policy/controlloop/actor/appc/AppcServiceProviderTest.java b/controlloop/common/actors/actor.appc/src/test/java/org/onap/policy/controlloop/actor/appc/AppcServiceProviderTest.java
index e07589081..89de717fb 100644
--- a/controlloop/common/actors/actor.appc/src/test/java/org/onap/policy/controlloop/actor/appc/AppcServiceProviderTest.java
+++ b/controlloop/common/actors/actor.appc/src/test/java/org/onap/policy/controlloop/actor/appc/AppcServiceProviderTest.java
@@ -60,24 +60,24 @@ public class AppcServiceProviderTest {
* generic-vnf.vnf-id and a target type of VM.
*/
onsetEvent = new VirtualControlLoopEvent();
- onsetEvent.closedLoopControlName = "closedLoopControlName-Test";
- onsetEvent.requestID = UUID.randomUUID();
- onsetEvent.closedLoopEventClient = "tca.instance00001";
- onsetEvent.target_type = ControlLoopTargetType.VNF;
- onsetEvent.target = "generic-vnf.vnf-name";
- onsetEvent.from = "DCAE";
- onsetEvent.closedLoopAlarmStart = Instant.now();
- onsetEvent.AAI = new HashMap<>();
- onsetEvent.AAI.put("generic-vnf.vnf-name", "fw0001vm001fw001");
- onsetEvent.closedLoopEventStatus = ControlLoopEventStatus.ONSET;
+ onsetEvent.setClosedLoopControlName("closedLoopControlName-Test");
+ onsetEvent.setRequestID(UUID.randomUUID());
+ onsetEvent.setClosedLoopEventClient("tca.instance00001");
+ onsetEvent.setTargetType(ControlLoopTargetType.VNF);
+ onsetEvent.setTarget("generic-vnf.vnf-name");
+ onsetEvent.setFrom("DCAE");
+ onsetEvent.setClosedLoopAlarmStart(Instant.now());
+ onsetEvent.setAAI(new HashMap<>());
+ onsetEvent.getAAI().put("generic-vnf.vnf-name", "fw0001vm001fw001");
+ onsetEvent.setClosedLoopEventStatus(ControlLoopEventStatus.ONSET);
/* Construct an operation with an APPC actor and ModifyConfig operation. */
operation = new ControlLoopOperation();
- operation.actor = "APPC";
- operation.operation = "ModifyConfig";
- operation.target = "VNF";
- operation.end = Instant.now();
- operation.subRequestId = "1";
+ operation.setActor("APPC");
+ operation.setOperation("ModifyConfig");
+ operation.setTarget("VNF");
+ operation.setEnd(Instant.now());
+ operation.setSubRequestId("1");
/* Construct a policy specifying to modify configuration. */
policy = new Policy();
@@ -123,7 +123,7 @@ public class AppcServiceProviderTest {
/* A common header is required and cannot be null */
assertNotNull(appcRequest.getCommonHeader());
- assertEquals(appcRequest.getCommonHeader().getRequestID(), onsetEvent.requestID);
+ assertEquals(appcRequest.getCommonHeader().getRequestID(), onsetEvent.getRequestID());
/* An action is required and cannot be null */
assertNotNull(appcRequest.getAction());
diff --git a/controlloop/common/actors/actor.appclcm/src/main/java/org/onap/policy/controlloop/actor/appclcm/AppcLcmActorServiceProvider.java b/controlloop/common/actors/actor.appclcm/src/main/java/org/onap/policy/controlloop/actor/appclcm/AppcLcmActorServiceProvider.java
index 0f4a00423..8e416cb63 100644
--- a/controlloop/common/actors/actor.appclcm/src/main/java/org/onap/policy/controlloop/actor/appclcm/AppcLcmActorServiceProvider.java
+++ b/controlloop/common/actors/actor.appclcm/src/main/java/org/onap/policy/controlloop/actor/appclcm/AppcLcmActorServiceProvider.java
@@ -211,7 +211,7 @@ public class AppcLcmActorServiceProvider implements Actor {
*/
LCMRequestWrapper dmaapRequest = new LCMRequestWrapper();
dmaapRequest.setVersion("2.0");
- dmaapRequest.setCorrelationId(onset.requestID + "-" + operation.subRequestId);
+ dmaapRequest.setCorrelationId(onset.getRequestID() + "-" + operation.getSubRequestId());
dmaapRequest.setRpcName(policy.getRecipe().toLowerCase());
dmaapRequest.setType("request");
@@ -220,9 +220,9 @@ public class AppcLcmActorServiceProvider implements Actor {
/* The common header is a required field for all APPC requests. */
LCMCommonHeader requestCommonHeader = new LCMCommonHeader();
- requestCommonHeader.setOriginatorId(onset.requestID.toString());
- requestCommonHeader.setRequestId(onset.requestID);
- requestCommonHeader.setSubRequestId(operation.subRequestId);
+ requestCommonHeader.setOriginatorId(onset.getRequestID().toString());
+ requestCommonHeader.setRequestId(onset.getRequestID());
+ requestCommonHeader.setSubRequestId(operation.getSubRequestId());
appcRequest.setCommonHeader(requestCommonHeader);
diff --git a/controlloop/common/actors/actor.appclcm/src/test/java/org/onap/policy/controlloop/actor/appclcm/AppcLcmServiceProviderTest.java b/controlloop/common/actors/actor.appclcm/src/test/java/org/onap/policy/controlloop/actor/appclcm/AppcLcmServiceProviderTest.java
index d446968ef..b498566da 100644
--- a/controlloop/common/actors/actor.appclcm/src/test/java/org/onap/policy/controlloop/actor/appclcm/AppcLcmServiceProviderTest.java
+++ b/controlloop/common/actors/actor.appclcm/src/test/java/org/onap/policy/controlloop/actor/appclcm/AppcLcmServiceProviderTest.java
@@ -66,24 +66,24 @@ public class AppcLcmServiceProviderTest {
* generic-vnf.vnf-id and a target type of VM.
*/
onsetEvent = new VirtualControlLoopEvent();
- onsetEvent.closedLoopControlName = "closedLoopControlName-Test";
- onsetEvent.requestID = UUID.randomUUID();
- onsetEvent.closedLoopEventClient = "tca.instance00001";
- onsetEvent.target_type = ControlLoopTargetType.VM;
- onsetEvent.target = "generic-vnf.vnf-name";
- onsetEvent.from = "DCAE";
- onsetEvent.closedLoopAlarmStart = Instant.now();
- onsetEvent.AAI = new HashMap<>();
- onsetEvent.AAI.put("generic-vnf.vnf-name", "fw0001vm001fw001");
- onsetEvent.closedLoopEventStatus = ControlLoopEventStatus.ONSET;
+ onsetEvent.setClosedLoopControlName("closedLoopControlName-Test");
+ onsetEvent.setRequestID(UUID.randomUUID());
+ onsetEvent.setClosedLoopEventClient("tca.instance00001");
+ onsetEvent.setTargetType(ControlLoopTargetType.VM);
+ onsetEvent.setTarget("generic-vnf.vnf-name");
+ onsetEvent.setFrom("DCAE");
+ onsetEvent.setClosedLoopAlarmStart(Instant.now());
+ onsetEvent.setAAI(new HashMap<>());
+ onsetEvent.getAAI().put("generic-vnf.vnf-name", "fw0001vm001fw001");
+ onsetEvent.setClosedLoopEventStatus(ControlLoopEventStatus.ONSET);
/* Construct an operation with an APPC actor and restart operation. */
operation = new ControlLoopOperation();
- operation.actor = "APPC";
- operation.operation = "Restart";
- operation.target = "VM";
- operation.end = Instant.now();
- operation.subRequestId = "1";
+ operation.setActor("APPC");
+ operation.setOperation("Restart");
+ operation.setTarget("VM");
+ operation.setEnd(Instant.now());
+ operation.setSubRequestId("1");
/* Construct a policy specifying to restart vm. */
policy = new Policy();
@@ -98,13 +98,13 @@ public class AppcLcmServiceProviderTest {
/* A sample DMAAP request wrapper. */
dmaapRequest = new LCMRequestWrapper();
- dmaapRequest.setCorrelationId(onsetEvent.requestID.toString() + "-" + "1");
+ dmaapRequest.setCorrelationId(onsetEvent.getRequestID().toString() + "-" + "1");
dmaapRequest.setRpcName(policy.getRecipe().toLowerCase());
dmaapRequest.setType("request");
/* A sample DMAAP response wrapper */
dmaapResponse = new LCMResponseWrapper();
- dmaapResponse.setCorrelationId(onsetEvent.requestID.toString() + "-" + "1");
+ dmaapResponse.setCorrelationId(onsetEvent.getRequestID().toString() + "-" + "1");
dmaapResponse.setRpcName(policy.getRecipe().toLowerCase());
dmaapResponse.setType("response");
@@ -125,9 +125,9 @@ public class AppcLcmServiceProviderTest {
appcRequest.setActionIdentifiers(actionIdentifiers);
LCMCommonHeader commonHeader = new LCMCommonHeader();
- commonHeader.setRequestId(onsetEvent.requestID);
+ commonHeader.setRequestId(onsetEvent.getRequestID());
commonHeader.setSubRequestId("1");
- commonHeader.setOriginatorId(onsetEvent.requestID.toString());
+ commonHeader.setOriginatorId(onsetEvent.getRequestID().toString());
appcRequest.setCommonHeader(commonHeader);
@@ -184,7 +184,7 @@ public class AppcLcmServiceProviderTest {
/* A common header is required and cannot be null */
assertNotNull(appcRequest.getCommonHeader());
- assertEquals(appcRequest.getCommonHeader().getRequestId(), onsetEvent.requestID);
+ assertEquals(appcRequest.getCommonHeader().getRequestId(), onsetEvent.getRequestID());
/* An action is required and cannot be null */
assertNotNull(appcRequest.getAction());
diff --git a/controlloop/common/actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/SOActorServiceProvider.java b/controlloop/common/actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/SOActorServiceProvider.java
index ad27a0201..6fe1c7f36 100644
--- a/controlloop/common/actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/SOActorServiceProvider.java
+++ b/controlloop/common/actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/SOActorServiceProvider.java
@@ -158,7 +158,7 @@ public class SOActorServiceProvider implements Actor {
//
Map<String, Map<String, String>> aainqinstancefiltermap = new HashMap<>();
Map<String, String> aainqinstancefiltermapitem = new HashMap<>();
- aainqinstancefiltermapitem.put("vserver-name", onset.AAI.get("vserver.vserver-name")); // TO DO: get vserver.vname from dcae onset.AAI.get("vserver.vserver-name")
+ aainqinstancefiltermapitem.put("vserver-name", onset.getAAI().get("vserver.vserver-name")); // TO DO: get vserver.vname from dcae onset.AAI.get("vserver.vserver-name")
aainqinstancefiltermap.put("vserver", aainqinstancefiltermapitem);
aainqinstancefilter.getInstanceFilter().add(aainqinstancefiltermap);
aainqrequest.setInstanceFilters(aainqinstancefilter);
@@ -186,7 +186,7 @@ public class SOActorServiceProvider implements Actor {
//***** send the request *****\\
AAINQResponse aainqresponse = new AAIManager(new RESTManager()).postQuery(aaiUrl, aaiUsername, aaiPassword,
- aainqrequest, onset.requestID);
+ aainqrequest, onset.getRequestID());
// Check AAI response
if (aainqresponse == null) {
@@ -196,7 +196,7 @@ public class SOActorServiceProvider implements Actor {
return null;
} else {
// Create AAINQResponseWrapper
- AAINQResponseWrapper aainqResponseWrapper = new AAINQResponseWrapper(onset.requestID, aainqresponse);
+ AAINQResponseWrapper aainqResponseWrapper = new AAINQResponseWrapper(onset.getRequestID(), aainqresponse);
// insert aainqResponseWrapper to memory -- Is this needed?
// insert(aainqResponseWrapper);
diff --git a/controlloop/common/actors/actor.vfc/src/main/java/org/onap/policy/controlloop/actor/vfc/VFCActorServiceProvider.java b/controlloop/common/actors/actor.vfc/src/main/java/org/onap/policy/controlloop/actor/vfc/VFCActorServiceProvider.java
index efa3dba1f..dae60cb82 100644
--- a/controlloop/common/actors/actor.vfc/src/main/java/org/onap/policy/controlloop/actor/vfc/VFCActorServiceProvider.java
+++ b/controlloop/common/actors/actor.vfc/src/main/java/org/onap/policy/controlloop/actor/vfc/VFCActorServiceProvider.java
@@ -70,7 +70,7 @@ public class VFCActorServiceProvider implements Actor {
Policy policy, AAIGETVnfResponse vnfResponse) {
// Construct an VFC request
VFCRequest request = new VFCRequest();
- String serviceInstance = onset.AAI.get("service-instance.service-instance-id");
+ String serviceInstance = onset.getAAI().get("service-instance.service-instance-id");
if (serviceInstance == null || "".equals(serviceInstance))
{
AAIGETVnfResponse tempVnfResp = vnfResponse;
@@ -83,18 +83,18 @@ public class VFCActorServiceProvider implements Actor {
serviceInstance = tempVnfResp.getServiceId();
}
request.nsInstanceId = serviceInstance;
- request.requestId = onset.requestID;
+ request.requestId = onset.getRequestID();
request.healRequest = new VFCHealRequest();
- request.healRequest.vnfInstanceId = onset.AAI.get("generic-vnf.vnf-id");
- request.healRequest.cause = operation.message;
+ request.healRequest.vnfInstanceId = onset.getAAI().get("generic-vnf.vnf-id");
+ request.healRequest.cause = operation.getMessage();
request.healRequest.additionalParams = new VFCHealAdditionalParams();
switch (policy.getRecipe().toLowerCase()) {
case "restart":
request.healRequest.additionalParams.action = "restartvm";
request.healRequest.additionalParams.actionInfo = new VFCHealActionVmInfo();
- request.healRequest.additionalParams.actionInfo.vmid = onset.AAI.get("vserver.vserver-id");
- request.healRequest.additionalParams.actionInfo.vmname = onset.AAI.get("vserver.vserver-name");
+ request.healRequest.additionalParams.actionInfo.vmid = onset.getAAI().get("vserver.vserver-id");
+ request.healRequest.additionalParams.actionInfo.vmname = onset.getAAI().get("vserver.vserver-name");
break;
default:
return null;
@@ -105,9 +105,9 @@ public class VFCActorServiceProvider implements Actor {
private static AAIGETVnfResponse getAAIServiceInstance(VirtualControlLoopEvent event) {
AAIGETVnfResponse response = null;
- UUID requestID = event.requestID;
- String vnfName = event.AAI.get("generic-vnf.vnf-name");
- String vnfID = event.AAI.get("generic-vnf.vnf-id");
+ UUID requestID = event.getRequestID();
+ String vnfName = event.getAAI().get("generic-vnf.vnf-name");
+ String vnfID = event.getAAI().get("generic-vnf.vnf-id");
String aaiUrl = PolicyEngine.manager.getEnvironmentProperty("aai.url");
String aaiUsername = PolicyEngine.manager.getEnvironmentProperty("aai.username");
String aaiPassword = PolicyEngine.manager.getEnvironmentProperty("aai.password");