From b2a9a8adbcf036780bf47c5c94dbf65a088ab540 Mon Sep 17 00:00:00 2001 From: Liam Fallon Date: Thu, 18 Jan 2018 10:55:53 +0000 Subject: 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 --- .../actor/appc/APPCActorServiceProvider.java | 4 +-- .../actor/appc/AppcServiceProviderTest.java | 32 +++++++++++----------- 2 files changed, 18 insertions(+), 18 deletions(-) (limited to 'controlloop/common/actors/actor.appc') 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()); -- cgit 1.2.3-korg