From 59d71c593d295b2bd48a9971d89635f95759a0a2 Mon Sep 17 00:00:00 2001 From: Liam Fallon Date: Tue, 16 Jan 2018 18:42:01 +0000 Subject: Fix Sonar Technical Debt, Unit Test for APPC 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.appc Change-Id: If3db740bc146a09f8f7387f02c12b048ad00b201 Signed-off-by: Liam Fallon Issue-ID: POLICY-455 Signed-off-by: Liam Fallon --- .../eventmanager/ControlLoopOperationManager.java | 13 ++++++------- .../org/onap/policy/drools/impl/PolicyEngineJUnitImpl.java | 2 +- 2 files changed, 7 insertions(+), 8 deletions(-) (limited to 'controlloop/common/eventmanager/src') diff --git a/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManager.java b/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManager.java index 5084d4cbc..0ce3bc5c3 100644 --- a/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManager.java +++ b/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManager.java @@ -47,7 +47,6 @@ import org.onap.policy.controlloop.policy.Policy; import org.onap.policy.controlloop.policy.PolicyResult; import org.onap.policy.drools.system.PolicyEngine; import org.onap.policy.guard.Util; -import org.onap.policy.so.SOResponse; import org.onap.policy.so.SOResponseWrapper; import org.onap.policy.vfc.VFCResponse; import org.slf4j.Logger; @@ -324,7 +323,7 @@ public class ControlLoopOperationManager implements Serializable { // Integer operationAttempt = null; try { - operationAttempt = Integer.parseInt(appcResponse.CommonHeader.SubRequestID); + operationAttempt = Integer.parseInt(appcResponse.getCommonHeader().getSubRequestID()); } catch (NumberFormatException e) { // // We cannot tell what happened if this doesn't exist @@ -335,7 +334,7 @@ public class ControlLoopOperationManager implements Serializable { // // Sanity check the response message // - if (appcResponse.Status == null) { + if (appcResponse.getStatus() == null) { // // We cannot tell what happened if this doesn't exist // @@ -345,7 +344,7 @@ public class ControlLoopOperationManager implements Serializable { // // Get the Response Code // - ResponseCode code = ResponseCode.toResponseCode(appcResponse.Status.Code); + ResponseCode code = ResponseCode.toResponseCode(appcResponse.getStatus().getCode()); if (code == null) { // // We are unaware of this code @@ -370,7 +369,7 @@ public class ControlLoopOperationManager implements Serializable { // // We'll consider these two codes as exceptions // - this.completeOperation(operationAttempt, appcResponse.getStatus().Description, PolicyResult.FAILURE_EXCEPTION); + this.completeOperation(operationAttempt, appcResponse.getStatus().getDescription(), PolicyResult.FAILURE_EXCEPTION); if (this.policyResult != null && this.policyResult.equals(PolicyResult.FAILURE_TIMEOUT)) { return null; } @@ -379,7 +378,7 @@ public class ControlLoopOperationManager implements Serializable { // // // - this.completeOperation(operationAttempt, appcResponse.getStatus().Description, PolicyResult.SUCCESS); + this.completeOperation(operationAttempt, appcResponse.getStatus().getDescription(), PolicyResult.SUCCESS); if (this.policyResult != null && this.policyResult.equals(PolicyResult.FAILURE_TIMEOUT)) { return null; } @@ -388,7 +387,7 @@ public class ControlLoopOperationManager implements Serializable { // // // - this.completeOperation(operationAttempt, appcResponse.getStatus().Description, PolicyResult.FAILURE); + this.completeOperation(operationAttempt, appcResponse.getStatus().getDescription(), PolicyResult.FAILURE); if (this.policyResult != null && this.policyResult.equals(PolicyResult.FAILURE_TIMEOUT)) { return null; } diff --git a/controlloop/common/eventmanager/src/main/java/org/onap/policy/drools/impl/PolicyEngineJUnitImpl.java b/controlloop/common/eventmanager/src/main/java/org/onap/policy/drools/impl/PolicyEngineJUnitImpl.java index a20731aaf..36feaaf93 100644 --- a/controlloop/common/eventmanager/src/main/java/org/onap/policy/drools/impl/PolicyEngineJUnitImpl.java +++ b/controlloop/common/eventmanager/src/main/java/org/onap/policy/drools/impl/PolicyEngineJUnitImpl.java @@ -74,7 +74,7 @@ public class PolicyEngineJUnitImpl implements PolicyEngine { } if (obj instanceof Request) { Request request = (Request) obj; - logger.debug("Request: {} subrequest {}", request.Action, request.CommonHeader.SubRequestID); + logger.debug("Request: {} subrequest {}", request.getAction(), request.getCommonHeader().getSubRequestID()); } else if (obj instanceof LCMRequestWrapper) { LCMRequestWrapper dmaapRequest = (LCMRequestWrapper) obj; -- cgit 1.2.3-korg