summaryrefslogtreecommitdiffstats
path: root/controlloop
diff options
context:
space:
mode:
Diffstat (limited to 'controlloop')
-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.java8
-rw-r--r--controlloop/common/actors/actor.appclcm/src/main/java/org/onap/policy/controlloop/actor/appclcm/AppcLcmActorServiceProvider.java42
-rw-r--r--controlloop/common/actors/actor.appclcm/src/test/java/org/onap/policy/controlloop/actor/appclcm/AppcLcmServiceProviderTest.java44
-rw-r--r--controlloop/common/actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/SOActorServiceProvider.java8
-rw-r--r--controlloop/common/actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/TestSOActorServiceProvider.java2
-rw-r--r--controlloop/common/actors/actor.vfc/src/main/java/org/onap/policy/controlloop/actor/vfc/VFCActorServiceProvider.java16
-rw-r--r--controlloop/common/actors/actor.vfc/src/test/java/org/onap/policy/controlloop/actor/vfc/TestVFCActorServiceProvider.java8
-rw-r--r--controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManager.java48
-rw-r--r--controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManager.java22
-rw-r--r--controlloop/common/eventmanager/src/main/java/org/onap/policy/drools/impl/PolicyEngineJUnitImpl.java8
-rw-r--r--controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManagerTest.java170
-rw-r--r--controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManagerTest.java114
-rw-r--r--controlloop/common/eventmanager/src/test/java/org/onap/policy/drools/DroolsPolicyEngineTest.java14
-rw-r--r--controlloop/common/feature-controlloop-trans/src/main/java/org/onap/policy/drools/apps/controlloop/feature/trans/ControlLoopMetrics.java131
-rw-r--r--controlloop/common/feature-controlloop-trans/src/test/java/org/onap/policy/drools/apps/controlloop/feature/trans/ControlLoopMetricsFeatureTest.java24
-rw-r--r--controlloop/common/model-impl/appc/pom.xml41
-rw-r--r--controlloop/common/model-impl/appc/src/main/java/org/onap/policy/appc/CommonHeader.java350
-rw-r--r--controlloop/common/model-impl/appc/src/main/java/org/onap/policy/appc/Request.java263
-rw-r--r--controlloop/common/model-impl/appc/src/main/java/org/onap/policy/appc/Response.java202
-rw-r--r--controlloop/common/model-impl/appc/src/main/java/org/onap/policy/appc/ResponseCode.java75
-rw-r--r--controlloop/common/model-impl/appc/src/main/java/org/onap/policy/appc/ResponseStatus.java162
-rw-r--r--controlloop/common/model-impl/appc/src/main/java/org/onap/policy/appc/ResponseValue.java85
-rw-r--r--controlloop/common/model-impl/appc/src/main/java/org/onap/policy/appc/util/Serialization.java96
-rw-r--r--controlloop/common/model-impl/appc/src/test/java/org/onap/policy/appc/TestCommonHeader.java136
-rw-r--r--controlloop/common/model-impl/appc/src/test/java/org/onap/policy/appc/TestEnums.java87
-rw-r--r--controlloop/common/model-impl/appc/src/test/java/org/onap/policy/appc/TestRequest.java106
-rw-r--r--controlloop/common/model-impl/appc/src/test/java/org/onap/policy/appc/TestResponse.java82
-rw-r--r--controlloop/common/model-impl/appc/src/test/java/org/onap/policy/appc/TestResponseStatus.java52
-rw-r--r--controlloop/common/model-impl/appc/src/test/java/org/onap/policy/appc/util/TestSerialization.java49
-rw-r--r--controlloop/common/model-impl/appclcm/pom.xml41
-rw-r--r--controlloop/common/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/LCMResponseStatus.java107
-rw-r--r--controlloop/common/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/LcmCommonHeader.java (renamed from controlloop/common/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/LCMCommonHeader.java)59
-rw-r--r--controlloop/common/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/LcmRequest.java (renamed from controlloop/common/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/LCMRequest.java)42
-rw-r--r--controlloop/common/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/LcmRequestWrapper.java (renamed from controlloop/common/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/LCMRequestWrapper.java)27
-rw-r--r--controlloop/common/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/LcmResponse.java (renamed from controlloop/common/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/LCMResponse.java)45
-rw-r--r--controlloop/common/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/LcmResponseCode.java (renamed from controlloop/common/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/LCMResponseCode.java)37
-rw-r--r--controlloop/common/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/LcmResponseStatus.java116
-rw-r--r--controlloop/common/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/LcmResponseWrapper.java (renamed from controlloop/common/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/LCMResponseWrapper.java)29
-rw-r--r--controlloop/common/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/LcmWrapper.java (renamed from controlloop/common/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/LCMWrapper.java)51
-rw-r--r--controlloop/common/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/util/Serialization.java121
-rw-r--r--controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/AppcLcmTest.java136
-rw-r--r--controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/LCMResponseTest.java109
-rw-r--r--controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/LcmResponseTest.java113
-rw-r--r--controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/TestLCMCommonHeader.java159
-rw-r--r--controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/TestLCMRequest.java107
-rw-r--r--controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/TestLCMRequestWrapper.java62
-rw-r--r--controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/TestLCMResonseCode.java54
-rw-r--r--controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/TestLCMResponseWrapper.java61
-rw-r--r--controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/TestLCMWrapper.java111
-rw-r--r--controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/TestLcmCommonHeader.java143
-rw-r--r--controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/TestLcmRequest.java111
-rw-r--r--controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/TestLcmRequestWrapper.java66
-rw-r--r--controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/TestLcmResonseCode.java55
-rw-r--r--controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/TestLcmResponseStatus.java (renamed from controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/TestLCMResponseStatus.java)46
-rw-r--r--controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/TestLcmResponseWrapper.java65
-rw-r--r--controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/TestLcmWrapper.java115
-rw-r--r--controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/util/TestSerialization.java51
-rw-r--r--controlloop/common/model-impl/events/pom.xml41
-rw-r--r--controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopEvent.java259
-rw-r--r--controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopEventStatus.java64
-rw-r--r--controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopNotification.java303
-rw-r--r--controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopNotificationType.java96
-rw-r--r--controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopOperation.java380
-rw-r--r--controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopOperationWrapper.java56
-rw-r--r--controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopTargetType.java68
-rw-r--r--controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/PhysicalControlLoopEvent.java24
-rw-r--r--controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/PhysicalControlLoopNotification.java26
-rw-r--r--controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/VirtualControlLoopEvent.java86
-rw-r--r--controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/VirtualControlLoopNotification.java85
-rw-r--r--controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/params/ControlLoopParams.java7
-rw-r--r--controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/util/Serialization.java188
-rw-r--r--controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/config/__artifactId__-controller.properties6
-rw-r--r--controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/config/__artifactId__-controller.rest.json8
-rw-r--r--controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/resources/__closedLoopControlName__.drl136
-rw-r--r--controlloop/templates/archetype-cl-beijing/src/main/resources/archetype-resources/src/main/config/__artifactId__-controller.properties6
-rw-r--r--controlloop/templates/archetype-cl-beijing/src/main/resources/archetype-resources/src/main/config/__artifactId__-controller.rest.json8
-rw-r--r--controlloop/templates/archetype-cl-beijing/src/main/resources/archetype-resources/src/main/resources/__closedLoopControlName__.drl128
-rw-r--r--controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/ControlLoopFailureTest.java260
-rw-r--r--controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VCPEControlLoopTest.java282
-rw-r--r--controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VDNSControlLoopTest.java299
-rw-r--r--controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VFCControlLoopTest.java346
-rw-r--r--controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VFWControlLoopTest.java315
83 files changed, 4193 insertions, 3972 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 e9cd70c42..8960ee022 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
@@ -93,8 +93,8 @@ public class APPCActorServiceProvider implements Actor {
*/
Request request = new Request();
request.setCommonHeader(new CommonHeader());
- request.getCommonHeader().setRequestID(onset.getRequestID());
- request.getCommonHeader().setSubRequestID(operation.getSubRequestId());
+ 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 673a23c32..f081e8105 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
@@ -64,14 +64,14 @@ public class AppcServiceProviderTest {
*/
onsetEvent = new VirtualControlLoopEvent();
onsetEvent.setClosedLoopControlName("closedLoopControlName-Test");
- onsetEvent.setRequestID(UUID.randomUUID());
+ 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.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. */
@@ -132,7 +132,7 @@ public class AppcServiceProviderTest {
/* A common header is required and cannot be null */
assertNotNull(appcRequest.getCommonHeader());
- assertEquals(appcRequest.getCommonHeader().getRequestID(), onsetEvent.getRequestID());
+ 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 0db66c5af..c370f153f 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
@@ -39,12 +39,12 @@ import org.onap.policy.aai.AaiNqQueryParameters;
import org.onap.policy.aai.AaiNqRequest;
import org.onap.policy.aai.AaiNqResponse;
import org.onap.policy.aai.util.AaiException;
-import org.onap.policy.appclcm.LCMCommonHeader;
-import org.onap.policy.appclcm.LCMRequest;
-import org.onap.policy.appclcm.LCMRequestWrapper;
-import org.onap.policy.appclcm.LCMResponse;
-import org.onap.policy.appclcm.LCMResponseCode;
-import org.onap.policy.appclcm.LCMResponseWrapper;
+import org.onap.policy.appclcm.LcmCommonHeader;
+import org.onap.policy.appclcm.LcmRequest;
+import org.onap.policy.appclcm.LcmRequestWrapper;
+import org.onap.policy.appclcm.LcmResponse;
+import org.onap.policy.appclcm.LcmResponseCode;
+import org.onap.policy.appclcm.LcmResponseWrapper;
import org.onap.policy.controlloop.ControlLoopOperation;
import org.onap.policy.controlloop.VirtualControlLoopEvent;
import org.onap.policy.controlloop.actorserviceprovider.spi.Actor;
@@ -187,7 +187,7 @@ public class AppcLcmActorServiceProvider implements Actor {
* Policy GUI/API
* @return an APPC request conforming to the lcm API using the DMAAP wrapper
*/
- public static LCMRequestWrapper constructRequest(VirtualControlLoopEvent onset, ControlLoopOperation operation,
+ public static LcmRequestWrapper constructRequest(VirtualControlLoopEvent onset, ControlLoopOperation operation,
Policy policy, String targetVnf) {
/* Construct an APPC request using LCM Model */
@@ -196,19 +196,19 @@ public class AppcLcmActorServiceProvider implements Actor {
* The actual LCM request is placed in a wrapper used to send through dmaap. The current
* version is 2.0 as of R1.
*/
- LCMRequestWrapper dmaapRequest = new LCMRequestWrapper();
+ LcmRequestWrapper dmaapRequest = new LcmRequestWrapper();
dmaapRequest.setVersion("2.0");
- dmaapRequest.setCorrelationId(onset.getRequestID() + "-" + operation.getSubRequestId());
+ dmaapRequest.setCorrelationId(onset.getRequestId() + "-" + operation.getSubRequestId());
dmaapRequest.setRpcName(policy.getRecipe().toLowerCase());
dmaapRequest.setType("request");
/* This is the actual request that is placed in the dmaap wrapper. */
- final LCMRequest appcRequest = new LCMRequest();
+ final LcmRequest appcRequest = new LcmRequest();
/* The common header is a required field for all APPC requests. */
- LCMCommonHeader requestCommonHeader = new LCMCommonHeader();
- requestCommonHeader.setOriginatorId(onset.getRequestID().toString());
- requestCommonHeader.setRequestId(onset.getRequestID());
+ LcmCommonHeader requestCommonHeader = new LcmCommonHeader();
+ requestCommonHeader.setOriginatorId(onset.getRequestId().toString());
+ requestCommonHeader.setRequestId(onset.getRequestId());
requestCommonHeader.setSubRequestId(operation.getSubRequestId());
appcRequest.setCommonHeader(requestCommonHeader);
@@ -276,9 +276,9 @@ public class AppcLcmActorServiceProvider implements Actor {
*
* @return an key-value pair that contains the Policy result and APPC response message
*/
- public static SimpleEntry<PolicyResult, String> processResponse(LCMResponseWrapper dmaapResponse) {
+ public static SimpleEntry<PolicyResult, String> processResponse(LcmResponseWrapper dmaapResponse) {
/* The actual APPC response is inside the wrapper's body field. */
- LCMResponse appcResponse = dmaapResponse.getBody();
+ LcmResponse appcResponse = dmaapResponse.getBody();
/* The message returned in the APPC response. */
String message;
@@ -293,7 +293,7 @@ public class AppcLcmActorServiceProvider implements Actor {
}
/* If there is no code, Policy cannot determine if the request was successful. */
- String responseValue = LCMResponseCode.toResponseValue(appcResponse.getStatus().getCode());
+ String responseValue = LcmResponseCode.toResponseValue(appcResponse.getStatus().getCode());
if (responseValue == null) {
message = "Policy was unable to parse APP-C response status code field.";
return new AbstractMap.SimpleEntry<>(PolicyResult.FAILURE_EXCEPTION, message);
@@ -304,18 +304,18 @@ public class AppcLcmActorServiceProvider implements Actor {
/* Maps the APPC response result to a Policy result. */
switch (responseValue) {
- case LCMResponseCode.ACCEPTED:
+ case LcmResponseCode.ACCEPTED:
/* Nothing to do if code is accept, continue processing */
result = null;
break;
- case LCMResponseCode.SUCCESS:
+ case LcmResponseCode.SUCCESS:
result = PolicyResult.SUCCESS;
break;
- case LCMResponseCode.FAILURE:
+ case LcmResponseCode.FAILURE:
result = PolicyResult.FAILURE;
break;
- case LCMResponseCode.REJECT:
- case LCMResponseCode.ERROR:
+ case LcmResponseCode.REJECT:
+ case LcmResponseCode.ERROR:
default:
result = PolicyResult.FAILURE_EXCEPTION;
}
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 72d43d318..4fb6ac4b9 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
@@ -33,11 +33,11 @@ import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import org.onap.policy.aai.util.AaiException;
-import org.onap.policy.appclcm.LCMCommonHeader;
-import org.onap.policy.appclcm.LCMRequest;
-import org.onap.policy.appclcm.LCMRequestWrapper;
-import org.onap.policy.appclcm.LCMResponse;
-import org.onap.policy.appclcm.LCMResponseWrapper;
+import org.onap.policy.appclcm.LcmCommonHeader;
+import org.onap.policy.appclcm.LcmRequest;
+import org.onap.policy.appclcm.LcmRequestWrapper;
+import org.onap.policy.appclcm.LcmResponse;
+import org.onap.policy.appclcm.LcmResponseWrapper;
import org.onap.policy.controlloop.ControlLoopEventStatus;
import org.onap.policy.controlloop.ControlLoopOperation;
import org.onap.policy.controlloop.ControlLoopTargetType;
@@ -59,8 +59,8 @@ public class AppcLcmServiceProviderTest {
private static VirtualControlLoopEvent onsetEvent;
private static ControlLoopOperation operation;
private static Policy policy;
- private static LCMRequestWrapper dmaapRequest;
- private static LCMResponseWrapper dmaapResponse;
+ private static LcmRequestWrapper dmaapRequest;
+ private static LcmResponseWrapper dmaapResponse;
static {
/*
@@ -69,14 +69,14 @@ public class AppcLcmServiceProviderTest {
*/
onsetEvent = new VirtualControlLoopEvent();
onsetEvent.setClosedLoopControlName("closedLoopControlName-Test");
- onsetEvent.setRequestID(UUID.randomUUID());
+ 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.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. */
@@ -99,14 +99,14 @@ public class AppcLcmServiceProviderTest {
policy.setTimeout(300);
/* A sample DMAAP request wrapper. */
- dmaapRequest = new LCMRequestWrapper();
- dmaapRequest.setCorrelationId(onsetEvent.getRequestID().toString() + "-" + "1");
+ dmaapRequest = new LcmRequestWrapper();
+ 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.getRequestID().toString() + "-" + "1");
+ dmaapResponse = new LcmResponseWrapper();
+ dmaapResponse.setCorrelationId(onsetEvent.getRequestId().toString() + "-" + "1");
dmaapResponse.setRpcName(policy.getRecipe().toLowerCase());
dmaapResponse.setType("response");
@@ -116,7 +116,7 @@ public class AppcLcmServiceProviderTest {
PolicyEngine.manager.setEnvironmentProperty("aai.password", "AAI");
/* A sample APPC LCM request. */
- LCMRequest appcRequest = new LCMRequest();
+ LcmRequest appcRequest = new LcmRequest();
/* The following code constructs a sample APPC LCM Request */
appcRequest.setAction("restart");
@@ -126,10 +126,10 @@ public class AppcLcmServiceProviderTest {
appcRequest.setActionIdentifiers(actionIdentifiers);
- LCMCommonHeader commonHeader = new LCMCommonHeader();
- commonHeader.setRequestId(onsetEvent.getRequestID());
+ LcmCommonHeader commonHeader = new LcmCommonHeader();
+ commonHeader.setRequestId(onsetEvent.getRequestId());
commonHeader.setSubRequestId("1");
- commonHeader.setOriginatorId(onsetEvent.getRequestID().toString());
+ commonHeader.setOriginatorId(onsetEvent.getRequestId().toString());
appcRequest.setCommonHeader(commonHeader);
@@ -138,7 +138,7 @@ public class AppcLcmServiceProviderTest {
dmaapRequest.setBody(appcRequest);
/* The following code constructs a sample APPC LCM Response */
- LCMResponse appcResponse = new LCMResponse(appcRequest);
+ LcmResponse appcResponse = new LcmResponse(appcRequest);
appcResponse.getStatus().setCode(400);
appcResponse.getStatus().setMessage("Restart Successful");
@@ -171,7 +171,7 @@ public class AppcLcmServiceProviderTest {
@Test
public void constructRestartRequestTest() {
- LCMRequestWrapper dmaapRequest =
+ LcmRequestWrapper dmaapRequest =
AppcLcmActorServiceProvider.constructRequest(onsetEvent, operation, policy, "vnf01");
/* The service provider must return a non null DMAAP request wrapper */
@@ -183,11 +183,11 @@ public class AppcLcmServiceProviderTest {
/* The DMAAP wrapper's body field cannot be null */
assertNotNull(dmaapRequest.getBody());
- LCMRequest appcRequest = dmaapRequest.getBody();
+ LcmRequest appcRequest = dmaapRequest.getBody();
/* A common header is required and cannot be null */
assertNotNull(appcRequest.getCommonHeader());
- assertEquals(appcRequest.getCommonHeader().getRequestId(), onsetEvent.getRequestID());
+ 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 231b8fae5..820910e9b 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
@@ -171,7 +171,7 @@ public class SOActorServiceProvider implements Actor {
// Construct SO Request
SORequest request = new SORequest();
- request.setRequestId(onset.getRequestID());
+ request.setRequestId(onset.getRequestId());
request.setRequestDetails(new SORequestDetails());
request.getRequestDetails().setModelInfo(new SOModelInfo());
request.getRequestDetails().setCloudConfiguration(new SOCloudConfiguration());
@@ -325,7 +325,7 @@ public class SOActorServiceProvider implements Actor {
Map<String, Map<String, String>> aaiNqInstanceFilterMap = new HashMap<>();
Map<String, String> aaiNqInstanceFilterMapItem = new HashMap<>();
// TO DO: get vserver.vname from dcae onset.AAI.get("vserver.vserver-name")
- aaiNqInstanceFilterMapItem.put("vserver-name", onset.getAAI().get("vserver.vserver-name"));
+ aaiNqInstanceFilterMapItem.put("vserver-name", onset.getAai().get("vserver.vserver-name"));
aaiNqInstanceFilterMap.put("vserver", aaiNqInstanceFilterMapItem);
aaiNqInstanceFilter.getInstanceFilter().add(aaiNqInstanceFilterMap);
aaiNqRequest.setInstanceFilters(aaiNqInstanceFilter);
@@ -336,7 +336,7 @@ public class SOActorServiceProvider implements Actor {
AaiNqResponse aaiNqResponse = new AaiManager(new RESTManager()).postQuery(getPeManagerEnvProperty("aai.url"),
getPeManagerEnvProperty("aai.username"), getPeManagerEnvProperty("aai.password"), aaiNqRequest,
- onset.getRequestID());
+ onset.getRequestId());
// Check AAI response
if (aaiNqResponse == null) {
@@ -345,7 +345,7 @@ public class SOActorServiceProvider implements Actor {
}
// Create AAINQResponseWrapper
- AaiNqResponseWrapper aaiNqResponseWrapper = new AaiNqResponseWrapper(onset.getRequestID(), aaiNqResponse);
+ AaiNqResponseWrapper aaiNqResponseWrapper = new AaiNqResponseWrapper(onset.getRequestId(), aaiNqResponse);
if (logger.isDebugEnabled()) {
logger.debug("AAI Named Query Response: ");
diff --git a/controlloop/common/actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/TestSOActorServiceProvider.java b/controlloop/common/actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/TestSOActorServiceProvider.java
index 108962c22..0ef7c9f32 100644
--- a/controlloop/common/actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/TestSOActorServiceProvider.java
+++ b/controlloop/common/actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/TestSOActorServiceProvider.java
@@ -66,7 +66,7 @@ public class TestSOActorServiceProvider {
final ControlLoopOperation operation = new ControlLoopOperation();
final UUID requestId = UUID.randomUUID();
- onset.setRequestID(requestId);
+ onset.setRequestId(requestId);
PolicyEngine.manager.setEnvironmentProperty("aai.url", "http://localhost:6666");
PolicyEngine.manager.setEnvironmentProperty("aai.username", "AAI");
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 83f44a1ed..b8aaf854a 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
@@ -90,7 +90,7 @@ public class VFCActorServiceProvider implements Actor {
// Construct an VFC request
VFCRequest request = new VFCRequest();
- String serviceInstance = onset.getAAI().get("service-instance.service-instance-id");
+ String serviceInstance = onset.getAai().get("service-instance.service-instance-id");
if (serviceInstance == null || "".equals(serviceInstance)) {
AaiGetVnfResponse tempVnfResp = vnfResponse;
if (tempVnfResp == null) { // if the response is null, we haven't queried
@@ -103,9 +103,9 @@ public class VFCActorServiceProvider implements Actor {
serviceInstance = tempVnfResp.getServiceId();
}
request.setNSInstanceId(serviceInstance);
- request.setRequestId(onset.getRequestID());
+ request.setRequestId(onset.getRequestId());
request.setHealRequest(new VFCHealRequest());
- request.getHealRequest().setVnfInstanceId(onset.getAAI().get("generic-vnf.vnf-id"));
+ request.getHealRequest().setVnfInstanceId(onset.getAai().get("generic-vnf.vnf-id"));
request.getHealRequest().setCause(operation.getMessage());
request.getHealRequest().setAdditionalParams(new VFCHealAdditionalParams());
@@ -113,9 +113,9 @@ public class VFCActorServiceProvider implements Actor {
request.getHealRequest().getAdditionalParams().setAction("restartvm");
request.getHealRequest().getAdditionalParams().setActionInfo(new VFCHealActionVmInfo());
request.getHealRequest().getAdditionalParams().getActionInfo()
- .setVmid(onset.getAAI().get("vserver.vserver-id"));
+ .setVmid(onset.getAai().get("vserver.vserver-id"));
request.getHealRequest().getAdditionalParams().getActionInfo()
- .setVmname(onset.getAAI().get("vserver.vserver-name"));
+ .setVmname(onset.getAai().get("vserver.vserver-name"));
} else {
return null;
}
@@ -124,9 +124,9 @@ public class VFCActorServiceProvider implements Actor {
private static AaiGetVnfResponse getAaiServiceInstance(VirtualControlLoopEvent event) {
AaiGetVnfResponse response = null;
- UUID requestId = event.getRequestID();
- String vnfName = event.getAAI().get("generic-vnf.vnf-name");
- String vnfId = event.getAAI().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");
diff --git a/controlloop/common/actors/actor.vfc/src/test/java/org/onap/policy/controlloop/actor/vfc/TestVFCActorServiceProvider.java b/controlloop/common/actors/actor.vfc/src/test/java/org/onap/policy/controlloop/actor/vfc/TestVFCActorServiceProvider.java
index 8c0ab22eb..86b0aeef7 100644
--- a/controlloop/common/actors/actor.vfc/src/test/java/org/onap/policy/controlloop/actor/vfc/TestVFCActorServiceProvider.java
+++ b/controlloop/common/actors/actor.vfc/src/test/java/org/onap/policy/controlloop/actor/vfc/TestVFCActorServiceProvider.java
@@ -68,7 +68,7 @@ public class TestVFCActorServiceProvider {
assertNull(VFCActorServiceProvider.constructRequest(onset, operation, policy, null));
- onset.getAAI().put("generic-vnf.vnf-id", "dorothy.gale.1939");
+ onset.getAai().put("generic-vnf.vnf-id", "dorothy.gale.1939");
assertNull(VFCActorServiceProvider.constructRequest(onset, operation, policy, null));
PolicyEngine.manager.setEnvironmentProperty("aai.url", "http://localhost:6666");
@@ -77,17 +77,17 @@ public class TestVFCActorServiceProvider {
assertNull(VFCActorServiceProvider.constructRequest(onset, operation, policy, null));
UUID requestId = UUID.randomUUID();
- onset.setRequestID(requestId);
+ onset.setRequestId(requestId);
assertNull(VFCActorServiceProvider.constructRequest(onset, operation, policy, null));
- onset.getAAI().put("generic-vnf.vnf-name", "Dorothy");
+ onset.getAai().put("generic-vnf.vnf-name", "Dorothy");
PolicyEngine.manager.getEnvironment().remove("aai.password");
assertNull(VFCActorServiceProvider.constructRequest(onset, operation, policy, null));
PolicyEngine.manager.setEnvironmentProperty("aai.password", "AAI");
assertNull(VFCActorServiceProvider.constructRequest(onset, operation, policy, null));
- onset.getAAI().put("service-instance.service-instance-id", "");
+ onset.getAai().put("service-instance.service-instance-id", "");
assertNull(VFCActorServiceProvider.constructRequest(onset, operation, policy, null));
assertNull(VFCActorServiceProvider.constructRequest(onset, operation, policy, new AaiGetVnfResponse()));
diff --git a/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManager.java b/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManager.java
index 39a4886a2..92b618f42 100644
--- a/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManager.java
+++ b/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManager.java
@@ -457,7 +457,7 @@ public class ControlLoopEventManager implements LockCallback, Serializable {
//
LockResult<GuardResult, TargetLock> lockResult =
PolicyGuard.lockTarget(this.currentOperation.policy.getTarget().getType(),
- this.currentOperation.getTargetEntity(), this.onset.getRequestID(), this);
+ this.currentOperation.getTargetEntity(), this.onset.getRequestId(), this);
//
// Was it acquired?
//
@@ -613,7 +613,7 @@ public class ControlLoopEventManager implements LockCallback, Serializable {
if (event.getClosedLoopControlName() == null || event.getClosedLoopControlName().length() < 1) {
throw new ControlLoopException("No control loop name");
}
- if (event.getRequestID() == null) {
+ if (event.getRequestId() == null) {
throw new ControlLoopException("No request ID");
}
if (event.getClosedLoopEventStatus() == ControlLoopEventStatus.ABATED) {
@@ -627,11 +627,11 @@ public class ControlLoopEventManager implements LockCallback, Serializable {
&& !GENERIC_VNF_VNF_NAME.equalsIgnoreCase(event.getTarget())) {
throw new ControlLoopException("target field invalid - expecting VM_NAME or VNF_NAME");
}
- if (event.getAAI() == null) {
+ if (event.getAai() == null) {
throw new ControlLoopException("AAI is null");
}
- if (event.getAAI().get(GENERIC_VNF_VNF_ID) == null && event.getAAI().get(VSERVER_VSERVER_NAME) == null
- && event.getAAI().get(GENERIC_VNF_VNF_NAME) == null) {
+ if (event.getAai().get(GENERIC_VNF_VNF_ID) == null && event.getAai().get(VSERVER_VSERVER_NAME) == null
+ && event.getAai().get(GENERIC_VNF_VNF_NAME) == null) {
throw new ControlLoopException(
"generic-vnf.vnf-id or generic-vnf.vnf-name or vserver.vserver-name information missing");
}
@@ -644,16 +644,16 @@ public class ControlLoopEventManager implements LockCallback, Serializable {
* @throws AaiException if an error occurs retrieving information from A&AI
*/
public void queryAai(VirtualControlLoopEvent event) throws AaiException {
- if ((event.getAAI().get(VSERVER_IS_CLOSED_LOOP_DISABLED) != null
- || event.getAAI().get(GENERIC_VNF_IS_CLOSED_LOOP_DISABLED) != null) && isClosedLoopDisabled(event)) {
+ if ((event.getAai().get(VSERVER_IS_CLOSED_LOOP_DISABLED) != null
+ || event.getAai().get(GENERIC_VNF_IS_CLOSED_LOOP_DISABLED) != null) && isClosedLoopDisabled(event)) {
throw new AaiException("is-closed-loop-disabled is set to true on VServer or VNF");
}
try {
- if (event.getAAI().get(GENERIC_VNF_VNF_ID) != null || event.getAAI().get(GENERIC_VNF_VNF_NAME) != null) {
+ if (event.getAai().get(GENERIC_VNF_VNF_ID) != null || event.getAai().get(GENERIC_VNF_VNF_NAME) != null) {
vnfResponse = getAAIVnfInfo(event);
- processVNFResponse(vnfResponse, event.getAAI().get(GENERIC_VNF_VNF_ID) != null);
- } else if (event.getAAI().get(VSERVER_VSERVER_NAME) != null) {
+ processVNFResponse(vnfResponse, event.getAai().get(GENERIC_VNF_VNF_ID) != null);
+ } else if (event.getAai().get(VSERVER_VSERVER_NAME) != null) {
vserverResponse = getAAIVserverInfo(event);
processVServerResponse(vserverResponse);
}
@@ -714,16 +714,16 @@ public class ControlLoopEventManager implements LockCallback, Serializable {
* @return <code>true</code> if the contol loop is disabled, <code>false</code> otherwise
*/
public static boolean isClosedLoopDisabled(VirtualControlLoopEvent event) {
- if ("true".equalsIgnoreCase(event.getAAI().get(VSERVER_IS_CLOSED_LOOP_DISABLED))
- || "T".equalsIgnoreCase(event.getAAI().get(VSERVER_IS_CLOSED_LOOP_DISABLED))
- || "yes".equalsIgnoreCase(event.getAAI().get(VSERVER_IS_CLOSED_LOOP_DISABLED))
- || "Y".equalsIgnoreCase(event.getAAI().get(VSERVER_IS_CLOSED_LOOP_DISABLED))) {
+ if ("true".equalsIgnoreCase(event.getAai().get(VSERVER_IS_CLOSED_LOOP_DISABLED))
+ || "T".equalsIgnoreCase(event.getAai().get(VSERVER_IS_CLOSED_LOOP_DISABLED))
+ || "yes".equalsIgnoreCase(event.getAai().get(VSERVER_IS_CLOSED_LOOP_DISABLED))
+ || "Y".equalsIgnoreCase(event.getAai().get(VSERVER_IS_CLOSED_LOOP_DISABLED))) {
return true;
}
- return ("true".equalsIgnoreCase(event.getAAI().get(GENERIC_VNF_IS_CLOSED_LOOP_DISABLED))
- || "T".equalsIgnoreCase(event.getAAI().get(GENERIC_VNF_IS_CLOSED_LOOP_DISABLED))
- || "yes".equalsIgnoreCase(event.getAAI().get(GENERIC_VNF_IS_CLOSED_LOOP_DISABLED))
- || "Y".equalsIgnoreCase(event.getAAI().get(GENERIC_VNF_IS_CLOSED_LOOP_DISABLED)));
+ return ("true".equalsIgnoreCase(event.getAai().get(GENERIC_VNF_IS_CLOSED_LOOP_DISABLED))
+ || "T".equalsIgnoreCase(event.getAai().get(GENERIC_VNF_IS_CLOSED_LOOP_DISABLED))
+ || "yes".equalsIgnoreCase(event.getAai().get(GENERIC_VNF_IS_CLOSED_LOOP_DISABLED))
+ || "Y".equalsIgnoreCase(event.getAai().get(GENERIC_VNF_IS_CLOSED_LOOP_DISABLED)));
}
/**
@@ -734,9 +734,9 @@ public class ControlLoopEventManager implements LockCallback, Serializable {
* @throws ControlLoopException if an error occurs
*/
public static AaiGetVserverResponse getAAIVserverInfo(VirtualControlLoopEvent event) throws ControlLoopException {
- UUID requestId = event.getRequestID();
+ UUID requestId = event.getRequestId();
AaiGetVserverResponse response = null;
- String vserverName = event.getAAI().get(VSERVER_VSERVER_NAME);
+ String vserverName = event.getAai().get(VSERVER_VSERVER_NAME);
try {
if (vserverName != null) {
@@ -765,10 +765,10 @@ public class ControlLoopEventManager implements LockCallback, Serializable {
* @throws ControlLoopException if an error occurs
*/
public static AaiGetVnfResponse getAAIVnfInfo(VirtualControlLoopEvent event) throws ControlLoopException {
- UUID requestId = event.getRequestID();
+ UUID requestId = event.getRequestId();
AaiGetVnfResponse response = null;
- String vnfName = event.getAAI().get(GENERIC_VNF_VNF_NAME);
- String vnfId = event.getAAI().get(GENERIC_VNF_VNF_ID);
+ String vnfName = event.getAai().get(GENERIC_VNF_VNF_NAME);
+ String vnfId = event.getAai().get(GENERIC_VNF_VNF_ID);
aaiHostURL = PolicyEngine.manager.getEnvironmentProperty("aai.url");
aaiUser = PolicyEngine.manager.getEnvironmentProperty("aai.username");
@@ -811,7 +811,7 @@ public class ControlLoopEventManager implements LockCallback, Serializable {
@Override
public String toString() {
return "ControlLoopEventManager [closedLoopControlName=" + closedLoopControlName + ", requestID=" + requestID
- + ", processor=" + processor + ", onset=" + (onset != null ? onset.getRequestID() : "null")
+ + ", processor=" + processor + ", onset=" + (onset != null ? onset.getRequestId() : "null")
+ ", numOnsets=" + numOnsets + ", numAbatements=" + numAbatements + ", isActivated=" + isActivated
+ ", currentOperation=" + currentOperation + ", targetLock=" + targetLock + "]";
}
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 97eaf9048..7ef2a2e04 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
@@ -35,7 +35,7 @@ import org.eclipse.persistence.config.PersistenceUnitProperties;
import org.onap.policy.aai.util.AaiException;
import org.onap.policy.appc.Response;
import org.onap.policy.appc.ResponseCode;
-import org.onap.policy.appclcm.LCMResponseWrapper;
+import org.onap.policy.appclcm.LcmResponseWrapper;
import org.onap.policy.controlloop.ControlLoopEvent;
import org.onap.policy.controlloop.ControlLoopException;
import org.onap.policy.controlloop.ControlLoopOperation;
@@ -63,7 +63,7 @@ public class ControlLoopOperationManager implements Serializable {
@Override
public String toString() {
- return "ControlLoopOperationManager [onset=" + (onset != null ? onset.getRequestID() : "null") + ", policy="
+ return "ControlLoopOperationManager [onset=" + (onset != null ? onset.getRequestId() : "null") + ", policy="
+ (policy != null ? policy.getId() : "null") + ", attempts=" + attempts + ", policyResult="
+ policyResult + ", currentOperation=" + currentOperation + ", operationHistory=" + operationHistory
+ "]";
@@ -152,15 +152,15 @@ public class ControlLoopOperationManager implements Serializable {
case VNF:
VirtualControlLoopEvent virtualOnset = (VirtualControlLoopEvent) this.onset;
if (this.onset.getTarget().equalsIgnoreCase(VSERVER_VSERVER_NAME)) {
- return virtualOnset.getAAI().get(VSERVER_VSERVER_NAME);
+ return virtualOnset.getAai().get(VSERVER_VSERVER_NAME);
} else if (this.onset.getTarget().equalsIgnoreCase(GENERIC_VNF_VNF_ID)) {
- return virtualOnset.getAAI().get(GENERIC_VNF_VNF_ID);
+ return virtualOnset.getAai().get(GENERIC_VNF_VNF_ID);
} else if (this.onset.getTarget().equalsIgnoreCase(GENERIC_VNF_VNF_NAME)) {
/*
* If the onset is enriched with the vnf-id, we don't need an A&AI response
*/
- if (virtualOnset.getAAI().containsKey(GENERIC_VNF_VNF_ID)) {
- return virtualOnset.getAAI().get(GENERIC_VNF_VNF_ID);
+ if (virtualOnset.getAai().containsKey(GENERIC_VNF_VNF_ID)) {
+ return virtualOnset.getAai().get(GENERIC_VNF_VNF_ID);
}
/*
@@ -303,11 +303,11 @@ public class ControlLoopOperationManager implements Serializable {
// Cast APPC response and handle it
//
return onResponse((Response) response);
- } else if (response instanceof LCMResponseWrapper) {
+ } else if (response instanceof LcmResponseWrapper) {
//
// Cast LCM response and handle it
//
- return onResponse((LCMResponseWrapper) response);
+ return onResponse((LcmResponseWrapper) response);
} else if (response instanceof SOResponseWrapper) {
//
// Cast SO response and handle it
@@ -335,7 +335,7 @@ public class ControlLoopOperationManager implements Serializable {
//
Integer operationAttempt = null;
try {
- operationAttempt = Integer.parseInt(appcResponse.getCommonHeader().getSubRequestID());
+ operationAttempt = Integer.parseInt(appcResponse.getCommonHeader().getSubRequestId());
} catch (NumberFormatException e) {
//
// We cannot tell what happened if this doesn't exist
@@ -422,7 +422,7 @@ public class ControlLoopOperationManager implements Serializable {
* @param dmaapResponse the LCM response
* @return The result of the response handling
*/
- private PolicyResult onResponse(LCMResponseWrapper dmaapResponse) {
+ private PolicyResult onResponse(LcmResponseWrapper dmaapResponse) {
/*
* Parse out the operation attempt using the subrequestid
*/
@@ -789,7 +789,7 @@ public class ControlLoopOperationManager implements Serializable {
OperationsHistoryDbEntry newEntry = new OperationsHistoryDbEntry();
newEntry.setClosedLoopName(this.onset.getClosedLoopControlName());
- newEntry.setRequestId(this.onset.getRequestID().toString());
+ newEntry.setRequestId(this.onset.getRequestId().toString());
newEntry.setActor(this.currentOperation.clOperation.getActor());
newEntry.setOperation(this.currentOperation.clOperation.getOperation());
newEntry.setTarget(this.targetEntity);
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 d5f73c741..773299dc2 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
@@ -28,7 +28,7 @@ import java.util.Map;
import java.util.Queue;
import org.onap.policy.appc.Request;
-import org.onap.policy.appclcm.LCMRequestWrapper;
+import org.onap.policy.appclcm.LcmRequestWrapper;
import org.onap.policy.controlloop.ControlLoopNotification;
import org.onap.policy.controlloop.util.Serialization;
import org.onap.policy.drools.PolicyEngine;
@@ -74,9 +74,9 @@ public class PolicyEngineJUnitImpl implements PolicyEngine {
}
if (obj instanceof Request) {
Request request = (Request) obj;
- logger.debug("Request: {} subrequest {}", request.getAction(), request.getCommonHeader().getSubRequestID());
- } else if (obj instanceof LCMRequestWrapper) {
- LCMRequestWrapper dmaapRequest = (LCMRequestWrapper) obj;
+ logger.debug("Request: {} subrequest {}", request.getAction(), request.getCommonHeader().getSubRequestId());
+ } else if (obj instanceof LcmRequestWrapper) {
+ LcmRequestWrapper dmaapRequest = (LcmRequestWrapper) obj;
logger.debug("Request: {} subrequest {}", dmaapRequest.getBody().getAction(),
dmaapRequest.getBody().getCommonHeader().getSubRequestId());
}
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 4ff8338a6..700d1abf8 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
@@ -74,13 +74,13 @@ public class ControlLoopEventManagerTest {
{
onset = new VirtualControlLoopEvent();
onset.setClosedLoopControlName("ControlLoop-vUSP");
- onset.setRequestID(UUID.randomUUID());
+ 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.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);
}
@@ -209,12 +209,12 @@ public class ControlLoopEventManagerTest {
public void abatemetCheckEventSyntaxTest() {
VirtualControlLoopEvent event = new VirtualControlLoopEvent();
event.setClosedLoopControlName("abatementAAI");
- event.setRequestID(UUID.randomUUID());
+ 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());
+ new ControlLoopEventManager(event.getClosedLoopControlName(), event.getRequestId());
assertNull(manager.getVnfResponse());
assertNull(manager.getVserverResponse());
try {
@@ -228,8 +228,8 @@ public class ControlLoopEventManagerTest {
assertNull(manager.getVserverResponse());
- event.setAAI(new HashMap<>());
- event.getAAI().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) {
@@ -246,15 +246,15 @@ public class ControlLoopEventManagerTest {
UUID requestId = UUID.randomUUID();
VirtualControlLoopEvent event = new VirtualControlLoopEvent();
event.setClosedLoopControlName("TwoOnsetTest");
- event.setRequestID(requestId);
+ 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");
+ event.setAai(new HashMap<>());
+ event.getAai().put("generic-vnf.vnf-name", "onsetOne");
ControlLoopEventManager manager =
- new ControlLoopEventManager(event.getClosedLoopControlName(), event.getRequestID());
+ new ControlLoopEventManager(event.getClosedLoopControlName(), event.getRequestId());
VirtualControlLoopNotification notification = manager.activate(event);
assertNotNull(notification);
@@ -276,12 +276,12 @@ public class ControlLoopEventManagerTest {
VirtualControlLoopEvent event2 = new VirtualControlLoopEvent();
event2.setClosedLoopControlName("TwoOnsetTest");
- event2.setRequestID(requestId);
+ 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");
+ event2.setAai(new HashMap<>());
+ event2.getAai().put("generic-vnf.vnf-name", "onsetTwo");
try {
@@ -494,15 +494,15 @@ public class ControlLoopEventManagerTest {
UUID requestId = UUID.randomUUID();
VirtualControlLoopEvent event = new VirtualControlLoopEvent();
event.setClosedLoopControlName("TwoOnsetTest");
- event.setRequestID(requestId);
+ 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");
+ event.setAai(new HashMap<>());
+ event.getAai().put("generic-vnf.vnf-name", "onsetOne");
ControlLoopEventManager manager =
- new ControlLoopEventManager(event.getClosedLoopControlName(), event.getRequestID());
+ new ControlLoopEventManager(event.getClosedLoopControlName(), event.getRequestId());
manager.setActivated(true);
VirtualControlLoopNotification notification = manager.activate(event);
assertEquals(ControlLoopNotificationType.REJECTED, notification.getNotification());
@@ -519,15 +519,15 @@ public class ControlLoopEventManagerTest {
UUID requestId = UUID.randomUUID();
VirtualControlLoopEvent event = new VirtualControlLoopEvent();
event.setClosedLoopControlName("TwoOnsetTest");
- event.setRequestID(requestId);
+ 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");
+ event.setAai(new HashMap<>());
+ event.getAai().put("generic-vnf.vnf-name", "onsetOne");
ControlLoopEventManager manager =
- new ControlLoopEventManager(event.getClosedLoopControlName(), event.getRequestID());
+ new ControlLoopEventManager(event.getClosedLoopControlName(), event.getRequestId());
// Null YAML should fail
VirtualControlLoopNotification notificationNull = manager.activate(null, event);
@@ -562,15 +562,15 @@ public class ControlLoopEventManagerTest {
UUID requestId = UUID.randomUUID();
VirtualControlLoopEvent event = new VirtualControlLoopEvent();
event.setClosedLoopControlName("TwoOnsetTest");
- event.setRequestID(requestId);
+ 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");
+ event.setAai(new HashMap<>());
+ event.getAai().put("generic-vnf.vnf-name", "onsetOne");
ControlLoopEventManager manager =
- new ControlLoopEventManager(event.getClosedLoopControlName(), event.getRequestID());
+ new ControlLoopEventManager(event.getClosedLoopControlName(), event.getRequestId());
try {
manager.isControlLoopFinal();
fail("test should throw an exception here");
@@ -599,7 +599,7 @@ public class ControlLoopEventManagerTest {
assertNotNull(clfNotification);
assertEquals(ControlLoopNotificationType.FINAL_SUCCESS, clfNotification.getNotification());
- manager = new ControlLoopEventManager(event.getClosedLoopControlName(), event.getRequestID());
+ manager = new ControlLoopEventManager(event.getClosedLoopControlName(), event.getRequestId());
notification = manager.activate(yamlString, event);
assertNotNull(notification);
assertEquals(ControlLoopNotificationType.ACTIVE, notification.getNotification());
@@ -609,7 +609,7 @@ public class ControlLoopEventManagerTest {
assertNotNull(clfNotification);
assertEquals(ControlLoopNotificationType.FINAL_FAILURE, clfNotification.getNotification());
- manager = new ControlLoopEventManager(event.getClosedLoopControlName(), event.getRequestID());
+ manager = new ControlLoopEventManager(event.getClosedLoopControlName(), event.getRequestId());
notification = manager.activate(yamlString, event);
assertNotNull(notification);
assertEquals(ControlLoopNotificationType.ACTIVE, notification.getNotification());
@@ -633,15 +633,15 @@ public class ControlLoopEventManagerTest {
UUID requestId = UUID.randomUUID();
VirtualControlLoopEvent event = new VirtualControlLoopEvent();
event.setClosedLoopControlName("TwoOnsetTest");
- event.setRequestID(requestId);
+ 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");
+ event.setAai(new HashMap<>());
+ event.getAai().put("generic-vnf.vnf-name", "onsetOne");
ControlLoopEventManager manager =
- new ControlLoopEventManager(event.getClosedLoopControlName(), event.getRequestID());
+ new ControlLoopEventManager(event.getClosedLoopControlName(), event.getRequestId());
try {
manager.processControlLoop();
fail("test should throw an exception here");
@@ -674,7 +674,7 @@ public class ControlLoopEventManagerTest {
assertEquals("Already working an Operation, do not call this method.", e.getMessage());
}
- manager = new ControlLoopEventManager(event.getClosedLoopControlName(), event.getRequestID());
+ manager = new ControlLoopEventManager(event.getClosedLoopControlName(), event.getRequestId());
notification = manager.activate(yamlString, event);
assertNotNull(notification);
assertEquals(ControlLoopNotificationType.ACTIVE, notification.getNotification());
@@ -692,7 +692,7 @@ public class ControlLoopEventManagerTest {
assertEquals("Control Loop is in FINAL state, do not call this method.", e.getMessage());
}
- manager = new ControlLoopEventManager(event.getClosedLoopControlName(), event.getRequestID());
+ manager = new ControlLoopEventManager(event.getClosedLoopControlName(), event.getRequestId());
notification = manager.activate(yamlString, event);
assertNotNull(notification);
assertEquals(ControlLoopNotificationType.ACTIVE, notification.getNotification());
@@ -718,15 +718,15 @@ public class ControlLoopEventManagerTest {
UUID requestId = UUID.randomUUID();
VirtualControlLoopEvent event = new VirtualControlLoopEvent();
event.setClosedLoopControlName("TwoOnsetTest");
- event.setRequestID(requestId);
+ 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");
+ event.setAai(new HashMap<>());
+ event.getAai().put("generic-vnf.vnf-name", "onsetOne");
ControlLoopEventManager manager =
- new ControlLoopEventManager(event.getClosedLoopControlName(), event.getRequestID());
+ new ControlLoopEventManager(event.getClosedLoopControlName(), event.getRequestId());
try {
manager.finishOperation(null);
fail("test should throw an exception here");
@@ -781,7 +781,7 @@ public class ControlLoopEventManagerTest {
manager.finishOperation(clom);
ControlLoopEventManager otherManager =
- new ControlLoopEventManager(event.getClosedLoopControlName(), event.getRequestID());
+ new ControlLoopEventManager(event.getClosedLoopControlName(), event.getRequestId());
VirtualControlLoopNotification otherNotification = otherManager.activate(yamlStringStd, event);
assertNotNull(otherNotification);
assertEquals(ControlLoopNotificationType.ACTIVE, otherNotification.getNotification());
@@ -801,24 +801,24 @@ public class ControlLoopEventManagerTest {
UUID requestId = UUID.randomUUID();
VirtualControlLoopEvent onsetEvent = new VirtualControlLoopEvent();
onsetEvent.setClosedLoopControlName("TwoOnsetTest");
- onsetEvent.setRequestID(requestId);
+ onsetEvent.setRequestId(requestId);
onsetEvent.setTarget("generic-vnf.vnf-id");
onsetEvent.setClosedLoopAlarmStart(Instant.now());
onsetEvent.setClosedLoopEventStatus(ControlLoopEventStatus.ONSET);
- onsetEvent.setAAI(new HashMap<>());
- onsetEvent.getAAI().put("generic-vnf.vnf-name", "onsetOne");
+ onsetEvent.setAai(new HashMap<>());
+ onsetEvent.getAai().put("generic-vnf.vnf-name", "onsetOne");
VirtualControlLoopEvent abatedEvent = new VirtualControlLoopEvent();
abatedEvent.setClosedLoopControlName("TwoOnsetTest");
- abatedEvent.setRequestID(requestId);
+ abatedEvent.setRequestId(requestId);
abatedEvent.setTarget("generic-vnf.vnf-id");
abatedEvent.setClosedLoopAlarmStart(Instant.now());
abatedEvent.setClosedLoopEventStatus(ControlLoopEventStatus.ABATED);
- abatedEvent.setAAI(new HashMap<>());
- abatedEvent.getAAI().put("generic-vnf.vnf-name", "onsetOne");
+ abatedEvent.setAai(new HashMap<>());
+ abatedEvent.getAai().put("generic-vnf.vnf-name", "onsetOne");
ControlLoopEventManager manager =
- new ControlLoopEventManager(onsetEvent.getClosedLoopControlName(), onsetEvent.getRequestID());
+ new ControlLoopEventManager(onsetEvent.getClosedLoopControlName(), onsetEvent.getRequestId());
VirtualControlLoopNotification notification = manager.activate(yamlString, onsetEvent);
assertNotNull(notification);
assertEquals(ControlLoopNotificationType.ACTIVE, notification.getNotification());
@@ -828,7 +828,7 @@ public class ControlLoopEventManagerTest {
assertEquals(NEW_EVENT_STATUS.SUBSEQUENT_ABATEMENT, manager.onNewEvent(abatedEvent));
VirtualControlLoopEvent checkSyntaxEvent = new VirtualControlLoopEvent();
- checkSyntaxEvent.setAAI(null);
+ checkSyntaxEvent.setAai(null);
checkSyntaxEvent.setClosedLoopAlarmEnd(null);
checkSyntaxEvent.setClosedLoopAlarmStart(null);
checkSyntaxEvent.setClosedLoopControlName(null);
@@ -838,7 +838,7 @@ public class ControlLoopEventManagerTest {
checkSyntaxEvent.setPolicyName(null);
checkSyntaxEvent.setPolicyScope(null);
checkSyntaxEvent.setPolicyVersion(null);
- checkSyntaxEvent.setRequestID(null);
+ checkSyntaxEvent.setRequestId(null);
checkSyntaxEvent.setTarget(null);
checkSyntaxEvent.setTargetType(null);
checkSyntaxEvent.setVersion(null);
@@ -857,16 +857,16 @@ public class ControlLoopEventManagerTest {
checkSyntaxEvent.setClosedLoopControlName("TwoOnsetTest");
assertEquals(NEW_EVENT_STATUS.SYNTAX_ERROR, manager.onNewEvent(checkSyntaxEvent));
- checkSyntaxEvent.setRequestID(null);
+ checkSyntaxEvent.setRequestId(null);
assertEquals(NEW_EVENT_STATUS.SYNTAX_ERROR, manager.onNewEvent(checkSyntaxEvent));
- checkSyntaxEvent.setRequestID(requestId);
+ checkSyntaxEvent.setRequestId(requestId);
assertEquals(NEW_EVENT_STATUS.SYNTAX_ERROR, manager.onNewEvent(checkSyntaxEvent));
- checkSyntaxEvent.setAAI(null);
+ checkSyntaxEvent.setAai(null);
assertEquals(NEW_EVENT_STATUS.SYNTAX_ERROR, manager.onNewEvent(checkSyntaxEvent));
- checkSyntaxEvent.setAAI(new HashMap<>());
+ checkSyntaxEvent.setAai(new HashMap<>());
assertEquals(NEW_EVENT_STATUS.SYNTAX_ERROR, manager.onNewEvent(checkSyntaxEvent));
checkSyntaxEvent.setTarget("");
@@ -896,19 +896,19 @@ public class ControlLoopEventManagerTest {
checkSyntaxEvent.setTarget("generic-vnf.vnf-name");
assertEquals(NEW_EVENT_STATUS.SYNTAX_ERROR, manager.onNewEvent(checkSyntaxEvent));
- checkSyntaxEvent.setAAI(null);
+ checkSyntaxEvent.setAai(null);
assertEquals(NEW_EVENT_STATUS.SYNTAX_ERROR, manager.onNewEvent(checkSyntaxEvent));
- checkSyntaxEvent.setAAI(new HashMap<>());
+ checkSyntaxEvent.setAai(new HashMap<>());
assertEquals(NEW_EVENT_STATUS.SYNTAX_ERROR, manager.onNewEvent(checkSyntaxEvent));
- checkSyntaxEvent.getAAI().put("generic-vnf.vnf-name", "onsetOne");
+ checkSyntaxEvent.getAai().put("generic-vnf.vnf-name", "onsetOne");
assertEquals(NEW_EVENT_STATUS.SUBSEQUENT_ABATEMENT, manager.onNewEvent(abatedEvent));
- checkSyntaxEvent.getAAI().put("vserver.vserver-name", "onsetOne");
+ checkSyntaxEvent.getAai().put("vserver.vserver-name", "onsetOne");
assertEquals(NEW_EVENT_STATUS.SUBSEQUENT_ABATEMENT, manager.onNewEvent(abatedEvent));
- checkSyntaxEvent.getAAI().put("generic-vnf.vnf-id", "onsetOne");
+ checkSyntaxEvent.getAai().put("generic-vnf.vnf-id", "onsetOne");
assertEquals(NEW_EVENT_STATUS.SUBSEQUENT_ABATEMENT, manager.onNewEvent(abatedEvent));
}
@@ -920,15 +920,15 @@ public class ControlLoopEventManagerTest {
UUID requestId = UUID.randomUUID();
VirtualControlLoopEvent onsetEvent = new VirtualControlLoopEvent();
onsetEvent.setClosedLoopControlName("TwoOnsetTest");
- onsetEvent.setRequestID(requestId);
+ onsetEvent.setRequestId(requestId);
onsetEvent.setTarget("generic-vnf.vnf-id");
onsetEvent.setClosedLoopAlarmStart(Instant.now());
onsetEvent.setClosedLoopEventStatus(ControlLoopEventStatus.ONSET);
- onsetEvent.setAAI(new HashMap<>());
- onsetEvent.getAAI().put("generic-vnf.vnf-name", "onsetOne");
+ onsetEvent.setAai(new HashMap<>());
+ onsetEvent.getAai().put("generic-vnf.vnf-name", "onsetOne");
ControlLoopEventManager manager =
- new ControlLoopEventManager(onsetEvent.getClosedLoopControlName(), onsetEvent.getRequestID());
+ new ControlLoopEventManager(onsetEvent.getClosedLoopControlName(), onsetEvent.getRequestId());
assertTrue(0 == manager.getControlLoopTimeout(null));
assertTrue(120 == manager.getControlLoopTimeout(120));
@@ -947,15 +947,15 @@ public class ControlLoopEventManagerTest {
UUID requestId = UUID.randomUUID();
VirtualControlLoopEvent onsetEvent = new VirtualControlLoopEvent();
onsetEvent.setClosedLoopControlName("TwoOnsetTest");
- onsetEvent.setRequestID(requestId);
+ onsetEvent.setRequestId(requestId);
onsetEvent.setTarget("generic-vnf.vnf-id");
onsetEvent.setClosedLoopAlarmStart(Instant.now());
onsetEvent.setClosedLoopEventStatus(ControlLoopEventStatus.ONSET);
- onsetEvent.setAAI(new HashMap<>());
- onsetEvent.getAAI().put("generic-vnf.vnf-name", "onsetOne");
+ onsetEvent.setAai(new HashMap<>());
+ onsetEvent.getAai().put("generic-vnf.vnf-name", "onsetOne");
ControlLoopEventManager manager =
- new ControlLoopEventManager(onsetEvent.getClosedLoopControlName(), onsetEvent.getRequestID());
+ new ControlLoopEventManager(onsetEvent.getClosedLoopControlName(), onsetEvent.getRequestId());
manager.queryAai(onsetEvent);
VirtualControlLoopNotification notification = manager.activate(yamlString, onsetEvent);
@@ -964,53 +964,53 @@ public class ControlLoopEventManagerTest {
manager.queryAai(onsetEvent);
- onsetEvent.getAAI().put("generic-vnf.is-closed-loop-disabled", "true");
+ onsetEvent.getAai().put("generic-vnf.is-closed-loop-disabled", "true");
try {
manager.queryAai(onsetEvent);
fail("test should throw an exception here");
} catch (Exception e) {
assertEquals("is-closed-loop-disabled is set to true on VServer or VNF", e.getMessage());
}
- onsetEvent.getAAI().put("vserver.is-closed-loop-disabled", "true");
+ onsetEvent.getAai().put("vserver.is-closed-loop-disabled", "true");
try {
manager.queryAai(onsetEvent);
fail("test should throw an exception here");
} catch (Exception e) {
assertEquals("is-closed-loop-disabled is set to true on VServer or VNF", e.getMessage());
}
- onsetEvent.getAAI().remove("generic-vnf.is-closed-loop-disabled");
+ onsetEvent.getAai().remove("generic-vnf.is-closed-loop-disabled");
try {
manager.queryAai(onsetEvent);
fail("test should throw an exception here");
} catch (Exception e) {
assertEquals("is-closed-loop-disabled is set to true on VServer or VNF", e.getMessage());
}
- onsetEvent.getAAI().remove("vserver.is-closed-loop-disabled");
+ onsetEvent.getAai().remove("vserver.is-closed-loop-disabled");
manager.queryAai(onsetEvent);
- onsetEvent.getAAI().put("generic-vnf.is-closed-loop-disabled", "false");
+ onsetEvent.getAai().put("generic-vnf.is-closed-loop-disabled", "false");
manager.queryAai(onsetEvent);
- onsetEvent.getAAI().put("vserver.is-closed-loop-disabled", "false");
+ onsetEvent.getAai().put("vserver.is-closed-loop-disabled", "false");
manager.queryAai(onsetEvent);
- onsetEvent.getAAI().remove("generic-vnf.vnf-id");
- onsetEvent.getAAI().remove("generic-vnf.vnf-name");
- onsetEvent.getAAI().remove("vserver.vserver-name");
+ onsetEvent.getAai().remove("generic-vnf.vnf-id");
+ onsetEvent.getAai().remove("generic-vnf.vnf-name");
+ onsetEvent.getAai().remove("vserver.vserver-name");
manager.queryAai(onsetEvent);
- onsetEvent.getAAI().put("vserver.vserver-name", "AVserver");
+ onsetEvent.getAai().put("vserver.vserver-name", "AVserver");
manager.queryAai(onsetEvent);
- onsetEvent.getAAI().put("generic-vnf.vnf-name", "AVNFName");
+ onsetEvent.getAai().put("generic-vnf.vnf-name", "AVNFName");
manager.queryAai(onsetEvent);
- onsetEvent.getAAI().put("generic-vnf.vnf-id", "AVNFID");
+ onsetEvent.getAai().put("generic-vnf.vnf-id", "AVNFID");
manager.queryAai(onsetEvent);
- onsetEvent.getAAI().remove("vserver.vserver-name");
+ onsetEvent.getAai().remove("vserver.vserver-name");
manager.queryAai(onsetEvent);
- onsetEvent.getAAI().remove("generic-vnf.vnf-name");
+ onsetEvent.getAai().remove("generic-vnf.vnf-name");
manager.queryAai(onsetEvent);
// Force AAI errors
@@ -1024,8 +1024,8 @@ public class ControlLoopEventManagerTest {
+ "(query by vnf-id)", e.getMessage());
}
- onsetEvent.getAAI().remove("generic-vnf.vnf-id");
- onsetEvent.getAAI().put("generic-vnf.vnf-name", "AVNFName");
+ onsetEvent.getAai().remove("generic-vnf.vnf-id");
+ onsetEvent.getAai().put("generic-vnf.vnf-name", "AVNFName");
try {
manager.queryAai(onsetEvent);
fail("test should throw an exception here");
@@ -1034,8 +1034,8 @@ public class ControlLoopEventManagerTest {
+ "(query by vnf-name)", e.getMessage());
}
- onsetEvent.getAAI().remove("generic-vnf.vnf-name");
- onsetEvent.getAAI().put("vserver.vserver-name", "AVserver");
+ onsetEvent.getAai().remove("generic-vnf.vnf-name");
+ onsetEvent.getAai().put("vserver.vserver-name", "AVserver");
try {
manager.queryAai(onsetEvent);
fail("test should throw an exception here");
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 8efa3706d..fd4405d61 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
@@ -45,11 +45,11 @@ import org.onap.policy.appc.CommonHeader;
import org.onap.policy.appc.Response;
import org.onap.policy.appc.ResponseCode;
import org.onap.policy.appc.ResponseStatus;
-import org.onap.policy.appclcm.LCMCommonHeader;
-import org.onap.policy.appclcm.LCMRequest;
-import org.onap.policy.appclcm.LCMRequestWrapper;
-import org.onap.policy.appclcm.LCMResponse;
-import org.onap.policy.appclcm.LCMResponseWrapper;
+import org.onap.policy.appclcm.LcmCommonHeader;
+import org.onap.policy.appclcm.LcmRequest;
+import org.onap.policy.appclcm.LcmRequestWrapper;
+import org.onap.policy.appclcm.LcmResponse;
+import org.onap.policy.appclcm.LcmResponseWrapper;
import org.onap.policy.controlloop.ControlLoopEventStatus;
import org.onap.policy.controlloop.ControlLoopException;
import org.onap.policy.controlloop.ControlLoopNotificationType;
@@ -80,12 +80,12 @@ public class ControlLoopOperationManagerTest {
static {
onset = new VirtualControlLoopEvent();
- onset.setRequestID(UUID.randomUUID());
+ 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.setAai(new HashMap<>());
+ onset.getAai().put("generic-vnf.vnf-name", "testTriggerSource");
onset.setClosedLoopEventStatus(ControlLoopEventStatus.ONSET);
/* Set environment properties */
@@ -127,7 +127,7 @@ public class ControlLoopOperationManagerTest {
// create the manager
//
ControlLoopEventManager eventManager =
- new ControlLoopEventManager(onset.getClosedLoopControlName(), onset.getRequestID());
+ new ControlLoopEventManager(onset.getClosedLoopControlName(), onset.getRequestId());
VirtualControlLoopNotification notification = eventManager.activate(onset);
assertNotNull(notification);
@@ -157,17 +157,17 @@ public class ControlLoopOperationManagerTest {
Object request = manager.startOperation(onset);
logger.debug("{}", manager);
assertNotNull(request);
- assertTrue(request instanceof LCMRequestWrapper);
- LCMRequestWrapper dmaapRequest = (LCMRequestWrapper) request;
- LCMRequest appcRequest = dmaapRequest.getBody();
+ assertTrue(request instanceof LcmRequestWrapper);
+ LcmRequestWrapper dmaapRequest = (LcmRequestWrapper) request;
+ LcmRequest appcRequest = dmaapRequest.getBody();
assertTrue(appcRequest.getCommonHeader().getSubRequestId().contentEquals("1"));
assertFalse(manager.isOperationComplete());
assertTrue(manager.isOperationRunning());
//
// Accept
//
- LCMResponseWrapper dmaapResponse = new LCMResponseWrapper();
- LCMResponse appcResponse = new LCMResponse(appcRequest);
+ LcmResponseWrapper dmaapResponse = new LcmResponseWrapper();
+ LcmResponse appcResponse = new LcmResponse(appcRequest);
appcResponse.getStatus().setCode(100);
appcResponse.getStatus().setMessage("ACCEPT");
dmaapResponse.setBody(appcResponse);
@@ -182,7 +182,7 @@ public class ControlLoopOperationManagerTest {
//
// Now we are going to Fail it
//
- appcResponse = new LCMResponse(appcRequest);
+ appcResponse = new LcmResponse(appcRequest);
appcResponse.getStatus().setCode(401);
appcResponse.getStatus().setMessage("AppC failed for some reason");
dmaapResponse.setBody(appcResponse);
@@ -197,8 +197,8 @@ public class ControlLoopOperationManagerTest {
request = manager.startOperation(onset);
logger.debug("{}", manager);
assertNotNull(request);
- assertTrue(request instanceof LCMRequestWrapper);
- dmaapRequest = (LCMRequestWrapper) request;
+ assertTrue(request instanceof LcmRequestWrapper);
+ dmaapRequest = (LcmRequestWrapper) request;
appcRequest = dmaapRequest.getBody();
assertTrue(appcRequest.getCommonHeader().getSubRequestId().contentEquals("2"));
assertFalse(manager.isOperationComplete());
@@ -206,7 +206,7 @@ public class ControlLoopOperationManagerTest {
//
//
//
- appcResponse = new LCMResponse(appcRequest);
+ appcResponse = new LcmResponse(appcRequest);
logger.debug("{}", manager);
appcResponse.getStatus().setCode(100);
appcResponse.getStatus().setMessage("ACCEPT");
@@ -222,7 +222,7 @@ public class ControlLoopOperationManagerTest {
//
// Now we are going to Fail it
//
- appcResponse = new LCMResponse(appcRequest);
+ appcResponse = new LcmResponse(appcRequest);
appcResponse.getStatus().setCode(401);
appcResponse.getStatus().setMessage("AppC failed for some reason");
dmaapResponse.setBody(appcResponse);
@@ -258,7 +258,7 @@ public class ControlLoopOperationManagerTest {
// create the manager
//
ControlLoopEventManager eventManager =
- new ControlLoopEventManager(onset.getClosedLoopControlName(), onset.getRequestID());
+ new ControlLoopEventManager(onset.getClosedLoopControlName(), onset.getRequestId());
VirtualControlLoopNotification notification = eventManager.activate(onset);
assertNotNull(notification);
@@ -288,17 +288,17 @@ public class ControlLoopOperationManagerTest {
Object request = manager.startOperation(onset);
logger.debug("{}", manager);
assertNotNull(request);
- assertTrue((request) instanceof LCMRequestWrapper);
- LCMRequestWrapper dmaapRequest = (LCMRequestWrapper) request;
- LCMRequest appcRequest = dmaapRequest.getBody();
+ assertTrue((request) instanceof LcmRequestWrapper);
+ LcmRequestWrapper dmaapRequest = (LcmRequestWrapper) request;
+ LcmRequest appcRequest = dmaapRequest.getBody();
assertTrue((appcRequest).getCommonHeader().getSubRequestId().contentEquals("1"));
assertFalse(manager.isOperationComplete());
assertTrue(manager.isOperationRunning());
//
// Accept
//
- LCMResponseWrapper dmaapResponse = new LCMResponseWrapper();
- LCMResponse appcResponse = new LCMResponse(appcRequest);
+ LcmResponseWrapper dmaapResponse = new LcmResponseWrapper();
+ LcmResponse appcResponse = new LcmResponse(appcRequest);
dmaapResponse.setBody(appcResponse);
appcResponse.getStatus().setCode(100);
appcResponse.getStatus().setMessage("ACCEPT");
@@ -322,7 +322,7 @@ public class ControlLoopOperationManagerTest {
//
// Now we are going to Fail the previous request
//
- appcResponse = new LCMResponse(appcRequest);
+ appcResponse = new LcmResponse(appcRequest);
appcResponse.getStatus().setCode(401);
appcResponse.getStatus().setMessage("AppC failed for some reason");
dmaapResponse.setBody(appcResponse);
@@ -348,15 +348,15 @@ public class ControlLoopOperationManagerTest {
UUID requestId = UUID.randomUUID();
VirtualControlLoopEvent onsetEvent = new VirtualControlLoopEvent();
onsetEvent.setClosedLoopControlName("TwoOnsetTest");
- onsetEvent.setRequestID(requestId);
+ onsetEvent.setRequestId(requestId);
onsetEvent.setTarget("generic-vnf.vnf-id");
onsetEvent.setClosedLoopAlarmStart(Instant.now());
onsetEvent.setClosedLoopEventStatus(ControlLoopEventStatus.ONSET);
- onsetEvent.setAAI(new HashMap<>());
- onsetEvent.getAAI().put("generic-vnf.vnf-name", "onsetOne");
+ onsetEvent.setAai(new HashMap<>());
+ onsetEvent.getAai().put("generic-vnf.vnf-name", "onsetOne");
ControlLoopEventManager manager =
- new ControlLoopEventManager(onsetEvent.getClosedLoopControlName(), onsetEvent.getRequestID());
+ new ControlLoopEventManager(onsetEvent.getClosedLoopControlName(), onsetEvent.getRequestId());
VirtualControlLoopNotification notification = manager.activate(yamlString, onsetEvent);
assertNotNull(notification);
assertEquals(ControlLoopNotificationType.ACTIVE, notification.getNotification());
@@ -406,9 +406,9 @@ public class ControlLoopOperationManagerTest {
}
onsetEvent.setTarget("Oz");
- onsetEvent.getAAI().remove("generic-vnf.vnf-name");
- onsetEvent.getAAI().remove("generic-vnf.vnf-id");
- onsetEvent.getAAI().remove("vserver.vserver-name");
+ onsetEvent.getAai().remove("generic-vnf.vnf-name");
+ onsetEvent.getAai().remove("generic-vnf.vnf-id");
+ onsetEvent.getAai().remove("vserver.vserver-name");
policy.getTarget().setType(TargetType.VNF);
try {
@@ -419,12 +419,12 @@ public class ControlLoopOperationManagerTest {
}
onsetEvent.setTarget("vserver.vserver-name");
- onsetEvent.getAAI().put("vserver.vserver-name", "OzVServer");
+ onsetEvent.getAai().put("vserver.vserver-name", "OzVServer");
assertEquals("OzVServer", clom.getTarget(policy));
- onsetEvent.getAAI().remove("vserver.vserver-name");
+ onsetEvent.getAai().remove("vserver.vserver-name");
onsetEvent.setTarget("generic-vnf.vnf-id");
- onsetEvent.getAAI().put("generic-vnf.vnf-id", "OzVNF");
+ onsetEvent.getAai().put("generic-vnf.vnf-id", "OzVNF");
assertEquals("OzVNF", clom.getTarget(policy));
onsetEvent.setTarget("generic-vnf.vnf-name");
@@ -432,7 +432,7 @@ public class ControlLoopOperationManagerTest {
manager.onNewEvent(onsetEvent);
- onsetEvent.getAAI().remove("generic-vnf.vnf-id");
+ onsetEvent.getAai().remove("generic-vnf.vnf-id");
manager.getVnfResponse();
clom.getEventManager().getVnfResponse().setVnfId("generic-vnf.vnf-id");
assertEquals("generic-vnf.vnf-id", clom.getTarget(policy));
@@ -475,15 +475,15 @@ public class ControlLoopOperationManagerTest {
UUID requestId = UUID.randomUUID();
VirtualControlLoopEvent onsetEvent = new VirtualControlLoopEvent();
onsetEvent.setClosedLoopControlName("TwoOnsetTest");
- onsetEvent.setRequestID(requestId);
+ onsetEvent.setRequestId(requestId);
onsetEvent.setTarget("generic-vnf.vnf-id");
onsetEvent.setClosedLoopAlarmStart(Instant.now());
onsetEvent.setClosedLoopEventStatus(ControlLoopEventStatus.ONSET);
- onsetEvent.setAAI(new HashMap<>());
- onsetEvent.getAAI().put("generic-vnf.vnf-name", "onsetOne");
+ onsetEvent.setAai(new HashMap<>());
+ onsetEvent.getAai().put("generic-vnf.vnf-name", "onsetOne");
ControlLoopEventManager manager =
- new ControlLoopEventManager(onsetEvent.getClosedLoopControlName(), onsetEvent.getRequestID());
+ new ControlLoopEventManager(onsetEvent.getClosedLoopControlName(), onsetEvent.getRequestId());
VirtualControlLoopNotification notification = manager.activate(yamlString, onsetEvent);
assertNotNull(notification);
assertEquals(ControlLoopNotificationType.ACTIVE, notification.getNotification());
@@ -530,15 +530,15 @@ public class ControlLoopOperationManagerTest {
UUID requestId = UUID.randomUUID();
VirtualControlLoopEvent onsetEvent = new VirtualControlLoopEvent();
onsetEvent.setClosedLoopControlName("TwoOnsetTest");
- onsetEvent.setRequestID(requestId);
+ onsetEvent.setRequestId(requestId);
onsetEvent.setTarget("generic-vnf.vnf-id");
onsetEvent.setClosedLoopAlarmStart(Instant.now());
onsetEvent.setClosedLoopEventStatus(ControlLoopEventStatus.ONSET);
- onsetEvent.setAAI(new HashMap<>());
- onsetEvent.getAAI().put("generic-vnf.vnf-name", "onsetOne");
+ onsetEvent.setAai(new HashMap<>());
+ onsetEvent.getAai().put("generic-vnf.vnf-name", "onsetOne");
ControlLoopEventManager manager =
- new ControlLoopEventManager(onsetEvent.getClosedLoopControlName(), onsetEvent.getRequestID());
+ new ControlLoopEventManager(onsetEvent.getClosedLoopControlName(), onsetEvent.getRequestId());
VirtualControlLoopNotification notification = manager.activate(yamlString, onsetEvent);
assertNotNull(notification);
assertEquals(ControlLoopNotificationType.ACTIVE, notification.getNotification());
@@ -634,15 +634,15 @@ public class ControlLoopOperationManagerTest {
UUID requestId = UUID.randomUUID();
VirtualControlLoopEvent onsetEvent = new VirtualControlLoopEvent();
onsetEvent.setClosedLoopControlName("TwoOnsetTest");
- onsetEvent.setRequestID(requestId);
+ onsetEvent.setRequestId(requestId);
onsetEvent.setTarget("generic-vnf.vnf-id");
onsetEvent.setClosedLoopAlarmStart(Instant.now());
onsetEvent.setClosedLoopEventStatus(ControlLoopEventStatus.ONSET);
- onsetEvent.setAAI(new HashMap<>());
- onsetEvent.getAAI().put("generic-vnf.vnf-name", "onsetOne");
+ onsetEvent.setAai(new HashMap<>());
+ onsetEvent.getAai().put("generic-vnf.vnf-name", "onsetOne");
ControlLoopEventManager manager =
- new ControlLoopEventManager(onsetEvent.getClosedLoopControlName(), onsetEvent.getRequestID());
+ new ControlLoopEventManager(onsetEvent.getClosedLoopControlName(), onsetEvent.getRequestId());
VirtualControlLoopNotification notification = manager.activate(yamlString, onsetEvent);
assertNotNull(notification);
assertEquals(ControlLoopNotificationType.ACTIVE, notification.getNotification());
@@ -658,7 +658,7 @@ public class ControlLoopOperationManagerTest {
appcResponse.setCommonHeader(commonHeader);
assertEquals(PolicyResult.FAILURE_EXCEPTION, clom.onResponse(appcResponse));
- commonHeader.setSubRequestID("12345");
+ commonHeader.setSubRequestId("12345");
appcResponse.setStatus(null);
assertEquals(PolicyResult.FAILURE_EXCEPTION, clom.onResponse(appcResponse));
@@ -684,9 +684,9 @@ public class ControlLoopOperationManagerTest {
responseStatus.setCode(ResponseCode.SUCCESS.getValue());
assertEquals(PolicyResult.SUCCESS, clom.onResponse(appcResponse));
- LCMResponseWrapper lrw = new LCMResponseWrapper();
- LCMResponse body = new LCMResponse();
- LCMCommonHeader lcmCh = new LCMCommonHeader();
+ LcmResponseWrapper lrw = new LcmResponseWrapper();
+ LcmResponse body = new LcmResponse();
+ LcmCommonHeader lcmCh = new LcmCommonHeader();
body.setCommonHeader(lcmCh);
lrw.setBody(body);
@@ -727,15 +727,15 @@ public class ControlLoopOperationManagerTest {
UUID requestId = UUID.randomUUID();
VirtualControlLoopEvent onsetEvent = new VirtualControlLoopEvent();
onsetEvent.setClosedLoopControlName("TwoOnsetTest");
- onsetEvent.setRequestID(requestId);
+ onsetEvent.setRequestId(requestId);
onsetEvent.setTarget("generic-vnf.vnf-id");
onsetEvent.setClosedLoopAlarmStart(Instant.now());
onsetEvent.setClosedLoopEventStatus(ControlLoopEventStatus.ONSET);
- onsetEvent.setAAI(new HashMap<>());
- onsetEvent.getAAI().put("generic-vnf.vnf-name", "onsetOne");
+ onsetEvent.setAai(new HashMap<>());
+ onsetEvent.getAai().put("generic-vnf.vnf-name", "onsetOne");
ControlLoopEventManager manager =
- new ControlLoopEventManager(onsetEvent.getClosedLoopControlName(), onsetEvent.getRequestID());
+ new ControlLoopEventManager(onsetEvent.getClosedLoopControlName(), onsetEvent.getRequestId());
VirtualControlLoopNotification notification = manager.activate(yamlString, onsetEvent);
assertNotNull(notification);
assertEquals(ControlLoopNotificationType.ACTIVE, notification.getNotification());
diff --git a/controlloop/common/eventmanager/src/test/java/org/onap/policy/drools/DroolsPolicyEngineTest.java b/controlloop/common/eventmanager/src/test/java/org/onap/policy/drools/DroolsPolicyEngineTest.java
index 13d5f3679..dcf3e6c95 100644
--- a/controlloop/common/eventmanager/src/test/java/org/onap/policy/drools/DroolsPolicyEngineTest.java
+++ b/controlloop/common/eventmanager/src/test/java/org/onap/policy/drools/DroolsPolicyEngineTest.java
@@ -26,9 +26,9 @@ import static org.junit.Assert.assertNotNull;
import org.junit.Test;
import org.onap.policy.appc.CommonHeader;
import org.onap.policy.appc.Request;
-import org.onap.policy.appclcm.LCMCommonHeader;
-import org.onap.policy.appclcm.LCMRequest;
-import org.onap.policy.appclcm.LCMRequestWrapper;
+import org.onap.policy.appclcm.LcmCommonHeader;
+import org.onap.policy.appclcm.LcmRequest;
+import org.onap.policy.appclcm.LcmRequestWrapper;
import org.onap.policy.controlloop.ControlLoopNotification;
import org.onap.policy.controlloop.VirtualControlLoopNotification;
import org.onap.policy.drools.impl.PolicyEngineJUnitImpl;
@@ -54,12 +54,12 @@ public class DroolsPolicyEngineTest {
Request request = new Request();
request.setCommonHeader(new CommonHeader());
- request.getCommonHeader().setSubRequestID("12321");
+ request.getCommonHeader().setSubRequestId("12321");
pe.deliver("OmniBus", "TheWizardOfOz", request);
- LCMRequestWrapper lcmRw = new LCMRequestWrapper();
- lcmRw.setBody(new LCMRequest());
- lcmRw.getBody().setCommonHeader(new LCMCommonHeader());
+ LcmRequestWrapper lcmRw = new LcmRequestWrapper();
+ lcmRw.setBody(new LcmRequest());
+ lcmRw.getBody().setCommonHeader(new LcmCommonHeader());
lcmRw.getBody().getCommonHeader().setSubRequestId("54321");
pe.deliver("OmniBus", "TheWizardOfOz", lcmRw);
}
diff --git a/controlloop/common/feature-controlloop-trans/src/main/java/org/onap/policy/drools/apps/controlloop/feature/trans/ControlLoopMetrics.java b/controlloop/common/feature-controlloop-trans/src/main/java/org/onap/policy/drools/apps/controlloop/feature/trans/ControlLoopMetrics.java
index 84d3aae03..2482d1814 100644
--- a/controlloop/common/feature-controlloop-trans/src/main/java/org/onap/policy/drools/apps/controlloop/feature/trans/ControlLoopMetrics.java
+++ b/controlloop/common/feature-controlloop-trans/src/main/java/org/onap/policy/drools/apps/controlloop/feature/trans/ControlLoopMetrics.java
@@ -25,6 +25,7 @@ import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
import com.google.common.cache.RemovalListener;
import com.google.common.cache.RemovalNotification;
+
import java.time.Instant;
import java.time.ZonedDateTime;
import java.util.ArrayList;
@@ -32,6 +33,7 @@ import java.util.List;
import java.util.Properties;
import java.util.UUID;
import java.util.concurrent.TimeUnit;
+
import org.onap.policy.controlloop.ControlLoopOperation;
import org.onap.policy.controlloop.VirtualControlLoopNotification;
import org.onap.policy.drools.persistence.SystemPersistence;
@@ -136,6 +138,7 @@ public interface ControlLoopMetrics {
ControlLoopMetrics manager = new CacheBasedControlLoopMetricsManager();
}
+
/**
* Control Loop Metrics Tracker Implementation
*/
@@ -151,28 +154,28 @@ class CacheBasedControlLoopMetricsManager implements ControlLoopMetrics {
public CacheBasedControlLoopMetricsManager() {
Properties properties =
- SystemPersistence.manager.getProperties(ControlLoopMetricsFeature.CONFIGURATION_PROPERTIES_NAME);
+ SystemPersistence.manager.getProperties(ControlLoopMetricsFeature.CONFIGURATION_PROPERTIES_NAME);
/* cache size */
try {
this.cacheSize =
- Long.parseLong(properties.getProperty(ControlLoopMetricsFeature.CL_CACHE_TRANS_SIZE_PROPERTY,
- "" + ControlLoopMetricsFeature.CL_CACHE_TRANS_SIZE_DEFAULT));
+ Long.parseLong(properties.getProperty(ControlLoopMetricsFeature.CL_CACHE_TRANS_SIZE_PROPERTY,
+ "" + ControlLoopMetricsFeature.CL_CACHE_TRANS_SIZE_DEFAULT));
} catch (Exception e) {
logger.warn("{}:{} property cannot be accessed", ControlLoopMetricsFeature.CONFIGURATION_PROPERTIES_NAME,
- ControlLoopMetricsFeature.CL_CACHE_TRANS_SIZE_PROPERTY, e);
+ ControlLoopMetricsFeature.CL_CACHE_TRANS_SIZE_PROPERTY, e);
}
/* transaction timeout */
try {
- this.transactionTimeout =
- Long.parseLong(properties.getProperty(ControlLoopMetricsFeature.CL_CACHE_TRANS_TIMEOUT_SECONDS_PROPERTY,
- "" + ControlLoopMetricsFeature.CL_CACHE_TRANS_TIMEOUT_SECONDS_DEFAULT));
+ this.transactionTimeout = Long
+ .parseLong(properties.getProperty(ControlLoopMetricsFeature.CL_CACHE_TRANS_TIMEOUT_SECONDS_PROPERTY,
+ "" + ControlLoopMetricsFeature.CL_CACHE_TRANS_TIMEOUT_SECONDS_DEFAULT));
} catch (Exception e) {
logger.warn("{}:{} property cannot be accessed", ControlLoopMetricsFeature.CONFIGURATION_PROPERTIES_NAME,
- ControlLoopMetricsFeature.CL_CACHE_TRANS_TIMEOUT_SECONDS_PROPERTY, e);
+ ControlLoopMetricsFeature.CL_CACHE_TRANS_TIMEOUT_SECONDS_PROPERTY, e);
}
resetCache(this.cacheSize, this.transactionTimeout);
@@ -183,24 +186,27 @@ class CacheBasedControlLoopMetricsManager implements ControlLoopMetrics {
this.cacheSize = cacheSize;
this.transactionTimeout = transactionTimeout;
- CacheLoader<UUID, VirtualControlLoopNotification> loader = new CacheLoader<UUID, VirtualControlLoopNotification>() {
-
- @Override
- public VirtualControlLoopNotification load(UUID key) throws Exception {
- return null;
- }
- };
-
- RemovalListener<UUID, VirtualControlLoopNotification> listener = new RemovalListener<UUID, VirtualControlLoopNotification>() {
- @Override
- public void onRemoval(RemovalNotification<UUID, VirtualControlLoopNotification> notification) {
- if (notification.wasEvicted()) {
- evicted(notification.getValue());
- } else {
- logger.info("REMOVAL: {} because of {}", notification.getValue().getRequestID(), notification.getCause().name());
- }
- }
- };
+ CacheLoader<UUID, VirtualControlLoopNotification> loader =
+ new CacheLoader<UUID, VirtualControlLoopNotification>() {
+
+ @Override
+ public VirtualControlLoopNotification load(UUID key) throws Exception {
+ return null;
+ }
+ };
+
+ RemovalListener<UUID, VirtualControlLoopNotification> listener =
+ new RemovalListener<UUID, VirtualControlLoopNotification>() {
+ @Override
+ public void onRemoval(RemovalNotification<UUID, VirtualControlLoopNotification> notification) {
+ if (notification.wasEvicted()) {
+ evicted(notification.getValue());
+ } else {
+ logger.info("REMOVAL: {} because of {}", notification.getValue().getRequestId(),
+ notification.getCause().name());
+ }
+ }
+ };
synchronized (this) {
if (this.cache != null) {
@@ -208,9 +214,8 @@ class CacheBasedControlLoopMetricsManager implements ControlLoopMetrics {
this.cache.invalidateAll();
}
- this.cache = CacheBuilder.newBuilder().
- maximumSize(this.cacheSize).expireAfterWrite(transactionTimeout, TimeUnit.SECONDS).
- removalListener(listener).build(loader);
+ this.cache = CacheBuilder.newBuilder().maximumSize(this.cacheSize)
+ .expireAfterWrite(transactionTimeout, TimeUnit.SECONDS).removalListener(listener).build(loader);
}
}
@@ -231,7 +236,7 @@ class CacheBasedControlLoopMetricsManager implements ControlLoopMetrics {
@Override
public void transactionEvent(PolicyController controller, VirtualControlLoopNotification notification) {
- if (notification == null || notification.getRequestID() == null || notification.getNotification() == null) {
+ if (notification == null || notification.getRequestId() == null || notification.getNotification() == null) {
logger.warn("Invalid notification: {}", notification);
return;
}
@@ -259,7 +264,7 @@ class CacheBasedControlLoopMetricsManager implements ControlLoopMetrics {
default:
/* unexpected */
logger.warn("unexpected notification type {} in notification {}",
- notification.getNotification().toString(), notification);
+ notification.getNotification().toString(), notification);
break;
}
}
@@ -280,8 +285,8 @@ class CacheBasedControlLoopMetricsManager implements ControlLoopMetrics {
* @param notification control loop notification
*/
protected void inProgressTransaction(VirtualControlLoopNotification notification) {
- if (cache.getIfPresent(notification.getRequestID()) == null) {
- cache.put(notification.getRequestID(), notification);
+ if (cache.getIfPresent(notification.getRequestId()) == null) {
+ cache.put(notification.getRequestId(), notification);
}
this.metric(notification);
@@ -294,7 +299,7 @@ class CacheBasedControlLoopMetricsManager implements ControlLoopMetrics {
*/
protected void endTransaction(VirtualControlLoopNotification notification) {
ZonedDateTime startTime;
- VirtualControlLoopNotification startNotification = cache.getIfPresent(notification.getRequestID());
+ VirtualControlLoopNotification startNotification = cache.getIfPresent(notification.getRequestId());
if (startNotification != null) {
startTime = startNotification.getNotificationTime();
} else {
@@ -307,14 +312,11 @@ class CacheBasedControlLoopMetricsManager implements ControlLoopMetrics {
protected void evicted(VirtualControlLoopNotification notification) {
// transaction(notification, ZonedDateTime.now());
- MDCTransaction trans =
- MDCTransaction.newTransaction(notification.getRequestID().toString(), notification.getFrom()).
- setServiceName(notification.getClosedLoopControlName()).
- setTargetEntity(notification.getTarget()).
- setStartTime(notification.getNotificationTime().toInstant()).
- setEndTime(Instant.now()).
- setResponseDescription("EVICTED").
- setStatusCode(false).metric().resetTransaction();
+ MDCTransaction trans = MDCTransaction
+ .newTransaction(notification.getRequestId().toString(), notification.getFrom())
+ .setServiceName(notification.getClosedLoopControlName()).setTargetEntity(notification.getTarget())
+ .setStartTime(notification.getNotificationTime().toInstant()).setEndTime(Instant.now())
+ .setResponseDescription("EVICTED").setStatusCode(false).metric().resetTransaction();
}
@Override
@@ -343,10 +345,9 @@ class CacheBasedControlLoopMetricsManager implements ControlLoopMetrics {
}
protected void metric(VirtualControlLoopNotification notification) {
- MDCTransaction trans =
- MDCTransaction.newTransaction(notification.getRequestID().toString(), notification.getFrom()).
- setServiceName(notification.getClosedLoopControlName()).
- setTargetEntity(notification.getTarget());
+ MDCTransaction trans = MDCTransaction
+ .newTransaction(notification.getRequestId().toString(), notification.getFrom())
+ .setServiceName(notification.getClosedLoopControlName()).setTargetEntity(notification.getTarget());
List<ControlLoopOperation> operations = notification.getHistory();
switch (notification.getNotification()) {
@@ -357,7 +358,7 @@ class CacheBasedControlLoopMetricsManager implements ControlLoopMetrics {
case OPERATION:
trans.setStatusCode(true);
if (!operations.isEmpty()) {
- ControlLoopOperation operation = operations.get(operations.size()-1);
+ ControlLoopOperation operation = operations.get(operations.size() - 1);
trans.setTargetEntity(operation.getTarget());
trans.setTargetServiceName(operation.getActor());
}
@@ -376,45 +377,49 @@ class CacheBasedControlLoopMetricsManager implements ControlLoopMetrics {
default:
/* unexpected */
logger.warn("unexpected notification type {} in notification {}",
- notification.getNotification().toString(), notification);
+ notification.getNotification().toString(), notification);
break;
}
}
protected void operation(MDCTransaction trans, List<ControlLoopOperation> operations) {
if (!operations.isEmpty()) {
- ControlLoopOperation operation = operations.get(operations.size()-1);
+ ControlLoopOperation operation = operations.get(operations.size() - 1);
- if (operation.getTarget() != null)
+ if (operation.getTarget() != null) {
trans.setTargetEntity(operation.getTarget());
+ }
- if (operation.getActor() != null)
+ if (operation.getActor() != null) {
trans.setTargetServiceName(operation.getActor());
+ }
- if (operation.getMessage() != null)
+ if (operation.getMessage() != null) {
trans.setResponseDescription(operation.getMessage());
+ }
trans.setInvocationId(operation.getSubRequestId());
- if (operation.getOutcome() != null)
+ if (operation.getOutcome() != null) {
trans.setResponseCode(operation.getOutcome());
+ }
- if (operation.getStart() != null)
+ if (operation.getStart() != null) {
trans.setStartTime(operation.getStart());
+ }
- if (operation.getEnd() != null)
+ if (operation.getEnd() != null) {
trans.setEndTime(operation.getEnd());
+ }
}
}
protected void transaction(VirtualControlLoopNotification notification, ZonedDateTime startTime) {
- MDCTransaction trans =
- MDCTransaction.newTransaction(notification.getRequestID().toString(), notification.getFrom()).
- setServiceName(notification.getClosedLoopControlName()).
- setTargetEntity(notification.getTarget()).
- setStartTime(startTime.toInstant()).
- setEndTime(notification.getNotificationTime().toInstant()).
- setResponseDescription(notification.getMessage());
+ MDCTransaction trans = MDCTransaction
+ .newTransaction(notification.getRequestId().toString(), notification.getFrom())
+ .setServiceName(notification.getClosedLoopControlName()).setTargetEntity(notification.getTarget())
+ .setStartTime(startTime.toInstant()).setEndTime(notification.getNotificationTime().toInstant())
+ .setResponseDescription(notification.getMessage());
switch (notification.getNotification()) {
case FINAL_OPENLOOP:
@@ -432,7 +437,7 @@ class CacheBasedControlLoopMetricsManager implements ControlLoopMetrics {
default:
/* unexpected */
logger.warn("unexpected notification type {} in notification {}",
- notification.getNotification().toString(), notification);
+ notification.getNotification().toString(), notification);
break;
}
diff --git a/controlloop/common/feature-controlloop-trans/src/test/java/org/onap/policy/drools/apps/controlloop/feature/trans/ControlLoopMetricsFeatureTest.java b/controlloop/common/feature-controlloop-trans/src/test/java/org/onap/policy/drools/apps/controlloop/feature/trans/ControlLoopMetricsFeatureTest.java
index 6e3db3f97..4c113aca7 100644
--- a/controlloop/common/feature-controlloop-trans/src/test/java/org/onap/policy/drools/apps/controlloop/feature/trans/ControlLoopMetricsFeatureTest.java
+++ b/controlloop/common/feature-controlloop-trans/src/test/java/org/onap/policy/drools/apps/controlloop/feature/trans/ControlLoopMetricsFeatureTest.java
@@ -73,7 +73,7 @@ public class ControlLoopMetricsFeatureTest {
this.cacheDefaults();
UUID requestId = UUID.randomUUID();
- notification.setRequestID(requestId);
+ notification.setRequestId(requestId);
feature.beforeDeliver(testController, CommInfrastructure.DMAAP, "POLICY-CL-MGT", notification);
assertNull(ControlLoopMetrics.manager.getTransaction(requestId));
@@ -85,7 +85,7 @@ public class ControlLoopMetricsFeatureTest {
ControlLoopMetricsFeature feature = new ControlLoopMetricsFeature();
VirtualControlLoopNotification notification = new VirtualControlLoopNotification();
UUID requestId = UUID.randomUUID();
- notification.setRequestID(requestId);
+ notification.setRequestId(requestId);
notification.setNotification(ControlLoopNotificationType.ACTIVE);
feature.beforeDeliver(testController, CommInfrastructure.DMAAP, "POLICY-CL-MGT", notification);
@@ -110,23 +110,23 @@ public class ControlLoopMetricsFeatureTest {
VirtualControlLoopNotification notification = this.generateNotification();
new ControlLoopMetricsFeature().beforeDeliver(testController, CommInfrastructure.DMAAP, "POLICY-CL-MGT", notification);
- assertNotNull(ControlLoopMetrics.manager.getTransaction(notification.getRequestID()));
+ assertNotNull(ControlLoopMetrics.manager.getTransaction(notification.getRequestId()));
ControlLoopMetrics.manager.resetCache(ControlLoopMetrics.manager.getCacheSize(), ControlLoopMetrics.manager.getTransactionTimeout());
- assertNull(ControlLoopMetrics.manager.getTransaction(notification.getRequestID()));
+ assertNull(ControlLoopMetrics.manager.getTransaction(notification.getRequestId()));
this.cacheDefaults();
}
@Test
public void removeTransaction() {
VirtualControlLoopNotification notification = this.generateNotification();
- assertNull(ControlLoopMetrics.manager.getTransaction(notification.getRequestID()));
- ControlLoopMetrics.manager.removeTransaction(notification.getRequestID());
+ assertNull(ControlLoopMetrics.manager.getTransaction(notification.getRequestId()));
+ ControlLoopMetrics.manager.removeTransaction(notification.getRequestId());
ControlLoopMetrics.manager.transactionEvent(testController, notification);
- assertNotNull(ControlLoopMetrics.manager.getTransaction(notification.getRequestID()));
- ControlLoopMetrics.manager.removeTransaction(notification.getRequestID());
- assertNull(ControlLoopMetrics.manager.getTransaction(notification.getRequestID()));
+ assertNotNull(ControlLoopMetrics.manager.getTransaction(notification.getRequestId()));
+ ControlLoopMetrics.manager.removeTransaction(notification.getRequestId());
+ assertNull(ControlLoopMetrics.manager.getTransaction(notification.getRequestId()));
}
@Test
@@ -135,7 +135,7 @@ public class ControlLoopMetricsFeatureTest {
for (int i=0; i < ControlLoopMetrics.manager.getCacheSize(); i++) {
VirtualControlLoopNotification notification = generateNotification();
feature.beforeDeliver(testController, CommInfrastructure.DMAAP, "POLICY-CL-MGT", notification);
- assertNotNull(ControlLoopMetrics.manager.getTransaction(notification.getRequestID()));
+ assertNotNull(ControlLoopMetrics.manager.getTransaction(notification.getRequestId()));
}
assertTrue(ControlLoopMetrics.manager.getCacheOccupancy() == ControlLoopMetrics.manager.getCacheOccupancy());
@@ -143,7 +143,7 @@ public class ControlLoopMetricsFeatureTest {
VirtualControlLoopNotification overflowNotification = generateNotification();
feature.beforeDeliver(testController, CommInfrastructure.DMAAP, "POLICY-CL-MGT", overflowNotification);
assertTrue(ControlLoopMetrics.manager.getCacheOccupancy() == ControlLoopMetrics.manager.getCacheOccupancy());
- assertNotNull(ControlLoopMetrics.manager.getTransaction(overflowNotification.getRequestID()));
+ assertNotNull(ControlLoopMetrics.manager.getTransaction(overflowNotification.getRequestId()));
assertTrue(ControlLoopMetrics.manager.getTransactionIds().size() == ControlLoopMetrics.manager.getCacheSize());
assertTrue(ControlLoopMetrics.manager.getCacheOccupancy() == ControlLoopMetrics.manager.getCacheSize());
assertFalse(ControlLoopMetrics.manager.getTransactionIds().isEmpty());
@@ -168,7 +168,7 @@ public class ControlLoopMetricsFeatureTest {
private VirtualControlLoopNotification generateNotification() {
VirtualControlLoopNotification notification = new VirtualControlLoopNotification();
UUID requestId = UUID.randomUUID();
- notification.setRequestID(requestId);
+ notification.setRequestId(requestId);
notification.setNotification(ControlLoopNotificationType.ACTIVE);
return notification;
}
diff --git a/controlloop/common/model-impl/appc/pom.xml b/controlloop/common/model-impl/appc/pom.xml
index d69f1eda8..2703b3e61 100644
--- a/controlloop/common/model-impl/appc/pom.xml
+++ b/controlloop/common/model-impl/appc/pom.xml
@@ -43,4 +43,45 @@
<scope>provided</scope>
</dependency>
</dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-checkstyle-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>onap-java-style</id>
+ <goals>
+ <goal>check</goal>
+ </goals>
+ <phase>process-sources</phase>
+ <configuration>
+ <!-- Use Google Java Style Guide:
+ https://github.com/checkstyle/checkstyle/blob/master/src/main/resources/google_checks.xml
+ with minor changes -->
+ <configLocation>onap-checkstyle/onap-java-style.xml</configLocation>
+ <!-- <sourceDirectory> is needed so that checkstyle ignores the generated sources directory -->
+ <sourceDirectory>${project.build.sourceDirectory}</sourceDirectory>
+ <includeResources>true</includeResources>
+ <includeTestSourceDirectory>true</includeTestSourceDirectory>
+ <includeTestResources>true</includeTestResources>
+ <excludes>
+ </excludes>
+ <consoleOutput>true</consoleOutput>
+ <failOnViolation>true</failOnViolation>
+ <violationSeverity>warning</violationSeverity>
+ </configuration>
+ </execution>
+ </executions>
+ <dependencies>
+ <dependency>
+ <groupId>org.onap.oparent</groupId>
+ <artifactId>checkstyle</artifactId>
+ <version>0.1.1</version>
+ <scope>compile</scope>
+ </dependency>
+ </dependencies>
+ </plugin>
+ </plugins>
+ </build>
</project>
diff --git a/controlloop/common/model-impl/appc/src/main/java/org/onap/policy/appc/CommonHeader.java b/controlloop/common/model-impl/appc/src/main/java/org/onap/policy/appc/CommonHeader.java
index 506303fc2..b2beb5548 100644
--- a/controlloop/common/model-impl/appc/src/main/java/org/onap/policy/appc/CommonHeader.java
+++ b/controlloop/common/model-impl/appc/src/main/java/org/onap/policy/appc/CommonHeader.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* appc
* ================================================================================
- * 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.
@@ -20,6 +20,8 @@
package org.onap.policy.appc;
+import com.google.gson.annotations.SerializedName;
+
import java.io.Serializable;
import java.time.Instant;
import java.util.ArrayList;
@@ -27,168 +29,188 @@ import java.util.Collection;
import java.util.Map;
import java.util.UUID;
-import com.google.gson.annotations.SerializedName;
-
public class CommonHeader implements Serializable {
- private static final long serialVersionUID = -3581658269910980336L;
-
- @SerializedName("TimeStamp")
- private Instant timeStamp = Instant.now();
-
- @SerializedName("APIver")
- private String apiVer = "1.01";
-
- @SerializedName("OriginatorID")
- private String originatorID;
-
- @SerializedName("RequestID")
- private UUID requestID;
-
- @SerializedName("SubRequestID")
- private String subRequestID;
-
- @SerializedName("RequestTrack")
- private Collection<String> requestTrack = new ArrayList<>();
-
- @SerializedName("Flags")
- private Collection<Map<String, String>> flags = new ArrayList<>();
-
- public CommonHeader() {
- }
-
- public CommonHeader(CommonHeader commonHeader) {
- this.originatorID = commonHeader.originatorID;
- this.requestID = commonHeader.requestID;
- this.subRequestID = commonHeader.subRequestID;
- if (commonHeader.requestTrack != null) {
- this.requestTrack.addAll(commonHeader.requestTrack);
- }
- if (commonHeader.flags != null) {
- this.flags.addAll(commonHeader.flags);
- }
- }
-
- public Instant getTimeStamp() {
- return timeStamp;
- }
-
- public void setTimeStamp(Instant timeStamp) {
- this.timeStamp = timeStamp;
- }
-
- public String getApiVer() {
- return apiVer;
- }
-
- public void setApiVer(String apiVer) {
- this.apiVer = apiVer;
- }
-
- public String getOriginatorID() {
- return originatorID;
- }
-
- public void setOriginatorID(String originatorID) {
- this.originatorID = originatorID;
- }
-
- public UUID getRequestID() {
- return requestID;
- }
-
- public void setRequestID(UUID requestID) {
- this.requestID = requestID;
- }
-
- public String getSubRequestID() {
- return subRequestID;
- }
-
- public void setSubRequestID(String subRequestID) {
- this.subRequestID = subRequestID;
- }
-
- public Collection<String> getRequestTrack() {
- return requestTrack;
- }
-
- public void setRequestTrack(Collection<String> requestTrack) {
- this.requestTrack = requestTrack;
- }
-
- public Collection<Map<String, String>> getFlags() {
- return flags;
- }
-
- public void setFlags(Collection<Map<String, String>> flags) {
- this.flags = flags;
- }
-
- @Override
- public String toString() {
- return "CommonHeader [TimeStamp=" + timeStamp + ", APIver=" + apiVer + ", OriginatorID=" + originatorID
- + ", RequestID=" + requestID + ", SubrequestID=" + subRequestID + ", RequestTrack=" + requestTrack
- + ", Flags=" + flags + "]";
- }
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((apiVer == null) ? 0 : apiVer.hashCode());
- result = prime * result + ((flags == null) ? 0 : flags.hashCode());
- result = prime * result + ((originatorID == null) ? 0 : originatorID.hashCode());
- result = prime * result + ((requestID == null) ? 0 : requestID.hashCode());
- result = prime * result + ((requestTrack == null) ? 0 : requestTrack.hashCode());
- result = prime * result + ((subRequestID == null) ? 0 : subRequestID.hashCode());
- result = prime * result + ((timeStamp == null) ? 0 : timeStamp.hashCode());
- return result;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (getClass() != obj.getClass())
- return false;
- CommonHeader other = (CommonHeader) obj;
- if (apiVer == null) {
- if (other.apiVer != null)
- return false;
- } else if (!apiVer.equals(other.apiVer))
- return false;
- if (flags == null) {
- if (other.flags != null)
- return false;
- } else if (!flags.equals(other.flags))
- return false;
- if (originatorID == null) {
- if (other.originatorID != null)
- return false;
- } else if (!originatorID.equals(other.originatorID))
- return false;
- if (requestID == null) {
- if (other.requestID != null)
- return false;
- } else if (!requestID.equals(other.requestID))
- return false;
- if (requestTrack == null) {
- if (other.requestTrack != null)
- return false;
- } else if (!requestTrack.equals(other.requestTrack))
- return false;
- if (subRequestID == null) {
- if (other.subRequestID != null)
- return false;
- } else if (!subRequestID.equals(other.subRequestID))
- return false;
- if (timeStamp == null) {
- if (other.timeStamp != null)
- return false;
- } else if (!timeStamp.equals(other.timeStamp))
- return false;
- return true;
- }
-
+ private static final long serialVersionUID = -3581658269910980336L;
+
+ @SerializedName("TimeStamp")
+ private Instant timeStamp = Instant.now();
+
+ @SerializedName("APIver")
+ private String apiVer = "1.01";
+
+ @SerializedName("OriginatorID")
+ private String originatorId;
+
+ @SerializedName("RequestID")
+ private UUID requestId;
+
+ @SerializedName("SubRequestID")
+ private String subRequestId;
+
+ @SerializedName("RequestTrack")
+ private Collection<String> requestTrack = new ArrayList<>();
+
+ @SerializedName("Flags")
+ private Collection<Map<String, String>> flags = new ArrayList<>();
+
+ public CommonHeader() {}
+
+ /**
+ * Construct an instance from an existing instance.
+ *
+ * @param commonHeader the existing instance
+ */
+ public CommonHeader(CommonHeader commonHeader) {
+ this.originatorId = commonHeader.originatorId;
+ this.requestId = commonHeader.requestId;
+ this.subRequestId = commonHeader.subRequestId;
+ if (commonHeader.requestTrack != null) {
+ this.requestTrack.addAll(commonHeader.requestTrack);
+ }
+ if (commonHeader.flags != null) {
+ this.flags.addAll(commonHeader.flags);
+ }
+ }
+
+ public Instant getTimeStamp() {
+ return timeStamp;
+ }
+
+ public void setTimeStamp(Instant timeStamp) {
+ this.timeStamp = timeStamp;
+ }
+
+ public String getApiVer() {
+ return apiVer;
+ }
+
+ public void setApiVer(String apiVer) {
+ this.apiVer = apiVer;
+ }
+
+ public String getOriginatorId() {
+ return originatorId;
+ }
+
+ public void setOriginatorId(String originatorId) {
+ this.originatorId = originatorId;
+ }
+
+ public UUID getRequestId() {
+ return requestId;
+ }
+
+ public void setRequestId(UUID requestId) {
+ this.requestId = requestId;
+ }
+
+ public String getSubRequestId() {
+ return subRequestId;
+ }
+
+ public void setSubRequestId(String subRequestId) {
+ this.subRequestId = subRequestId;
+ }
+
+ public Collection<String> getRequestTrack() {
+ return requestTrack;
+ }
+
+ public void setRequestTrack(Collection<String> requestTrack) {
+ this.requestTrack = requestTrack;
+ }
+
+ public Collection<Map<String, String>> getFlags() {
+ return flags;
+ }
+
+ public void setFlags(Collection<Map<String, String>> flags) {
+ this.flags = flags;
+ }
+
+ @Override
+ public String toString() {
+ return "CommonHeader [TimeStamp=" + timeStamp + ", APIver=" + apiVer + ", OriginatorID=" + originatorId
+ + ", RequestID=" + requestId + ", SubrequestID=" + subRequestId + ", RequestTrack=" + requestTrack
+ + ", Flags=" + flags + "]";
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((apiVer == null) ? 0 : apiVer.hashCode());
+ result = prime * result + ((flags == null) ? 0 : flags.hashCode());
+ result = prime * result + ((originatorId == null) ? 0 : originatorId.hashCode());
+ result = prime * result + ((requestId == null) ? 0 : requestId.hashCode());
+ result = prime * result + ((requestTrack == null) ? 0 : requestTrack.hashCode());
+ result = prime * result + ((subRequestId == null) ? 0 : subRequestId.hashCode());
+ result = prime * result + ((timeStamp == null) ? 0 : timeStamp.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ CommonHeader other = (CommonHeader) obj;
+ if (apiVer == null) {
+ if (other.apiVer != null) {
+ return false;
+ }
+ } else if (!apiVer.equals(other.apiVer)) {
+ return false;
+ }
+ if (flags == null) {
+ if (other.flags != null) {
+ return false;
+ }
+ } else if (!flags.equals(other.flags)) {
+ return false;
+ }
+ if (originatorId == null) {
+ if (other.originatorId != null) {
+ return false;
+ }
+ } else if (!originatorId.equals(other.originatorId)) {
+ return false;
+ }
+ if (requestId == null) {
+ if (other.requestId != null) {
+ return false;
+ }
+ } else if (!requestId.equals(other.requestId)) {
+ return false;
+ }
+ if (requestTrack == null) {
+ if (other.requestTrack != null) {
+ return false;
+ }
+ } else if (!requestTrack.equals(other.requestTrack)) {
+ return false;
+ }
+ if (subRequestId == null) {
+ if (other.subRequestId != null) {
+ return false;
+ }
+ } else if (!subRequestId.equals(other.subRequestId)) {
+ return false;
+ }
+ if (timeStamp == null) {
+ if (other.timeStamp != null) {
+ return false;
+ }
+ } else if (!timeStamp.equals(other.timeStamp)) {
+ return false;
+ }
+ return true;
+ }
+
}
diff --git a/controlloop/common/model-impl/appc/src/main/java/org/onap/policy/appc/Request.java b/controlloop/common/model-impl/appc/src/main/java/org/onap/policy/appc/Request.java
index fd37d31b2..c25e881a8 100644
--- a/controlloop/common/model-impl/appc/src/main/java/org/onap/policy/appc/Request.java
+++ b/controlloop/common/model-impl/appc/src/main/java/org/onap/policy/appc/Request.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* appc
* ================================================================================
- * 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.
@@ -20,133 +20,146 @@
package org.onap.policy.appc;
+import com.google.gson.annotations.SerializedName;
+
import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;
-import com.google.gson.annotations.SerializedName;
-
-public class Request implements Serializable{
- private static final long serialVersionUID = -3912323643990646431L;
-
- @SerializedName("CommonHeader")
- private CommonHeader commonHeader;
-
- @SerializedName("Action")
- private String action;
-
- @SerializedName("TargetID")
- private String targetID;
-
- @SerializedName("ObjectID")
- private String objectID;
-
- @SerializedName("Payload")
- private HashMap<String, Object> payload = new HashMap<>();
-
- public Request() {
- // Initiate an empty Request instance
- }
-
- public CommonHeader getCommonHeader() {
- return commonHeader;
- }
-
- public Map<String, Object> getPayload() {
- return payload;
- }
-
- public String getAction() {
- return action;
- }
-
- public void setAction(String action) {
- this.action = action;
- }
-
- public String getTargetID() {
- return targetID;
- }
-
- public void setTargetID(String targetID) {
- this.targetID = targetID;
- }
-
- public String getObjectID() {
- return objectID;
- }
-
- public void setObjectID(String objectID) {
- this.objectID = objectID;
- }
-
- public void setCommonHeader(CommonHeader commonHeader) {
- this.commonHeader = commonHeader;
- }
-
- public void setPayload(Map<String, Object> payload) {
- this.payload = new HashMap<>(payload);
- }
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((action == null) ? 0 : action.hashCode());
- result = prime * result + ((commonHeader == null) ? 0 : commonHeader.hashCode());
- result = prime * result + ((objectID == null) ? 0 : objectID.hashCode());
- result = prime * result + ((payload == null) ? 0 : payload.hashCode());
- result = prime * result + ((targetID == null) ? 0 : targetID.hashCode());
- return result;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (getClass() != obj.getClass())
- return false;
-
- Request other = (Request) obj;
- if (action == null) {
- if (other.action != null)
- return false;
- } else if (!action.equals(other.action))
- return false;
-
- if (commonHeader == null) {
- if (other.commonHeader != null)
- return false;
- } else if (!commonHeader.equals(other.commonHeader))
- return false;
-
- if (objectID == null) {
- if (other.objectID != null)
- return false;
- } else if (!objectID.equals(other.objectID))
- return false;
-
- if (payload == null) {
- if (other.payload != null)
- return false;
- } else if (!payload.equals(other.payload))
- return false;
-
- if (targetID == null) {
- if (other.targetID != null)
- return false;
- } else if (!targetID.equals(other.targetID))
- return false;
-
- return true;
- }
-
- @Override
- public String toString() {
- return "Request [CommonHeader=" + commonHeader + ", Action=" + action + ", TargetID=" + targetID + ", ObjectID="
- + objectID + ", Payload=" + payload + "]";
- }
+public class Request implements Serializable {
+ private static final long serialVersionUID = -3912323643990646431L;
+
+ @SerializedName("CommonHeader")
+ private CommonHeader commonHeader;
+
+ @SerializedName("Action")
+ private String action;
+
+ @SerializedName("TargetID")
+ private String targetId;
+
+ @SerializedName("ObjectID")
+ private String objectId;
+
+ @SerializedName("Payload")
+ private HashMap<String, Object> payload = new HashMap<>();
+
+ public Request() {
+ // Initiate an empty Request instance
+ }
+
+ public CommonHeader getCommonHeader() {
+ return commonHeader;
+ }
+
+ public Map<String, Object> getPayload() {
+ return payload;
+ }
+
+ public String getAction() {
+ return action;
+ }
+
+ public void setAction(String action) {
+ this.action = action;
+ }
+
+ public String getTargetId() {
+ return targetId;
+ }
+
+ public void setTargetId(String targetId) {
+ this.targetId = targetId;
+ }
+
+ public String getObjectId() {
+ return objectId;
+ }
+
+ public void setObjectId(String objectId) {
+ this.objectId = objectId;
+ }
+
+ public void setCommonHeader(CommonHeader commonHeader) {
+ this.commonHeader = commonHeader;
+ }
+
+ public void setPayload(Map<String, Object> payload) {
+ this.payload = new HashMap<>(payload);
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((action == null) ? 0 : action.hashCode());
+ result = prime * result + ((commonHeader == null) ? 0 : commonHeader.hashCode());
+ result = prime * result + ((objectId == null) ? 0 : objectId.hashCode());
+ result = prime * result + ((payload == null) ? 0 : payload.hashCode());
+ result = prime * result + ((targetId == null) ? 0 : targetId.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+
+ Request other = (Request) obj;
+ if (action == null) {
+ if (other.action != null) {
+ return false;
+ }
+ } else if (!action.equals(other.action)) {
+ return false;
+ }
+
+ if (commonHeader == null) {
+ if (other.commonHeader != null) {
+ return false;
+ }
+ } else if (!commonHeader.equals(other.commonHeader)) {
+ return false;
+ }
+
+ if (objectId == null) {
+ if (other.objectId != null) {
+ return false;
+ }
+ } else if (!objectId.equals(other.objectId)) {
+ return false;
+ }
+
+ if (payload == null) {
+ if (other.payload != null) {
+ return false;
+ }
+ } else if (!payload.equals(other.payload)) {
+ return false;
+ }
+
+ if (targetId == null) {
+ if (other.targetId != null) {
+ return false;
+ }
+ } else if (!targetId.equals(other.targetId)) {
+ return false;
+ }
+
+ return true;
+ }
+
+ @Override
+ public String toString() {
+ return "Request [CommonHeader=" + commonHeader + ", Action=" + action + ", TargetID=" + targetId + ", ObjectID="
+ + objectId + ", Payload=" + payload + "]";
+ }
}
diff --git a/controlloop/common/model-impl/appc/src/main/java/org/onap/policy/appc/Response.java b/controlloop/common/model-impl/appc/src/main/java/org/onap/policy/appc/Response.java
index b117350ae..af503b104 100644
--- a/controlloop/common/model-impl/appc/src/main/java/org/onap/policy/appc/Response.java
+++ b/controlloop/common/model-impl/appc/src/main/java/org/onap/policy/appc/Response.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* appc
* ================================================================================
- * 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.
@@ -20,101 +20,117 @@
package org.onap.policy.appc;
+import com.google.gson.annotations.SerializedName;
+
import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;
-import com.google.gson.annotations.SerializedName;
-
public class Response implements Serializable {
- private static final long serialVersionUID = 434953706339865151L;
-
- @SerializedName("CommonHeader")
- private CommonHeader commonHeader;
-
- @SerializedName("Status")
- private ResponseStatus status = new ResponseStatus();
-
- @SerializedName("Payload")
- private HashMap<String, Object> payload = new HashMap<>();
-
- public Response() {
-
- }
-
- public Response(Request request) {
- if (request.getCommonHeader() != null) {
- this.commonHeader = new CommonHeader(request.getCommonHeader());
- }
- if (request.getPayload() != null) {
- this.payload.putAll(request.getPayload());
- }
- }
-
- public CommonHeader getCommonHeader() {
- return commonHeader;
- }
-
- public void setCommonHeader(CommonHeader commonHeader) {
- this.commonHeader = commonHeader;
- }
-
- public ResponseStatus getStatus() {
- return status;
- }
-
- public void setStatus(ResponseStatus status) {
- this.status = status;
- }
-
- public Map<String, Object> getPayload() {
- return payload;
- }
-
- public void setPayload(Map<String, Object> payload) {
- this.payload = new HashMap<>(payload);
- }
-
- @Override
- public String toString() {
- return "Response [CommonHeader=" + commonHeader + ", Status=" + status + ", Payload=" + payload + "]";
- }
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((commonHeader == null) ? 0 : commonHeader.hashCode());
- result = prime * result + ((payload == null) ? 0 : payload.hashCode());
- result = prime * result + ((status == null) ? 0 : status.hashCode());
- return result;
- }
- @Override
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (getClass() != obj.getClass())
- return false;
- Response other = (Response) obj;
- if (commonHeader == null) {
- if (other.commonHeader != null)
- return false;
- } else if (!commonHeader.equals(other.commonHeader))
- return false;
- if (payload == null) {
- if (other.payload != null)
- return false;
- } else if (!payload.equals(other.payload))
- return false;
- if (status == null) {
- if (other.status != null)
- return false;
- } else if (!status.equals(other.status))
- return false;
- return true;
- }
-
-
-
+ private static final long serialVersionUID = 434953706339865151L;
+
+ @SerializedName("CommonHeader")
+ private CommonHeader commonHeader;
+
+ @SerializedName("Status")
+ private ResponseStatus status = new ResponseStatus();
+
+ @SerializedName("Payload")
+ private HashMap<String, Object> payload = new HashMap<>();
+
+ public Response() {
+
+ }
+
+ /**
+ * Construct an instance from an existing instance.
+ *
+ * @param request the existing instance
+ */
+ public Response(Request request) {
+ if (request.getCommonHeader() != null) {
+ this.commonHeader = new CommonHeader(request.getCommonHeader());
+ }
+ if (request.getPayload() != null) {
+ this.payload.putAll(request.getPayload());
+ }
+ }
+
+ public CommonHeader getCommonHeader() {
+ return commonHeader;
+ }
+
+ public void setCommonHeader(CommonHeader commonHeader) {
+ this.commonHeader = commonHeader;
+ }
+
+ public ResponseStatus getStatus() {
+ return status;
+ }
+
+ public void setStatus(ResponseStatus status) {
+ this.status = status;
+ }
+
+ public Map<String, Object> getPayload() {
+ return payload;
+ }
+
+ public void setPayload(Map<String, Object> payload) {
+ this.payload = new HashMap<>(payload);
+ }
+
+ @Override
+ public String toString() {
+ return "Response [CommonHeader=" + commonHeader + ", Status=" + status + ", Payload=" + payload + "]";
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((commonHeader == null) ? 0 : commonHeader.hashCode());
+ result = prime * result + ((payload == null) ? 0 : payload.hashCode());
+ result = prime * result + ((status == null) ? 0 : status.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ Response other = (Response) obj;
+ if (commonHeader == null) {
+ if (other.commonHeader != null) {
+ return false;
+ }
+ } else if (!commonHeader.equals(other.commonHeader)) {
+ return false;
+ }
+ if (payload == null) {
+ if (other.payload != null) {
+ return false;
+ }
+ } else if (!payload.equals(other.payload)) {
+ return false;
+ }
+ if (status == null) {
+ if (other.status != null) {
+ return false;
+ }
+ } else if (!status.equals(other.status)) {
+ return false;
+ }
+ return true;
+ }
+
+
+
}
diff --git a/controlloop/common/model-impl/appc/src/main/java/org/onap/policy/appc/ResponseCode.java b/controlloop/common/model-impl/appc/src/main/java/org/onap/policy/appc/ResponseCode.java
index 3b0d445aa..b62f917ba 100644
--- a/controlloop/common/model-impl/appc/src/main/java/org/onap/policy/appc/ResponseCode.java
+++ b/controlloop/common/model-impl/appc/src/main/java/org/onap/policy/appc/ResponseCode.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* appc
* ================================================================================
- * 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.
@@ -23,45 +23,46 @@ package org.onap.policy.appc;
import com.google.gson.annotations.SerializedName;
public enum ResponseCode {
- ACCEPT(100),
- ERROR(200),
- REJECT(300),
- SUCCESS(400),
- FAILURE(500)
- ;
+ ACCEPT(100), ERROR(200), REJECT(300), SUCCESS(400), FAILURE(500);
- @SerializedName("Code")
- private Integer code;
+ @SerializedName("Code")
+ private Integer code;
- private ResponseCode(int code) {
- this.code = code;
- }
+ private ResponseCode(int code) {
+ this.code = code;
+ }
- public int getValue() {
- return this.code;
- }
+ public int getValue() {
+ return this.code;
+ }
- @Override
- public String toString() {
- return Integer.toString(this.code);
- }
+ @Override
+ public String toString() {
+ return Integer.toString(this.code);
+ }
- public static ResponseCode toResponseCode(int code) {
- if (code == ACCEPT.code) {
- return ACCEPT;
- }
- if (code == ERROR.code) {
- return ERROR;
- }
- if (code == REJECT.code) {
- return REJECT;
- }
- if (code == SUCCESS.code) {
- return SUCCESS;
- }
- if (code == FAILURE.code) {
- return FAILURE;
- }
- return null;
- }
+ /**
+ * Convert an integer code to a ResponseCode.
+ *
+ * @param code the integer code
+ * @return the ResponseCode
+ */
+ public static ResponseCode toResponseCode(int code) {
+ if (code == ACCEPT.code) {
+ return ACCEPT;
+ }
+ if (code == ERROR.code) {
+ return ERROR;
+ }
+ if (code == REJECT.code) {
+ return REJECT;
+ }
+ if (code == SUCCESS.code) {
+ return SUCCESS;
+ }
+ if (code == FAILURE.code) {
+ return FAILURE;
+ }
+ return null;
+ }
}
diff --git a/controlloop/common/model-impl/appc/src/main/java/org/onap/policy/appc/ResponseStatus.java b/controlloop/common/model-impl/appc/src/main/java/org/onap/policy/appc/ResponseStatus.java
index 7f85ac7a7..f54117862 100644
--- a/controlloop/common/model-impl/appc/src/main/java/org/onap/policy/appc/ResponseStatus.java
+++ b/controlloop/common/model-impl/appc/src/main/java/org/onap/policy/appc/ResponseStatus.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* appc
* ================================================================================
- * 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.
@@ -20,83 +20,91 @@
package org.onap.policy.appc;
-import java.io.Serializable;
-
import com.google.gson.annotations.SerializedName;
+import java.io.Serializable;
+
public class ResponseStatus implements Serializable {
- private static final long serialVersionUID = 2421770469587860452L;
-
- @SerializedName("Code")
- private int code;
-
- @SerializedName("Value")
- private String value;
-
- @SerializedName("Description")
- private String description;
-
- @Override
- public String toString() {
- return "ResponseStatus [Code=" + code + ", Value=" + value + ", Description=" + description + "]";
- }
-
- public int getCode() {
- return code;
- }
-
- public void setCode(int code) {
- this.code = code;
- }
-
- public String getValue() {
- return value;
- }
-
- public void setValue(String value) {
- this.value = value;
- }
-
- public String getDescription() {
- return description;
- }
-
- public void setDescription(String description) {
- this.description = description;
- }
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + code;
- result = prime * result + ((description == null) ? 0 : description.hashCode());
- result = prime * result + ((value == null) ? 0 : value.hashCode());
- return result;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (getClass() != obj.getClass())
- return false;
- ResponseStatus other = (ResponseStatus) obj;
- if (code != other.code)
- return false;
- if (description == null) {
- if (other.description != null)
- return false;
- } else if (!description.equals(other.description))
- return false;
- if (value == null) {
- if (other.value != null)
- return false;
- } else if (!value.equals(other.value))
- return false;
- return true;
- }
-
+ private static final long serialVersionUID = 2421770469587860452L;
+
+ @SerializedName("Code")
+ private int code;
+
+ @SerializedName("Value")
+ private String value;
+
+ @SerializedName("Description")
+ private String description;
+
+ @Override
+ public String toString() {
+ return "ResponseStatus [Code=" + code + ", Value=" + value + ", Description=" + description + "]";
+ }
+
+ public int getCode() {
+ return code;
+ }
+
+ public void setCode(int code) {
+ this.code = code;
+ }
+
+ public String getValue() {
+ return value;
+ }
+
+ public void setValue(String value) {
+ this.value = value;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + code;
+ result = prime * result + ((description == null) ? 0 : description.hashCode());
+ result = prime * result + ((value == null) ? 0 : value.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ ResponseStatus other = (ResponseStatus) obj;
+ if (code != other.code) {
+ return false;
+ }
+ if (description == null) {
+ if (other.description != null) {
+ return false;
+ }
+ } else if (!description.equals(other.description)) {
+ return false;
+ }
+ if (value == null) {
+ if (other.value != null) {
+ return false;
+ }
+ } else if (!value.equals(other.value)) {
+ return false;
+ }
+ return true;
+ }
+
}
diff --git a/controlloop/common/model-impl/appc/src/main/java/org/onap/policy/appc/ResponseValue.java b/controlloop/common/model-impl/appc/src/main/java/org/onap/policy/appc/ResponseValue.java
index 8d9bede23..a12f9d139 100644
--- a/controlloop/common/model-impl/appc/src/main/java/org/onap/policy/appc/ResponseValue.java
+++ b/controlloop/common/model-impl/appc/src/main/java/org/onap/policy/appc/ResponseValue.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* appc
* ================================================================================
- * 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.
@@ -23,47 +23,48 @@ package org.onap.policy.appc;
import com.google.gson.annotations.SerializedName;
public enum ResponseValue {
- ACCEPT("ACCEPT"),
- ERROR("ERROR"),
- REJECT("REJECT"),
- SUCCESS("SUCCESS"),
- FAILURE("FAILURE")
- ;
-
- @SerializedName("Value")
- private String value;
-
- private ResponseValue(String value) {
- this.value = value;
- }
+ ACCEPT("ACCEPT"), ERROR("ERROR"), REJECT("REJECT"), SUCCESS("SUCCESS"), FAILURE("FAILURE");
- @Override
- public String toString() {
- return this.value;
- }
+ @SerializedName("Value")
+ private String value;
+
+ private ResponseValue(String value) {
+ this.value = value;
+ }
+
+ @Override
+ public String toString() {
+ return this.value;
+ }
+
+ /**
+ * Convert a String value to a ResponseValue.
+ *
+ * @param value the String value
+ * @return the ResponseValue
+ */
+ public static ResponseValue toResponseValue(String value) {
+ if (value == null) {
+ return null;
+ }
+
+ if (value.equals(ACCEPT.toString())) {
+ return ACCEPT;
+ }
+ if (value.equals(ERROR.toString())) {
+ return ERROR;
+ }
+ if (value.equals(REJECT.toString())) {
+ return REJECT;
+ }
+ if (value.equals(SUCCESS.toString())) {
+ return SUCCESS;
+ }
+ if (value.equals(FAILURE.toString())) {
+ return FAILURE;
+ }
+
+ return null;
+ }
- public static ResponseValue toResponseValue(String value) {
- if (value == null) {
- return null;
- }
-
- if (value.equals(ACCEPT.toString())) {
- return ACCEPT;
- }
- if (value.equals(ERROR.toString())) {
- return ERROR;
- }
- if (value.equals(REJECT.toString())) {
- return REJECT;
- }
- if (value.equals(SUCCESS.toString())) {
- return SUCCESS;
- }
- if (value.equals(FAILURE.toString())) {
- return FAILURE;
- }
-
- return null;
- }
-
}
diff --git a/controlloop/common/model-impl/appc/src/main/java/org/onap/policy/appc/util/Serialization.java b/controlloop/common/model-impl/appc/src/main/java/org/onap/policy/appc/util/Serialization.java
index 6e04ee977..3e16f2943 100644
--- a/controlloop/common/model-impl/appc/src/main/java/org/onap/policy/appc/util/Serialization.java
+++ b/controlloop/common/model-impl/appc/src/main/java/org/onap/policy/appc/util/Serialization.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* appc
* ================================================================================
- * 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.
@@ -20,14 +20,6 @@
package org.onap.policy.appc.util;
-import java.lang.reflect.Type;
-import java.time.Instant;
-import java.time.ZonedDateTime;
-import java.time.format.DateTimeFormatter;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonDeserializationContext;
@@ -37,51 +29,57 @@ import com.google.gson.JsonPrimitive;
import com.google.gson.JsonSerializationContext;
import com.google.gson.JsonSerializer;
+import java.lang.reflect.Type;
+import java.time.Instant;
+import java.time.ZonedDateTime;
+import java.time.format.DateTimeFormatter;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
public final class Serialization {
- public static final DateTimeFormatter format = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSSSSSxxx");
+ public static final DateTimeFormatter format = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSSSSSxxx");
+
+ private Serialization() {}
+
+ public static class GsonUtcAdapter implements JsonSerializer<ZonedDateTime>, JsonDeserializer<ZonedDateTime> {
+ private static final Logger logger = LoggerFactory.getLogger(GsonUtcAdapter.class);
+
+ @Override
+ public ZonedDateTime deserialize(JsonElement element, Type type, JsonDeserializationContext context) {
+ try {
+ return ZonedDateTime.parse(element.getAsString(), format);
+ } catch (Exception e) {
+ logger.error("deserialize threw: ", e);
+ }
+ return null;
+ }
+
+ @Override
+ public JsonElement serialize(ZonedDateTime datetime, Type type, JsonSerializationContext context) {
+ return new JsonPrimitive(datetime.format(format));
+ }
+ }
- private Serialization(){
- }
+ public static class GsonInstantAdapter implements JsonSerializer<Instant>, JsonDeserializer<Instant> {
- public static class GSONUTCAdapter implements JsonSerializer<ZonedDateTime>, JsonDeserializer<ZonedDateTime> {
- private static final Logger logger = LoggerFactory.getLogger(GSONUTCAdapter.class);
-
- @Override
- public ZonedDateTime deserialize(JsonElement element, Type type, JsonDeserializationContext context) {
- try {
- return ZonedDateTime.parse(element.getAsString(), format);
- } catch (Exception e) {
- logger.error("deserialize threw: ", e);
- }
- return null;
- }
+ @Override
+ public Instant deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) {
+ return Instant.ofEpochMilli(json.getAsLong());
+ }
- public JsonElement serialize(ZonedDateTime datetime, Type type, JsonSerializationContext context) {
- return new JsonPrimitive(datetime.format(format));
- }
- }
-
- public static class GSONInstantAdapter implements JsonSerializer<Instant>, JsonDeserializer<Instant> {
+ @Override
+ public JsonElement serialize(Instant src, Type typeOfSrc, JsonSerializationContext context) {
+ return new JsonPrimitive(src.toEpochMilli());
+ }
- @Override
- public Instant deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) {
- return Instant.ofEpochMilli(json.getAsLong());
- }
+ }
- @Override
- public JsonElement serialize(Instant src, Type typeOfSrc, JsonSerializationContext context) {
- return new JsonPrimitive(src.toEpochMilli());
- }
-
- }
+ public static final Gson gsonPretty = new GsonBuilder().disableHtmlEscaping().setPrettyPrinting()
+ .registerTypeAdapter(ZonedDateTime.class, new GsonUtcAdapter())
+ .registerTypeAdapter(Instant.class, new GsonInstantAdapter())
+ // .registerTypeAdapter(CommonHeader1607.class, new gsonCommonHeaderInstance())
+ // .registerTypeAdapter(ResponseStatus1607.class, new gsonResponseStatus())
+ .create();
- public static final Gson gsonPretty = new GsonBuilder()
- .disableHtmlEscaping()
- .setPrettyPrinting()
- .registerTypeAdapter(ZonedDateTime.class, new GSONUTCAdapter())
- .registerTypeAdapter(Instant.class, new GSONInstantAdapter())
-// .registerTypeAdapter(CommonHeader1607.class, new gsonCommonHeaderInstance())
-// .registerTypeAdapter(ResponseStatus1607.class, new gsonResponseStatus())
- .create();
-
}
diff --git a/controlloop/common/model-impl/appc/src/test/java/org/onap/policy/appc/TestCommonHeader.java b/controlloop/common/model-impl/appc/src/test/java/org/onap/policy/appc/TestCommonHeader.java
index 039117272..2e456bca0 100644
--- a/controlloop/common/model-impl/appc/src/test/java/org/onap/policy/appc/TestCommonHeader.java
+++ b/controlloop/common/model-impl/appc/src/test/java/org/onap/policy/appc/TestCommonHeader.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* appc
* ================================================================================
- * 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.
@@ -40,7 +40,11 @@
package org.onap.policy.appc;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
import java.time.Instant;
import java.util.ArrayList;
@@ -52,56 +56,56 @@ import org.junit.Test;
public class TestCommonHeader {
- @Test
- public void testCommonHeader() {
- CommonHeader commonHeader = new CommonHeader();
- assertNotNull(commonHeader);
- assertNotNull(new CommonHeader(commonHeader));
- assertNotEquals(0, commonHeader.hashCode());
-
- commonHeader.setApiVer("Kansas");
- assertEquals("Kansas", commonHeader.getApiVer());
-
- List<Map<String, String>> flagSet = new ArrayList<>();
- commonHeader.setFlags(flagSet);
- assertEquals(flagSet, commonHeader.getFlags());
-
- commonHeader.setOriginatorID("Dorothy");
- assertEquals("Dorothy", commonHeader.getOriginatorID());
-
- UUID requestID = UUID.randomUUID();
- commonHeader.setRequestID(requestID);
- assertEquals(requestID, commonHeader.getRequestID());
-
- List<String> requestTrackSet = new ArrayList<>();
- commonHeader.setRequestTrack(requestTrackSet);
- assertEquals(requestTrackSet, commonHeader.getRequestTrack());
-
- commonHeader.setSubRequestID("Can I go home?");
- assertEquals("Can I go home?", commonHeader.getSubRequestID());
-
- Instant timestamp = Instant.now();
- commonHeader.setTimeStamp(timestamp);
- assertEquals(timestamp, commonHeader.getTimeStamp());
-
- assertNotEquals(0, commonHeader.hashCode());
-
- assertEquals("CommonHeader [TimeStamp=", commonHeader.toString().substring(0, 24));
-
+ @Test
+ public void testCommonHeader() {
+ CommonHeader commonHeader = new CommonHeader();
+ assertNotNull(commonHeader);
+ assertNotNull(new CommonHeader(commonHeader));
+ assertNotEquals(0, commonHeader.hashCode());
+
+ commonHeader.setApiVer("Kansas");
+ assertEquals("Kansas", commonHeader.getApiVer());
+
+ List<Map<String, String>> flagSet = new ArrayList<>();
+ commonHeader.setFlags(flagSet);
+ assertEquals(flagSet, commonHeader.getFlags());
+
+ commonHeader.setOriginatorId("Dorothy");
+ assertEquals("Dorothy", commonHeader.getOriginatorId());
+
+ UUID requestId = UUID.randomUUID();
+ commonHeader.setRequestId(requestId);
+ assertEquals(requestId, commonHeader.getRequestId());
+
+ List<String> requestTrackSet = new ArrayList<>();
+ commonHeader.setRequestTrack(requestTrackSet);
+ assertEquals(requestTrackSet, commonHeader.getRequestTrack());
+
+ commonHeader.setSubRequestId("Can I go home?");
+ assertEquals("Can I go home?", commonHeader.getSubRequestId());
+
+ Instant timestamp = Instant.now();
+ commonHeader.setTimeStamp(timestamp);
+ assertEquals(timestamp, commonHeader.getTimeStamp());
+
+ assertNotEquals(0, commonHeader.hashCode());
+
+ assertEquals("CommonHeader [TimeStamp=", commonHeader.toString().substring(0, 24));
+
CommonHeader copiedCommonHeader = new CommonHeader();
copiedCommonHeader.setApiVer(commonHeader.getApiVer());
copiedCommonHeader.setFlags(commonHeader.getFlags());
- copiedCommonHeader.setOriginatorID(commonHeader.getOriginatorID());
- copiedCommonHeader.setRequestID(commonHeader.getRequestID());
+ copiedCommonHeader.setOriginatorId(commonHeader.getOriginatorId());
+ copiedCommonHeader.setRequestId(commonHeader.getRequestId());
copiedCommonHeader.setRequestTrack(commonHeader.getRequestTrack());
- copiedCommonHeader.setSubRequestID(commonHeader.getSubRequestID());
+ copiedCommonHeader.setSubRequestId(commonHeader.getSubRequestId());
copiedCommonHeader.setTimeStamp(commonHeader.getTimeStamp());
-
+
assertTrue(commonHeader.equals(commonHeader));
assertTrue(commonHeader.equals(copiedCommonHeader));
assertFalse(commonHeader.equals(null));
assertFalse(commonHeader.equals("Hello"));
-
+
CommonHeader clonedCommonHeader = new CommonHeader(commonHeader);
clonedCommonHeader.setApiVer(commonHeader.getApiVer());
clonedCommonHeader.setTimeStamp(commonHeader.getTimeStamp());
@@ -116,7 +120,7 @@ public class TestCommonHeader {
assertFalse(commonHeader.equals(copiedCommonHeader));
copiedCommonHeader.setApiVer("Kansas");
assertTrue(commonHeader.equals(copiedCommonHeader));
-
+
commonHeader.setFlags(null);
assertFalse(commonHeader.equals(copiedCommonHeader));
copiedCommonHeader.setFlags(null);
@@ -125,50 +129,50 @@ public class TestCommonHeader {
assertFalse(commonHeader.equals(copiedCommonHeader));
copiedCommonHeader.setFlags(flagSet);
assertTrue(commonHeader.equals(copiedCommonHeader));
-
- commonHeader.setOriginatorID(null);
+
+ commonHeader.setOriginatorId(null);
assertFalse(commonHeader.equals(copiedCommonHeader));
- copiedCommonHeader.setOriginatorID(null);
+ copiedCommonHeader.setOriginatorId(null);
assertTrue(commonHeader.equals(copiedCommonHeader));
- commonHeader.setOriginatorID("Dorothy");
+ commonHeader.setOriginatorId("Dorothy");
assertFalse(commonHeader.equals(copiedCommonHeader));
- copiedCommonHeader.setOriginatorID("Dorothy");
+ copiedCommonHeader.setOriginatorId("Dorothy");
assertTrue(commonHeader.equals(copiedCommonHeader));
-
- commonHeader.setRequestID(null);
+
+ commonHeader.setRequestId(null);
assertFalse(commonHeader.equals(copiedCommonHeader));
- copiedCommonHeader.setRequestID(null);
+ copiedCommonHeader.setRequestId(null);
assertTrue(commonHeader.equals(copiedCommonHeader));
- commonHeader.setRequestID(requestID);
+ commonHeader.setRequestId(requestId);
assertFalse(commonHeader.equals(copiedCommonHeader));
- copiedCommonHeader.setRequestID(requestID);
+ copiedCommonHeader.setRequestId(requestId);
assertTrue(commonHeader.equals(copiedCommonHeader));
-
+
commonHeader.setRequestTrack(null);
assertFalse(commonHeader.equals(copiedCommonHeader));
- copiedCommonHeader.setRequestTrack(null);
+ copiedCommonHeader.setRequestTrack(null);
assertTrue(commonHeader.equals(copiedCommonHeader));
commonHeader.setRequestTrack(requestTrackSet);
assertFalse(commonHeader.equals(copiedCommonHeader));
- copiedCommonHeader.setRequestTrack(requestTrackSet);
+ copiedCommonHeader.setRequestTrack(requestTrackSet);
assertTrue(commonHeader.equals(copiedCommonHeader));
-
- commonHeader.setSubRequestID(null);
+
+ commonHeader.setSubRequestId(null);
assertFalse(commonHeader.equals(copiedCommonHeader));
- copiedCommonHeader.setSubRequestID(null);
+ copiedCommonHeader.setSubRequestId(null);
assertTrue(commonHeader.equals(copiedCommonHeader));
- commonHeader.setSubRequestID("Can I go home?");
+ commonHeader.setSubRequestId("Can I go home?");
assertFalse(commonHeader.equals(copiedCommonHeader));
- copiedCommonHeader.setSubRequestID("Can I go home?");
+ copiedCommonHeader.setSubRequestId("Can I go home?");
assertTrue(commonHeader.equals(copiedCommonHeader));
-
+
commonHeader.setTimeStamp(null);
assertFalse(commonHeader.equals(copiedCommonHeader));
- copiedCommonHeader.setTimeStamp(null);
+ copiedCommonHeader.setTimeStamp(null);
assertTrue(commonHeader.equals(copiedCommonHeader));
commonHeader.setTimeStamp(timestamp);
assertFalse(commonHeader.equals(copiedCommonHeader));
- copiedCommonHeader.setTimeStamp(timestamp);
+ copiedCommonHeader.setTimeStamp(timestamp);
assertTrue(commonHeader.equals(copiedCommonHeader));
- }
+ }
}
diff --git a/controlloop/common/model-impl/appc/src/test/java/org/onap/policy/appc/TestEnums.java b/controlloop/common/model-impl/appc/src/test/java/org/onap/policy/appc/TestEnums.java
index e04da3cce..95adec84f 100644
--- a/controlloop/common/model-impl/appc/src/test/java/org/onap/policy/appc/TestEnums.java
+++ b/controlloop/common/model-impl/appc/src/test/java/org/onap/policy/appc/TestEnums.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* appc
* ================================================================================
- * 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.
@@ -20,54 +20,55 @@
package org.onap.policy.appc;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
import org.junit.Test;
public class TestEnums {
- @Test
- public void testResponseCode() {
- assertEquals(5, ResponseCode.values().length);
-
- assertNull(ResponseCode.toResponseCode(0));
-
- assertEquals(ResponseCode.ACCEPT, ResponseCode.toResponseCode(100));
- assertEquals(ResponseCode.ERROR, ResponseCode.toResponseCode(200));
- assertEquals(ResponseCode.REJECT, ResponseCode.toResponseCode(300));
- assertEquals(ResponseCode.SUCCESS, ResponseCode.toResponseCode(400));
- assertEquals(ResponseCode.FAILURE, ResponseCode.toResponseCode(500));
-
- assertEquals(100, ResponseCode.ACCEPT.getValue());
- assertEquals(200, ResponseCode.ERROR.getValue());
- assertEquals(300, ResponseCode.REJECT.getValue());
- assertEquals(400, ResponseCode.SUCCESS.getValue());
- assertEquals(500, ResponseCode.FAILURE.getValue());
+ @Test
+ public void testResponseCode() {
+ assertEquals(5, ResponseCode.values().length);
- assertEquals("100", ResponseCode.ACCEPT.toString());
- assertEquals("200", ResponseCode.ERROR.toString());
- assertEquals("300", ResponseCode.REJECT.toString());
- assertEquals("400", ResponseCode.SUCCESS.toString());
- assertEquals("500", ResponseCode.FAILURE.toString());
- }
+ assertNull(ResponseCode.toResponseCode(0));
- @Test
- public void testResponseValue() {
- assertEquals(5, ResponseValue.values().length);
-
- assertNull(ResponseValue.toResponseValue("Dorothy"));
- assertNull(ResponseValue.toResponseValue(null));
-
- assertEquals(ResponseValue.ACCEPT, ResponseValue.toResponseValue("ACCEPT"));
- assertEquals(ResponseValue.ERROR, ResponseValue.toResponseValue("ERROR"));
- assertEquals(ResponseValue.REJECT, ResponseValue.toResponseValue("REJECT"));
- assertEquals(ResponseValue.SUCCESS, ResponseValue.toResponseValue("SUCCESS"));
- assertEquals(ResponseValue.FAILURE, ResponseValue.toResponseValue("FAILURE"));
+ assertEquals(ResponseCode.ACCEPT, ResponseCode.toResponseCode(100));
+ assertEquals(ResponseCode.ERROR, ResponseCode.toResponseCode(200));
+ assertEquals(ResponseCode.REJECT, ResponseCode.toResponseCode(300));
+ assertEquals(ResponseCode.SUCCESS, ResponseCode.toResponseCode(400));
+ assertEquals(ResponseCode.FAILURE, ResponseCode.toResponseCode(500));
- assertEquals("ACCEPT", ResponseValue.ACCEPT.toString());
- assertEquals("ERROR", ResponseValue.ERROR.toString());
- assertEquals("REJECT", ResponseValue.REJECT.toString());
- assertEquals("SUCCESS", ResponseValue.SUCCESS.toString());
- assertEquals("FAILURE", ResponseValue.FAILURE.toString());
- }
+ assertEquals(100, ResponseCode.ACCEPT.getValue());
+ assertEquals(200, ResponseCode.ERROR.getValue());
+ assertEquals(300, ResponseCode.REJECT.getValue());
+ assertEquals(400, ResponseCode.SUCCESS.getValue());
+ assertEquals(500, ResponseCode.FAILURE.getValue());
+
+ assertEquals("100", ResponseCode.ACCEPT.toString());
+ assertEquals("200", ResponseCode.ERROR.toString());
+ assertEquals("300", ResponseCode.REJECT.toString());
+ assertEquals("400", ResponseCode.SUCCESS.toString());
+ assertEquals("500", ResponseCode.FAILURE.toString());
+ }
+
+ @Test
+ public void testResponseValue() {
+ assertEquals(5, ResponseValue.values().length);
+
+ assertNull(ResponseValue.toResponseValue("Dorothy"));
+ assertNull(ResponseValue.toResponseValue(null));
+
+ assertEquals(ResponseValue.ACCEPT, ResponseValue.toResponseValue("ACCEPT"));
+ assertEquals(ResponseValue.ERROR, ResponseValue.toResponseValue("ERROR"));
+ assertEquals(ResponseValue.REJECT, ResponseValue.toResponseValue("REJECT"));
+ assertEquals(ResponseValue.SUCCESS, ResponseValue.toResponseValue("SUCCESS"));
+ assertEquals(ResponseValue.FAILURE, ResponseValue.toResponseValue("FAILURE"));
+
+ assertEquals("ACCEPT", ResponseValue.ACCEPT.toString());
+ assertEquals("ERROR", ResponseValue.ERROR.toString());
+ assertEquals("REJECT", ResponseValue.REJECT.toString());
+ assertEquals("SUCCESS", ResponseValue.SUCCESS.toString());
+ assertEquals("FAILURE", ResponseValue.FAILURE.toString());
+ }
}
diff --git a/controlloop/common/model-impl/appc/src/test/java/org/onap/policy/appc/TestRequest.java b/controlloop/common/model-impl/appc/src/test/java/org/onap/policy/appc/TestRequest.java
index 6fdfe0968..462fb7a01 100644
--- a/controlloop/common/model-impl/appc/src/test/java/org/onap/policy/appc/TestRequest.java
+++ b/controlloop/common/model-impl/appc/src/test/java/org/onap/policy/appc/TestRequest.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* appc
* ================================================================================
- * 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.
@@ -20,7 +20,11 @@
package org.onap.policy.appc;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
import java.util.HashMap;
import java.util.Map;
@@ -29,49 +33,49 @@ import org.junit.Test;
public class TestRequest {
- @Test
- public void testRequest() {
- Request request = new Request();
- assertNotNull(request);
- assertNotEquals(0, request.hashCode());
-
- CommonHeader commonHeader = new CommonHeader();
-
- request.setCommonHeader(commonHeader);
- assertEquals(commonHeader, request.getCommonHeader());
-
- request.setAction("Go to Oz");
- assertEquals("Go to Oz", request.getAction());
-
- request.setObjectID("Wizard");
- assertEquals("Wizard", request.getObjectID());
-
- request.setTargetID("Oz");
- assertEquals("Oz", request.getTargetID());
-
- Map<String, Object> payload = new HashMap<>();
- payload.put("North", "Good Witch");
- payload.put("West", "Bad Witch");
-
- request.setPayload(payload);
- assertEquals(payload, request.getPayload());
-
- assertNotEquals(0, request.hashCode());
-
- assertEquals("Request [CommonHeader=CommonHeader [TimeStamp=", request.toString().substring(0, 46));
-
+ @Test
+ public void testRequest() {
+ Request request = new Request();
+ assertNotNull(request);
+ assertNotEquals(0, request.hashCode());
+
+ CommonHeader commonHeader = new CommonHeader();
+
+ request.setCommonHeader(commonHeader);
+ assertEquals(commonHeader, request.getCommonHeader());
+
+ request.setAction("Go to Oz");
+ assertEquals("Go to Oz", request.getAction());
+
+ request.setObjectId("Wizard");
+ assertEquals("Wizard", request.getObjectId());
+
+ request.setTargetId("Oz");
+ assertEquals("Oz", request.getTargetId());
+
+ Map<String, Object> payload = new HashMap<>();
+ payload.put("North", "Good Witch");
+ payload.put("West", "Bad Witch");
+
+ request.setPayload(payload);
+ assertEquals(payload, request.getPayload());
+
+ assertNotEquals(0, request.hashCode());
+
+ assertEquals("Request [CommonHeader=CommonHeader [TimeStamp=", request.toString().substring(0, 46));
+
Request copiedRequest = new Request();
copiedRequest.setCommonHeader(request.getCommonHeader());
copiedRequest.setAction(request.getAction());
- copiedRequest.setObjectID(request.getObjectID());
+ copiedRequest.setObjectId(request.getObjectId());
copiedRequest.setPayload(request.getPayload());
- copiedRequest.setTargetID(request.getTargetID());
+ copiedRequest.setTargetId(request.getTargetId());
assertTrue(request.equals(request));
assertTrue(request.equals(copiedRequest));
assertFalse(request.equals(null));
assertFalse(request.equals("Hello"));
-
+
request.setCommonHeader(null);
assertFalse(request.equals(copiedRequest));
copiedRequest.setCommonHeader(null);
@@ -80,7 +84,7 @@ public class TestRequest {
assertFalse(request.equals(copiedRequest));
copiedRequest.setCommonHeader(commonHeader);
assertTrue(request.equals(copiedRequest));
-
+
request.setAction(null);
assertFalse(request.equals(copiedRequest));
copiedRequest.setAction(null);
@@ -89,32 +93,32 @@ public class TestRequest {
assertFalse(request.equals(copiedRequest));
copiedRequest.setAction("Go to Oz");
assertTrue(request.equals(copiedRequest));
-
- request.setObjectID(null);
+
+ request.setObjectId(null);
assertFalse(request.equals(copiedRequest));
- copiedRequest.setObjectID(null);
+ copiedRequest.setObjectId(null);
assertTrue(request.equals(copiedRequest));
- request.setObjectID("Wizard");
+ request.setObjectId("Wizard");
assertFalse(request.equals(copiedRequest));
- copiedRequest.setObjectID("Wizard");
+ copiedRequest.setObjectId("Wizard");
assertTrue(request.equals(copiedRequest));
-
- request.setTargetID(null);
+
+ request.setTargetId(null);
assertFalse(request.equals(copiedRequest));
- copiedRequest.setTargetID(null);
+ copiedRequest.setTargetId(null);
assertTrue(request.equals(copiedRequest));
- request.setTargetID("Oz");
+ request.setTargetId("Oz");
assertFalse(request.equals(copiedRequest));
- copiedRequest.setTargetID("Oz");
+ copiedRequest.setTargetId("Oz");
assertTrue(request.equals(copiedRequest));
-
+
request.setPayload(new HashMap<String, Object>());
assertFalse(request.equals(copiedRequest));
- copiedRequest.setPayload(new HashMap<String, Object>());
+ copiedRequest.setPayload(new HashMap<String, Object>());
assertTrue(request.equals(copiedRequest));
request.setPayload(payload);
assertFalse(request.equals(copiedRequest));
- copiedRequest.setPayload(payload);
+ copiedRequest.setPayload(payload);
assertTrue(request.equals(copiedRequest));
- }
+ }
}
diff --git a/controlloop/common/model-impl/appc/src/test/java/org/onap/policy/appc/TestResponse.java b/controlloop/common/model-impl/appc/src/test/java/org/onap/policy/appc/TestResponse.java
index 5306a3344..bf5fec86a 100644
--- a/controlloop/common/model-impl/appc/src/test/java/org/onap/policy/appc/TestResponse.java
+++ b/controlloop/common/model-impl/appc/src/test/java/org/onap/policy/appc/TestResponse.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* appc
* ================================================================================
- * 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.
@@ -20,7 +20,11 @@
package org.onap.policy.appc;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
import java.util.HashMap;
import java.util.Map;
@@ -29,37 +33,37 @@ import org.junit.Test;
public class TestResponse {
- @Test
- public void testResonse() {
- Response response = new Response();
- assertNotNull(response);
- assertNotNull(new Response(new Request()));
- assertNotEquals(0, response.hashCode());
-
- CommonHeader commonHeader = new CommonHeader();
-
- Request request = new Request();
- request.setCommonHeader(commonHeader);
- assertNotNull(new Response(request));
-
- response.setCommonHeader(commonHeader);
- assertEquals(commonHeader, response.getCommonHeader());
-
- ResponseStatus status = new ResponseStatus();
- response.setStatus(status );
- assertEquals(status, response.getStatus());
-
- Map<String, Object> payload = new HashMap<>();
- payload.put("North", "Good Witch");
- payload.put("West", "Bad Witch");
-
- response.setPayload(payload);
- assertEquals(payload, response.getPayload());
-
- assertNotEquals(0, response.hashCode());
-
- assertEquals("Response [CommonHeader=CommonHeader [TimeStamp=", response.toString().substring(0, 47));
-
+ @Test
+ public void testResonse() {
+ Response response = new Response();
+ assertNotNull(response);
+ assertNotNull(new Response(new Request()));
+ assertNotEquals(0, response.hashCode());
+
+ CommonHeader commonHeader = new CommonHeader();
+
+ Request request = new Request();
+ request.setCommonHeader(commonHeader);
+ assertNotNull(new Response(request));
+
+ response.setCommonHeader(commonHeader);
+ assertEquals(commonHeader, response.getCommonHeader());
+
+ ResponseStatus status = new ResponseStatus();
+ response.setStatus(status);
+ assertEquals(status, response.getStatus());
+
+ Map<String, Object> payload = new HashMap<>();
+ payload.put("North", "Good Witch");
+ payload.put("West", "Bad Witch");
+
+ response.setPayload(payload);
+ assertEquals(payload, response.getPayload());
+
+ assertNotEquals(0, response.hashCode());
+
+ assertEquals("Response [CommonHeader=CommonHeader [TimeStamp=", response.toString().substring(0, 47));
+
Response copiedResponse = new Response();
copiedResponse.setCommonHeader(response.getCommonHeader());
copiedResponse.setStatus(response.getStatus());
@@ -69,7 +73,7 @@ public class TestResponse {
assertTrue(response.equals(copiedResponse));
assertFalse(response.equals(null));
assertFalse(response.equals("Hello"));
-
+
response.setCommonHeader(null);
assertFalse(response.equals(copiedResponse));
copiedResponse.setCommonHeader(null);
@@ -78,7 +82,7 @@ public class TestResponse {
assertFalse(response.equals(copiedResponse));
copiedResponse.setCommonHeader(commonHeader);
assertTrue(response.equals(copiedResponse));
-
+
response.setStatus(null);
assertFalse(response.equals(copiedResponse));
copiedResponse.setStatus(null);
@@ -87,14 +91,14 @@ public class TestResponse {
assertFalse(response.equals(copiedResponse));
copiedResponse.setStatus(status);
assertTrue(response.equals(copiedResponse));
-
+
response.setPayload(new HashMap<String, Object>());
assertFalse(response.equals(copiedResponse));
- copiedResponse.setPayload(new HashMap<String, Object>());
+ copiedResponse.setPayload(new HashMap<String, Object>());
assertTrue(response.equals(copiedResponse));
response.setPayload(payload);
assertFalse(response.equals(copiedResponse));
- copiedResponse.setPayload(payload);
+ copiedResponse.setPayload(payload);
assertTrue(response.equals(copiedResponse));
- }
+ }
}
diff --git a/controlloop/common/model-impl/appc/src/test/java/org/onap/policy/appc/TestResponseStatus.java b/controlloop/common/model-impl/appc/src/test/java/org/onap/policy/appc/TestResponseStatus.java
index 0cac93ca4..46d8a0b25 100644
--- a/controlloop/common/model-impl/appc/src/test/java/org/onap/policy/appc/TestResponseStatus.java
+++ b/controlloop/common/model-impl/appc/src/test/java/org/onap/policy/appc/TestResponseStatus.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* appc
* ================================================================================
- * 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.
@@ -20,30 +20,34 @@
package org.onap.policy.appc;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
import org.junit.Test;
public class TestResponseStatus {
- @Test
- public void testResonseStatus() {
- ResponseStatus status = new ResponseStatus();
- assertNotNull(status);
- assertNotEquals(0, status.hashCode());
-
- status.setCode(1234);
- assertEquals(1234, status.getCode());
-
- status.setDescription("The wonderful land of Oz");
- assertEquals("The wonderful land of Oz", status.getDescription());
-
- status.setValue("There's no place like home");
- assertEquals("There's no place like home", status.getValue());
- assertNotEquals(0, status.hashCode());
-
- assertEquals("ResponseStatus [Code=1234, Value=There's no pla", status.toString().substring(0, 47));
-
+ @Test
+ public void testResonseStatus() {
+ ResponseStatus status = new ResponseStatus();
+ assertNotNull(status);
+ assertNotEquals(0, status.hashCode());
+
+ status.setCode(1234);
+ assertEquals(1234, status.getCode());
+
+ status.setDescription("The wonderful land of Oz");
+ assertEquals("The wonderful land of Oz", status.getDescription());
+
+ status.setValue("There's no place like home");
+ assertEquals("There's no place like home", status.getValue());
+ assertNotEquals(0, status.hashCode());
+
+ assertEquals("ResponseStatus [Code=1234, Value=There's no pla", status.toString().substring(0, 47));
+
ResponseStatus copiedStatus = new ResponseStatus();
copiedStatus.setCode(status.getCode());
copiedStatus.setDescription(status.getDescription());
@@ -53,7 +57,7 @@ public class TestResponseStatus {
assertTrue(status.equals(copiedStatus));
assertFalse(status.equals(null));
assertFalse(status.equals("Hello"));
-
+
status.setCode(-1);
assertFalse(status.equals(copiedStatus));
copiedStatus.setCode(-1);
@@ -62,7 +66,7 @@ public class TestResponseStatus {
assertFalse(status.equals(copiedStatus));
copiedStatus.setCode(1234);
assertTrue(status.equals(copiedStatus));
-
+
status.setDescription(null);
assertFalse(status.equals(copiedStatus));
copiedStatus.setDescription(null);
@@ -71,7 +75,7 @@ public class TestResponseStatus {
assertFalse(status.equals(copiedStatus));
copiedStatus.setDescription("The wonderful land of Oz");
assertTrue(status.equals(copiedStatus));
-
+
status.setValue(null);
assertFalse(status.equals(copiedStatus));
copiedStatus.setValue(null);
@@ -80,5 +84,5 @@ public class TestResponseStatus {
assertFalse(status.equals(copiedStatus));
copiedStatus.setValue("There's no place like home");
assertTrue(status.equals(copiedStatus));
- }
+ }
}
diff --git a/controlloop/common/model-impl/appc/src/test/java/org/onap/policy/appc/util/TestSerialization.java b/controlloop/common/model-impl/appc/src/test/java/org/onap/policy/appc/util/TestSerialization.java
index 0a82892ea..ae1890acf 100644
--- a/controlloop/common/model-impl/appc/src/test/java/org/onap/policy/appc/util/TestSerialization.java
+++ b/controlloop/common/model-impl/appc/src/test/java/org/onap/policy/appc/util/TestSerialization.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* appc
* ================================================================================
- * 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.
@@ -20,7 +20,8 @@
package org.onap.policy.appc.util;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
import java.time.Instant;
import java.time.ZoneId;
@@ -30,26 +31,26 @@ import org.junit.Test;
public class TestSerialization {
- @Test
- public void test() {
- String nameString = "Dorothy";
- String jsonName = Serialization.gsonPretty.toJson(nameString, String.class);
- assertEquals("\"Dorothy\"", jsonName);
- String jsonInOutName = Serialization.gsonPretty.fromJson(jsonName, String.class);
- assertEquals("Dorothy", jsonInOutName);
-
- Instant instant = Instant.ofEpochMilli(1516127215000L);
- String instantString = Serialization.gsonPretty.toJson(instant, Instant.class);
- assertEquals("1516127215000", instantString);
- Instant outInstant = Serialization.gsonPretty.fromJson(instantString, Instant.class);
- assertEquals(instant, outInstant);
-
- ZonedDateTime zdt = ZonedDateTime.ofInstant(instant, ZoneId.of("UTC"));
- String zdtString = Serialization.gsonPretty.toJson(zdt, ZonedDateTime.class);
- assertEquals("\"2018-01-16 18:26:55.000000+00:00\"", zdtString);
- ZonedDateTime outZdt = Serialization.gsonPretty.fromJson(zdtString, ZonedDateTime.class);
- assertEquals(zdt.getDayOfWeek(), outZdt.getDayOfWeek());
-
- assertNull(Serialization.gsonPretty.fromJson("oz time is weird", ZonedDateTime.class));
- }
+ @Test
+ public void test() {
+ String nameString = "Dorothy";
+ String jsonName = Serialization.gsonPretty.toJson(nameString, String.class);
+ assertEquals("\"Dorothy\"", jsonName);
+ String jsonInOutName = Serialization.gsonPretty.fromJson(jsonName, String.class);
+ assertEquals("Dorothy", jsonInOutName);
+
+ Instant instant = Instant.ofEpochMilli(1516127215000L);
+ String instantString = Serialization.gsonPretty.toJson(instant, Instant.class);
+ assertEquals("1516127215000", instantString);
+ Instant outInstant = Serialization.gsonPretty.fromJson(instantString, Instant.class);
+ assertEquals(instant, outInstant);
+
+ ZonedDateTime zdt = ZonedDateTime.ofInstant(instant, ZoneId.of("UTC"));
+ String zdtString = Serialization.gsonPretty.toJson(zdt, ZonedDateTime.class);
+ assertEquals("\"2018-01-16 18:26:55.000000+00:00\"", zdtString);
+ ZonedDateTime outZdt = Serialization.gsonPretty.fromJson(zdtString, ZonedDateTime.class);
+ assertEquals(zdt.getDayOfWeek(), outZdt.getDayOfWeek());
+
+ assertNull(Serialization.gsonPretty.fromJson("oz time is weird", ZonedDateTime.class));
+ }
}
diff --git a/controlloop/common/model-impl/appclcm/pom.xml b/controlloop/common/model-impl/appclcm/pom.xml
index 26368ee9a..e84f5f2d7 100644
--- a/controlloop/common/model-impl/appclcm/pom.xml
+++ b/controlloop/common/model-impl/appclcm/pom.xml
@@ -43,4 +43,45 @@
<scope>provided</scope>
</dependency>
</dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-checkstyle-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>onap-java-style</id>
+ <goals>
+ <goal>check</goal>
+ </goals>
+ <phase>process-sources</phase>
+ <configuration>
+ <!-- Use Google Java Style Guide:
+ https://github.com/checkstyle/checkstyle/blob/master/src/main/resources/google_checks.xml
+ with minor changes -->
+ <configLocation>onap-checkstyle/onap-java-style.xml</configLocation>
+ <!-- <sourceDirectory> is needed so that checkstyle ignores the generated sources directory -->
+ <sourceDirectory>${project.build.sourceDirectory}</sourceDirectory>
+ <includeResources>true</includeResources>
+ <includeTestSourceDirectory>true</includeTestSourceDirectory>
+ <includeTestResources>true</includeTestResources>
+ <excludes>
+ </excludes>
+ <consoleOutput>true</consoleOutput>
+ <failOnViolation>true</failOnViolation>
+ <violationSeverity>warning</violationSeverity>
+ </configuration>
+ </execution>
+ </executions>
+ <dependencies>
+ <dependency>
+ <groupId>org.onap.oparent</groupId>
+ <artifactId>checkstyle</artifactId>
+ <version>0.1.1</version>
+ <scope>compile</scope>
+ </dependency>
+ </dependencies>
+ </plugin>
+ </plugins>
+ </build>
</project>
diff --git a/controlloop/common/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/LCMResponseStatus.java b/controlloop/common/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/LCMResponseStatus.java
deleted file mode 100644
index 1db4e8ef7..000000000
--- a/controlloop/common/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/LCMResponseStatus.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * appclcm
- * ================================================================================
- * Copyright (C) 2017 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.appclcm;
-
-import com.google.gson.annotations.SerializedName;
-import java.io.Serializable;
-
-public class LCMResponseStatus implements Serializable {
-
- private static final long serialVersionUID = 974891505135467199L;
-
- @SerializedName(value="code")
- private int code;
-
- @SerializedName(value="message")
- private String message;
-
- public LCMResponseStatus() {
- // Create a default LCMResponseStatus instance
- }
-
- /**
- * @return the code
- */
- public int getCode() {
- return code;
- }
-
- /**
- * @param code the code to set
- */
- public void setCode(int code) {
- this.code = code;
- }
-
- /**
- * @return the message
- */
- public String getMessage() {
- return message;
- }
-
- /**
- * @param message the message to set
- */
- public void setMessage(String message) {
- this.message = message;
- }
-
- @Override
- public String toString() {
- return "ResponseStatus [code=" + code + ", message=" + message + "]";
- }
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + code;
- result = prime * result + ((message == null) ? 0 : message.hashCode());
- return result;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj == null) {
- return false;
- }
- if (getClass() != obj.getClass()) {
- return false;
- }
- LCMResponseStatus other = (LCMResponseStatus) obj;
- if (code != other.code) {
- return false;
- }
- if (message == null) {
- if (other.message != null) {
- return false;
- }
- } else if (!message.equals(other.message)) {
- return false;
- }
- return true;
- }
-
-}
diff --git a/controlloop/common/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/LCMCommonHeader.java b/controlloop/common/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/LcmCommonHeader.java
index a9392b468..dbf8dd0cd 100644
--- a/controlloop/common/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/LCMCommonHeader.java
+++ b/controlloop/common/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/LcmCommonHeader.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* appclcm
* ================================================================================
- * 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.
@@ -20,57 +20,58 @@
package org.onap.policy.appclcm;
+import com.google.gson.annotations.SerializedName;
+
import java.io.Serializable;
import java.time.Instant;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
-import com.google.gson.annotations.SerializedName;
-
-public class LCMCommonHeader implements Serializable {
+public class LcmCommonHeader implements Serializable {
private static final long serialVersionUID = 6581963539127062114L;
- @SerializedName(value="timestamp")
+ @SerializedName(value = "timestamp")
private Instant timeStamp = Instant.now();
- @SerializedName(value="api-ver")
- private String apiVer="2.00";
+ @SerializedName(value = "api-ver")
+ private String apiVer = "2.00";
- @SerializedName(value="originator-id")
+ @SerializedName(value = "originator-id")
private String originatorId;
- @SerializedName(value="request-id")
+ @SerializedName(value = "request-id")
private UUID requestId;
- @SerializedName(value="sub-request-id")
+ @SerializedName(value = "sub-request-id")
private String subRequestId;
- @SerializedName(value="flags")
+ @SerializedName(value = "flags")
private Map<String, String> flags = new HashMap<>();
- public LCMCommonHeader() {
+ public LcmCommonHeader() {
}
/**
* Used to copy a common header.
*
- * @param commonHeader
- * a header that is defined by the lcm api guide that contains
- * information about the request (requestId, flags, etc.)
+ * @param commonHeader a header that is defined by the lcm api guide that contains information
+ * about the request (requestId, flags, etc.)
*/
- public LCMCommonHeader(LCMCommonHeader commonHeader) {
+ public LcmCommonHeader(LcmCommonHeader commonHeader) {
this.originatorId = commonHeader.originatorId;
this.requestId = commonHeader.requestId;
this.subRequestId = commonHeader.subRequestId;
if (commonHeader.flags != null) {
this.flags.putAll(commonHeader.flags);
}
- }
+ }
/**
+ * Get the timestamp.
+ *
* @return the timeStamp
*/
public Instant getTimeStamp() {
@@ -78,6 +79,8 @@ public class LCMCommonHeader implements Serializable {
}
/**
+ * Set the timestamp.
+ *
* @param timeStamp the timeStamp to set
*/
public void setTimeStamp(Instant timeStamp) {
@@ -85,6 +88,8 @@ public class LCMCommonHeader implements Serializable {
}
/**
+ * Get the API version.
+ *
* @return the apiVer
*/
public String getApiVer() {
@@ -92,6 +97,8 @@ public class LCMCommonHeader implements Serializable {
}
/**
+ * Set the API version.
+ *
* @param apiVer the apiVer to set
*/
public void setApiVer(String apiVer) {
@@ -99,6 +106,8 @@ public class LCMCommonHeader implements Serializable {
}
/**
+ * Get the originator Id.
+ *
* @return the originatorId
*/
public String getOriginatorId() {
@@ -106,6 +115,8 @@ public class LCMCommonHeader implements Serializable {
}
/**
+ * Set the originator Id.
+ *
* @param originatorId the originatorId to set
*/
public void setOriginatorId(String originatorId) {
@@ -113,6 +124,8 @@ public class LCMCommonHeader implements Serializable {
}
/**
+ * Get the request Id.
+ *
* @return the requestId
*/
public UUID getRequestId() {
@@ -120,6 +133,8 @@ public class LCMCommonHeader implements Serializable {
}
/**
+ * Set the request Id.
+ *
* @param requestId the requestId to set
*/
public void setRequestId(UUID requestId) {
@@ -127,6 +142,8 @@ public class LCMCommonHeader implements Serializable {
}
/**
+ * Get the sub request Id.
+ *
* @return the subRequestId
*/
public String getSubRequestId() {
@@ -134,6 +151,8 @@ public class LCMCommonHeader implements Serializable {
}
/**
+ * Set the sub request Id.
+ *
* @param subRequestId the subRequestId to set
*/
public void setSubRequestId(String subRequestId) {
@@ -141,6 +160,8 @@ public class LCMCommonHeader implements Serializable {
}
/**
+ * Get the flags.
+ *
* @return the flags
*/
public Map<String, String> getFlags() {
@@ -148,6 +169,8 @@ public class LCMCommonHeader implements Serializable {
}
/**
+ * Set the flags.
+ *
* @param flags the flags to set
*/
public void setFlags(Map<String, String> flags) {
@@ -184,7 +207,7 @@ public class LCMCommonHeader implements Serializable {
if (getClass() != obj.getClass()) {
return false;
}
- LCMCommonHeader other = (LCMCommonHeader) obj;
+ LcmCommonHeader other = (LcmCommonHeader) obj;
if (apiVer == null) {
if (other.apiVer != null) {
return false;
diff --git a/controlloop/common/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/LCMRequest.java b/controlloop/common/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/LcmRequest.java
index 83442d9bf..afac0dece 100644
--- a/controlloop/common/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/LCMRequest.java
+++ b/controlloop/common/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/LcmRequest.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* appclcm
* ================================================================================
- * 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.
@@ -20,36 +20,38 @@
package org.onap.policy.appclcm;
+import com.google.gson.annotations.SerializedName;
+
import java.io.Serializable;
import java.util.Map;
-import com.google.gson.annotations.SerializedName;
-
-public class LCMRequest implements Serializable {
+public class LcmRequest implements Serializable {
private static final long serialVersionUID = 219375564922846624L;
- @SerializedName(value="common-header")
- private LCMCommonHeader commonHeader;
+ @SerializedName(value = "common-header")
+ private LcmCommonHeader commonHeader;
- @SerializedName(value="action")
+ @SerializedName(value = "action")
private String action;
- @SerializedName(value="action-identifiers")
+ @SerializedName(value = "action-identifiers")
private Map<String, String> actionIdentifiers;
- @SerializedName(value="payload")
+ @SerializedName(value = "payload")
private String payload;
- public LCMRequest() {
- // Create a default LCM request
+ public LcmRequest() {
+ // Create a default LCM request
}
- public LCMCommonHeader getCommonHeader() {
+ public LcmCommonHeader getCommonHeader() {
return commonHeader;
}
/**
+ * Get the action.
+ *
* @return the action
*/
public String getAction() {
@@ -57,6 +59,8 @@ public class LCMRequest implements Serializable {
}
/**
+ * Set the action.
+ *
* @param action the action to set
*/
public void setAction(String action) {
@@ -64,6 +68,8 @@ public class LCMRequest implements Serializable {
}
/**
+ * Get the action identifiers.
+ *
* @return the actionIdentifiers
*/
public Map<String, String> getActionIdentifiers() {
@@ -71,6 +77,8 @@ public class LCMRequest implements Serializable {
}
/**
+ * Set the action identifiers.
+ *
* @param actionIdentifiers the actionIdentifiers to set
*/
public void setActionIdentifiers(Map<String, String> actionIdentifiers) {
@@ -78,6 +86,8 @@ public class LCMRequest implements Serializable {
}
/**
+ * Get the payload.
+ *
* @return the payload
*/
public String getPayload() {
@@ -85,6 +95,8 @@ public class LCMRequest implements Serializable {
}
/**
+ * Set the payload.
+ *
* @param payload the payload to set
*/
public void setPayload(String payload) {
@@ -92,9 +104,11 @@ public class LCMRequest implements Serializable {
}
/**
+ * Get the common header.
+ *
* @param commonHeader the commonHeader to set
*/
- public void setCommonHeader(LCMCommonHeader commonHeader) {
+ public void setCommonHeader(LcmCommonHeader commonHeader) {
this.commonHeader = commonHeader;
}
@@ -126,7 +140,7 @@ public class LCMRequest implements Serializable {
if (getClass() != obj.getClass()) {
return false;
}
- LCMRequest other = (LCMRequest) obj;
+ LcmRequest other = (LcmRequest) obj;
if (commonHeader == null) {
if (other.commonHeader != null) {
return false;
diff --git a/controlloop/common/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/LCMRequestWrapper.java b/controlloop/common/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/LcmRequestWrapper.java
index ea7e6762f..b77303ad0 100644
--- a/controlloop/common/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/LCMRequestWrapper.java
+++ b/controlloop/common/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/LcmRequestWrapper.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* appclcm
* ================================================================================
- * 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.
@@ -21,34 +21,39 @@
package org.onap.policy.appclcm;
import com.google.gson.annotations.SerializedName;
+
import java.io.Serializable;
-public class LCMRequestWrapper extends LCMWrapper implements Serializable {
+public class LcmRequestWrapper extends LcmWrapper implements Serializable {
private static final long serialVersionUID = 424866914715980798L;
-
- @SerializedName(value="body")
- private LCMRequest body;
- public LCMRequestWrapper() {
+ @SerializedName(value = "body")
+ private LcmRequest body;
+
+ public LcmRequestWrapper() {
super();
}
- public LCMRequestWrapper(LCMRequest request) {
+ public LcmRequestWrapper(LcmRequest request) {
body = request;
}
-
+
/**
+ * Get the body.
+ *
* @return the body
*/
- public LCMRequest getBody() {
+ public LcmRequest getBody() {
return body;
}
/**
+ * Set the body.
+ *
* @param body the body to set
*/
- public void setBody(LCMRequest body) {
+ public void setBody(LcmRequest body) {
this.body = body;
}
@@ -76,7 +81,7 @@ public class LCMRequestWrapper extends LCMWrapper implements Serializable {
if (getClass() != obj.getClass()) {
return false;
}
- LCMRequestWrapper other = (LCMRequestWrapper) obj;
+ LcmRequestWrapper other = (LcmRequestWrapper) obj;
if (body == null) {
if (other.body != null) {
return false;
diff --git a/controlloop/common/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/LCMResponse.java b/controlloop/common/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/LcmResponse.java
index 82f374868..2a65c9a14 100644
--- a/controlloop/common/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/LCMResponse.java
+++ b/controlloop/common/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/LcmResponse.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* appclcm
* ================================================================================
- * 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.
@@ -21,34 +21,33 @@
package org.onap.policy.appclcm;
import com.google.gson.annotations.SerializedName;
+
import java.io.Serializable;
-public class LCMResponse implements Serializable {
+public class LcmResponse implements Serializable {
private static final long serialVersionUID = 6332508597287669750L;
@SerializedName(value = "common-header")
- private LCMCommonHeader commonHeader;
+ private LcmCommonHeader commonHeader;
@SerializedName(value = "status")
- private LCMResponseStatus status = new LCMResponseStatus();
+ private LcmResponseStatus status = new LcmResponseStatus();
@SerializedName(value = "payload")
private String payload;
- public LCMResponse() {
- // EMPTY
+ public LcmResponse() {
+ // EMPTY
}
/**
- * Constructs a response using the common header of the request since they
- * will be the same.
+ * Constructs a response using the common header of the request since they will be the same.
*
- * @param request
- * an appc lcm request object specified by the lcm api guide
+ * @param request an appc lcm request object specified by the lcm api guide
*/
- public LCMResponse(LCMRequest request) {
- this.commonHeader = new LCMCommonHeader(request.getCommonHeader());
+ public LcmResponse(LcmRequest request) {
+ this.commonHeader = new LcmCommonHeader(request.getCommonHeader());
String requestPayload = request.getPayload();
if (requestPayload != null) {
this.payload = requestPayload;
@@ -56,34 +55,44 @@ public class LCMResponse implements Serializable {
}
/**
+ * Get the common header.
+ *
* @return the commonHeader
*/
- public LCMCommonHeader getCommonHeader() {
+ public LcmCommonHeader getCommonHeader() {
return commonHeader;
}
/**
+ * Set the common header.
+ *
* @param commonHeader the commonHeader to set
*/
- public void setCommonHeader(LCMCommonHeader commonHeader) {
+ public void setCommonHeader(LcmCommonHeader commonHeader) {
this.commonHeader = commonHeader;
}
/**
+ * Get the status.
+ *
* @return the status
*/
- public LCMResponseStatus getStatus() {
+ public LcmResponseStatus getStatus() {
return status;
}
/**
+ * Set the status.
+ *
* @param status the status to set
*/
- public void setStatus(LCMResponseStatus status) {
+ public void setStatus(LcmResponseStatus status) {
this.status = status;
}
/**
+ * Get the payload.
+ *
* @return the payload
*/
public String getPayload() {
@@ -91,6 +100,8 @@ public class LCMResponse implements Serializable {
}
/**
+ * Set the payload.
+ *
* @param payload the payload to set
*/
public void setPayload(String payload) {
@@ -123,7 +134,7 @@ public class LCMResponse implements Serializable {
if (getClass() != obj.getClass()) {
return false;
}
- LCMResponse other = (LCMResponse) obj;
+ LcmResponse other = (LcmResponse) obj;
if (commonHeader == null) {
if (other.commonHeader != null) {
return false;
diff --git a/controlloop/common/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/LCMResponseCode.java b/controlloop/common/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/LcmResponseCode.java
index 8a7c36d2b..cca69b132 100644
--- a/controlloop/common/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/LCMResponseCode.java
+++ b/controlloop/common/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/LcmResponseCode.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* appclcm
* ================================================================================
- * 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.
@@ -20,8 +20,8 @@
package org.onap.policy.appclcm;
-public class LCMResponseCode {
-
+public class LcmResponseCode {
+
/* These fields define the key to the response code value. */
public static final String ACCEPTED = "ACCEPTED";
public static final String ERROR = "ERROR";
@@ -30,13 +30,13 @@ public class LCMResponseCode {
public static final String FAILURE = "FAILURE";
public static final String PARTIAL_SUCCESS = "PARTIAL SUCCESS";
public static final String PARTIAL_FAILURE = "PARTIAL FAILURE";
-
+
private Integer code;
- protected LCMResponseCode(final int code) {
- this.code = code;
+ protected LcmResponseCode(final int code) {
+ this.code = code;
}
-
+
public int getCode() {
return this.code;
}
@@ -49,31 +49,24 @@ public class LCMResponseCode {
/**
* Translates the code to a string value that represents the meaning of the code.
*
- * @param code
- * the numeric value that is returned by APPC based on success,
- * failure, etc. of the action requested
+ * @param code the numeric value that is returned by APPC based on success, failure, etc. of the
+ * action requested
* @return the string value equivalent of the APPC response code
*/
public static String toResponseValue(int code) {
if (code == 100) {
return ACCEPTED;
- }
- else if (code == 200) {
+ } else if (code == 200) {
return ERROR;
- }
- else if (code >= 300 && code <= 313) {
+ } else if (code >= 300 && code <= 313) {
return REJECT;
- }
- else if (code == 400) {
+ } else if (code == 400) {
return SUCCESS;
- }
- else if (code == 450 || (code >= 401 && code <= 406)) {
+ } else if (code == 450 || (code >= 401 && code <= 406)) {
return FAILURE;
- }
- else if (code == 500) {
+ } else if (code == 500) {
return PARTIAL_SUCCESS;
- }
- else if (code >= 501 && code <= 599) {
+ } else if (code >= 501 && code <= 599) {
return PARTIAL_FAILURE;
}
return null;
diff --git a/controlloop/common/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/LcmResponseStatus.java b/controlloop/common/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/LcmResponseStatus.java
new file mode 100644
index 000000000..4c044a0a8
--- /dev/null
+++ b/controlloop/common/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/LcmResponseStatus.java
@@ -0,0 +1,116 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * appclcm
+ * ================================================================================
+ * 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.appclcm;
+
+import com.google.gson.annotations.SerializedName;
+
+import java.io.Serializable;
+
+public class LcmResponseStatus implements Serializable {
+
+ private static final long serialVersionUID = 974891505135467199L;
+
+ @SerializedName(value = "code")
+ private int code;
+
+ @SerializedName(value = "message")
+ private String message;
+
+ public LcmResponseStatus() {
+ // Create a default LCMResponseStatus instance
+ }
+
+ /**
+ * Get the code.
+ *
+ * @return the code
+ */
+ public int getCode() {
+ return code;
+ }
+
+ /**
+ * Set the code.
+ *
+ * @param code the code to set
+ */
+ public void setCode(int code) {
+ this.code = code;
+ }
+
+ /**
+ * Get the message.
+ *
+ * @return the message
+ */
+ public String getMessage() {
+ return message;
+ }
+
+ /**
+ * Set the message.
+ *
+ * @param message the message to set
+ */
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ @Override
+ public String toString() {
+ return "ResponseStatus [code=" + code + ", message=" + message + "]";
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + code;
+ result = prime * result + ((message == null) ? 0 : message.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ LcmResponseStatus other = (LcmResponseStatus) obj;
+ if (code != other.code) {
+ return false;
+ }
+ if (message == null) {
+ if (other.message != null) {
+ return false;
+ }
+ } else if (!message.equals(other.message)) {
+ return false;
+ }
+ return true;
+ }
+
+}
diff --git a/controlloop/common/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/LCMResponseWrapper.java b/controlloop/common/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/LcmResponseWrapper.java
index 7d9062979..43cc32511 100644
--- a/controlloop/common/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/LCMResponseWrapper.java
+++ b/controlloop/common/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/LcmResponseWrapper.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* appclcm
* ================================================================================
- * 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.
@@ -21,30 +21,35 @@
package org.onap.policy.appclcm;
import com.google.gson.annotations.SerializedName;
+
import java.io.Serializable;
-public class LCMResponseWrapper extends LCMWrapper implements Serializable {
+public class LcmResponseWrapper extends LcmWrapper implements Serializable {
private static final long serialVersionUID = 463937813781086802L;
-
- @SerializedName(value="body")
- private LCMResponse body;
-
- public LCMResponseWrapper() {
+
+ @SerializedName(value = "body")
+ private LcmResponse body;
+
+ public LcmResponseWrapper() {
super();
}
-
+
/**
+ * Get the body.
+ *
* @return the body
*/
- public LCMResponse getBody() {
+ public LcmResponse getBody() {
return body;
}
/**
+ * Set the body.
+ *
* @param body the body to set
*/
- public void setBody(LCMResponse body) {
+ public void setBody(LcmResponse body) {
this.body = body;
}
@@ -52,7 +57,7 @@ public class LCMResponseWrapper extends LCMWrapper implements Serializable {
public String toString() {
return "ResponseWrapper [body=" + body + ", toString()=" + super.toString() + "]";
}
-
+
@Override
public int hashCode() {
final int prime = 31;
@@ -72,7 +77,7 @@ public class LCMResponseWrapper extends LCMWrapper implements Serializable {
if (getClass() != obj.getClass()) {
return false;
}
- LCMResponseWrapper other = (LCMResponseWrapper) obj;
+ LcmResponseWrapper other = (LcmResponseWrapper) obj;
if (body == null) {
if (other.body != null) {
return false;
diff --git a/controlloop/common/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/LCMWrapper.java b/controlloop/common/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/LcmWrapper.java
index c70e7423a..322abb015 100644
--- a/controlloop/common/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/LCMWrapper.java
+++ b/controlloop/common/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/LcmWrapper.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* appclcm
* ================================================================================
- * 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.
@@ -21,32 +21,35 @@
package org.onap.policy.appclcm;
import com.google.gson.annotations.SerializedName;
+
import java.io.Serializable;
-public class LCMWrapper implements Serializable {
+public class LcmWrapper implements Serializable {
private static final long serialVersionUID = 753005805432396532L;
- @SerializedName(value="version")
+ @SerializedName(value = "version")
private String version;
-
- @SerializedName(value="cambria-partition")
+
+ @SerializedName(value = "cambria-partition")
private String cambriaPartition;
-
- @SerializedName(value="rpc-name")
+
+ @SerializedName(value = "rpc-name")
private String rpcName;
-
- @SerializedName(value="correlation-id")
+
+ @SerializedName(value = "correlation-id")
private String correlationId;
-
- @SerializedName(value="type")
+
+ @SerializedName(value = "type")
private String type;
- public LCMWrapper() {
- // Create a default LCMWrapper instance
+ public LcmWrapper() {
+ // Create a default LCMWrapper instance
}
-
+
/**
+ * Get the version.
+ *
* @return the version
*/
public String getVersion() {
@@ -54,6 +57,8 @@ public class LCMWrapper implements Serializable {
}
/**
+ * Set the version.
+ *
* @param version the version to set
*/
public void setVersion(String version) {
@@ -61,6 +66,8 @@ public class LCMWrapper implements Serializable {
}
/**
+ * Get the cambria partition.
+ *
* @return the cambriaPartition
*/
public String getCambriaPartition() {
@@ -68,6 +75,8 @@ public class LCMWrapper implements Serializable {
}
/**
+ * Set the cambria partition.
+ *
* @param cambriaPartition the cambriaPartition to set
*/
public void setCambriaPartition(String cambriaPartition) {
@@ -75,6 +84,8 @@ public class LCMWrapper implements Serializable {
}
/**
+ * Get the RPN name.
+ *
* @return the rpcName
*/
public String getRpcName() {
@@ -82,6 +93,8 @@ public class LCMWrapper implements Serializable {
}
/**
+ * Set the RPC name.
+ *
* @param rpcName the rpcName to set
*/
public void setRpcName(String rpcName) {
@@ -89,6 +102,8 @@ public class LCMWrapper implements Serializable {
}
/**
+ * Get the correlation Id.
+ *
* @return the correlationId
*/
public String getCorrelationId() {
@@ -96,6 +111,8 @@ public class LCMWrapper implements Serializable {
}
/**
+ * Set the correclation Id.
+ *
* @param correlationId the correlationId to set
*/
public void setCorrelationId(String correlationId) {
@@ -103,6 +120,8 @@ public class LCMWrapper implements Serializable {
}
/**
+ * Get the type.
+ *
* @return the type
*/
public String getType() {
@@ -110,6 +129,8 @@ public class LCMWrapper implements Serializable {
}
/**
+ * Set the type.
+ *
* @param type the type to set
*/
public void setType(String type) {
@@ -145,7 +166,7 @@ public class LCMWrapper implements Serializable {
if (getClass() != obj.getClass()) {
return false;
}
- LCMWrapper other = (LCMWrapper) obj;
+ LcmWrapper other = (LcmWrapper) obj;
if (cambriaPartition == null) {
if (other.cambriaPartition != null) {
return false;
diff --git a/controlloop/common/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/util/Serialization.java b/controlloop/common/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/util/Serialization.java
index 5a5e2e2e6..944d56846 100644
--- a/controlloop/common/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/util/Serialization.java
+++ b/controlloop/common/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/util/Serialization.java
@@ -20,12 +20,6 @@
package org.onap.policy.appclcm.util;
-import java.lang.reflect.Type;
-import java.time.Instant;
-
-import org.onap.policy.appclcm.LCMRequest;
-import org.onap.policy.appclcm.LCMResponse;
-
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonDeserializationContext;
@@ -36,79 +30,84 @@ import com.google.gson.JsonPrimitive;
import com.google.gson.JsonSerializationContext;
import com.google.gson.JsonSerializer;
+import java.lang.reflect.Type;
+import java.time.Instant;
+
+import org.onap.policy.appclcm.LcmRequest;
+import org.onap.policy.appclcm.LcmResponse;
+
public final class Serialization {
- private Serialization() {
- }
+ private Serialization() {}
- public static class RequestAdapter implements JsonSerializer<LCMRequest>, JsonDeserializer<LCMRequest> {
+ public static class RequestAdapter implements JsonSerializer<LcmRequest>, JsonDeserializer<LcmRequest> {
- @Override
- public JsonElement serialize(LCMRequest src, Type typeOfSrc, JsonSerializationContext context) {
- JsonElement requestJson = gsonPretty.toJsonTree(src, LCMRequest.class);
- JsonObject input = new JsonObject();
- input.add("input", requestJson);
+ @Override
+ public JsonElement serialize(LcmRequest src, Type typeOfSrc, JsonSerializationContext context) {
+ JsonElement requestJson = gsonPretty.toJsonTree(src, LcmRequest.class);
+ JsonObject input = new JsonObject();
+ input.add("input", requestJson);
- return input;
- }
+ return input;
+ }
- @Override
- public LCMRequest deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) {
- return gsonPretty.fromJson(json.getAsJsonObject().get("input"), LCMRequest.class);
- }
- }
+ @Override
+ public LcmRequest deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) {
+ return gsonPretty.fromJson(json.getAsJsonObject().get("input"), LcmRequest.class);
+ }
+ }
- public static class ResponseAdapter implements JsonSerializer<LCMResponse>, JsonDeserializer<LCMResponse> {
+ public static class ResponseAdapter implements JsonSerializer<LcmResponse>, JsonDeserializer<LcmResponse> {
- @Override
- public JsonElement serialize(LCMResponse src, Type typeOfSrc, JsonSerializationContext context) {
- JsonElement responseJson = gsonPretty.toJsonTree(src, LCMResponse.class);
- JsonObject output = new JsonObject();
- output.add("output", responseJson);
- return output;
- }
+ @Override
+ public JsonElement serialize(LcmResponse src, Type typeOfSrc, JsonSerializationContext context) {
+ JsonElement responseJson = gsonPretty.toJsonTree(src, LcmResponse.class);
+ JsonObject output = new JsonObject();
+ output.add("output", responseJson);
+ return output;
+ }
- @Override
- public LCMResponse deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) {
- return gsonPretty.fromJson(json.getAsJsonObject().get("output"), LCMResponse.class);
- }
- }
+ @Override
+ public LcmResponse deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) {
+ return gsonPretty.fromJson(json.getAsJsonObject().get("output"), LcmResponse.class);
+ }
+ }
- public static class InstantAdapter implements JsonSerializer<Instant>, JsonDeserializer<Instant> {
+ public static class InstantAdapter implements JsonSerializer<Instant>, JsonDeserializer<Instant> {
- @Override
- public Instant deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) {
- return Instant.parse(json.getAsString());
- }
+ @Override
+ public Instant deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) {
+ return Instant.parse(json.getAsString());
+ }
- @Override
- public JsonElement serialize(Instant src, Type typeOfSrc, JsonSerializationContext context) {
- return new JsonPrimitive(src.toString());
- }
+ @Override
+ public JsonElement serialize(Instant src, Type typeOfSrc, JsonSerializationContext context) {
+ return new JsonPrimitive(src.toString());
+ }
- }
+ }
- public static class InstantJunitAdapter implements JsonSerializer<Instant>, JsonDeserializer<Instant> {
+ public static class InstantJunitAdapter implements JsonSerializer<Instant>, JsonDeserializer<Instant> {
- @Override
- public Instant deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) {
- return Instant.ofEpochMilli(json.getAsLong());
- }
+ @Override
+ public Instant deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) {
+ return Instant.ofEpochMilli(json.getAsLong());
+ }
- @Override
- public JsonElement serialize(Instant src, Type typeOfSrc, JsonSerializationContext context) {
- return new JsonPrimitive(src.toEpochMilli());
- }
+ @Override
+ public JsonElement serialize(Instant src, Type typeOfSrc, JsonSerializationContext context) {
+ return new JsonPrimitive(src.toEpochMilli());
+ }
- }
+ }
- public static final Gson gsonPretty = new GsonBuilder().disableHtmlEscaping().setPrettyPrinting()
- .registerTypeAdapter(Instant.class, new InstantAdapter()).create();
+ public static final Gson gsonPretty = new GsonBuilder().disableHtmlEscaping().setPrettyPrinting()
+ .registerTypeAdapter(Instant.class, new InstantAdapter()).create();
- public static final Gson gson = new GsonBuilder().disableHtmlEscaping().setPrettyPrinting()
- .registerTypeAdapter(LCMRequest.class, new RequestAdapter())
- .registerTypeAdapter(LCMResponse.class, new ResponseAdapter()).create();
+ public static final Gson gson = new GsonBuilder().disableHtmlEscaping().setPrettyPrinting()
+ .registerTypeAdapter(LcmRequest.class, new RequestAdapter())
+ .registerTypeAdapter(LcmResponse.class, new ResponseAdapter()).create();
- public static final Gson gsonJunit = new GsonBuilder().disableHtmlEscaping().setPrettyPrinting()
- .registerTypeAdapter(Instant.class, new InstantJunitAdapter()).create();
+ public static final Gson gsonJunit = new GsonBuilder().disableHtmlEscaping().setPrettyPrinting()
+ .registerTypeAdapter(Instant.class, new InstantJunitAdapter()).create();
}
diff --git a/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/AppcLcmTest.java b/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/AppcLcmTest.java
index 2d58bfd99..cee87077a 100644
--- a/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/AppcLcmTest.java
+++ b/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/AppcLcmTest.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* appclcm
* ================================================================================
- * 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.
@@ -20,7 +20,9 @@
package org.onap.policy.appclcm;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
import java.util.HashMap;
import java.util.UUID;
@@ -33,49 +35,49 @@ import org.slf4j.LoggerFactory;
public class AppcLcmTest {
private static final Logger logger = LoggerFactory.getLogger(AppcLcmTest.class);
-
- private static LCMRequestWrapper dmaapRequest;
- private static LCMResponseWrapper dmaapResponse;
+
+ private static LcmRequestWrapper dmaapRequest;
+ private static LcmResponseWrapper dmaapResponse;
static {
/*
* Construct an APPCLCM Request to be Serialized
*/
- dmaapRequest = new LCMRequestWrapper();
+ dmaapRequest = new LcmRequestWrapper();
dmaapRequest.setCorrelationId("664be3d2-6c12-4f4b-a3e7-c349acced200" + "-" + "1");
dmaapRequest.setRpcName("restart");
dmaapRequest.setType("request");
- dmaapResponse = new LCMResponseWrapper();
+ dmaapResponse = new LcmResponseWrapper();
dmaapResponse.setCorrelationId("664be3d2-6c12-4f4b-a3e7-c349acced200" + "-" + "1");
dmaapResponse.setRpcName("restart");
dmaapResponse.setType("response");
- LCMRequest appcRequest = new LCMRequest();
-
+ LcmRequest appcRequest = new LcmRequest();
+
appcRequest.setAction("restart");
-
+
HashMap<String, String> actionIdentifiers = new HashMap<>();
actionIdentifiers.put("vnf-id", "trial-vnf-003");
actionIdentifiers.put("vserver-id", "08f6c1f9-99e7-49f3-a662-c62b9f200d79");
-
+
appcRequest.setActionIdentifiers(actionIdentifiers);
-
- LCMCommonHeader commonHeader = new LCMCommonHeader();
+
+ LcmCommonHeader commonHeader = new LcmCommonHeader();
commonHeader.setRequestId(UUID.fromString("664be3d2-6c12-4f4b-a3e7-c349acced200"));
commonHeader.setSubRequestId("1");
commonHeader.setOriginatorId("664be3d2-6c12-4f4b-a3e7-c349acced200");
-
+
appcRequest.setCommonHeader(commonHeader);
-
+
appcRequest.setPayload(null);
dmaapRequest.setBody(appcRequest);
-
+
/*
* Construct an APPCLCM Response to be Serialized
*/
- LCMResponse appcResponse = new LCMResponse(appcRequest);
+ LcmResponse appcResponse = new LcmResponse(appcRequest);
appcResponse.getStatus().setCode(400);
appcResponse.getStatus().setMessage("Restart Successful");
appcResponse.setPayload(null);
@@ -85,69 +87,63 @@ public class AppcLcmTest {
@Test
public void testRequestSerialization() {
-
+
/*
* Use the gson serializer to obtain json
*/
- String jsonRequest = Serialization.gson.toJson(dmaapRequest, LCMRequestWrapper.class);
+ String jsonRequest = Serialization.gson.toJson(dmaapRequest, LcmRequestWrapper.class);
assertNotNull(jsonRequest);
-
+
/*
- * The serializer should have added an extra
- * sub-tag called "input" that wraps the request
+ * The serializer should have added an extra sub-tag called "input" that wraps the request
*/
assertTrue(jsonRequest.contains("input"));
-
+
/*
- * The common-header, request-id, and
- * sub-request-id should exist
+ * The common-header, request-id, and sub-request-id should exist
*/
assertTrue(jsonRequest.contains("common-header"));
assertTrue(jsonRequest.contains("request-id"));
assertTrue(jsonRequest.contains("sub-request-id"));
-
+
/*
- * action-identifiers should exist and contain
- * a vnf-id
+ * action-identifiers should exist and contain a vnf-id
*/
assertTrue(jsonRequest.contains("action-identifiers"));
assertTrue(jsonRequest.contains("vnf-id"));
-
+
/*
* The action sub-tag should exist
*/
assertTrue(jsonRequest.contains("action"));
-
+
logger.debug("Request as JSON: " + jsonRequest + "\n\n");
}
@Test
public void testRequestDeserialization() {
-
+
/*
- * Convert the LCM request object into json
- * so we have a string of json to use for testing
+ * Convert the LCM request object into json so we have a string of json to use for testing
*/
- String jsonRequest = Serialization.gson.toJson(dmaapRequest, LCMRequestWrapper.class);
-
+ String jsonRequest = Serialization.gson.toJson(dmaapRequest, LcmRequestWrapper.class);
+
/*
- * Use the serializer to convert the json string
- * into a java object
+ * Use the serializer to convert the json string into a java object
*/
- LCMRequestWrapper dmaapRequest = Serialization.gson.fromJson(jsonRequest, LCMRequestWrapper.class);
+ LcmRequestWrapper dmaapRequest = Serialization.gson.fromJson(jsonRequest, LcmRequestWrapper.class);
assertNotNull(dmaapRequest);
-
+
/*
* The type of the DMAAP wrapper should be request
*/
assertEquals("request", dmaapRequest.getType());
-
+
/*
- * The DMAAP wrapper must have a body as that is
- * the true APPC request
+ * The DMAAP wrapper must have a body as that is the true APPC request
*/
assertNotNull(dmaapRequest.getBody());
- LCMRequest appcRequest = dmaapRequest.getBody();
+ LcmRequest appcRequest = dmaapRequest.getBody();
assertNotNull(appcRequest);
/*
@@ -156,85 +152,77 @@ public class AppcLcmTest {
assertNotNull(appcRequest.getCommonHeader());
/*
- * The action should not be null and should be
- * set to restart
+ * The action should not be null and should be set to restart
*/
assertNotNull(appcRequest.getAction());
assertEquals("restart", appcRequest.getAction());
/*
- * The action-identifiers should not be null
- * and should contain a vnf-id
+ * The action-identifiers should not be null and should contain a vnf-id
*/
assertNotNull(appcRequest.getActionIdentifiers());
assertNotNull(appcRequest.getActionIdentifiers().get("vnf-id"));
-
+
logger.debug("Request as a Java Object: \n" + appcRequest.toString() + "\n\n");
}
@Test
public void testResponseSerialization() {
-
+
/*
* Use the serializer to convert the object into json
*/
- String jsonResponse = Serialization.gson.toJson(dmaapResponse, LCMResponseWrapper.class);
+ String jsonResponse = Serialization.gson.toJson(dmaapResponse, LcmResponseWrapper.class);
assertNotNull(jsonResponse);
-
+
/*
- * The serializer should have added an extra
- * sub-tag called "input" that wraps the request
+ * The serializer should have added an extra sub-tag called "input" that wraps the request
*/
assertTrue(jsonResponse.contains("output"));
-
+
/*
- * The response should contain a common-header,
- * request-id, sub-request-id, and status
+ * The response should contain a common-header, request-id, sub-request-id, and status
*/
assertTrue(jsonResponse.contains("common-header"));
assertTrue(jsonResponse.contains("request-id"));
assertTrue(jsonResponse.contains("sub-request-id"));
assertTrue(jsonResponse.contains("status"));
-
+
logger.debug("Response as JSON: " + jsonResponse + "\n\n");
}
-
+
@Test
public void testResponseDeserialization() {
/*
- * Convert the LCM response object into json
- * so we have a string of json to use for testing
+ * Convert the LCM response object into json so we have a string of json to use for testing
*/
- String jsonResponse = Serialization.gson.toJson(dmaapResponse, LCMResponseWrapper.class);
-
+ String jsonResponse = Serialization.gson.toJson(dmaapResponse, LcmResponseWrapper.class);
+
/*
- * Use the serializer to convert the json string
- * into a java object
+ * Use the serializer to convert the json string into a java object
*/
- LCMResponseWrapper dmaapResponse = Serialization.gson.fromJson(jsonResponse, LCMResponseWrapper.class);
+ LcmResponseWrapper dmaapResponse = Serialization.gson.fromJson(jsonResponse, LcmResponseWrapper.class);
assertNotNull(dmaapResponse);
-
+
/*
* The type of the DMAAP wrapper should be response
*/
assertEquals("response", dmaapResponse.getType());
-
+
/*
- * The DMAAP wrapper must have a body as that is
- * the true APPC response
+ * The DMAAP wrapper must have a body as that is the true APPC response
*/
assertNotNull(dmaapResponse.getBody());
- LCMResponse appcResponse = dmaapResponse.getBody();
+ LcmResponse appcResponse = dmaapResponse.getBody();
assertNotNull(appcResponse);
-
+
/*
* The common header should not be null
*/
assertNotNull(appcResponse.getCommonHeader());
-
+
/*
- * The status should not be null and the
- * status code should be 400
+ * The status should not be null and the status code should be 400
*/
assertNotNull(appcResponse.getStatus());
assertEquals(400, appcResponse.getStatus().getCode());
diff --git a/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/LCMResponseTest.java b/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/LCMResponseTest.java
deleted file mode 100644
index 14dee480b..000000000
--- a/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/LCMResponseTest.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * appclcm
- * ================================================================================
- * Copyright (C) 2017 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-package org.onap.policy.appclcm;
-
-import static org.junit.Assert.*;
-
-import org.junit.Test;
-
-public class LCMResponseTest {
-
- private static final String PAYLOAD = "payload";
-
- @Test
- public void testHashCode() {
- LCMResponse response = new LCMResponse();
- assertTrue(response.hashCode() != 0);
- response.setCommonHeader(new LCMCommonHeader());
- assertTrue(response.hashCode() != 0);
- response.setPayload(PAYLOAD);
- assertTrue(response.hashCode() != 0);
- response.setStatus(null);
- assertTrue(response.hashCode() != 0);
- }
-
- @Test
- public void testLCMResponse() {
- LCMResponse response = new LCMResponse();
- assertNull(response.getCommonHeader());
- assertNull(response.getPayload());
- assertNotNull(response.getStatus());
- }
-
- @Test
- public void testToString() {
- LCMResponse response = new LCMResponse();
- assertFalse(response.toString().isEmpty());
- }
-
- @Test
- public void testEqualsObject() {
- LCMResponse response = new LCMResponse();
- assertTrue(response.equals(response));
- assertFalse(response.equals(null));
- assertFalse(response.equals(new Object()));
-
- LCMResponse response2 = new LCMResponse();
- assertTrue(response.equals(response2));
-
- response.setCommonHeader(new LCMCommonHeader());
- assertFalse(response.equals(response2));
- response2.setCommonHeader(response.getCommonHeader());
- assertTrue(response.equals(response2));
-
- response.setPayload(PAYLOAD);
- assertFalse(response.equals(response2));
- response2.setPayload(response.getPayload());
- assertTrue(response.equals(response2));
-
- response.setCommonHeader(null);
- assertFalse(response.equals(response2));
- response2.setCommonHeader(null);
- assertTrue(response.equals(response2));
-
- response.setPayload(null);
- assertFalse(response.equals(response2));
- response2.setPayload(response.getPayload());
- assertTrue(response.equals(response2));
-
- response.setStatus(null);
- assertFalse(response.equals(response2));
- response2.setStatus(response.getStatus());
- assertTrue(response.equals(response2));
-
- LCMResponseStatus status = new LCMResponseStatus();
- status.setCode(5);
- response.setStatus(status);
- response2.setStatus(new LCMResponseStatus());
- assertFalse(response.equals(response2));
- }
-
- @Test
- public void testResponseRequest() {
- LCMRequest request = new LCMRequest();
- request.setCommonHeader(new LCMCommonHeader());
- request.setPayload(PAYLOAD);
-
- LCMResponse response = new LCMResponse(request);
-
- assertTrue(response.getPayload().equals(PAYLOAD));
- }
-
-}
diff --git a/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/LcmResponseTest.java b/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/LcmResponseTest.java
new file mode 100644
index 000000000..7583ee0c4
--- /dev/null
+++ b/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/LcmResponseTest.java
@@ -0,0 +1,113 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * appclcm
+ * ================================================================================
+ * 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.appclcm;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Test;
+
+public class LcmResponseTest {
+
+ private static final String PAYLOAD = "payload";
+
+ @Test
+ public void testHashCode() {
+ LcmResponse response = new LcmResponse();
+ assertTrue(response.hashCode() != 0);
+ response.setCommonHeader(new LcmCommonHeader());
+ assertTrue(response.hashCode() != 0);
+ response.setPayload(PAYLOAD);
+ assertTrue(response.hashCode() != 0);
+ response.setStatus(null);
+ assertTrue(response.hashCode() != 0);
+ }
+
+ @Test
+ public void testLcmResponse() {
+ LcmResponse response = new LcmResponse();
+ assertNull(response.getCommonHeader());
+ assertNull(response.getPayload());
+ assertNotNull(response.getStatus());
+ }
+
+ @Test
+ public void testToString() {
+ LcmResponse response = new LcmResponse();
+ assertFalse(response.toString().isEmpty());
+ }
+
+ @Test
+ public void testEqualsObject() {
+ LcmResponse response = new LcmResponse();
+ assertTrue(response.equals(response));
+ assertFalse(response.equals(null));
+ assertFalse(response.equals(new Object()));
+
+ LcmResponse response2 = new LcmResponse();
+ assertTrue(response.equals(response2));
+
+ response.setCommonHeader(new LcmCommonHeader());
+ assertFalse(response.equals(response2));
+ response2.setCommonHeader(response.getCommonHeader());
+ assertTrue(response.equals(response2));
+
+ response.setPayload(PAYLOAD);
+ assertFalse(response.equals(response2));
+ response2.setPayload(response.getPayload());
+ assertTrue(response.equals(response2));
+
+ response.setCommonHeader(null);
+ assertFalse(response.equals(response2));
+ response2.setCommonHeader(null);
+ assertTrue(response.equals(response2));
+
+ response.setPayload(null);
+ assertFalse(response.equals(response2));
+ response2.setPayload(response.getPayload());
+ assertTrue(response.equals(response2));
+
+ response.setStatus(null);
+ assertFalse(response.equals(response2));
+ response2.setStatus(response.getStatus());
+ assertTrue(response.equals(response2));
+
+ LcmResponseStatus status = new LcmResponseStatus();
+ status.setCode(5);
+ response.setStatus(status);
+ response2.setStatus(new LcmResponseStatus());
+ assertFalse(response.equals(response2));
+ }
+
+ @Test
+ public void testResponseRequest() {
+ LcmRequest request = new LcmRequest();
+ request.setCommonHeader(new LcmCommonHeader());
+ request.setPayload(PAYLOAD);
+
+ LcmResponse response = new LcmResponse(request);
+
+ assertTrue(response.getPayload().equals(PAYLOAD));
+ }
+
+}
diff --git a/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/TestLCMCommonHeader.java b/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/TestLCMCommonHeader.java
deleted file mode 100644
index 6921068e5..000000000
--- a/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/TestLCMCommonHeader.java
+++ /dev/null
@@ -1,159 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * appc
- * ================================================================================
- * Copyright (C) 2017 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-/*-
- * ============LICENSE_START=======================================================
- * appc
- * ================================================================================
- * Copyright (C) 2017 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.appclcm;
-
-import static org.junit.Assert.*;
-
-import java.time.Instant;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.UUID;
-
-import org.junit.Test;
-
-public class TestLCMCommonHeader {
-
- @Test
- public void testLCMLCMCommonHeader() {
- LCMCommonHeader commonHeader = new LCMCommonHeader();
- assertNotNull(commonHeader);
- assertNotNull(new LCMCommonHeader(commonHeader));
- assertNotEquals(0, commonHeader.hashCode());
-
- commonHeader.setApiVer("Kansas");
- assertEquals("Kansas", commonHeader.getApiVer());
-
- Map<String, String> flagMap = new HashMap<>();
- commonHeader.setFlags(flagMap);
- assertEquals(flagMap, commonHeader.getFlags());
-
- commonHeader.setOriginatorId("Dorothy");
- assertEquals("Dorothy", commonHeader.getOriginatorId());
-
- UUID requestId = UUID.randomUUID();
- commonHeader.setRequestId(requestId);
- assertEquals(requestId, commonHeader.getRequestId());
-
- commonHeader.setSubRequestId("Can I go home?");
- assertEquals("Can I go home?", commonHeader.getSubRequestId());
-
- Instant timestamp = Instant.now();
- commonHeader.setTimeStamp(timestamp);
- assertEquals(timestamp, commonHeader.getTimeStamp());
-
- assertNotEquals(0, commonHeader.hashCode());
-
- assertEquals("CommonHeader [timeStamp=", commonHeader.toString().substring(0, 24));
-
- LCMCommonHeader copiedLCMCommonHeader = new LCMCommonHeader();
- copiedLCMCommonHeader.setApiVer(commonHeader.getApiVer());
- copiedLCMCommonHeader.setFlags(commonHeader.getFlags());
- copiedLCMCommonHeader.setOriginatorId(commonHeader.getOriginatorId());
- copiedLCMCommonHeader.setRequestId(commonHeader.getRequestId());
- copiedLCMCommonHeader.setSubRequestId(commonHeader.getSubRequestId());
- copiedLCMCommonHeader.setTimeStamp(commonHeader.getTimeStamp());
-
- assertTrue(commonHeader.equals(commonHeader));
- assertTrue(commonHeader.equals(copiedLCMCommonHeader));
- assertFalse(commonHeader.equals(null));
- assertFalse(commonHeader.equals("Hello"));
-
- LCMCommonHeader clonedLCMCommonHeader = new LCMCommonHeader(commonHeader);
- clonedLCMCommonHeader.setApiVer(commonHeader.getApiVer());
- clonedLCMCommonHeader.setTimeStamp(commonHeader.getTimeStamp());
-
- assertTrue(commonHeader.equals(clonedLCMCommonHeader));
-
- commonHeader.setApiVer(null);
- assertFalse(commonHeader.equals(copiedLCMCommonHeader));
- copiedLCMCommonHeader.setApiVer(null);
- assertTrue(commonHeader.equals(copiedLCMCommonHeader));
- commonHeader.setApiVer("Kansas");
- assertFalse(commonHeader.equals(copiedLCMCommonHeader));
- copiedLCMCommonHeader.setApiVer("Kansas");
- assertTrue(commonHeader.equals(copiedLCMCommonHeader));
-
- commonHeader.setFlags(null);
- assertFalse(commonHeader.equals(copiedLCMCommonHeader));
- copiedLCMCommonHeader.setFlags(null);
- assertTrue(commonHeader.equals(copiedLCMCommonHeader));
- commonHeader.setFlags(flagMap);
- assertFalse(commonHeader.equals(copiedLCMCommonHeader));
- copiedLCMCommonHeader.setFlags(flagMap);
- assertTrue(commonHeader.equals(copiedLCMCommonHeader));
-
- commonHeader.setOriginatorId(null);
- assertFalse(commonHeader.equals(copiedLCMCommonHeader));
- copiedLCMCommonHeader.setOriginatorId(null);
- assertTrue(commonHeader.equals(copiedLCMCommonHeader));
- commonHeader.setOriginatorId("Dorothy");
- assertFalse(commonHeader.equals(copiedLCMCommonHeader));
- copiedLCMCommonHeader.setOriginatorId("Dorothy");
- assertTrue(commonHeader.equals(copiedLCMCommonHeader));
-
- commonHeader.setRequestId(null);
- assertFalse(commonHeader.equals(copiedLCMCommonHeader));
- copiedLCMCommonHeader.setRequestId(null);
- assertTrue(commonHeader.equals(copiedLCMCommonHeader));
- commonHeader.setRequestId(requestId);
- assertFalse(commonHeader.equals(copiedLCMCommonHeader));
- copiedLCMCommonHeader.setRequestId(requestId);
- assertTrue(commonHeader.equals(copiedLCMCommonHeader));
-
- commonHeader.setSubRequestId(null);
- assertFalse(commonHeader.equals(copiedLCMCommonHeader));
- copiedLCMCommonHeader.setSubRequestId(null);
- assertTrue(commonHeader.equals(copiedLCMCommonHeader));
- commonHeader.setSubRequestId("Can I go home?");
- assertFalse(commonHeader.equals(copiedLCMCommonHeader));
- copiedLCMCommonHeader.setSubRequestId("Can I go home?");
- assertTrue(commonHeader.equals(copiedLCMCommonHeader));
-
- commonHeader.setTimeStamp(null);
- assertFalse(commonHeader.equals(copiedLCMCommonHeader));
- copiedLCMCommonHeader.setTimeStamp(null);
- assertTrue(commonHeader.equals(copiedLCMCommonHeader));
- commonHeader.setTimeStamp(timestamp);
- assertFalse(commonHeader.equals(copiedLCMCommonHeader));
- copiedLCMCommonHeader.setTimeStamp(timestamp);
- assertTrue(commonHeader.equals(copiedLCMCommonHeader));
- }
-}
diff --git a/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/TestLCMRequest.java b/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/TestLCMRequest.java
deleted file mode 100644
index 223e50147..000000000
--- a/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/TestLCMRequest.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * appc
- * ================================================================================
- * Copyright (C) 2017 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.appclcm;
-
-import static org.junit.Assert.*;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.junit.Test;
-
-public class TestLCMRequest {
-
- @Test
- public void testLCMRequest() {
- LCMRequest request = new LCMRequest();
- assertNotNull(request);
- assertNotEquals(0, request.hashCode());
-
- LCMCommonHeader commonHeader = new LCMCommonHeader();
-
- request.setCommonHeader(commonHeader);
- assertEquals(commonHeader, request.getCommonHeader());
-
- request.setAction("Go to Oz");
- assertEquals("Go to Oz", request.getAction());
-
- Map<String, String> actionIdentifiers = new HashMap<>();
- actionIdentifiers.put("North", "Good Witch");
- actionIdentifiers.put("West", "Bad Witch");
-
- request.setActionIdentifiers(actionIdentifiers);
- assertEquals(actionIdentifiers, request.getActionIdentifiers());
-
- request.setPayload("The Emerald City");
- assertEquals("The Emerald City", request.getPayload());
-
- assertNotEquals(0, request.hashCode());
-
- assertEquals("Request [commonHeader=CommonHeader [timeStamp=", request.toString().substring(0, 46));
-
- LCMRequest copiedLCMRequest = new LCMRequest();
- copiedLCMRequest.setCommonHeader(request.getCommonHeader());
- copiedLCMRequest.setAction(request.getAction());
- copiedLCMRequest.setActionIdentifiers(request.getActionIdentifiers());
- copiedLCMRequest.setPayload(request.getPayload());
-
- assertTrue(request.equals(request));
- assertTrue(request.equals(copiedLCMRequest));
- assertFalse(request.equals(null));
- assertFalse(request.equals("Hello"));
-
- request.setCommonHeader(null);
- assertFalse(request.equals(copiedLCMRequest));
- copiedLCMRequest.setCommonHeader(null);
- assertTrue(request.equals(copiedLCMRequest));
- request.setCommonHeader(commonHeader);
- assertFalse(request.equals(copiedLCMRequest));
- copiedLCMRequest.setCommonHeader(commonHeader);
- assertTrue(request.equals(copiedLCMRequest));
-
- request.setAction(null);
- assertFalse(request.equals(copiedLCMRequest));
- copiedLCMRequest.setAction(null);
- assertTrue(request.equals(copiedLCMRequest));
- request.setAction("Go to Oz");
- assertFalse(request.equals(copiedLCMRequest));
- copiedLCMRequest.setAction("Go to Oz");
- assertTrue(request.equals(copiedLCMRequest));
-
- request.setActionIdentifiers(null);
- assertFalse(request.equals(copiedLCMRequest));
- copiedLCMRequest.setActionIdentifiers(null);
- assertTrue(request.equals(copiedLCMRequest));
- request.setActionIdentifiers(actionIdentifiers);
- assertFalse(request.equals(copiedLCMRequest));
- copiedLCMRequest.setActionIdentifiers(actionIdentifiers);
- assertTrue(request.equals(copiedLCMRequest));
-
- request.setPayload(null);
- assertFalse(request.equals(copiedLCMRequest));
- copiedLCMRequest.setPayload(null);
- assertTrue(request.equals(copiedLCMRequest));
- request.setPayload("The Emerald City");
- assertFalse(request.equals(copiedLCMRequest));
- copiedLCMRequest.setPayload("The Emerald City");
- assertTrue(request.equals(copiedLCMRequest));
- }
-}
diff --git a/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/TestLCMRequestWrapper.java b/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/TestLCMRequestWrapper.java
deleted file mode 100644
index 0a5205509..000000000
--- a/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/TestLCMRequestWrapper.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * appc
- * ================================================================================
- * Copyright (C) 2017 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.appclcm;
-
-import static org.junit.Assert.*;
-
-import org.junit.Test;
-
-public class TestLCMRequestWrapper {
-
- @Test
- public void testLCMRequestWrapperWrapper() {
- assertNotNull(new LCMRequestWrapper(new LCMRequest()));
- LCMRequestWrapper requestWrapper = new LCMRequestWrapper();
- assertNotNull(requestWrapper);
- assertNotEquals(0, requestWrapper.hashCode());
-
- LCMRequest request = new LCMRequest();
-
- requestWrapper.setBody(request);
- assertEquals(request, requestWrapper.getBody());
-
- assertNotEquals(0, requestWrapper.hashCode());
-
- assertEquals("RequestWrapper [body=Request [commonHeader=nul", requestWrapper.toString().substring(0, 46));
-
- LCMRequestWrapper copiedLCMRequestWrapper = new LCMRequestWrapper();
- copiedLCMRequestWrapper.setBody(requestWrapper.getBody());
-
- assertTrue(requestWrapper.equals(requestWrapper));
- assertTrue(requestWrapper.equals(copiedLCMRequestWrapper));
- assertFalse(requestWrapper.equals(null));
- assertFalse(requestWrapper.equals("Hello"));
-
- requestWrapper.setBody(null);
- assertFalse(requestWrapper.equals(copiedLCMRequestWrapper));
- copiedLCMRequestWrapper.setBody(null);
- assertTrue(requestWrapper.equals(copiedLCMRequestWrapper));
- requestWrapper.setBody(request);
- assertFalse(requestWrapper.equals(copiedLCMRequestWrapper));
- copiedLCMRequestWrapper.setBody(request);
- assertTrue(requestWrapper.equals(copiedLCMRequestWrapper));
- }
-}
diff --git a/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/TestLCMResonseCode.java b/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/TestLCMResonseCode.java
deleted file mode 100644
index 59606f8b4..000000000
--- a/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/TestLCMResonseCode.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * appc
- * ================================================================================
- * Copyright (C) 2017 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.appclcm;
-
-import static org.junit.Assert.*;
-
-import org.junit.Test;
-
-public class TestLCMResonseCode {
-
- @Test
- public void testLCMResponseCode() {
- assertNull(LCMResponseCode.toResponseValue(0));
-
- assertEquals(LCMResponseCode.ACCEPTED, LCMResponseCode.toResponseValue(100));
- assertEquals(LCMResponseCode.ERROR, LCMResponseCode.toResponseValue(200));
- assertEquals(LCMResponseCode.REJECT, LCMResponseCode.toResponseValue(300));
- assertEquals(LCMResponseCode.SUCCESS, LCMResponseCode.toResponseValue(400));
- assertEquals(LCMResponseCode.FAILURE, LCMResponseCode.toResponseValue(450));
- assertEquals(LCMResponseCode.FAILURE, LCMResponseCode.toResponseValue(401));
- assertEquals(LCMResponseCode.FAILURE, LCMResponseCode.toResponseValue(406));
- assertEquals(LCMResponseCode.PARTIAL_SUCCESS, LCMResponseCode.toResponseValue(500));
- assertEquals(LCMResponseCode.PARTIAL_FAILURE, LCMResponseCode.toResponseValue(501));
- assertEquals(LCMResponseCode.PARTIAL_FAILURE, LCMResponseCode.toResponseValue(599));
-
- assertEquals("100", new LCMResponseCode(100).toString());
- assertEquals("200", new LCMResponseCode(200).toString());
- assertEquals("300", new LCMResponseCode(300).toString());
- assertEquals("400", new LCMResponseCode(400).toString());
- assertEquals("450", new LCMResponseCode(450).toString());
- assertEquals("500", new LCMResponseCode(500).toString());
- assertEquals("510", new LCMResponseCode(510).toString());
-
- assertEquals(300, new LCMResponseCode(300).getCode());
- }
-}
diff --git a/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/TestLCMResponseWrapper.java b/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/TestLCMResponseWrapper.java
deleted file mode 100644
index d27fbaff3..000000000
--- a/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/TestLCMResponseWrapper.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * appc
- * ================================================================================
- * Copyright (C) 2017 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.appclcm;
-
-import static org.junit.Assert.*;
-
-import org.junit.Test;
-
-public class TestLCMResponseWrapper {
-
- @Test
- public void testLCMResponseWrapperWrapper() {
- LCMResponseWrapper responseWrapper = new LCMResponseWrapper();
- assertNotNull(responseWrapper);
- assertNotEquals(0, responseWrapper.hashCode());
-
- LCMResponse response = new LCMResponse();
-
- responseWrapper.setBody(response);
- assertEquals(response, responseWrapper.getBody());
-
- assertNotEquals(0, responseWrapper.hashCode());
-
- assertEquals("ResponseWrapper [body=Response [commonHeader=n", responseWrapper.toString().substring(0, 46));
-
- LCMResponseWrapper copiedLCMResponseWrapper = new LCMResponseWrapper();
- copiedLCMResponseWrapper.setBody(responseWrapper.getBody());
-
- assertTrue(responseWrapper.equals(responseWrapper));
- assertTrue(responseWrapper.equals(copiedLCMResponseWrapper));
- assertFalse(responseWrapper.equals(null));
- assertFalse(responseWrapper.equals("Hello"));
-
- responseWrapper.setBody(null);
- assertFalse(responseWrapper.equals(copiedLCMResponseWrapper));
- copiedLCMResponseWrapper.setBody(null);
- assertTrue(responseWrapper.equals(copiedLCMResponseWrapper));
- responseWrapper.setBody(response);
- assertFalse(responseWrapper.equals(copiedLCMResponseWrapper));
- copiedLCMResponseWrapper.setBody(response);
- assertTrue(responseWrapper.equals(copiedLCMResponseWrapper));
- }
-}
diff --git a/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/TestLCMWrapper.java b/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/TestLCMWrapper.java
deleted file mode 100644
index 20baf154d..000000000
--- a/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/TestLCMWrapper.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * appc
- * ================================================================================
- * Copyright (C) 2017 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.appclcm;
-
-import static org.junit.Assert.*;
-
-import org.junit.Test;
-
-public class TestLCMWrapper {
-
- @Test
- public void testLCMWrapper() {
- LCMWrapper wrapper = new LCMWrapper();
- assertNotNull(wrapper);
- assertNotEquals(0, wrapper.hashCode());
-
- wrapper.setVersion("19.3.9");
- assertEquals("19.3.9", wrapper.getVersion());
-
- wrapper.setCambriaPartition("The Emerald City");
- assertEquals("The Emerald City", wrapper.getCambriaPartition());
-
- wrapper.setRpcName("Tornado");
- assertEquals("Tornado", wrapper.getRpcName());
-
- wrapper.setCorrelationId("YellowBrickRoad");
- assertEquals("YellowBrickRoad", wrapper.getCorrelationId());
-
- wrapper.setType("Munchkin");
- assertEquals("Munchkin", wrapper.getType());
-
- assertNotEquals(0, wrapper.hashCode());
-
- assertEquals("Wrapper [version=19.3.9, cambriaPartition=The ", wrapper.toString().substring(0, 46));
-
- LCMWrapper copiedLCMWrapper = new LCMWrapper();
- copiedLCMWrapper.setVersion(wrapper.getVersion());
- copiedLCMWrapper.setCambriaPartition(wrapper.getCambriaPartition());
- copiedLCMWrapper.setRpcName(wrapper.getRpcName());
- copiedLCMWrapper.setCorrelationId(wrapper.getCorrelationId());
- copiedLCMWrapper.setType(wrapper.getType());
-
- assertTrue(wrapper.equals(wrapper));
- assertTrue(wrapper.equals(copiedLCMWrapper));
- assertFalse(wrapper.equals(null));
- assertFalse(wrapper.equals("Hello"));
-
- wrapper.setVersion(null);
- assertFalse(wrapper.equals(copiedLCMWrapper));
- copiedLCMWrapper.setVersion(null);
- assertTrue(wrapper.equals(copiedLCMWrapper));
- wrapper.setVersion("19.3.9");
- assertFalse(wrapper.equals(copiedLCMWrapper));
- copiedLCMWrapper.setVersion("19.3.9");
- assertTrue(wrapper.equals(copiedLCMWrapper));
-
- wrapper.setCambriaPartition(null);
- assertFalse(wrapper.equals(copiedLCMWrapper));
- copiedLCMWrapper.setCambriaPartition(null);
- assertTrue(wrapper.equals(copiedLCMWrapper));
- wrapper.setCambriaPartition("The Emerald City");
- assertFalse(wrapper.equals(copiedLCMWrapper));
- copiedLCMWrapper.setCambriaPartition("The Emerald City");
- assertTrue(wrapper.equals(copiedLCMWrapper));
-
- wrapper.setRpcName(null);
- assertFalse(wrapper.equals(copiedLCMWrapper));
- copiedLCMWrapper.setRpcName(null);
- assertTrue(wrapper.equals(copiedLCMWrapper));
- wrapper.setRpcName("Tornado");
- assertFalse(wrapper.equals(copiedLCMWrapper));
- copiedLCMWrapper.setRpcName("Tornado");
- assertTrue(wrapper.equals(copiedLCMWrapper));
-
- wrapper.setCorrelationId(null);
- assertFalse(wrapper.equals(copiedLCMWrapper));
- copiedLCMWrapper.setCorrelationId(null);
- assertTrue(wrapper.equals(copiedLCMWrapper));
- wrapper.setCorrelationId("YellowBrickRoad");
- assertFalse(wrapper.equals(copiedLCMWrapper));
- copiedLCMWrapper.setCorrelationId("YellowBrickRoad");
- assertTrue(wrapper.equals(copiedLCMWrapper));
-
- wrapper.setType(null);
- assertFalse(wrapper.equals(copiedLCMWrapper));
- copiedLCMWrapper.setType(null);
- assertTrue(wrapper.equals(copiedLCMWrapper));
- wrapper.setType("Munchkin");
- assertFalse(wrapper.equals(copiedLCMWrapper));
- copiedLCMWrapper.setType("Munchkin");
- assertTrue(wrapper.equals(copiedLCMWrapper));
- }
-}
diff --git a/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/TestLcmCommonHeader.java b/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/TestLcmCommonHeader.java
new file mode 100644
index 000000000..49cc7f7de
--- /dev/null
+++ b/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/TestLcmCommonHeader.java
@@ -0,0 +1,143 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * appc
+ * ================================================================================
+ * 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.appclcm;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.time.Instant;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.UUID;
+
+import org.junit.Test;
+
+public class TestLcmCommonHeader {
+
+ @Test
+ public void testLcmCommonHeader() {
+ LcmCommonHeader commonHeader = new LcmCommonHeader();
+ assertNotNull(commonHeader);
+ assertNotNull(new LcmCommonHeader(commonHeader));
+ assertNotEquals(0, commonHeader.hashCode());
+
+ commonHeader.setApiVer("Kansas");
+ assertEquals("Kansas", commonHeader.getApiVer());
+
+ Map<String, String> flagMap = new HashMap<>();
+ commonHeader.setFlags(flagMap);
+ assertEquals(flagMap, commonHeader.getFlags());
+
+ commonHeader.setOriginatorId("Dorothy");
+ assertEquals("Dorothy", commonHeader.getOriginatorId());
+
+ UUID requestId = UUID.randomUUID();
+ commonHeader.setRequestId(requestId);
+ assertEquals(requestId, commonHeader.getRequestId());
+
+ commonHeader.setSubRequestId("Can I go home?");
+ assertEquals("Can I go home?", commonHeader.getSubRequestId());
+
+ Instant timestamp = Instant.now();
+ commonHeader.setTimeStamp(timestamp);
+ assertEquals(timestamp, commonHeader.getTimeStamp());
+
+ assertNotEquals(0, commonHeader.hashCode());
+
+ assertEquals("CommonHeader [timeStamp=", commonHeader.toString().substring(0, 24));
+
+ LcmCommonHeader copiedLcmCommonHeader = new LcmCommonHeader();
+ copiedLcmCommonHeader.setApiVer(commonHeader.getApiVer());
+ copiedLcmCommonHeader.setFlags(commonHeader.getFlags());
+ copiedLcmCommonHeader.setOriginatorId(commonHeader.getOriginatorId());
+ copiedLcmCommonHeader.setRequestId(commonHeader.getRequestId());
+ copiedLcmCommonHeader.setSubRequestId(commonHeader.getSubRequestId());
+ copiedLcmCommonHeader.setTimeStamp(commonHeader.getTimeStamp());
+
+ assertTrue(commonHeader.equals(commonHeader));
+ assertTrue(commonHeader.equals(copiedLcmCommonHeader));
+ assertFalse(commonHeader.equals(null));
+ assertFalse(commonHeader.equals("Hello"));
+
+ LcmCommonHeader clonedLcmCommonHeader = new LcmCommonHeader(commonHeader);
+ clonedLcmCommonHeader.setApiVer(commonHeader.getApiVer());
+ clonedLcmCommonHeader.setTimeStamp(commonHeader.getTimeStamp());
+
+ assertTrue(commonHeader.equals(clonedLcmCommonHeader));
+
+ commonHeader.setApiVer(null);
+ assertFalse(commonHeader.equals(copiedLcmCommonHeader));
+ copiedLcmCommonHeader.setApiVer(null);
+ assertTrue(commonHeader.equals(copiedLcmCommonHeader));
+ commonHeader.setApiVer("Kansas");
+ assertFalse(commonHeader.equals(copiedLcmCommonHeader));
+ copiedLcmCommonHeader.setApiVer("Kansas");
+ assertTrue(commonHeader.equals(copiedLcmCommonHeader));
+
+ commonHeader.setFlags(null);
+ assertFalse(commonHeader.equals(copiedLcmCommonHeader));
+ copiedLcmCommonHeader.setFlags(null);
+ assertTrue(commonHeader.equals(copiedLcmCommonHeader));
+ commonHeader.setFlags(flagMap);
+ assertFalse(commonHeader.equals(copiedLcmCommonHeader));
+ copiedLcmCommonHeader.setFlags(flagMap);
+ assertTrue(commonHeader.equals(copiedLcmCommonHeader));
+
+ commonHeader.setOriginatorId(null);
+ assertFalse(commonHeader.equals(copiedLcmCommonHeader));
+ copiedLcmCommonHeader.setOriginatorId(null);
+ assertTrue(commonHeader.equals(copiedLcmCommonHeader));
+ commonHeader.setOriginatorId("Dorothy");
+ assertFalse(commonHeader.equals(copiedLcmCommonHeader));
+ copiedLcmCommonHeader.setOriginatorId("Dorothy");
+ assertTrue(commonHeader.equals(copiedLcmCommonHeader));
+
+ commonHeader.setRequestId(null);
+ assertFalse(commonHeader.equals(copiedLcmCommonHeader));
+ copiedLcmCommonHeader.setRequestId(null);
+ assertTrue(commonHeader.equals(copiedLcmCommonHeader));
+ commonHeader.setRequestId(requestId);
+ assertFalse(commonHeader.equals(copiedLcmCommonHeader));
+ copiedLcmCommonHeader.setRequestId(requestId);
+ assertTrue(commonHeader.equals(copiedLcmCommonHeader));
+
+ commonHeader.setSubRequestId(null);
+ assertFalse(commonHeader.equals(copiedLcmCommonHeader));
+ copiedLcmCommonHeader.setSubRequestId(null);
+ assertTrue(commonHeader.equals(copiedLcmCommonHeader));
+ commonHeader.setSubRequestId("Can I go home?");
+ assertFalse(commonHeader.equals(copiedLcmCommonHeader));
+ copiedLcmCommonHeader.setSubRequestId("Can I go home?");
+ assertTrue(commonHeader.equals(copiedLcmCommonHeader));
+
+ commonHeader.setTimeStamp(null);
+ assertFalse(commonHeader.equals(copiedLcmCommonHeader));
+ copiedLcmCommonHeader.setTimeStamp(null);
+ assertTrue(commonHeader.equals(copiedLcmCommonHeader));
+ commonHeader.setTimeStamp(timestamp);
+ assertFalse(commonHeader.equals(copiedLcmCommonHeader));
+ copiedLcmCommonHeader.setTimeStamp(timestamp);
+ assertTrue(commonHeader.equals(copiedLcmCommonHeader));
+ }
+}
diff --git a/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/TestLcmRequest.java b/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/TestLcmRequest.java
new file mode 100644
index 000000000..ce8b0415e
--- /dev/null
+++ b/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/TestLcmRequest.java
@@ -0,0 +1,111 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * appc
+ * ================================================================================
+ * 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.appclcm;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.junit.Test;
+
+public class TestLcmRequest {
+
+ @Test
+ public void testLcmRequest() {
+ LcmRequest request = new LcmRequest();
+ assertNotNull(request);
+ assertNotEquals(0, request.hashCode());
+
+ LcmCommonHeader commonHeader = new LcmCommonHeader();
+
+ request.setCommonHeader(commonHeader);
+ assertEquals(commonHeader, request.getCommonHeader());
+
+ request.setAction("Go to Oz");
+ assertEquals("Go to Oz", request.getAction());
+
+ Map<String, String> actionIdentifiers = new HashMap<>();
+ actionIdentifiers.put("North", "Good Witch");
+ actionIdentifiers.put("West", "Bad Witch");
+
+ request.setActionIdentifiers(actionIdentifiers);
+ assertEquals(actionIdentifiers, request.getActionIdentifiers());
+
+ request.setPayload("The Emerald City");
+ assertEquals("The Emerald City", request.getPayload());
+
+ assertNotEquals(0, request.hashCode());
+
+ assertEquals("Request [commonHeader=CommonHeader [timeStamp=", request.toString().substring(0, 46));
+
+ LcmRequest copiedLcmRequest = new LcmRequest();
+ copiedLcmRequest.setCommonHeader(request.getCommonHeader());
+ copiedLcmRequest.setAction(request.getAction());
+ copiedLcmRequest.setActionIdentifiers(request.getActionIdentifiers());
+ copiedLcmRequest.setPayload(request.getPayload());
+
+ assertTrue(request.equals(request));
+ assertTrue(request.equals(copiedLcmRequest));
+ assertFalse(request.equals(null));
+ assertFalse(request.equals("Hello"));
+
+ request.setCommonHeader(null);
+ assertFalse(request.equals(copiedLcmRequest));
+ copiedLcmRequest.setCommonHeader(null);
+ assertTrue(request.equals(copiedLcmRequest));
+ request.setCommonHeader(commonHeader);
+ assertFalse(request.equals(copiedLcmRequest));
+ copiedLcmRequest.setCommonHeader(commonHeader);
+ assertTrue(request.equals(copiedLcmRequest));
+
+ request.setAction(null);
+ assertFalse(request.equals(copiedLcmRequest));
+ copiedLcmRequest.setAction(null);
+ assertTrue(request.equals(copiedLcmRequest));
+ request.setAction("Go to Oz");
+ assertFalse(request.equals(copiedLcmRequest));
+ copiedLcmRequest.setAction("Go to Oz");
+ assertTrue(request.equals(copiedLcmRequest));
+
+ request.setActionIdentifiers(null);
+ assertFalse(request.equals(copiedLcmRequest));
+ copiedLcmRequest.setActionIdentifiers(null);
+ assertTrue(request.equals(copiedLcmRequest));
+ request.setActionIdentifiers(actionIdentifiers);
+ assertFalse(request.equals(copiedLcmRequest));
+ copiedLcmRequest.setActionIdentifiers(actionIdentifiers);
+ assertTrue(request.equals(copiedLcmRequest));
+
+ request.setPayload(null);
+ assertFalse(request.equals(copiedLcmRequest));
+ copiedLcmRequest.setPayload(null);
+ assertTrue(request.equals(copiedLcmRequest));
+ request.setPayload("The Emerald City");
+ assertFalse(request.equals(copiedLcmRequest));
+ copiedLcmRequest.setPayload("The Emerald City");
+ assertTrue(request.equals(copiedLcmRequest));
+ }
+}
diff --git a/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/TestLcmRequestWrapper.java b/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/TestLcmRequestWrapper.java
new file mode 100644
index 000000000..0f1b85a33
--- /dev/null
+++ b/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/TestLcmRequestWrapper.java
@@ -0,0 +1,66 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * appc
+ * ================================================================================
+ * 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.appclcm;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Test;
+
+public class TestLcmRequestWrapper {
+
+ @Test
+ public void testLcmRequestWrapperWrapper() {
+ assertNotNull(new LcmRequestWrapper(new LcmRequest()));
+ LcmRequestWrapper requestWrapper = new LcmRequestWrapper();
+ assertNotNull(requestWrapper);
+ assertNotEquals(0, requestWrapper.hashCode());
+
+ LcmRequest request = new LcmRequest();
+
+ requestWrapper.setBody(request);
+ assertEquals(request, requestWrapper.getBody());
+
+ assertNotEquals(0, requestWrapper.hashCode());
+
+ assertEquals("RequestWrapper [body=Request [commonHeader=nul", requestWrapper.toString().substring(0, 46));
+
+ LcmRequestWrapper copiedLcmRequestWrapper = new LcmRequestWrapper();
+ copiedLcmRequestWrapper.setBody(requestWrapper.getBody());
+
+ assertTrue(requestWrapper.equals(requestWrapper));
+ assertTrue(requestWrapper.equals(copiedLcmRequestWrapper));
+ assertFalse(requestWrapper.equals(null));
+ assertFalse(requestWrapper.equals("Hello"));
+
+ requestWrapper.setBody(null);
+ assertFalse(requestWrapper.equals(copiedLcmRequestWrapper));
+ copiedLcmRequestWrapper.setBody(null);
+ assertTrue(requestWrapper.equals(copiedLcmRequestWrapper));
+ requestWrapper.setBody(request);
+ assertFalse(requestWrapper.equals(copiedLcmRequestWrapper));
+ copiedLcmRequestWrapper.setBody(request);
+ assertTrue(requestWrapper.equals(copiedLcmRequestWrapper));
+ }
+}
diff --git a/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/TestLcmResonseCode.java b/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/TestLcmResonseCode.java
new file mode 100644
index 000000000..cf42845cc
--- /dev/null
+++ b/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/TestLcmResonseCode.java
@@ -0,0 +1,55 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * appc
+ * ================================================================================
+ * 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.appclcm;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+
+import org.junit.Test;
+
+public class TestLcmResonseCode {
+
+ @Test
+ public void testLcmResponseCode() {
+ assertNull(LcmResponseCode.toResponseValue(0));
+
+ assertEquals(LcmResponseCode.ACCEPTED, LcmResponseCode.toResponseValue(100));
+ assertEquals(LcmResponseCode.ERROR, LcmResponseCode.toResponseValue(200));
+ assertEquals(LcmResponseCode.REJECT, LcmResponseCode.toResponseValue(300));
+ assertEquals(LcmResponseCode.SUCCESS, LcmResponseCode.toResponseValue(400));
+ assertEquals(LcmResponseCode.FAILURE, LcmResponseCode.toResponseValue(450));
+ assertEquals(LcmResponseCode.FAILURE, LcmResponseCode.toResponseValue(401));
+ assertEquals(LcmResponseCode.FAILURE, LcmResponseCode.toResponseValue(406));
+ assertEquals(LcmResponseCode.PARTIAL_SUCCESS, LcmResponseCode.toResponseValue(500));
+ assertEquals(LcmResponseCode.PARTIAL_FAILURE, LcmResponseCode.toResponseValue(501));
+ assertEquals(LcmResponseCode.PARTIAL_FAILURE, LcmResponseCode.toResponseValue(599));
+
+ assertEquals("100", new LcmResponseCode(100).toString());
+ assertEquals("200", new LcmResponseCode(200).toString());
+ assertEquals("300", new LcmResponseCode(300).toString());
+ assertEquals("400", new LcmResponseCode(400).toString());
+ assertEquals("450", new LcmResponseCode(450).toString());
+ assertEquals("500", new LcmResponseCode(500).toString());
+ assertEquals("510", new LcmResponseCode(510).toString());
+
+ assertEquals(300, new LcmResponseCode(300).getCode());
+ }
+}
diff --git a/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/TestLCMResponseStatus.java b/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/TestLcmResponseStatus.java
index 0b6cbcf22..b5d4cf3a5 100644
--- a/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/TestLCMResponseStatus.java
+++ b/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/TestLcmResponseStatus.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* appc
* ================================================================================
- * 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.
@@ -20,27 +20,31 @@
package org.onap.policy.appclcm;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
import org.junit.Test;
-public class TestLCMResponseStatus {
+public class TestLcmResponseStatus {
- @Test
- public void testResonseStatus() {
- LCMResponseStatus status = new LCMResponseStatus();
- assertNotNull(status);
- assertNotEquals(0, status.hashCode());
-
- status.setCode(1234);
- assertEquals(1234, status.getCode());
-
- status.setMessage("The wonderful land of Oz");
- assertEquals("The wonderful land of Oz", status.getMessage());
-
- assertEquals("ResponseStatus [code=1234, message=The wonderfu", status.toString().substring(0, 47));
-
- LCMResponseStatus copiedStatus = new LCMResponseStatus();
+ @Test
+ public void testResonseStatus() {
+ LcmResponseStatus status = new LcmResponseStatus();
+ assertNotNull(status);
+ assertNotEquals(0, status.hashCode());
+
+ status.setCode(1234);
+ assertEquals(1234, status.getCode());
+
+ status.setMessage("The wonderful land of Oz");
+ assertEquals("The wonderful land of Oz", status.getMessage());
+
+ assertEquals("ResponseStatus [code=1234, message=The wonderfu", status.toString().substring(0, 47));
+
+ LcmResponseStatus copiedStatus = new LcmResponseStatus();
copiedStatus.setCode(status.getCode());
copiedStatus.setMessage(status.getMessage());
@@ -48,7 +52,7 @@ public class TestLCMResponseStatus {
assertTrue(status.equals(copiedStatus));
assertFalse(status.equals(null));
assertFalse(status.equals("Hello"));
-
+
status.setCode(-1);
assertFalse(status.equals(copiedStatus));
copiedStatus.setCode(-1);
@@ -57,7 +61,7 @@ public class TestLCMResponseStatus {
assertFalse(status.equals(copiedStatus));
copiedStatus.setCode(1234);
assertTrue(status.equals(copiedStatus));
-
+
status.setMessage(null);
assertFalse(status.equals(copiedStatus));
copiedStatus.setMessage(null);
@@ -66,5 +70,5 @@ public class TestLCMResponseStatus {
assertFalse(status.equals(copiedStatus));
copiedStatus.setMessage("The wonderful land of Oz");
assertTrue(status.equals(copiedStatus));
- }
+ }
}
diff --git a/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/TestLcmResponseWrapper.java b/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/TestLcmResponseWrapper.java
new file mode 100644
index 000000000..bf448534f
--- /dev/null
+++ b/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/TestLcmResponseWrapper.java
@@ -0,0 +1,65 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * appc
+ * ================================================================================
+ * Copyright (C) 2017 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.appclcm;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Test;
+
+public class TestLcmResponseWrapper {
+
+ @Test
+ public void testLcmResponseWrapperWrapper() {
+ LcmResponseWrapper responseWrapper = new LcmResponseWrapper();
+ assertNotNull(responseWrapper);
+ assertNotEquals(0, responseWrapper.hashCode());
+
+ LcmResponse response = new LcmResponse();
+
+ responseWrapper.setBody(response);
+ assertEquals(response, responseWrapper.getBody());
+
+ assertNotEquals(0, responseWrapper.hashCode());
+
+ assertEquals("ResponseWrapper [body=Response [commonHeader=n", responseWrapper.toString().substring(0, 46));
+
+ LcmResponseWrapper copiedLcmResponseWrapper = new LcmResponseWrapper();
+ copiedLcmResponseWrapper.setBody(responseWrapper.getBody());
+
+ assertTrue(responseWrapper.equals(responseWrapper));
+ assertTrue(responseWrapper.equals(copiedLcmResponseWrapper));
+ assertFalse(responseWrapper.equals(null));
+ assertFalse(responseWrapper.equals("Hello"));
+
+ responseWrapper.setBody(null);
+ assertFalse(responseWrapper.equals(copiedLcmResponseWrapper));
+ copiedLcmResponseWrapper.setBody(null);
+ assertTrue(responseWrapper.equals(copiedLcmResponseWrapper));
+ responseWrapper.setBody(response);
+ assertFalse(responseWrapper.equals(copiedLcmResponseWrapper));
+ copiedLcmResponseWrapper.setBody(response);
+ assertTrue(responseWrapper.equals(copiedLcmResponseWrapper));
+ }
+}
diff --git a/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/TestLcmWrapper.java b/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/TestLcmWrapper.java
new file mode 100644
index 000000000..d14cb4b24
--- /dev/null
+++ b/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/TestLcmWrapper.java
@@ -0,0 +1,115 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * appc
+ * ================================================================================
+ * Copyright (C) 2017 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.appclcm;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Test;
+
+public class TestLcmWrapper {
+
+ @Test
+ public void testLcmWrapper() {
+ LcmWrapper wrapper = new LcmWrapper();
+ assertNotNull(wrapper);
+ assertNotEquals(0, wrapper.hashCode());
+
+ wrapper.setVersion("19.3.9");
+ assertEquals("19.3.9", wrapper.getVersion());
+
+ wrapper.setCambriaPartition("The Emerald City");
+ assertEquals("The Emerald City", wrapper.getCambriaPartition());
+
+ wrapper.setRpcName("Tornado");
+ assertEquals("Tornado", wrapper.getRpcName());
+
+ wrapper.setCorrelationId("YellowBrickRoad");
+ assertEquals("YellowBrickRoad", wrapper.getCorrelationId());
+
+ wrapper.setType("Munchkin");
+ assertEquals("Munchkin", wrapper.getType());
+
+ assertNotEquals(0, wrapper.hashCode());
+
+ assertEquals("Wrapper [version=19.3.9, cambriaPartition=The ", wrapper.toString().substring(0, 46));
+
+ LcmWrapper copiedLcmWrapper = new LcmWrapper();
+ copiedLcmWrapper.setVersion(wrapper.getVersion());
+ copiedLcmWrapper.setCambriaPartition(wrapper.getCambriaPartition());
+ copiedLcmWrapper.setRpcName(wrapper.getRpcName());
+ copiedLcmWrapper.setCorrelationId(wrapper.getCorrelationId());
+ copiedLcmWrapper.setType(wrapper.getType());
+
+ assertTrue(wrapper.equals(wrapper));
+ assertTrue(wrapper.equals(copiedLcmWrapper));
+ assertFalse(wrapper.equals(null));
+ assertFalse(wrapper.equals("Hello"));
+
+ wrapper.setVersion(null);
+ assertFalse(wrapper.equals(copiedLcmWrapper));
+ copiedLcmWrapper.setVersion(null);
+ assertTrue(wrapper.equals(copiedLcmWrapper));
+ wrapper.setVersion("19.3.9");
+ assertFalse(wrapper.equals(copiedLcmWrapper));
+ copiedLcmWrapper.setVersion("19.3.9");
+ assertTrue(wrapper.equals(copiedLcmWrapper));
+
+ wrapper.setCambriaPartition(null);
+ assertFalse(wrapper.equals(copiedLcmWrapper));
+ copiedLcmWrapper.setCambriaPartition(null);
+ assertTrue(wrapper.equals(copiedLcmWrapper));
+ wrapper.setCambriaPartition("The Emerald City");
+ assertFalse(wrapper.equals(copiedLcmWrapper));
+ copiedLcmWrapper.setCambriaPartition("The Emerald City");
+ assertTrue(wrapper.equals(copiedLcmWrapper));
+
+ wrapper.setRpcName(null);
+ assertFalse(wrapper.equals(copiedLcmWrapper));
+ copiedLcmWrapper.setRpcName(null);
+ assertTrue(wrapper.equals(copiedLcmWrapper));
+ wrapper.setRpcName("Tornado");
+ assertFalse(wrapper.equals(copiedLcmWrapper));
+ copiedLcmWrapper.setRpcName("Tornado");
+ assertTrue(wrapper.equals(copiedLcmWrapper));
+
+ wrapper.setCorrelationId(null);
+ assertFalse(wrapper.equals(copiedLcmWrapper));
+ copiedLcmWrapper.setCorrelationId(null);
+ assertTrue(wrapper.equals(copiedLcmWrapper));
+ wrapper.setCorrelationId("YellowBrickRoad");
+ assertFalse(wrapper.equals(copiedLcmWrapper));
+ copiedLcmWrapper.setCorrelationId("YellowBrickRoad");
+ assertTrue(wrapper.equals(copiedLcmWrapper));
+
+ wrapper.setType(null);
+ assertFalse(wrapper.equals(copiedLcmWrapper));
+ copiedLcmWrapper.setType(null);
+ assertTrue(wrapper.equals(copiedLcmWrapper));
+ wrapper.setType("Munchkin");
+ assertFalse(wrapper.equals(copiedLcmWrapper));
+ copiedLcmWrapper.setType("Munchkin");
+ assertTrue(wrapper.equals(copiedLcmWrapper));
+ }
+}
diff --git a/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/util/TestSerialization.java b/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/util/TestSerialization.java
index 030c8a5fe..4e403ecb4 100644
--- a/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/util/TestSerialization.java
+++ b/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/util/TestSerialization.java
@@ -20,39 +20,38 @@
package org.onap.policy.appclcm.util;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
import java.time.Instant;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import org.junit.Test;
-import org.onap.policy.appclcm.util.Serialization;
public class TestSerialization {
- @Test
- public void test() {
- String nameString = "Dorothy";
- String jsonName = Serialization.gsonPretty.toJson(nameString, String.class);
- assertEquals("\"Dorothy\"", jsonName);
- String jsonInOutName = Serialization.gsonPretty.fromJson(jsonName, String.class);
- assertEquals("Dorothy", jsonInOutName);
-
- Instant instant0 = Instant.ofEpochMilli(1516127215000L);
- String instantString0 = Serialization.gsonPretty.toJson(instant0, Instant.class);
- assertEquals("\"2018-01-16T18:26:55Z\"", instantString0);
- Instant outInstant0 = Serialization.gsonPretty.fromJson(instantString0, Instant.class);
- assertEquals(instant0, outInstant0);
-
- Instant instant1 = Instant.ofEpochMilli(1516127215000L);
- String instantString1 = Serialization.gsonJunit.toJson(instant1, Instant.class);
- assertEquals("1516127215000", instantString1);
- Instant outInstant1 = Serialization.gsonJunit.fromJson(instantString1, Instant.class);
- assertEquals(instant1, outInstant1);
-
- ZonedDateTime zdt = ZonedDateTime.ofInstant(instant0, ZoneId.of("UTC"));
- String zdtString = Serialization.gsonPretty.toJson(zdt, ZonedDateTime.class);
- assertEquals("{\n \"dateTime\": {\n \"date\":", zdtString.substring(0, 29));
- }
+ @Test
+ public void test() {
+ String nameString = "Dorothy";
+ String jsonName = Serialization.gsonPretty.toJson(nameString, String.class);
+ assertEquals("\"Dorothy\"", jsonName);
+ String jsonInOutName = Serialization.gsonPretty.fromJson(jsonName, String.class);
+ assertEquals("Dorothy", jsonInOutName);
+
+ Instant instant0 = Instant.ofEpochMilli(1516127215000L);
+ String instantString0 = Serialization.gsonPretty.toJson(instant0, Instant.class);
+ assertEquals("\"2018-01-16T18:26:55Z\"", instantString0);
+ Instant outInstant0 = Serialization.gsonPretty.fromJson(instantString0, Instant.class);
+ assertEquals(instant0, outInstant0);
+
+ Instant instant1 = Instant.ofEpochMilli(1516127215000L);
+ String instantString1 = Serialization.gsonJunit.toJson(instant1, Instant.class);
+ assertEquals("1516127215000", instantString1);
+ Instant outInstant1 = Serialization.gsonJunit.fromJson(instantString1, Instant.class);
+ assertEquals(instant1, outInstant1);
+
+ ZonedDateTime zdt = ZonedDateTime.ofInstant(instant0, ZoneId.of("UTC"));
+ String zdtString = Serialization.gsonPretty.toJson(zdt, ZonedDateTime.class);
+ assertEquals("{\n \"dateTime\": {\n \"date\":", zdtString.substring(0, 29));
+ }
}
diff --git a/controlloop/common/model-impl/events/pom.xml b/controlloop/common/model-impl/events/pom.xml
index f3d56f67b..97b686e4e 100644
--- a/controlloop/common/model-impl/events/pom.xml
+++ b/controlloop/common/model-impl/events/pom.xml
@@ -43,4 +43,45 @@
<scope>test</scope>
</dependency>
</dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-checkstyle-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>onap-java-style</id>
+ <goals>
+ <goal>check</goal>
+ </goals>
+ <phase>process-sources</phase>
+ <configuration>
+ <!-- Use Google Java Style Guide:
+ https://github.com/checkstyle/checkstyle/blob/master/src/main/resources/google_checks.xml
+ with minor changes -->
+ <configLocation>onap-checkstyle/onap-java-style.xml</configLocation>
+ <!-- <sourceDirectory> is needed so that checkstyle ignores the generated sources directory -->
+ <sourceDirectory>${project.build.sourceDirectory}</sourceDirectory>
+ <includeResources>true</includeResources>
+ <includeTestSourceDirectory>true</includeTestSourceDirectory>
+ <includeTestResources>true</includeTestResources>
+ <excludes>
+ </excludes>
+ <consoleOutput>true</consoleOutput>
+ <failOnViolation>true</failOnViolation>
+ <violationSeverity>warning</violationSeverity>
+ </configuration>
+ </execution>
+ </executions>
+ <dependencies>
+ <dependency>
+ <groupId>org.onap.oparent</groupId>
+ <artifactId>checkstyle</artifactId>
+ <version>0.1.1</version>
+ <scope>compile</scope>
+ </dependency>
+ </dependencies>
+ </plugin>
+ </plugins>
+ </build>
</project>
diff --git a/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopEvent.java b/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopEvent.java
index 1d85ccb77..d3f1786c7 100644
--- a/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopEvent.java
+++ b/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopEvent.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* controlloop
* ================================================================================
- * 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.
@@ -24,130 +24,135 @@ import java.io.Serializable;
import java.util.UUID;
public abstract class ControlLoopEvent implements Serializable {
-
- private static final long serialVersionUID = 2391252138583119195L;
-
- private String closedLoopControlName;
- private String version = "1.0.2";
- private UUID requestID;
- private String closedLoopEventClient;
- private ControlLoopTargetType targetType;
- private String target;
- private String from;
- private String policyScope;
- private String policyName;
- private String policyVersion;
- private ControlLoopEventStatus closedLoopEventStatus;
-
- public ControlLoopEvent() {
-
- }
-
- public ControlLoopEvent(ControlLoopEvent event) {
- if (event == null) {
- return;
- }
- this.closedLoopControlName = event.closedLoopControlName;
- this.requestID = event.requestID;
- this.closedLoopEventClient = event.closedLoopEventClient;
- this.targetType = event.targetType;
- this.target = event.target;
- this.from = event.from;
- this.policyScope = event.policyScope;
- this.policyName = event.policyName;
- this.policyVersion = event.policyVersion;
- this.closedLoopEventStatus = event.closedLoopEventStatus;
- }
-
- public boolean isEventStatusValid() {
- return this.closedLoopEventStatus != null;
- }
-
- public String getClosedLoopControlName() {
- return closedLoopControlName;
- }
-
- public void setClosedLoopControlName(String closedLoopControlName) {
- this.closedLoopControlName = closedLoopControlName;
- }
-
- public String getVersion() {
- return version;
- }
-
- public void setVersion(String version) {
- this.version = version;
- }
-
- public UUID getRequestID() {
- return requestID;
- }
-
- public void setRequestID(UUID requestID) {
- this.requestID = requestID;
- }
-
- public String getClosedLoopEventClient() {
- return closedLoopEventClient;
- }
-
- public void setClosedLoopEventClient(String closedLoopEventClient) {
- this.closedLoopEventClient = closedLoopEventClient;
- }
-
- public ControlLoopTargetType getTargetType() {
- return targetType;
- }
-
- public void setTargetType(ControlLoopTargetType targetType) {
- this.targetType = targetType;
- }
-
- public String getTarget() {
- return target;
- }
-
- public void setTarget(String target) {
- this.target = target;
- }
-
- public String getFrom() {
- return from;
- }
-
- public void setFrom(String from) {
- this.from = from;
- }
-
- public String getPolicyScope() {
- return policyScope;
- }
-
- public void setPolicyScope(String policyScope) {
- this.policyScope = policyScope;
- }
-
- public String getPolicyName() {
- return policyName;
- }
-
- public void setPolicyName(String policyName) {
- this.policyName = policyName;
- }
-
- public String getPolicyVersion() {
- return policyVersion;
- }
-
- public void setPolicyVersion(String policyVersion) {
- this.policyVersion = policyVersion;
- }
-
- public ControlLoopEventStatus getClosedLoopEventStatus() {
- return closedLoopEventStatus;
- }
-
- public void setClosedLoopEventStatus(ControlLoopEventStatus closedLoopEventStatus) {
- this.closedLoopEventStatus = closedLoopEventStatus;
- }
+
+ private static final long serialVersionUID = 2391252138583119195L;
+
+ private String closedLoopControlName;
+ private String version = "1.0.2";
+ private UUID requestId;
+ private String closedLoopEventClient;
+ private ControlLoopTargetType targetType;
+ private String target;
+ private String from;
+ private String policyScope;
+ private String policyName;
+ private String policyVersion;
+ private ControlLoopEventStatus closedLoopEventStatus;
+
+ public ControlLoopEvent() {
+
+ }
+
+ /**
+ * Construct an instace from an existing instance.
+ *
+ * @param event the existing instance
+ */
+ public ControlLoopEvent(ControlLoopEvent event) {
+ if (event == null) {
+ return;
+ }
+ this.closedLoopControlName = event.closedLoopControlName;
+ this.requestId = event.requestId;
+ this.closedLoopEventClient = event.closedLoopEventClient;
+ this.targetType = event.targetType;
+ this.target = event.target;
+ this.from = event.from;
+ this.policyScope = event.policyScope;
+ this.policyName = event.policyName;
+ this.policyVersion = event.policyVersion;
+ this.closedLoopEventStatus = event.closedLoopEventStatus;
+ }
+
+ public boolean isEventStatusValid() {
+ return this.closedLoopEventStatus != null;
+ }
+
+ public String getClosedLoopControlName() {
+ return closedLoopControlName;
+ }
+
+ public void setClosedLoopControlName(String closedLoopControlName) {
+ this.closedLoopControlName = closedLoopControlName;
+ }
+
+ public String getVersion() {
+ return version;
+ }
+
+ public void setVersion(String version) {
+ this.version = version;
+ }
+
+ public UUID getRequestId() {
+ return requestId;
+ }
+
+ public void setRequestId(UUID requestId) {
+ this.requestId = requestId;
+ }
+
+ public String getClosedLoopEventClient() {
+ return closedLoopEventClient;
+ }
+
+ public void setClosedLoopEventClient(String closedLoopEventClient) {
+ this.closedLoopEventClient = closedLoopEventClient;
+ }
+
+ public ControlLoopTargetType getTargetType() {
+ return targetType;
+ }
+
+ public void setTargetType(ControlLoopTargetType targetType) {
+ this.targetType = targetType;
+ }
+
+ public String getTarget() {
+ return target;
+ }
+
+ public void setTarget(String target) {
+ this.target = target;
+ }
+
+ public String getFrom() {
+ return from;
+ }
+
+ public void setFrom(String from) {
+ this.from = from;
+ }
+
+ public String getPolicyScope() {
+ return policyScope;
+ }
+
+ public void setPolicyScope(String policyScope) {
+ this.policyScope = policyScope;
+ }
+
+ public String getPolicyName() {
+ return policyName;
+ }
+
+ public void setPolicyName(String policyName) {
+ this.policyName = policyName;
+ }
+
+ public String getPolicyVersion() {
+ return policyVersion;
+ }
+
+ public void setPolicyVersion(String policyVersion) {
+ this.policyVersion = policyVersion;
+ }
+
+ public ControlLoopEventStatus getClosedLoopEventStatus() {
+ return closedLoopEventStatus;
+ }
+
+ public void setClosedLoopEventStatus(ControlLoopEventStatus closedLoopEventStatus) {
+ this.closedLoopEventStatus = closedLoopEventStatus;
+ }
}
diff --git a/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopEventStatus.java b/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopEventStatus.java
index ed726201a..f439e70ab 100644
--- a/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopEventStatus.java
+++ b/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopEventStatus.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* controlloop
* ================================================================================
- * 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.
@@ -21,35 +21,39 @@
package org.onap.policy.controlloop;
public enum ControlLoopEventStatus {
- ONSET("ONSET"),
- ABATED("ABATED")
- ;
-
- private String status;
-
- private ControlLoopEventStatus(String status) {
- this.status = status;
- }
+ ONSET("ONSET"), ABATED("ABATED");
- @Override
- public String toString() {
- return this.status;
- }
-
- public static ControlLoopEventStatus toStatus(String status) {
- if (ONSET.status.equalsIgnoreCase(status)) {
- return ONSET;
- }
- if (ABATED.status.equalsIgnoreCase(status)) {
- return ABATED;
- }
- //
- // In case DCAE uses the old abatement
- //
- if ("abatement".equalsIgnoreCase(status)) {
- return ABATED;
- }
- return null;
- }
+ private String status;
+
+ private ControlLoopEventStatus(String status) {
+ this.status = status;
+ }
+
+ @Override
+ public String toString() {
+ return this.status;
+ }
+
+ /**
+ * Convert a String status to a ControlLoopEventStatus.
+ *
+ * @param status the String status
+ * @return the ControlLoopEventStatus
+ */
+ public static ControlLoopEventStatus toStatus(String status) {
+ if (ONSET.status.equalsIgnoreCase(status)) {
+ return ONSET;
+ }
+ if (ABATED.status.equalsIgnoreCase(status)) {
+ return ABATED;
+ }
+ //
+ // In case DCAE uses the old abatement
+ //
+ if ("abatement".equalsIgnoreCase(status)) {
+ return ABATED;
+ }
+ return null;
+ }
}
diff --git a/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopNotification.java b/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopNotification.java
index 8e7a50fac..8c670fe9e 100644
--- a/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopNotification.java
+++ b/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopNotification.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* controlloop
* ================================================================================
- * 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.
@@ -29,157 +29,162 @@ import java.util.UUID;
public abstract class ControlLoopNotification implements Serializable {
- private static final long serialVersionUID = 7538596984567127915L;
-
- private String closedLoopControlName;
- private String version = "1.0.2";
- private UUID requestID;
- private String closedLoopEventClient;
- private ControlLoopTargetType targetType;
- private String target;
- private String from;
- private String policyScope;
- private String policyName;
- private String policyVersion;
- private ControlLoopNotificationType notification;
- private String message;
- private ZonedDateTime notificationTime = ZonedDateTime.now(ZoneOffset.UTC);
- private Integer opsCLTimer;
- private List<ControlLoopOperation> history = new LinkedList<>();
-
- public ControlLoopNotification() {
-
- }
-
- public ControlLoopNotification(ControlLoopEvent event) {
- if (event == null) {
- return;
- }
-
- this.setClosedLoopControlName(event.getClosedLoopControlName());
- this.setRequestID(event.getRequestID());
- this.setClosedLoopEventClient(event.getClosedLoopEventClient());
- this.setTargetType(event.getTargetType());
- this.setTarget(event.getTarget());
- }
-
- public String getClosedLoopControlName() {
- return closedLoopControlName;
- }
-
- public void setClosedLoopControlName(String closedLoopControlName) {
- this.closedLoopControlName = closedLoopControlName;
- }
-
- public String getVersion() {
- return version;
- }
-
- public void setVersion(String version) {
- this.version = version;
- }
-
- public UUID getRequestID() {
- return requestID;
- }
-
- public void setRequestID(UUID requestID) {
- this.requestID = requestID;
- }
-
- public String getClosedLoopEventClient() {
- return closedLoopEventClient;
- }
-
- public void setClosedLoopEventClient(String closedLoopEventClient) {
- this.closedLoopEventClient = closedLoopEventClient;
- }
-
- public ControlLoopTargetType getTargetType() {
- return targetType;
- }
-
- public void setTargetType(ControlLoopTargetType targetType) {
- this.targetType = targetType;
- }
-
- public String getTarget() {
- return target;
- }
-
- public void setTarget(String target) {
- this.target = target;
- }
-
- public String getFrom() {
- return from;
- }
-
- public void setFrom(String from) {
- this.from = from;
- }
-
- public String getPolicyScope() {
- return policyScope;
- }
-
- public void setPolicyScope(String policyScope) {
- this.policyScope = policyScope;
- }
-
- public String getPolicyName() {
- return policyName;
- }
-
- public void setPolicyName(String policyName) {
- this.policyName = policyName;
- }
-
- public String getPolicyVersion() {
- return policyVersion;
- }
-
- public void setPolicyVersion(String policyVersion) {
- this.policyVersion = policyVersion;
- }
-
- public ControlLoopNotificationType getNotification() {
- return notification;
- }
-
- public void setNotification(ControlLoopNotificationType notification) {
- this.notification = notification;
- }
-
- public String getMessage() {
- return message;
- }
-
- public void setMessage(String message) {
- this.message = message;
- }
-
- public ZonedDateTime getNotificationTime() {
- return notificationTime;
- }
+ private static final long serialVersionUID = 7538596984567127915L;
+
+ private String closedLoopControlName;
+ private String version = "1.0.2";
+ private UUID requestId;
+ private String closedLoopEventClient;
+ private ControlLoopTargetType targetType;
+ private String target;
+ private String from;
+ private String policyScope;
+ private String policyName;
+ private String policyVersion;
+ private ControlLoopNotificationType notification;
+ private String message;
+ private ZonedDateTime notificationTime = ZonedDateTime.now(ZoneOffset.UTC);
+ private Integer opsClTimer;
+ private List<ControlLoopOperation> history = new LinkedList<>();
+
+ public ControlLoopNotification() {
+
+ }
+
+ /**
+ * Construct an instance.
+ *
+ * @param event the event
+ */
+ public ControlLoopNotification(ControlLoopEvent event) {
+ if (event == null) {
+ return;
+ }
+
+ this.setClosedLoopControlName(event.getClosedLoopControlName());
+ this.setRequestId(event.getRequestId());
+ this.setClosedLoopEventClient(event.getClosedLoopEventClient());
+ this.setTargetType(event.getTargetType());
+ this.setTarget(event.getTarget());
+ }
+
+ public String getClosedLoopControlName() {
+ return closedLoopControlName;
+ }
+
+ public void setClosedLoopControlName(String closedLoopControlName) {
+ this.closedLoopControlName = closedLoopControlName;
+ }
+
+ public String getVersion() {
+ return version;
+ }
+
+ public void setVersion(String version) {
+ this.version = version;
+ }
+
+ public UUID getRequestId() {
+ return requestId;
+ }
+
+ public void setRequestId(UUID requestId) {
+ this.requestId = requestId;
+ }
+
+ public String getClosedLoopEventClient() {
+ return closedLoopEventClient;
+ }
+
+ public void setClosedLoopEventClient(String closedLoopEventClient) {
+ this.closedLoopEventClient = closedLoopEventClient;
+ }
+
+ public ControlLoopTargetType getTargetType() {
+ return targetType;
+ }
+
+ public void setTargetType(ControlLoopTargetType targetType) {
+ this.targetType = targetType;
+ }
+
+ public String getTarget() {
+ return target;
+ }
+
+ public void setTarget(String target) {
+ this.target = target;
+ }
+
+ public String getFrom() {
+ return from;
+ }
+
+ public void setFrom(String from) {
+ this.from = from;
+ }
+
+ public String getPolicyScope() {
+ return policyScope;
+ }
+
+ public void setPolicyScope(String policyScope) {
+ this.policyScope = policyScope;
+ }
+
+ public String getPolicyName() {
+ return policyName;
+ }
+
+ public void setPolicyName(String policyName) {
+ this.policyName = policyName;
+ }
+
+ public String getPolicyVersion() {
+ return policyVersion;
+ }
+
+ public void setPolicyVersion(String policyVersion) {
+ this.policyVersion = policyVersion;
+ }
+
+ public ControlLoopNotificationType getNotification() {
+ return notification;
+ }
+
+ public void setNotification(ControlLoopNotificationType notification) {
+ this.notification = notification;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ public ZonedDateTime getNotificationTime() {
+ return notificationTime;
+ }
- public void setNotificationTime(ZonedDateTime notificationTime) {
- this.notificationTime = notificationTime;
- }
+ public void setNotificationTime(ZonedDateTime notificationTime) {
+ this.notificationTime = notificationTime;
+ }
- public Integer getOpsCLTimer() {
- return opsCLTimer;
- }
+ public Integer getOpsClTimer() {
+ return opsClTimer;
+ }
- public void setOpsCLTimer(Integer opsCLTimer) {
- this.opsCLTimer = opsCLTimer;
- }
+ public void setOpsClTimer(Integer opsClTimer) {
+ this.opsClTimer = opsClTimer;
+ }
- public List<ControlLoopOperation> getHistory() {
- return history;
- }
+ public List<ControlLoopOperation> getHistory() {
+ return history;
+ }
- public void setHistory(List<ControlLoopOperation> history) {
- this.history = history;
- }
+ public void setHistory(List<ControlLoopOperation> history) {
+ this.history = history;
+ }
}
diff --git a/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopNotificationType.java b/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopNotificationType.java
index 29f53c8fa..9f5a41d39 100644
--- a/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopNotificationType.java
+++ b/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopNotificationType.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* controlloop
* ================================================================================
- * 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.
@@ -21,53 +21,53 @@
package org.onap.policy.controlloop;
public enum ControlLoopNotificationType {
- ACTIVE("ACTIVE"),
- REJECTED("REJECTED"),
- OPERATION("OPERATION"),
- OPERATION_SUCCESS("OPERATION: SUCCESS"),
- OPERATION_FAILURE("OPERATION: FAILURE"),
- FINAL_FAILURE("FINAL: FAILURE"),
- FINAL_SUCCESS("FINAL: SUCCESS"),
- FINAL_OPENLOOP("FINAL: OPENLOOP")
- ;
-
- private String type;
-
- private ControlLoopNotificationType(String type) {
- this.type = type;
- }
-
- @Override
- public String toString() {
- return this.type;
- }
+ ACTIVE("ACTIVE"), REJECTED("REJECTED"), OPERATION("OPERATION"), OPERATION_SUCCESS(
+ "OPERATION: SUCCESS"), OPERATION_FAILURE("OPERATION: FAILURE"), FINAL_FAILURE(
+ "FINAL: FAILURE"), FINAL_SUCCESS("FINAL: SUCCESS"), FINAL_OPENLOOP("FINAL: OPENLOOP");
- public static ControlLoopNotificationType toType(String type) {
- if (ACTIVE.toString().equals(type)) {
- return ACTIVE;
- }
- if (REJECTED.toString().equals(type)) {
- return REJECTED;
- }
- if (OPERATION.toString().equals(type)) {
- return OPERATION;
- }
- if (OPERATION_SUCCESS.toString().equals(type)) {
- return OPERATION_SUCCESS;
- }
- if (OPERATION_FAILURE.toString().equals(type)) {
- return OPERATION_FAILURE;
- }
- if (FINAL_FAILURE.toString().equals(type)) {
- return FINAL_FAILURE;
- }
- if (FINAL_SUCCESS.toString().equals(type)) {
- return FINAL_SUCCESS;
- }
- if (FINAL_OPENLOOP.toString().equals(type)) {
- return FINAL_OPENLOOP;
- }
- return null;
- }
+ private String type;
+
+ private ControlLoopNotificationType(String type) {
+ this.type = type;
+ }
+
+ @Override
+ public String toString() {
+ return this.type;
+ }
+
+ /**
+ * Convert a String type to a ControlLoopNotificationType.
+ *
+ * @param type the String type
+ * @return the ControlLoopNotificationType
+ */
+ public static ControlLoopNotificationType toType(String type) {
+ if (ACTIVE.toString().equals(type)) {
+ return ACTIVE;
+ }
+ if (REJECTED.toString().equals(type)) {
+ return REJECTED;
+ }
+ if (OPERATION.toString().equals(type)) {
+ return OPERATION;
+ }
+ if (OPERATION_SUCCESS.toString().equals(type)) {
+ return OPERATION_SUCCESS;
+ }
+ if (OPERATION_FAILURE.toString().equals(type)) {
+ return OPERATION_FAILURE;
+ }
+ if (FINAL_FAILURE.toString().equals(type)) {
+ return FINAL_FAILURE;
+ }
+ if (FINAL_SUCCESS.toString().equals(type)) {
+ return FINAL_SUCCESS;
+ }
+ if (FINAL_OPENLOOP.toString().equals(type)) {
+ return FINAL_OPENLOOP;
+ }
+ return null;
+ }
}
diff --git a/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopOperation.java b/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopOperation.java
index d024b7cec..3ef731687 100644
--- a/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopOperation.java
+++ b/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopOperation.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* controlloop
* ================================================================================
- * 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.
@@ -25,183 +25,205 @@ import java.time.Instant;
public class ControlLoopOperation implements Serializable {
- /**
- *
- */
- private static final long serialVersionUID = 8662706581293017099L;
-
- private String actor;
- private String operation;
- private String target;
- private Instant start = Instant.now();
- private Instant end;
- private String subRequestId;
- private String outcome;
- private String message;
-
- public ControlLoopOperation() {
-
- }
-
- public ControlLoopOperation(ControlLoopOperation op) {
- if (op == null) {
- return;
- }
-
- this.actor = op.actor;
- this.operation = op.operation;
- this.target = op.target;
- this.start = op.start;
- this.end = op.end;
- this.subRequestId = op.subRequestId;
- this.outcome = op.outcome;
- this.message = op.message;
- }
-
- public String toMessage() {
- return "actor="+actor+",operation="+operation+",target="+target+",subRequestId="+subRequestId;
- }
-
- public String toHistory() {
- return "actor="+actor+",operation="+operation+",target="+target+",start="+start+",end="+end+",subRequestId="+subRequestId+",outcome="+outcome+",message="+message;
- }
-
- public String getActor() {
- return actor;
- }
-
- public void setActor(String actor) {
- this.actor = actor;
- }
-
- public String getOperation() {
- return operation;
- }
-
- public void setOperation(String operation) {
- this.operation = operation;
- }
-
- public String getTarget() {
- return target;
- }
-
- public void setTarget(String target) {
- this.target = target;
- }
-
- public Instant getStart() {
- return start;
- }
-
- public void setStart(Instant start) {
- this.start = start;
- }
-
- public Instant getEnd() {
- return end;
- }
-
- public void setEnd(Instant end) {
- this.end = end;
- }
-
- public String getSubRequestId() {
- return subRequestId;
- }
-
- public void setSubRequestId(String subRequestId) {
- this.subRequestId = subRequestId;
- }
-
- public String getOutcome() {
- return outcome;
- }
-
- public void setOutcome(String outcome) {
- this.outcome = outcome;
- }
-
- public String getMessage() {
- return message;
- }
-
- public void setMessage(String message) {
- this.message = message;
- }
-
- @Override
- public String toString() {
- return "ControlLoopOperation [actor=" + actor + ", operation=" + operation + ", target=" + target + ", start="
- + start + ", end=" + end + ", subRequestId=" + subRequestId + ", outcome=" + outcome + ", message="
- + message + "]";
- }
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((actor == null) ? 0 : actor.hashCode());
- result = prime * result + ((end == null) ? 0 : end.hashCode());
- result = prime * result + ((message == null) ? 0 : message.hashCode());
- result = prime * result + ((operation == null) ? 0 : operation.hashCode());
- result = prime * result + ((outcome == null) ? 0 : outcome.hashCode());
- result = prime * result + ((start == null) ? 0 : start.hashCode());
- result = prime * result + ((subRequestId == null) ? 0 : subRequestId.hashCode());
- result = prime * result + ((target == null) ? 0 : target.hashCode());
- return result;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (getClass() != obj.getClass())
- return false;
- ControlLoopOperation other = (ControlLoopOperation) obj;
- if (actor == null) {
- if (other.actor != null)
- return false;
- } else if (!actor.equals(other.actor))
- return false;
- if (end == null) {
- if (other.end != null)
- return false;
- } else if (!end.equals(other.end))
- return false;
- if (message == null) {
- if (other.message != null)
- return false;
- } else if (!message.equals(other.message))
- return false;
- if (operation == null) {
- if (other.operation != null)
- return false;
- } else if (!operation.equals(other.operation))
- return false;
- if (outcome == null) {
- if (other.outcome != null)
- return false;
- } else if (!outcome.equals(other.outcome))
- return false;
- if (start == null) {
- if (other.start != null)
- return false;
- } else if (!start.equals(other.start))
- return false;
- if (subRequestId == null) {
- if (other.subRequestId != null)
- return false;
- } else if (!subRequestId.equals(other.subRequestId))
- return false;
- if (target == null) {
- if (other.target != null)
- return false;
- } else if (!target.equals(other.target))
- return false;
- return true;
- }
+ private static final long serialVersionUID = 8662706581293017099L;
+
+ private String actor;
+ private String operation;
+ private String target;
+ private Instant start = Instant.now();
+ private Instant end;
+ private String subRequestId;
+ private String outcome;
+ private String message;
+
+ public ControlLoopOperation() {
+
+ }
+
+ /**
+ * Construct an instance from an existing instance.
+ *
+ * @param op the existing instance
+ */
+ public ControlLoopOperation(ControlLoopOperation op) {
+ if (op == null) {
+ return;
+ }
+
+ this.actor = op.actor;
+ this.operation = op.operation;
+ this.target = op.target;
+ this.start = op.start;
+ this.end = op.end;
+ this.subRequestId = op.subRequestId;
+ this.outcome = op.outcome;
+ this.message = op.message;
+ }
+
+ public String toMessage() {
+ return "actor=" + actor + ",operation=" + operation + ",target=" + target + ",subRequestId=" + subRequestId;
+ }
+
+ public String toHistory() {
+ return "actor=" + actor + ",operation=" + operation + ",target=" + target + ",start=" + start + ",end=" + end
+ + ",subRequestId=" + subRequestId + ",outcome=" + outcome + ",message=" + message;
+ }
+
+ public String getActor() {
+ return actor;
+ }
+
+ public void setActor(String actor) {
+ this.actor = actor;
+ }
+
+ public String getOperation() {
+ return operation;
+ }
+
+ public void setOperation(String operation) {
+ this.operation = operation;
+ }
+
+ public String getTarget() {
+ return target;
+ }
+
+ public void setTarget(String target) {
+ this.target = target;
+ }
+
+ public Instant getStart() {
+ return start;
+ }
+
+ public void setStart(Instant start) {
+ this.start = start;
+ }
+
+ public Instant getEnd() {
+ return end;
+ }
+
+ public void setEnd(Instant end) {
+ this.end = end;
+ }
+
+ public String getSubRequestId() {
+ return subRequestId;
+ }
+
+ public void setSubRequestId(String subRequestId) {
+ this.subRequestId = subRequestId;
+ }
+
+ public String getOutcome() {
+ return outcome;
+ }
+
+ public void setOutcome(String outcome) {
+ this.outcome = outcome;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ @Override
+ public String toString() {
+ return "ControlLoopOperation [actor=" + actor + ", operation=" + operation + ", target=" + target + ", start="
+ + start + ", end=" + end + ", subRequestId=" + subRequestId + ", outcome=" + outcome + ", message="
+ + message + "]";
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((actor == null) ? 0 : actor.hashCode());
+ result = prime * result + ((end == null) ? 0 : end.hashCode());
+ result = prime * result + ((message == null) ? 0 : message.hashCode());
+ result = prime * result + ((operation == null) ? 0 : operation.hashCode());
+ result = prime * result + ((outcome == null) ? 0 : outcome.hashCode());
+ result = prime * result + ((start == null) ? 0 : start.hashCode());
+ result = prime * result + ((subRequestId == null) ? 0 : subRequestId.hashCode());
+ result = prime * result + ((target == null) ? 0 : target.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ ControlLoopOperation other = (ControlLoopOperation) obj;
+ if (actor == null) {
+ if (other.actor != null) {
+ return false;
+ }
+ } else if (!actor.equals(other.actor)) {
+ return false;
+ }
+ if (end == null) {
+ if (other.end != null) {
+ return false;
+ }
+ } else if (!end.equals(other.end)) {
+ return false;
+ }
+ if (message == null) {
+ if (other.message != null) {
+ return false;
+ }
+ } else if (!message.equals(other.message)) {
+ return false;
+ }
+ if (operation == null) {
+ if (other.operation != null) {
+ return false;
+ }
+ } else if (!operation.equals(other.operation)) {
+ return false;
+ }
+ if (outcome == null) {
+ if (other.outcome != null) {
+ return false;
+ }
+ } else if (!outcome.equals(other.outcome)) {
+ return false;
+ }
+ if (start == null) {
+ if (other.start != null) {
+ return false;
+ }
+ } else if (!start.equals(other.start)) {
+ return false;
+ }
+ if (subRequestId == null) {
+ if (other.subRequestId != null) {
+ return false;
+ }
+ } else if (!subRequestId.equals(other.subRequestId)) {
+ return false;
+ }
+ if (target == null) {
+ if (other.target != null) {
+ return false;
+ }
+ } else if (!target.equals(other.target)) {
+ return false;
+ }
+ return true;
+ }
}
diff --git a/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopOperationWrapper.java b/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopOperationWrapper.java
index f957808d1..0bdc5cace 100644
--- a/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopOperationWrapper.java
+++ b/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopOperationWrapper.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* controlloop
* ================================================================================
- * 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.
@@ -24,31 +24,31 @@ import java.util.UUID;
public class ControlLoopOperationWrapper {
- private UUID requestID;
- private ControlLoopOperation operation;
-
- public ControlLoopOperationWrapper() {
-
- }
-
- public ControlLoopOperationWrapper(UUID requestID, ControlLoopOperation operation) {
- this.requestID = requestID;
- this.operation = operation;
- }
-
- public UUID getRequestID() {
- return requestID;
- }
-
- public void setRequestID(UUID requestID) {
- this.requestID = requestID;
- }
-
- public ControlLoopOperation getOperation() {
- return operation;
- }
-
- public void setOperation(ControlLoopOperation operation) {
- this.operation = operation;
- }
+ private UUID requestId;
+ private ControlLoopOperation operation;
+
+ public ControlLoopOperationWrapper() {
+
+ }
+
+ public ControlLoopOperationWrapper(UUID requestId, ControlLoopOperation operation) {
+ this.requestId = requestId;
+ this.operation = operation;
+ }
+
+ public UUID getRequestId() {
+ return requestId;
+ }
+
+ public void setRequestId(UUID requestId) {
+ this.requestId = requestId;
+ }
+
+ public ControlLoopOperation getOperation() {
+ return operation;
+ }
+
+ public void setOperation(ControlLoopOperation operation) {
+ this.operation = operation;
+ }
}
diff --git a/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopTargetType.java b/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopTargetType.java
index 747dc7607..4782654fc 100644
--- a/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopTargetType.java
+++ b/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopTargetType.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* controlloop
* ================================================================================
- * 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.
@@ -21,37 +21,39 @@
package org.onap.policy.controlloop;
public enum ControlLoopTargetType {
- VM("VM"),
- VF("VF"),
- VFC("VFC"),
- VNF("VNF")
- ;
-
- private String type;
-
- private ControlLoopTargetType(String type) {
- this.type = type;
- }
-
- @Override
- public String toString() {
- return this.type;
- }
-
- public static ControlLoopTargetType toType(String type) {
- if (VM.toString().equals(type)) {
- return VM;
- }
- if (VF.toString().equals(type)) {
- return VF;
- }
- if (VFC.toString().equals(type)) {
- return VFC;
- }
- if (VNF.toString().equals(type)) {
- return VNF;
- }
+ VM("VM"), VF("VF"), VFC("VFC"), VNF("VNF");
- return null;
- }
+ private String type;
+
+ private ControlLoopTargetType(String type) {
+ this.type = type;
+ }
+
+ @Override
+ public String toString() {
+ return this.type;
+ }
+
+ /**
+ * Convert a String type to a ControlLoopTargetType.
+ *
+ * @param type the String type
+ * @return the ControlLoopTargetType
+ */
+ public static ControlLoopTargetType toType(String type) {
+ if (VM.toString().equals(type)) {
+ return VM;
+ }
+ if (VF.toString().equals(type)) {
+ return VF;
+ }
+ if (VFC.toString().equals(type)) {
+ return VFC;
+ }
+ if (VNF.toString().equals(type)) {
+ return VNF;
+ }
+
+ return null;
+ }
}
diff --git a/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/PhysicalControlLoopEvent.java b/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/PhysicalControlLoopEvent.java
index 12ced939e..4cae5ca5d 100644
--- a/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/PhysicalControlLoopEvent.java
+++ b/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/PhysicalControlLoopEvent.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* controlloop
* ================================================================================
- * 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.
@@ -21,15 +21,19 @@
package org.onap.policy.controlloop;
public class PhysicalControlLoopEvent extends ControlLoopEvent {
- private static final long serialVersionUID = -7282930271094849487L;
+ private static final long serialVersionUID = -7282930271094849487L;
- public PhysicalControlLoopEvent() {
- }
+ public PhysicalControlLoopEvent() {}
- public PhysicalControlLoopEvent(PhysicalControlLoopEvent event) {
- super(event);
- if (event == null) {
- return;
- }
- }
+ /**
+ * Construct an instance from an existing instance.
+ *
+ * @param event the existing instance
+ */
+ public PhysicalControlLoopEvent(PhysicalControlLoopEvent event) {
+ super(event);
+ if (event == null) {
+ return;
+ }
+ }
}
diff --git a/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/PhysicalControlLoopNotification.java b/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/PhysicalControlLoopNotification.java
index 9c63665ae..5dbc7f498 100644
--- a/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/PhysicalControlLoopNotification.java
+++ b/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/PhysicalControlLoopNotification.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* controlloop
* ================================================================================
- * 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.
@@ -21,16 +21,20 @@
package org.onap.policy.controlloop;
public class PhysicalControlLoopNotification extends ControlLoopNotification {
- private static final long serialVersionUID = 8105197217140032892L;
-
- public PhysicalControlLoopNotification() {
- }
+ private static final long serialVersionUID = 8105197217140032892L;
- public PhysicalControlLoopNotification(PhysicalControlLoopEvent event) {
- super(event);
- if (event == null) {
- return;
- }
- }
+ public PhysicalControlLoopNotification() {}
+
+ /**
+ * Construct an instance from an existing instance.
+ *
+ * @param event the existing instance
+ */
+ public PhysicalControlLoopNotification(PhysicalControlLoopEvent event) {
+ super(event);
+ if (event == null) {
+ return;
+ }
+ }
}
diff --git a/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/VirtualControlLoopEvent.java b/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/VirtualControlLoopEvent.java
index b5ce27112..ec4fc47dd 100644
--- a/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/VirtualControlLoopEvent.java
+++ b/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/VirtualControlLoopEvent.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* controlloop
* ================================================================================
- * 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.
@@ -20,59 +20,61 @@
package org.onap.policy.controlloop;
+import com.google.gson.annotations.SerializedName;
+
import java.time.Instant;
import java.util.HashMap;
import java.util.Map;
-import com.google.gson.annotations.SerializedName;
-
public class VirtualControlLoopEvent extends ControlLoopEvent {
- /**
- *
- */
- private static final long serialVersionUID = -5752405682246066226L;
- private Instant closedLoopAlarmStart;
- private Instant closedLoopAlarmEnd;
- @SerializedName("AAI")
- private Map<String, String> aai = new HashMap<>();
+ private static final long serialVersionUID = -5752405682246066226L;
+ private Instant closedLoopAlarmStart;
+ private Instant closedLoopAlarmEnd;
+ @SerializedName("AAI")
+ private Map<String, String> aai = new HashMap<>();
+
+ public VirtualControlLoopEvent() {}
- public VirtualControlLoopEvent() {
- }
- public VirtualControlLoopEvent(VirtualControlLoopEvent event) {
- super(event);
- if (event == null) {
- return;
- }
- if (event.aai != null) {
- this.aai = new HashMap<>(event.aai);
- }
- this.closedLoopAlarmStart = event.closedLoopAlarmStart;
- this.closedLoopAlarmEnd = event.closedLoopAlarmEnd;
- }
+ /**
+ * Construct an instance from an existing instance.
+ *
+ * @param event the existing instance
+ */
+ public VirtualControlLoopEvent(VirtualControlLoopEvent event) {
+ super(event);
+ if (event == null) {
+ return;
+ }
+ if (event.aai != null) {
+ this.aai = new HashMap<>(event.aai);
+ }
+ this.closedLoopAlarmStart = event.closedLoopAlarmStart;
+ this.closedLoopAlarmEnd = event.closedLoopAlarmEnd;
+ }
- public Instant getClosedLoopAlarmStart() {
- return closedLoopAlarmStart;
- }
+ public Instant getClosedLoopAlarmStart() {
+ return closedLoopAlarmStart;
+ }
- public void setClosedLoopAlarmStart(Instant closedLoopAlarmStart) {
- this.closedLoopAlarmStart = closedLoopAlarmStart;
- }
+ public void setClosedLoopAlarmStart(Instant closedLoopAlarmStart) {
+ this.closedLoopAlarmStart = closedLoopAlarmStart;
+ }
- public Instant getClosedLoopAlarmEnd() {
- return closedLoopAlarmEnd;
- }
+ public Instant getClosedLoopAlarmEnd() {
+ return closedLoopAlarmEnd;
+ }
- public void setClosedLoopAlarmEnd(Instant closedLoopAlarmEnd) {
- this.closedLoopAlarmEnd = closedLoopAlarmEnd;
- }
+ public void setClosedLoopAlarmEnd(Instant closedLoopAlarmEnd) {
+ this.closedLoopAlarmEnd = closedLoopAlarmEnd;
+ }
- public Map<String, String> getAAI() {
- return aai;
- }
+ public Map<String, String> getAai() {
+ return aai;
+ }
- public void setAAI(Map<String, String> aai) {
- this.aai = aai;
- }
+ public void setAai(Map<String, String> aai) {
+ this.aai = aai;
+ }
}
diff --git a/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/VirtualControlLoopNotification.java b/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/VirtualControlLoopNotification.java
index 72d88df92..acb81f8ba 100644
--- a/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/VirtualControlLoopNotification.java
+++ b/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/VirtualControlLoopNotification.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* controlloop
* ================================================================================
- * 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.
@@ -20,60 +20,61 @@
package org.onap.policy.controlloop;
+import com.google.gson.annotations.SerializedName;
+
import java.time.Instant;
import java.util.HashMap;
import java.util.Map;
-import com.google.gson.annotations.SerializedName;
-
public class VirtualControlLoopNotification extends ControlLoopNotification {
- /**
- *
- */
- private static final long serialVersionUID = 5354756047932144017L;
+ private static final long serialVersionUID = 5354756047932144017L;
- @SerializedName("AAI")
- private Map<String, String> aai = new HashMap<>();
- private Instant closedLoopAlarmStart;
- private Instant closedLoopAlarmEnd;
+ @SerializedName("AAI")
+ private Map<String, String> aai = new HashMap<>();
+ private Instant closedLoopAlarmStart;
+ private Instant closedLoopAlarmEnd;
- public VirtualControlLoopNotification() {
- }
+ public VirtualControlLoopNotification() {}
- public VirtualControlLoopNotification(VirtualControlLoopEvent event) {
- super(event);
- if (event == null) {
- return;
- }
- if (event.getAAI() != null) {
- this.setAAI(new HashMap<>(event.getAAI()));
- }
- this.closedLoopAlarmStart = event.getClosedLoopAlarmStart();
- this.closedLoopAlarmEnd = event.getClosedLoopAlarmEnd();
- }
+ /**
+ * Construct an instance.
+ *
+ * @param event the event
+ */
+ public VirtualControlLoopNotification(VirtualControlLoopEvent event) {
+ super(event);
+ if (event == null) {
+ return;
+ }
+ if (event.getAai() != null) {
+ this.setAai(new HashMap<>(event.getAai()));
+ }
+ this.closedLoopAlarmStart = event.getClosedLoopAlarmStart();
+ this.closedLoopAlarmEnd = event.getClosedLoopAlarmEnd();
+ }
- public Map<String, String> getAAI() {
- return aai;
- }
+ public Map<String, String> getAai() {
+ return aai;
+ }
- public void setAAI(Map<String, String> aAI) {
- this.aai = aAI;
- }
+ public void setAai(Map<String, String> aai) {
+ this.aai = aai;
+ }
- public Instant getClosedLoopAlarmStart() {
- return closedLoopAlarmStart;
- }
+ public Instant getClosedLoopAlarmStart() {
+ return closedLoopAlarmStart;
+ }
- public void setClosedLoopAlarmStart(Instant closedLoopAlarmStart) {
- this.closedLoopAlarmStart = closedLoopAlarmStart;
- }
+ public void setClosedLoopAlarmStart(Instant closedLoopAlarmStart) {
+ this.closedLoopAlarmStart = closedLoopAlarmStart;
+ }
- public Instant getClosedLoopAlarmEnd() {
- return closedLoopAlarmEnd;
- }
+ public Instant getClosedLoopAlarmEnd() {
+ return closedLoopAlarmEnd;
+ }
- public void setClosedLoopAlarmEnd(Instant closedLoopAlarmEnd) {
- this.closedLoopAlarmEnd = closedLoopAlarmEnd;
- }
+ public void setClosedLoopAlarmEnd(Instant closedLoopAlarmEnd) {
+ this.closedLoopAlarmEnd = closedLoopAlarmEnd;
+ }
}
diff --git a/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/params/ControlLoopParams.java b/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/params/ControlLoopParams.java
index d62dc0276..ab93f5e9b 100644
--- a/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/params/ControlLoopParams.java
+++ b/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/params/ControlLoopParams.java
@@ -25,7 +25,7 @@ import java.io.Serializable;
public class ControlLoopParams implements Serializable {
private static final long serialVersionUID = 970755684770982776L;
-
+
private String closedLoopControlName;
private String controlLoopYaml;
private String policyName;
@@ -36,6 +36,11 @@ public class ControlLoopParams implements Serializable {
super();
}
+ /**
+ * Construct an instance from an existing instance.
+ *
+ * @param params the existing instance
+ */
public ControlLoopParams(ControlLoopParams params) {
this.closedLoopControlName = params.closedLoopControlName;
this.controlLoopYaml = params.controlLoopYaml;
diff --git a/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/util/Serialization.java b/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/util/Serialization.java
index d2a51f770..864b31726 100644
--- a/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/util/Serialization.java
+++ b/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/util/Serialization.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* controlloop
* ================================================================================
- * 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.
@@ -20,6 +20,15 @@
package org.onap.policy.controlloop.util;
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
+import com.google.gson.JsonDeserializationContext;
+import com.google.gson.JsonDeserializer;
+import com.google.gson.JsonElement;
+import com.google.gson.JsonPrimitive;
+import com.google.gson.JsonSerializationContext;
+import com.google.gson.JsonSerializer;
+
import java.lang.reflect.Type;
import java.time.Instant;
import java.time.ZonedDateTime;
@@ -30,102 +39,87 @@ import org.onap.policy.controlloop.ControlLoopTargetType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import com.google.gson.Gson;
-import com.google.gson.GsonBuilder;
-import com.google.gson.JsonDeserializationContext;
-import com.google.gson.JsonDeserializer;
-import com.google.gson.JsonElement;
-import com.google.gson.JsonPrimitive;
-import com.google.gson.JsonSerializationContext;
-import com.google.gson.JsonSerializer;
-
public final class Serialization {
- private Serialization() {
- }
-
- public static class NotificationTypeAdapter implements JsonSerializer<ControlLoopNotificationType>, JsonDeserializer<ControlLoopNotificationType> {
- @Override
- public JsonElement serialize(ControlLoopNotificationType src, Type typeOfSrc,
- JsonSerializationContext context) {
- return new JsonPrimitive(src.toString());
- }
-
- @Override
- public ControlLoopNotificationType deserialize(JsonElement json, Type typeOfT,
- JsonDeserializationContext context) {
- return ControlLoopNotificationType.toType(json.getAsString());
- }
- }
-
- public static class TargetTypeAdapter implements JsonSerializer<ControlLoopTargetType>, JsonDeserializer<ControlLoopTargetType> {
- @Override
- public JsonElement serialize(ControlLoopTargetType src, Type typeOfSrc,
- JsonSerializationContext context) {
- return new JsonPrimitive(src.toString());
- }
-
- @Override
- public ControlLoopTargetType deserialize(JsonElement json, Type typeOfT,
- JsonDeserializationContext context) {
- return ControlLoopTargetType.toType(json.getAsString());
- }
- }
-
- public static class GSONUTCAdapter implements JsonSerializer<ZonedDateTime>, JsonDeserializer<ZonedDateTime> {
- private static final Logger logger = LoggerFactory.getLogger(GSONUTCAdapter.class);
- public static final DateTimeFormatter format = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSSSSSxxx");
-
- @Override
- public ZonedDateTime deserialize(JsonElement element, Type type, JsonDeserializationContext context) {
- try {
- return ZonedDateTime.parse(element.getAsString(), format);
- } catch (Exception e) {
- logger.error(e.getMessage(), e);
- }
- return null;
- }
-
- @Override
- public JsonElement serialize(ZonedDateTime datetime, Type type, JsonSerializationContext context) {
- return new JsonPrimitive(datetime.format(format));
- }
- }
-
- public static class GSONInstantAdapter implements JsonSerializer<Instant>, JsonDeserializer<Instant> {
-
- @Override
- public Instant deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) {
- return Instant.ofEpochMilli(json.getAsLong());
- }
-
- @Override
- public JsonElement serialize(Instant src, Type typeOfSrc, JsonSerializationContext context) {
- return new JsonPrimitive(src.toEpochMilli());
- }
-
- }
-
- public static final Gson gson = new GsonBuilder().disableHtmlEscaping()
- .registerTypeAdapter(ZonedDateTime.class, new GSONUTCAdapter())
- .registerTypeAdapter(Instant.class, new GSONInstantAdapter())
- .registerTypeAdapter(ControlLoopNotificationType.class, new NotificationTypeAdapter())
- .registerTypeAdapter(ControlLoopTargetType.class, new TargetTypeAdapter())
- .create();
-
-
- public static final Gson gsonPretty = new GsonBuilder().disableHtmlEscaping()
- .setPrettyPrinting()
- .registerTypeAdapter(ZonedDateTime.class, new GSONUTCAdapter())
- .registerTypeAdapter(Instant.class, new GSONInstantAdapter())
- .registerTypeAdapter(ControlLoopNotificationType.class, new NotificationTypeAdapter())
- .registerTypeAdapter(ControlLoopTargetType.class, new TargetTypeAdapter())
- .create();
-
- public static final Gson gsonJunit = new GsonBuilder().disableHtmlEscaping()
- .setPrettyPrinting()
- .registerTypeAdapter(ZonedDateTime.class, new GSONUTCAdapter())
- .registerTypeAdapter(Instant.class, new GSONInstantAdapter())
- .registerTypeAdapter(ControlLoopTargetType.class, new TargetTypeAdapter())
- .create();
+ private Serialization() {}
+
+ public static class NotificationTypeAdapter
+ implements JsonSerializer<ControlLoopNotificationType>, JsonDeserializer<ControlLoopNotificationType> {
+ @Override
+ public JsonElement serialize(ControlLoopNotificationType src, Type typeOfSrc,
+ JsonSerializationContext context) {
+ return new JsonPrimitive(src.toString());
+ }
+
+ @Override
+ public ControlLoopNotificationType deserialize(JsonElement json, Type typeOfT,
+ JsonDeserializationContext context) {
+ return ControlLoopNotificationType.toType(json.getAsString());
+ }
+ }
+
+ public static class TargetTypeAdapter
+ implements JsonSerializer<ControlLoopTargetType>, JsonDeserializer<ControlLoopTargetType> {
+ @Override
+ public JsonElement serialize(ControlLoopTargetType src, Type typeOfSrc, JsonSerializationContext context) {
+ return new JsonPrimitive(src.toString());
+ }
+
+ @Override
+ public ControlLoopTargetType deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) {
+ return ControlLoopTargetType.toType(json.getAsString());
+ }
+ }
+
+ public static class GsonUtcAdapter implements JsonSerializer<ZonedDateTime>, JsonDeserializer<ZonedDateTime> {
+ private static final Logger logger = LoggerFactory.getLogger(GsonUtcAdapter.class);
+ public static final DateTimeFormatter format = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSSSSSxxx");
+
+ @Override
+ public ZonedDateTime deserialize(JsonElement element, Type type, JsonDeserializationContext context) {
+ try {
+ return ZonedDateTime.parse(element.getAsString(), format);
+ } catch (Exception e) {
+ logger.error(e.getMessage(), e);
+ }
+ return null;
+ }
+
+ @Override
+ public JsonElement serialize(ZonedDateTime datetime, Type type, JsonSerializationContext context) {
+ return new JsonPrimitive(datetime.format(format));
+ }
+ }
+
+ public static class GsonInstantAdapter implements JsonSerializer<Instant>, JsonDeserializer<Instant> {
+
+ @Override
+ public Instant deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) {
+ return Instant.ofEpochMilli(json.getAsLong());
+ }
+
+ @Override
+ public JsonElement serialize(Instant src, Type typeOfSrc, JsonSerializationContext context) {
+ return new JsonPrimitive(src.toEpochMilli());
+ }
+
+ }
+
+ public static final Gson gson =
+ new GsonBuilder().disableHtmlEscaping().registerTypeAdapter(ZonedDateTime.class, new GsonUtcAdapter())
+ .registerTypeAdapter(Instant.class, new GsonInstantAdapter())
+ .registerTypeAdapter(ControlLoopNotificationType.class, new NotificationTypeAdapter())
+ .registerTypeAdapter(ControlLoopTargetType.class, new TargetTypeAdapter()).create();
+
+
+ public static final Gson gsonPretty = new GsonBuilder().disableHtmlEscaping().setPrettyPrinting()
+ .registerTypeAdapter(ZonedDateTime.class, new GsonUtcAdapter())
+ .registerTypeAdapter(Instant.class, new GsonInstantAdapter())
+ .registerTypeAdapter(ControlLoopNotificationType.class, new NotificationTypeAdapter())
+ .registerTypeAdapter(ControlLoopTargetType.class, new TargetTypeAdapter()).create();
+
+ public static final Gson gsonJunit = new GsonBuilder().disableHtmlEscaping().setPrettyPrinting()
+ .registerTypeAdapter(ZonedDateTime.class, new GsonUtcAdapter())
+ .registerTypeAdapter(Instant.class, new GsonInstantAdapter())
+ .registerTypeAdapter(ControlLoopTargetType.class, new TargetTypeAdapter()).create();
}
diff --git a/controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/config/__artifactId__-controller.properties b/controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/config/__artifactId__-controller.properties
index b22ba98eb..18d03b79f 100644
--- a/controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/config/__artifactId__-controller.properties
+++ b/controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/config/__artifactId__-controller.properties
@@ -39,8 +39,8 @@ ueb.source.topics.APPC-CL.events.custom.gson=org.onap.policy.appc.util.Serializa
ueb.source.topics.APPC-LCM-WRITE.servers=${dmaapServers}
ueb.source.topics.APPC-LCM-WRITE.apiKey=
ueb.source.topics.APPC-LCM-WRITE.apiSecret=
-ueb.source.topics.APPC-LCM-WRITE.events=org.onap.policy.appclcm.LCMResponseWrapper
-ueb.source.topics.APPC-LCM-WRITE.events.org.onap.policy.appclcm.LCMResponseWrapper.filter=type\=response
+ueb.source.topics.APPC-LCM-WRITE.events=org.onap.policy.appclcm.LcmResponseWrapper
+ueb.source.topics.APPC-LCM-WRITE.events.org.onap.policy.appclcm.LcmResponseWrapper.filter=type\=response
ueb.source.topics.APPC-LCM-WRITE.events.custom.gson=org.onap.policy.appclcm.util.Serialization,gson
noop.sink.topics=APPC-CL,APPC-LCM-READ,POLICY-CL-MGT
@@ -54,7 +54,7 @@ noop.sink.topics.APPC-CL.events.custom.gson=org.onap.policy.appc.util.Serializat
noop.sink.topics.APPC-LCM-READ.servers=${dmaapServers}
noop.sink.topics.APPC-LCM-READ.apiKey=
noop.sink.topics.APPC-LCM-READ.apiSecret=
-noop.sink.topics.APPC-LCM-READ.events=org.onap.policy.appclcm.LCMRequestWrapper
+noop.sink.topics.APPC-LCM-READ.events=org.onap.policy.appclcm.LcmRequestWrapper
noop.sink.topics.APPC-LCM-READ.events.custom.gson=org.onap.policy.appclcm.util.Serialization,gson
noop.sink.topics.POLICY-CL-MGT.servers=${dmaapServers}
diff --git a/controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/config/__artifactId__-controller.rest.json b/controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/config/__artifactId__-controller.rest.json
index 48d48de82..ee8e145b4 100644
--- a/controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/config/__artifactId__-controller.rest.json
+++ b/controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/config/__artifactId__-controller.rest.json
@@ -10,12 +10,12 @@
"ueb.source.topics.APPC-CL.servers": "${dmaapServers}",
"ueb.source.topics.APPC-CL.events": "org.onap.policy.appc.Response",
- "ueb.source.topics.APPC-CL.events.org.onap.policy.appclcm.LCMResponseWrapper.filter": "CommonHeader=.*,Status=.*",
+ "ueb.source.topics.APPC-CL.events.org.onap.policy.appclcm.LcmResponseWrapper.filter": "CommonHeader=.*,Status=.*",
"ueb.source.topics.APPC-CL.events.custom.gson": "org.onap.policy.appc.util.Serialization,gsonPretty",
"ueb.source.topics.APPC-LCM-WRITE.servers": "${dmaapServers}",
- "ueb.source.topics.APPC-LCM-WRITE.events": "org.onap.policy.appclcm.LCMResponseWrapper",
- "ueb.source.topics.APPC-LCM-WRITE.events.org.onap.policy.appclcm.LCMResponseWrapper.filter": "type=response",
+ "ueb.source.topics.APPC-LCM-WRITE.events": "org.onap.policy.appclcm.LcmResponseWrapper",
+ "ueb.source.topics.APPC-LCM-WRITE.events.org.onap.policy.appclcm.LcmResponseWrapper.filter": "type=response",
"ueb.source.topics.APPC-LCM-WRITE.events.custom.gson": "org.onap.policy.appclcm.util.Serialization,gson",
"noop.sink.topics": "APPC-CL,APPC-LCM-READ,POLICY-CL-MGT",
@@ -25,7 +25,7 @@
"noop.sink.topics.APPC-CL.events.custom.gson": "org.onap.policy.appc.util.Serialization,gsonPretty",
"noop.sink.topics.APPC-LCM-READ.servers": "${dmaapServers}",
- "noop.sink.topics.APPC-LCM-READ.events": "org.onap.policy.appclcm.LCMRequestWrapper",
+ "noop.sink.topics.APPC-LCM-READ.events": "org.onap.policy.appclcm.LcmRequestWrapper",
"noop.sink.topics.APPC-LCM-READ.events.custom.gson": "org.onap.policy.appclcm.util.Serialization,gson",
"noop.sink.topics.POLICY-CL-MGT.servers": "${dmaapServers}",
diff --git a/controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/resources/__closedLoopControlName__.drl b/controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/resources/__closedLoopControlName__.drl
index f5f82e02a..d9e6be122 100644
--- a/controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/resources/__closedLoopControlName__.drl
+++ b/controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/resources/__closedLoopControlName__.drl
@@ -35,11 +35,11 @@ import org.onap.policy.controlloop.actor.so.SOActorServiceProvider;
import org.onap.policy.appc.Request;
import org.onap.policy.appc.Response;
import org.onap.policy.appc.CommonHeader;
-import org.onap.policy.appclcm.LCMRequestWrapper;
-import org.onap.policy.appclcm.LCMResponseWrapper;
-import org.onap.policy.appclcm.LCMRequest;
-import org.onap.policy.appclcm.LCMResponse;
-import org.onap.policy.appclcm.LCMCommonHeader;
+import org.onap.policy.appclcm.LcmRequestWrapper;
+import org.onap.policy.appclcm.LcmResponseWrapper;
+import org.onap.policy.appclcm.LcmRequest;
+import org.onap.policy.appclcm.LcmResponse;
+import org.onap.policy.appclcm.LcmCommonHeader;
import org.onap.policy.vfc.VFCRequest;
import org.onap.policy.vfc.VFCResponse;
import org.onap.policy.vfc.VFCManager;
@@ -146,7 +146,7 @@ rule "${policyName}.EVENT"
when
$params : Params( getClosedLoopControlName() == "${closedLoopControlName}" )
$event : VirtualControlLoopEvent( closedLoopControlName == $params.getClosedLoopControlName() )
- not ( ControlLoopEventManager( closedLoopControlName == $event.getClosedLoopControlName(), requestID == $event.getRequestID() ) )
+ not ( ControlLoopEventManager( closedLoopControlName == $event.getClosedLoopControlName(), requestID == $event.getRequestId() ) )
then
Logger logger = LoggerFactory.getLogger(drools.getRule().getPackage());
@@ -159,11 +159,11 @@ rule "${policyName}.EVENT"
// we create the ControlLoopEventManager. The ControlLoopEventManager
// will do extra syntax checking as well check if the closed loop is disabled.
//
- if ($event.getRequestID() == null) {
+ if ($event.getRequestId() == null) {
VirtualControlLoopNotification notification = new VirtualControlLoopNotification($event);
notification.setNotification(ControlLoopNotificationType.REJECTED);
notification.setFrom("policy");
- notification.setMessage("Missing requestID");
+ notification.setMessage("Missing requestId");
notification.setPolicyName(drools.getRule().getName());
notification.setPolicyScope("${policyScope}");
notification.setPolicyVersion("${policyVersion}");
@@ -183,7 +183,7 @@ rule "${policyName}.EVENT"
//
// Create an EventManager
//
- ControlLoopEventManager manager = new ControlLoopEventManager($params.getClosedLoopControlName(), $event.getRequestID());
+ ControlLoopEventManager manager = new ControlLoopEventManager($params.getClosedLoopControlName(), $event.getRequestId());
//
// Determine if EventManager can actively process the event (i.e. syntax, is_closed_loop_disabled checks etc.)
//
@@ -209,7 +209,7 @@ rule "${policyName}.EVENT"
//
ControlLoopTimer clTimer = new ControlLoopTimer();
clTimer.setClosedLoopControlName($event.getClosedLoopControlName());
- clTimer.setRequestID($event.getRequestID().toString());
+ clTimer.setRequestID($event.getRequestId().toString());
clTimer.setDelay(manager.getControlLoopTimeout(1500) + "s");
//
// Insert it
@@ -229,7 +229,7 @@ rule "${policyName}.EVENT"
//
// Now that the manager is inserted into Drools working memory, we'll wait for
// another rule to fire in order to continue processing. This way we can also
- // then screen for additional ONSET and ABATED events for this RequestID.
+ // then screen for additional ONSET and ABATED events for this RequestId.
//
}
} catch (Exception e) {
@@ -262,8 +262,8 @@ rule "${policyName}.EVENT.MANAGER"
when
$params : Params( getClosedLoopControlName() == "${closedLoopControlName}" )
$event : VirtualControlLoopEvent( closedLoopControlName == $params.getClosedLoopControlName() )
- $manager : ControlLoopEventManager( closedLoopControlName == $event.getClosedLoopControlName(), requestID == $event.getRequestID() )
- $clTimer : ControlLoopTimer ( closedLoopControlName == $event.getClosedLoopControlName(), requestID == $event.getRequestID().toString() )
+ $manager : ControlLoopEventManager( closedLoopControlName == $event.getClosedLoopControlName(), requestID == $event.getRequestId() )
+ $clTimer : ControlLoopTimer ( closedLoopControlName == $event.getClosedLoopControlName(), requestID == $event.getRequestId().toString() )
then
Logger logger = LoggerFactory.getLogger(drools.getRule().getPackage());
@@ -327,7 +327,7 @@ rule "${policyName}.EVENT.MANAGER"
if ($manager.getNumAbatements() > 0) {
logger.info("{}: {}: abatement received for {}. Closing the control loop",
$params.getClosedLoopControlName(), drools.getRule().getName(),
- $event.getRequestID());
+ $event.getRequestId());
notification.setFrom("policy");
notification.setPolicyName(drools.getRule().getName());
notification.setPolicyScope("${policyScope}");
@@ -355,7 +355,7 @@ rule "${policyName}.EVENT.MANAGER"
retract($manager);
retract($clTimer);
//
- // TODO - what if we get subsequent Events for this RequestID?
+ // TODO - what if we get subsequent Events for this RequestId?
// By default, it will all start over again. May be confusing for Ruby.
// Or, we could track this and then subsequently ignore the events
//
@@ -369,7 +369,7 @@ rule "${policyName}.EVENT.MANAGER"
} else {
logger.info("{}: {}: no abatement expect for {}. Closing the control loop",
$params.getClosedLoopControlName(), drools.getRule().getName(),
- $event.getRequestID());
+ $event.getRequestId());
notification.setFrom("policy");
notification.setPolicyName(drools.getRule().getName());
@@ -424,7 +424,7 @@ rule "${policyName}.EVENT.MANAGER"
//
OperationTimer opTimer = new OperationTimer();
opTimer.setClosedLoopControlName($event.getClosedLoopControlName());
- opTimer.setRequestID($event.getRequestID().toString());
+ opTimer.setRequestID($event.getRequestId().toString());
opTimer.setDelay(operation.getOperationTimeout().toString() + "s");
insert(opTimer);
@@ -435,10 +435,10 @@ rule "${policyName}.EVENT.MANAGER"
}
else {
logger.debug("The target resource {} is already processing",
- $event.getAAI().get($event.getTarget()));
+ $event.getAai().get($event.getTarget()));
notification = new VirtualControlLoopNotification($event);
notification.setNotification(ControlLoopNotificationType.REJECTED);
- notification.setMessage("The target " + $event.getAAI().get($event.getTarget()) + " is already locked");
+ notification.setMessage("The target " + $event.getAai().get($event.getTarget()) + " is already locked");
notification.setFrom("policy");
notification.setPolicyName(drools.getRule().getName());
notification.setPolicyScope("${policyScope}");
@@ -492,10 +492,10 @@ rule "${policyName}.EVENT.MANAGER.OPERATION.LOCKED.GUARD_PERMITTED"
when
$params : Params( getClosedLoopControlName() == "${closedLoopControlName}" )
$event : VirtualControlLoopEvent( closedLoopControlName == $params.getClosedLoopControlName() )
- $manager : ControlLoopEventManager( closedLoopControlName == $event.getClosedLoopControlName(), requestID == $event.getRequestID() )
- $operation : ControlLoopOperationManager( onset.closedLoopControlName == $event.getClosedLoopControlName(), onset.getRequestID() == $event.getRequestID(), "Permit".equalsIgnoreCase(getGuardApprovalStatus()) )
- $lock : TargetLock (requestID == $event.getRequestID())
- $opTimer : OperationTimer( closedLoopControlName == $event.getClosedLoopControlName(), requestID == $event.getRequestID().toString() )
+ $manager : ControlLoopEventManager( closedLoopControlName == $event.getClosedLoopControlName(), requestID == $event.getRequestId() )
+ $operation : ControlLoopOperationManager( onset.closedLoopControlName == $event.getClosedLoopControlName(), onset.getRequestId() == $event.getRequestId(), "Permit".equalsIgnoreCase(getGuardApprovalStatus()) )
+ $lock : TargetLock (requestID == $event.getRequestId())
+ $opTimer : OperationTimer( closedLoopControlName == $event.getClosedLoopControlName(), requestID == $event.getRequestId().toString() )
then
Logger logger = LoggerFactory.getLogger(drools.getRule().getPackage());
@@ -547,7 +547,7 @@ rule "${policyName}.EVENT.MANAGER.OPERATION.LOCKED.GUARD_PERMITTED"
if (request instanceof Request) {
PolicyEngine.manager.deliver("APPC-CL", request);
}
- else if (request instanceof LCMRequestWrapper) {
+ else if (request instanceof LcmRequestWrapper) {
PolicyEngine.manager.deliver("APPC-LCM-READ", request);
}
break;
@@ -557,7 +557,7 @@ rule "${policyName}.EVENT.MANAGER.OPERATION.LOCKED.GUARD_PERMITTED"
if(request instanceof SORequest) {
// Call SO. The response will be inserted into memory once it's received
- SOActorServiceProvider.sendRequest($event.getRequestID().toString(), drools.getWorkingMemory(), request);
+ SOActorServiceProvider.sendRequest($event.getRequestId().toString(), drools.getWorkingMemory(), request);
}
break;
case "VFC":
@@ -600,9 +600,9 @@ rule "${policyName}.EVENT.MANAGER.OPERATION.LOCKED.GUARD_NOT_YET_QUERIED"
when
$params : Params( getClosedLoopControlName() == "${closedLoopControlName}" )
$event : VirtualControlLoopEvent( closedLoopControlName == $params.getClosedLoopControlName() )
- $manager : ControlLoopEventManager( closedLoopControlName == $event.getClosedLoopControlName(), requestID == $event.getRequestID() )
- $operation : ControlLoopOperationManager( onset.closedLoopControlName == $event.getClosedLoopControlName(), onset.getRequestID() == $event.getRequestID(), getGuardApprovalStatus() == "NONE" )
- $lock : TargetLock (requestID == $event.getRequestID())
+ $manager : ControlLoopEventManager( closedLoopControlName == $event.getClosedLoopControlName(), requestID == $event.getRequestId() )
+ $operation : ControlLoopOperationManager( onset.closedLoopControlName == $event.getClosedLoopControlName(), onset.getRequestId() == $event.getRequestId(), getGuardApprovalStatus() == "NONE" )
+ $lock : TargetLock (requestID == $event.getRequestId())
then
Logger logger = LoggerFactory.getLogger(drools.getRule().getPackage());
@@ -644,12 +644,12 @@ rule "${policyName}.EVENT.MANAGER.OPERATION.LOCKED.GUARD_NOT_YET_QUERIED"
$operation.policy.getActor().toString(),
$operation.policy.getRecipe(),
$operation.getTargetEntity(),
- $event.getRequestID().toString()
+ $event.getRequestId().toString()
));
t.start();
}
else{
- insert(new PolicyGuardResponse("Permit", $event.getRequestID(), $operation.policy.getRecipe()));
+ insert(new PolicyGuardResponse("Permit", $event.getRequestId(), $operation.policy.getRecipe()));
}
end
@@ -662,11 +662,11 @@ rule "${policyName}.GUARD.RESPONSE"
when
$params : Params( getClosedLoopControlName() == "${closedLoopControlName}" )
$event : VirtualControlLoopEvent( closedLoopControlName == $params.getClosedLoopControlName(), closedLoopEventStatus == ControlLoopEventStatus.ONSET )
- $manager : ControlLoopEventManager( closedLoopControlName == $event.getClosedLoopControlName(), requestID == $event.getRequestID() )
- $operation : ControlLoopOperationManager( onset.closedLoopControlName == $event.getClosedLoopControlName(), onset.getRequestID() == $event.getRequestID() )
- $lock : TargetLock (requestID == $event.getRequestID())
- $opTimer : OperationTimer( closedLoopControlName == $event.getClosedLoopControlName(), requestID == $event.getRequestID().toString() )
- $guardResponse : PolicyGuardResponse(requestID == $event.getRequestID(), $operation.policy.recipe == operation)
+ $manager : ControlLoopEventManager( closedLoopControlName == $event.getClosedLoopControlName(), requestID == $event.getRequestId() )
+ $operation : ControlLoopOperationManager( onset.closedLoopControlName == $event.getClosedLoopControlName(), onset.getRequestId() == $event.getRequestId() )
+ $lock : TargetLock (requestID == $event.getRequestId())
+ $opTimer : OperationTimer( closedLoopControlName == $event.getClosedLoopControlName(), requestID == $event.getRequestId().toString() )
+ $guardResponse : PolicyGuardResponse(requestID == $event.getRequestId(), $operation.policy.recipe == operation)
then
Logger logger = LoggerFactory.getLogger(drools.getRule().getPackage());
@@ -716,7 +716,7 @@ end
* This rule responds to APPC Response Events
*
* I would have like to be consistent and write the Response like this:
-* $response : Response( CommonHeader.RequestID == $onset.getRequestID() )
+* $response : Response( CommonHeader.RequestId == $onset.getRequestId() )
*
* However, no compile error was given. But a runtime error was given. I think
* because drools is confused between the classname CommonHeader vs the property CommonHeader.
@@ -726,11 +726,11 @@ rule "${policyName}.APPC.RESPONSE"
when
$params : Params( getClosedLoopControlName() == "${closedLoopControlName}" )
$event : VirtualControlLoopEvent( closedLoopControlName == $params.getClosedLoopControlName(), closedLoopEventStatus == ControlLoopEventStatus.ONSET )
- $manager : ControlLoopEventManager( closedLoopControlName == $event.getClosedLoopControlName(), requestID == $event.getRequestID() )
- $operation : ControlLoopOperationManager( onset.closedLoopControlName == $event.getClosedLoopControlName(), onset.getRequestID() == $event.getRequestID() )
- $opTimer : OperationTimer( closedLoopControlName == $event.getClosedLoopControlName(), requestID == $event.getRequestID().toString() )
- $lock : TargetLock (requestID == $event.getRequestID())
- $response : Response( getCommonHeader().RequestID == $event.getRequestID() )
+ $manager : ControlLoopEventManager( closedLoopControlName == $event.getClosedLoopControlName(), requestID == $event.getRequestId() )
+ $operation : ControlLoopOperationManager( onset.closedLoopControlName == $event.getClosedLoopControlName(), onset.getRequestId() == $event.getRequestId() )
+ $opTimer : OperationTimer( closedLoopControlName == $event.getClosedLoopControlName(), requestID == $event.getRequestId().toString() )
+ $lock : TargetLock (requestID == $event.getRequestId())
+ $response : Response( getCommonHeader().RequestId == $event.getRequestId() )
then
Logger logger = LoggerFactory.getLogger(drools.getRule().getPackage());
@@ -808,7 +808,7 @@ end
/*
*
* The problem with Responses is that they don't have a controlLoopControlName
-* field in them, so the only way to attach them is via RequestID. If we have multiple
+* field in them, so the only way to attach them is via RequestId. If we have multiple
* control loop .drl's loaded in the same container, we need to be sure the cleanup
* rules don't remove Responses for other control loops.
*
@@ -816,8 +816,8 @@ end
rule "${policyName}.APPC.RESPONSE.CLEANUP"
when
$params : Params( getClosedLoopControlName() == "${closedLoopControlName}" )
- $response : Response($id : getCommonHeader().RequestID )
- not ( VirtualControlLoopEvent( requestID == $id, closedLoopEventStatus == ControlLoopEventStatus.ONSET ) )
+ $response : Response($id : getCommonHeader().RequestId )
+ not ( VirtualControlLoopEvent( requestId == $id, closedLoopEventStatus == ControlLoopEventStatus.ONSET ) )
then
Logger logger = LoggerFactory.getLogger(drools.getRule().getPackage());
@@ -840,11 +840,11 @@ rule "${policyName}.APPC.LCM.RESPONSE"
when
$params : Params( getClosedLoopControlName() == "${closedLoopControlName}" )
$event : VirtualControlLoopEvent( closedLoopControlName == $params.getClosedLoopControlName(), closedLoopEventStatus == ControlLoopEventStatus.ONSET )
- $manager : ControlLoopEventManager( closedLoopControlName == $event.getClosedLoopControlName(), requestID == $event.getRequestID() )
- $operation : ControlLoopOperationManager( onset.closedLoopControlName == $event.getClosedLoopControlName(), onset.getRequestID() == $event.getRequestID() )
- $opTimer : OperationTimer( closedLoopControlName == $event.getClosedLoopControlName(), requestID == $event.getRequestID().toString() )
- $lock : TargetLock (requestID == $event.getRequestID())
- $response : LCMResponseWrapper( getBody().getCommonHeader().getRequestId() == $event.getRequestID() )
+ $manager : ControlLoopEventManager( closedLoopControlName == $event.getClosedLoopControlName(), requestID == $event.getRequestId() )
+ $operation : ControlLoopOperationManager( onset.closedLoopControlName == $event.getClosedLoopControlName(), onset.getRequestId() == $event.getRequestId() )
+ $opTimer : OperationTimer( closedLoopControlName == $event.getClosedLoopControlName(), requestID == $event.getRequestId().toString() )
+ $lock : TargetLock (requestID == $event.getRequestId())
+ $response : LcmResponseWrapper( getBody().getCommonHeader().getRequestId() == $event.getRequestId() )
then
Logger logger = LoggerFactory.getLogger(drools.getRule().getPackage());
@@ -922,8 +922,8 @@ end
rule "${policyName}.APPC.LCM.RESPONSE.CLEANUP"
when
$params : Params( getClosedLoopControlName() == "${closedLoopControlName}" )
- $response : LCMResponseWrapper($id : getBody().getCommonHeader().getRequestId )
- not ( VirtualControlLoopEvent( requestID == $id, closedLoopEventStatus == ControlLoopEventStatus.ONSET ) )
+ $response : LcmResponseWrapper($id : getBody().getCommonHeader().getRequestId )
+ not ( VirtualControlLoopEvent( requestId == $id, closedLoopEventStatus == ControlLoopEventStatus.ONSET ) )
then
Logger logger = LoggerFactory.getLogger(drools.getRule().getPackage());
@@ -946,10 +946,10 @@ rule "${policyName}.SO.RESPONSE"
$params : Params( getClosedLoopControlName() == "${closedLoopControlName}" )
$event : VirtualControlLoopEvent( closedLoopControlName == $params.getClosedLoopControlName(), closedLoopEventStatus == ControlLoopEventStatus.ONSET )
$manager : ControlLoopEventManager( closedLoopControlName == $event.getClosedLoopControlName() )
- $operation : ControlLoopOperationManager( onset.closedLoopControlName == $event.getClosedLoopControlName(), onset.getRequestID() == $event.getRequestID() )
- $opTimer : OperationTimer( closedLoopControlName == $event.getClosedLoopControlName(), requestID == $event.getRequestID().toString() )
- $lock : TargetLock (requestID == $event.getRequestID())
- $response : SOResponseWrapper(requestID.toString() == $event.getRequestID().toString() )
+ $operation : ControlLoopOperationManager( onset.closedLoopControlName == $event.getClosedLoopControlName(), onset.getRequestId() == $event.getRequestId() )
+ $opTimer : OperationTimer( closedLoopControlName == $event.getClosedLoopControlName(), requestID == $event.getRequestId().toString() )
+ $lock : TargetLock (requestID == $event.getRequestId())
+ $response : SOResponseWrapper(requestID.toString() == $event.getRequestId().toString() )
then
Logger logger = LoggerFactory.getLogger(drools.getRule().getPackage());
@@ -1030,10 +1030,10 @@ rule "${policyName}.VFC.RESPONSE"
$params : Params( getClosedLoopControlName() == "${closedLoopControlName}" )
$event : VirtualControlLoopEvent( closedLoopControlName == $params.getClosedLoopControlName(), closedLoopEventStatus == ControlLoopEventStatus.ONSET )
$manager : ControlLoopEventManager( closedLoopControlName == $event.getClosedLoopControlName() )
- $operation : ControlLoopOperationManager( onset.closedLoopControlName == $event.getClosedLoopControlName(), onset.getRequestID() == $event.getRequestID() )
- $opTimer : OperationTimer( closedLoopControlName == $event.getClosedLoopControlName(), requestID == $event.getRequestID().toString() )
- $lock : TargetLock (requestID == $event.getRequestID())
- $response : VFCResponse( requestId.toString() == $event.getRequestID().toString() )
+ $operation : ControlLoopOperationManager( onset.closedLoopControlName == $event.getClosedLoopControlName(), onset.getRequestId() == $event.getRequestId() )
+ $opTimer : OperationTimer( closedLoopControlName == $event.getClosedLoopControlName(), requestID == $event.getRequestId().toString() )
+ $lock : TargetLock (requestID == $event.getRequestId())
+ $response : VFCResponse( requestId.toString() == $event.getRequestId().toString() )
then
Logger logger = LoggerFactory.getLogger(drools.getRule().getPackage());
logger.info("{}: {}", $params.getClosedLoopControlName(), drools.getRule().getName());
@@ -1102,10 +1102,10 @@ rule "${policyName}.EVENT.MANAGER.OPERATION.TIMEOUT"
when
$params : Params( getClosedLoopControlName() == "${closedLoopControlName}" )
$event : VirtualControlLoopEvent( closedLoopControlName == $params.getClosedLoopControlName() )
- $manager : ControlLoopEventManager( closedLoopControlName == $event.getClosedLoopControlName(), requestID == $event.getRequestID() )
- $operation : ControlLoopOperationManager( onset.closedLoopControlName == $event.getClosedLoopControlName(), onset.getRequestID() == $event.getRequestID() )
- $opTimer : OperationTimer( closedLoopControlName == $event.getClosedLoopControlName(), requestID == $event.getRequestID().toString(), $to : getDelay() )
- $lock : TargetLock (requestID == $event.getRequestID())
+ $manager : ControlLoopEventManager( closedLoopControlName == $event.getClosedLoopControlName(), requestID == $event.getRequestId() )
+ $operation : ControlLoopOperationManager( onset.closedLoopControlName == $event.getClosedLoopControlName(), onset.getRequestId() == $event.getRequestId() )
+ $opTimer : OperationTimer( closedLoopControlName == $event.getClosedLoopControlName(), requestID == $event.getRequestId().toString(), $to : getDelay() )
+ $lock : TargetLock (requestID == $event.getRequestId())
then
Logger logger = LoggerFactory.getLogger(drools.getRule().getPackage());
@@ -1167,14 +1167,14 @@ rule "${policyName}.EVENT.MANAGER.TIMEOUT"
when
$params : Params( getClosedLoopControlName() == "${closedLoopControlName}" )
$event : VirtualControlLoopEvent( closedLoopControlName == $params.getClosedLoopControlName() )
- $manager : ControlLoopEventManager( closedLoopControlName == $event.getClosedLoopControlName(), requestID == $event.getRequestID() )
- $clTimer : ControlLoopTimer ( closedLoopControlName == $event.getClosedLoopControlName(), requestID == $event.getRequestID().toString(), $to : getDelay() )
+ $manager : ControlLoopEventManager( closedLoopControlName == $event.getClosedLoopControlName(), requestID == $event.getRequestId() )
+ $clTimer : ControlLoopTimer ( closedLoopControlName == $event.getClosedLoopControlName(), requestID == $event.getRequestId().toString(), $to : getDelay() )
$operations : LinkedList()
- from collect( ControlLoopOperationManager( onset.closedLoopControlName == $event.getClosedLoopControlName(), onset.getRequestID() == $event.getRequestID() ) )
+ from collect( ControlLoopOperationManager( onset.closedLoopControlName == $event.getClosedLoopControlName(), onset.getRequestId() == $event.getRequestId() ) )
$opTimers : LinkedList()
- from collect( OperationTimer( closedLoopControlName == $event.getClosedLoopControlName(), requestID == $event.getRequestID().toString() ) )
+ from collect( OperationTimer( closedLoopControlName == $event.getClosedLoopControlName(), requestID == $event.getRequestId().toString() ) )
$locks : LinkedList()
- from collect( TargetLock (requestID == $event.getRequestID()) )
+ from collect( TargetLock (requestID == $event.getRequestId()) )
then
Logger logger = LoggerFactory.getLogger(drools.getRule().getPackage());
diff --git a/controlloop/templates/archetype-cl-beijing/src/main/resources/archetype-resources/src/main/config/__artifactId__-controller.properties b/controlloop/templates/archetype-cl-beijing/src/main/resources/archetype-resources/src/main/config/__artifactId__-controller.properties
index 39688c306..390a946fe 100644
--- a/controlloop/templates/archetype-cl-beijing/src/main/resources/archetype-resources/src/main/config/__artifactId__-controller.properties
+++ b/controlloop/templates/archetype-cl-beijing/src/main/resources/archetype-resources/src/main/config/__artifactId__-controller.properties
@@ -45,8 +45,8 @@ ueb.source.topics.APPC-CL.events.custom.gson=org.onap.policy.appc.util.Serializa
ueb.source.topics.APPC-LCM-WRITE.servers=${dmaapServers}
ueb.source.topics.APPC-LCM-WRITE.apiKey=
ueb.source.topics.APPC-LCM-WRITE.apiSecret=
-ueb.source.topics.APPC-LCM-WRITE.events=org.onap.policy.appclcm.LCMResponseWrapper
-ueb.source.topics.APPC-LCM-WRITE.events.org.onap.policy.appclcm.LCMResponseWrapper.filter=type\=response
+ueb.source.topics.APPC-LCM-WRITE.events=org.onap.policy.appclcm.LcmResponseWrapper
+ueb.source.topics.APPC-LCM-WRITE.events.org.onap.policy.appclcm.LcmResponseWrapper.filter=type\=response
ueb.source.topics.APPC-LCM-WRITE.events.custom.gson=org.onap.policy.appclcm.util.Serialization,gson
noop.sink.topics=APPC-CL,APPC-LCM-READ,POLICY-CL-MGT
@@ -60,7 +60,7 @@ noop.sink.topics.APPC-CL.events.custom.gson=org.onap.policy.appc.util.Serializat
noop.sink.topics.APPC-LCM-READ.servers=${dmaapServers}
noop.sink.topics.APPC-LCM-READ.apiKey=
noop.sink.topics.APPC-LCM-READ.apiSecret=
-noop.sink.topics.APPC-LCM-READ.events=org.onap.policy.appclcm.LCMRequestWrapper
+noop.sink.topics.APPC-LCM-READ.events=org.onap.policy.appclcm.LcmRequestWrapper
noop.sink.topics.APPC-LCM-READ.events.custom.gson=org.onap.policy.appclcm.util.Serialization,gson
noop.sink.topics.POLICY-CL-MGT.servers=${dmaapServers}
diff --git a/controlloop/templates/archetype-cl-beijing/src/main/resources/archetype-resources/src/main/config/__artifactId__-controller.rest.json b/controlloop/templates/archetype-cl-beijing/src/main/resources/archetype-resources/src/main/config/__artifactId__-controller.rest.json
index 408b1254e..148e35562 100644
--- a/controlloop/templates/archetype-cl-beijing/src/main/resources/archetype-resources/src/main/config/__artifactId__-controller.rest.json
+++ b/controlloop/templates/archetype-cl-beijing/src/main/resources/archetype-resources/src/main/config/__artifactId__-controller.rest.json
@@ -14,12 +14,12 @@
"ueb.source.topics.APPC-CL.servers": "${dmaapServers}",
"ueb.source.topics.APPC-CL.events": "org.onap.policy.appc.Response",
- "ueb.source.topics.APPC-CL.events.org.onap.policy.appclcm.LCMResponseWrapper.filter": "CommonHeader=.*,Status=.*",
+ "ueb.source.topics.APPC-CL.events.org.onap.policy.appclcm.LcmResponseWrapper.filter": "CommonHeader=.*,Status=.*",
"ueb.source.topics.APPC-CL.events.custom.gson": "org.onap.policy.appc.util.Serialization,gsonPretty",
"ueb.source.topics.APPC-LCM-WRITE.servers": "${dmaapServers}",
- "ueb.source.topics.APPC-LCM-WRITE.events": "org.onap.policy.appclcm.LCMResponseWrapper",
- "ueb.source.topics.APPC-LCM-WRITE.events.org.onap.policy.appclcm.LCMResponseWrapper.filter": "type=response",
+ "ueb.source.topics.APPC-LCM-WRITE.events": "org.onap.policy.appclcm.LcmResponseWrapper",
+ "ueb.source.topics.APPC-LCM-WRITE.events.org.onap.policy.appclcm.LcmResponseWrapper.filter": "type=response",
"ueb.source.topics.APPC-LCM-WRITE.events.custom.gson": "org.onap.policy.appclcm.util.Serialization,gson",
"noop.sink.topics": "APPC-CL,APPC-LCM-READ,POLICY-CL-MGT",
@@ -29,7 +29,7 @@
"noop.sink.topics.APPC-CL.events.custom.gson": "org.onap.policy.appc.util.Serialization,gsonPretty",
"noop.sink.topics.APPC-LCM-READ.servers": "${dmaapServers}",
- "noop.sink.topics.APPC-LCM-READ.events": "org.onap.policy.appclcm.LCMRequestWrapper",
+ "noop.sink.topics.APPC-LCM-READ.events": "org.onap.policy.appclcm.LcmRequestWrapper",
"noop.sink.topics.APPC-LCM-READ.events.custom.gson": "org.onap.policy.appclcm.util.Serialization,gson",
"noop.sink.topics.POLICY-CL-MGT.servers": "${dmaapServers}",
diff --git a/controlloop/templates/archetype-cl-beijing/src/main/resources/archetype-resources/src/main/resources/__closedLoopControlName__.drl b/controlloop/templates/archetype-cl-beijing/src/main/resources/archetype-resources/src/main/resources/__closedLoopControlName__.drl
index 62bfb3ea5..013e6076e 100644
--- a/controlloop/templates/archetype-cl-beijing/src/main/resources/archetype-resources/src/main/resources/__closedLoopControlName__.drl
+++ b/controlloop/templates/archetype-cl-beijing/src/main/resources/archetype-resources/src/main/resources/__closedLoopControlName__.drl
@@ -36,11 +36,11 @@ import org.onap.policy.controlloop.actor.so.SOActorServiceProvider;
import org.onap.policy.appc.Request;
import org.onap.policy.appc.Response;
import org.onap.policy.appc.CommonHeader;
-import org.onap.policy.appclcm.LCMRequestWrapper;
-import org.onap.policy.appclcm.LCMResponseWrapper;
-import org.onap.policy.appclcm.LCMRequest;
-import org.onap.policy.appclcm.LCMResponse;
-import org.onap.policy.appclcm.LCMCommonHeader;
+import org.onap.policy.appclcm.LcmRequestWrapper;
+import org.onap.policy.appclcm.LcmResponseWrapper;
+import org.onap.policy.appclcm.LcmRequest;
+import org.onap.policy.appclcm.LcmResponse;
+import org.onap.policy.appclcm.LcmCommonHeader;
import org.onap.policy.vfc.VFCRequest;
import org.onap.policy.vfc.VFCResponse;
import org.onap.policy.vfc.VFCManager;
@@ -124,7 +124,7 @@ rule "EVENT"
when
$params : ControlLoopParams( $clName : getClosedLoopControlName() )
$event : VirtualControlLoopEvent( closedLoopControlName == $clName )
- not ( ControlLoopEventManager( closedLoopControlName == $event.getClosedLoopControlName(), requestID == $event.getRequestID() ) )
+ not ( ControlLoopEventManager( closedLoopControlName == $event.getClosedLoopControlName(), requestID == $event.getRequestId() ) )
then
Logger logger = LoggerFactory.getLogger(drools.getRule().getPackage());
@@ -137,7 +137,7 @@ rule "EVENT"
// we create the ControlLoopEventManager. The ControlLoopEventManager
// will do extra syntax checking as well check if the closed loop is disabled.
//
- if ($event.getRequestID() == null) {
+ if ($event.getRequestId() == null) {
VirtualControlLoopNotification notification = new VirtualControlLoopNotification($event);
notification.setNotification(ControlLoopNotificationType.REJECTED);
notification.setFrom("policy");
@@ -161,7 +161,7 @@ rule "EVENT"
//
// Create an EventManager
//
- ControlLoopEventManager manager = new ControlLoopEventManager($clName, $event.getRequestID());
+ ControlLoopEventManager manager = new ControlLoopEventManager($clName, $event.getRequestId());
//
// Determine if EventManager can actively process the event (i.e. syntax, is_closed_loop_disabled checks etc.)
//
@@ -187,7 +187,7 @@ rule "EVENT"
//
ControlLoopTimer clTimer = new ControlLoopTimer();
clTimer.setClosedLoopControlName($event.getClosedLoopControlName());
- clTimer.setRequestID($event.getRequestID().toString());
+ clTimer.setRequestID($event.getRequestId().toString());
clTimer.setDelay(manager.getControlLoopTimeout(1500) + "s");
//
// Insert it
@@ -240,8 +240,8 @@ rule "EVENT.MANAGER"
when
$params : ControlLoopParams( $clName : getClosedLoopControlName() )
$event : VirtualControlLoopEvent( closedLoopControlName == $clName )
- $manager : ControlLoopEventManager( closedLoopControlName == $event.getClosedLoopControlName(), requestID == $event.getRequestID() )
- $clTimer : ControlLoopTimer ( closedLoopControlName == $event.getClosedLoopControlName(), requestID == $event.getRequestID().toString() )
+ $manager : ControlLoopEventManager( closedLoopControlName == $event.getClosedLoopControlName(), requestID == $event.getRequestId() )
+ $clTimer : ControlLoopTimer ( closedLoopControlName == $event.getClosedLoopControlName(), requestID == $event.getRequestId().toString() )
then
Logger logger = LoggerFactory.getLogger(drools.getRule().getPackage());
@@ -305,7 +305,7 @@ rule "EVENT.MANAGER"
if ($manager.getNumAbatements() > 0) {
logger.info("{}: {}: abatement received for {}. Closing the control loop",
$clName, $params.getPolicyName() + "." + drools.getRule().getName(),
- $event.getRequestID());
+ $event.getRequestId());
notification.setFrom("policy");
notification.setPolicyName($params.getPolicyName() + "." + drools.getRule().getName());
notification.setPolicyScope($params.getPolicyScope());
@@ -347,7 +347,7 @@ rule "EVENT.MANAGER"
} else {
logger.info("{}: {}: no abatement expect for {}. Closing the control loop",
$clName, $params.getPolicyName() + "." + drools.getRule().getName(),
- $event.getRequestID());
+ $event.getRequestId());
notification.setFrom("policy");
notification.setPolicyName($params.getPolicyName() + "." + drools.getRule().getName());
@@ -402,7 +402,7 @@ rule "EVENT.MANAGER"
//
OperationTimer opTimer = new OperationTimer();
opTimer.setClosedLoopControlName($event.getClosedLoopControlName());
- opTimer.setRequestID($event.getRequestID().toString());
+ opTimer.setRequestID($event.getRequestId().toString());
opTimer.setDelay(operation.getOperationTimeout().toString() + "s");
insert(opTimer);
@@ -413,10 +413,10 @@ rule "EVENT.MANAGER"
}
else {
logger.debug("The target resource {} is already processing",
- $event.getAAI().get($event.getTarget()));
+ $event.getAai().get($event.getTarget()));
notification = new VirtualControlLoopNotification($event);
notification.setNotification(ControlLoopNotificationType.REJECTED);
- notification.setMessage("The target " + $event.getAAI().get($event.getTarget()) + " is already locked");
+ notification.setMessage("The target " + $event.getAai().get($event.getTarget()) + " is already locked");
notification.setFrom("policy");
notification.setPolicyName($params.getPolicyName() + "." + drools.getRule().getName());
notification.setPolicyScope($params.getPolicyScope());
@@ -470,10 +470,10 @@ rule "EVENT.MANAGER.OPERATION.LOCKED.GUARD_PERMITTED"
when
$params : ControlLoopParams( $clName : getClosedLoopControlName() )
$event : VirtualControlLoopEvent( closedLoopControlName == $clName )
- $manager : ControlLoopEventManager( closedLoopControlName == $event.getClosedLoopControlName(), requestID == $event.getRequestID() )
- $operation : ControlLoopOperationManager( onset.closedLoopControlName == $event.getClosedLoopControlName(), onset.getRequestID() == $event.getRequestID(), "Permit".equalsIgnoreCase(getGuardApprovalStatus()) )
- $lock : TargetLock (requestID == $event.getRequestID())
- $opTimer : OperationTimer( closedLoopControlName == $event.getClosedLoopControlName(), requestID == $event.getRequestID().toString() )
+ $manager : ControlLoopEventManager( closedLoopControlName == $event.getClosedLoopControlName(), requestID == $event.getRequestId() )
+ $operation : ControlLoopOperationManager( onset.closedLoopControlName == $event.getClosedLoopControlName(), onset.getRequestId() == $event.getRequestId(), "Permit".equalsIgnoreCase(getGuardApprovalStatus()) )
+ $lock : TargetLock (requestID == $event.getRequestId())
+ $opTimer : OperationTimer( closedLoopControlName == $event.getClosedLoopControlName(), requestID == $event.getRequestId().toString() )
then
Logger logger = LoggerFactory.getLogger(drools.getRule().getPackage());
@@ -525,7 +525,7 @@ rule "EVENT.MANAGER.OPERATION.LOCKED.GUARD_PERMITTED"
if (request instanceof Request) {
PolicyEngine.manager.deliver("APPC-CL", request);
}
- else if (request instanceof LCMRequestWrapper) {
+ else if (request instanceof LcmRequestWrapper) {
PolicyEngine.manager.deliver("APPC-LCM-READ", request);
}
break;
@@ -535,7 +535,7 @@ rule "EVENT.MANAGER.OPERATION.LOCKED.GUARD_PERMITTED"
if(request instanceof SORequest) {
// Call SO. The response will be inserted into memory once it's received
- SOActorServiceProvider.sendRequest($event.getRequestID().toString(), drools.getWorkingMemory(), request);
+ SOActorServiceProvider.sendRequest($event.getRequestId().toString(), drools.getWorkingMemory(), request);
}
break;
case "VFC":
@@ -578,9 +578,9 @@ rule "EVENT.MANAGER.OPERATION.LOCKED.GUARD_NOT_YET_QUERIED"
when
$params : ControlLoopParams( $clName : getClosedLoopControlName() )
$event : VirtualControlLoopEvent( closedLoopControlName == $clName )
- $manager : ControlLoopEventManager( closedLoopControlName == $event.getClosedLoopControlName(), requestID == $event.getRequestID() )
- $operation : ControlLoopOperationManager( onset.closedLoopControlName == $event.getClosedLoopControlName(), onset.getRequestID() == $event.getRequestID(), getGuardApprovalStatus() == "NONE" )
- $lock : TargetLock (requestID == $event.getRequestID())
+ $manager : ControlLoopEventManager( closedLoopControlName == $event.getClosedLoopControlName(), requestID == $event.getRequestId() )
+ $operation : ControlLoopOperationManager( onset.closedLoopControlName == $event.getClosedLoopControlName(), onset.getRequestId() == $event.getRequestId(), getGuardApprovalStatus() == "NONE" )
+ $lock : TargetLock (requestID == $event.getRequestId())
then
Logger logger = LoggerFactory.getLogger(drools.getRule().getPackage());
@@ -622,12 +622,12 @@ rule "EVENT.MANAGER.OPERATION.LOCKED.GUARD_NOT_YET_QUERIED"
$operation.policy.getActor().toString(),
$operation.policy.getRecipe(),
$operation.getTargetEntity(),
- $event.getRequestID().toString()
+ $event.getRequestId().toString()
));
t.start();
}
else{
- insert(new PolicyGuardResponse("Permit", $event.getRequestID(), $operation.policy.getRecipe()));
+ insert(new PolicyGuardResponse("Permit", $event.getRequestId(), $operation.policy.getRecipe()));
}
end
@@ -640,11 +640,11 @@ rule "GUARD.RESPONSE"
when
$params : ControlLoopParams( $clName : getClosedLoopControlName() )
$event : VirtualControlLoopEvent( closedLoopControlName == $clName, closedLoopEventStatus == ControlLoopEventStatus.ONSET )
- $manager : ControlLoopEventManager( closedLoopControlName == $event.getClosedLoopControlName(), requestID == $event.getRequestID() )
- $operation : ControlLoopOperationManager( onset.closedLoopControlName == $event.getClosedLoopControlName(), onset.getRequestID() == $event.getRequestID() )
- $lock : TargetLock (requestID == $event.getRequestID())
- $opTimer : OperationTimer( closedLoopControlName == $event.getClosedLoopControlName(), requestID == $event.getRequestID().toString() )
- $guardResponse : PolicyGuardResponse(requestID == $event.getRequestID(), $operation.policy.recipe == operation)
+ $manager : ControlLoopEventManager( closedLoopControlName == $event.getClosedLoopControlName(), requestID == $event.getRequestId() )
+ $operation : ControlLoopOperationManager( onset.closedLoopControlName == $event.getClosedLoopControlName(), onset.getRequestId() == $event.getRequestId() )
+ $lock : TargetLock (requestID == $event.getRequestId())
+ $opTimer : OperationTimer( closedLoopControlName == $event.getClosedLoopControlName(), requestID == $event.getRequestId().toString() )
+ $guardResponse : PolicyGuardResponse(requestID == $event.getRequestId(), $operation.policy.recipe == operation)
then
Logger logger = LoggerFactory.getLogger(drools.getRule().getPackage());
@@ -694,7 +694,7 @@ end
* This rule responds to APPC Response Events
*
* I would have like to be consistent and write the Response like this:
-* $response : Response( CommonHeader.RequestID == $onset.getRequestID() )
+* $response : Response( CommonHeader.RequestId == $onset.getRequestId() )
*
* However, no compile error was given. But a runtime error was given. I think
* because drools is confused between the classname CommonHeader vs the property CommonHeader.
@@ -704,11 +704,11 @@ rule "APPC.RESPONSE"
when
$params : ControlLoopParams( $clName : getClosedLoopControlName() )
$event : VirtualControlLoopEvent( closedLoopControlName == $clName, closedLoopEventStatus == ControlLoopEventStatus.ONSET )
- $manager : ControlLoopEventManager( closedLoopControlName == $event.getClosedLoopControlName(), requestID == $event.getRequestID() )
- $operation : ControlLoopOperationManager( onset.closedLoopControlName == $event.getClosedLoopControlName(), onset.getRequestID() == $event.getRequestID() )
- $opTimer : OperationTimer( closedLoopControlName == $event.getClosedLoopControlName(), requestID == $event.getRequestID().toString() )
- $lock : TargetLock (requestID == $event.getRequestID())
- $response : Response( getCommonHeader().RequestID == $event.getRequestID() )
+ $manager : ControlLoopEventManager( closedLoopControlName == $event.getClosedLoopControlName(), requestID == $event.getRequestId() )
+ $operation : ControlLoopOperationManager( onset.closedLoopControlName == $event.getClosedLoopControlName(), onset.getRequestId() == $event.getRequestId() )
+ $opTimer : OperationTimer( closedLoopControlName == $event.getClosedLoopControlName(), requestID == $event.getRequestId().toString() )
+ $lock : TargetLock (requestID == $event.getRequestId())
+ $response : Response( getCommonHeader().RequestId == $event.getRequestId() )
then
Logger logger = LoggerFactory.getLogger(drools.getRule().getPackage());
@@ -794,8 +794,8 @@ end
rule "APPC.RESPONSE.CLEANUP"
when
$params : ControlLoopParams( $clName : getClosedLoopControlName() )
- $response : Response($id : getCommonHeader().RequestID )
- not ( VirtualControlLoopEvent( requestID == $id, closedLoopEventStatus == ControlLoopEventStatus.ONSET ) )
+ $response : Response($id : getCommonHeader().RequestId )
+ not ( VirtualControlLoopEvent( requestId == $id, closedLoopEventStatus == ControlLoopEventStatus.ONSET ) )
then
Logger logger = LoggerFactory.getLogger(drools.getRule().getPackage());
@@ -818,11 +818,11 @@ rule "APPC.LCM.RESPONSE"
when
$params : ControlLoopParams( $clName : getClosedLoopControlName() )
$event : VirtualControlLoopEvent( closedLoopControlName == $clName, closedLoopEventStatus == ControlLoopEventStatus.ONSET )
- $manager : ControlLoopEventManager( closedLoopControlName == $event.getClosedLoopControlName(), requestID == $event.getRequestID() )
- $operation : ControlLoopOperationManager( onset.closedLoopControlName == $event.getClosedLoopControlName(), onset.getRequestID() == $event.getRequestID() )
- $opTimer : OperationTimer( closedLoopControlName == $event.getClosedLoopControlName(), requestID == $event.getRequestID().toString() )
- $lock : TargetLock (requestID == $event.getRequestID())
- $response : LCMResponseWrapper( getBody().getCommonHeader().getRequestId() == $event.getRequestID() )
+ $manager : ControlLoopEventManager( closedLoopControlName == $event.getClosedLoopControlName(), requestID == $event.getRequestId() )
+ $operation : ControlLoopOperationManager( onset.closedLoopControlName == $event.getClosedLoopControlName(), onset.getRequestId() == $event.getRequestId() )
+ $opTimer : OperationTimer( closedLoopControlName == $event.getClosedLoopControlName(), requestID == $event.getRequestId().toString() )
+ $lock : TargetLock (requestID == $event.getRequestId())
+ $response : LcmResponseWrapper( getBody().get().getRequestId() == $event.getRequestId() )
then
Logger logger = LoggerFactory.getLogger(drools.getRule().getPackage());
@@ -900,8 +900,8 @@ end
rule "APPC.LCM.RESPONSE.CLEANUP"
when
$params : ControlLoopParams( $clName : getClosedLoopControlName() )
- $response : LCMResponseWrapper($id : getBody().getCommonHeader().getRequestId )
- not ( VirtualControlLoopEvent( requestID == $id, closedLoopEventStatus == ControlLoopEventStatus.ONSET ) )
+ $response : LcmResponseWrapper($id : getBody().get().getRequestId )
+ not ( VirtualControlLoopEvent( requestId == $id, closedLoopEventStatus == ControlLoopEventStatus.ONSET ) )
then
Logger logger = LoggerFactory.getLogger(drools.getRule().getPackage());
@@ -924,10 +924,10 @@ rule "SO.RESPONSE"
$params : ControlLoopParams( $clName : getClosedLoopControlName() )
$event : VirtualControlLoopEvent( closedLoopControlName == $clName, closedLoopEventStatus == ControlLoopEventStatus.ONSET )
$manager : ControlLoopEventManager( closedLoopControlName == $event.getClosedLoopControlName() )
- $operation : ControlLoopOperationManager( onset.closedLoopControlName == $event.getClosedLoopControlName(), onset.getRequestID() == $event.getRequestID() )
- $opTimer : OperationTimer( closedLoopControlName == $event.getClosedLoopControlName(), requestID == $event.getRequestID().toString() )
- $lock : TargetLock (requestID == $event.getRequestID())
- $response : SOResponseWrapper(requestID.toString() == $event.getRequestID().toString() )
+ $operation : ControlLoopOperationManager( onset.closedLoopControlName == $event.getClosedLoopControlName(), onset.getRequestId() == $event.getRequestId() )
+ $opTimer : OperationTimer( closedLoopControlName == $event.getClosedLoopControlName(), requestID == $event.getRequestId().toString() )
+ $lock : TargetLock (requestID == $event.getRequestId())
+ $response : SOResponseWrapper(requestID.toString() == $event.getRequestId().toString() )
then
Logger logger = LoggerFactory.getLogger(drools.getRule().getPackage());
@@ -1008,10 +1008,10 @@ rule "VFC.RESPONSE"
$params : ControlLoopParams( $clName : getClosedLoopControlName() )
$event : VirtualControlLoopEvent( closedLoopControlName == $clName, closedLoopEventStatus == ControlLoopEventStatus.ONSET )
$manager : ControlLoopEventManager( closedLoopControlName == $event.getClosedLoopControlName() )
- $operation : ControlLoopOperationManager( onset.closedLoopControlName == $event.getClosedLoopControlName(), onset.getRequestID() == $event.getRequestID() )
- $opTimer : OperationTimer( closedLoopControlName == $event.getClosedLoopControlName(), requestID == $event.getRequestID().toString() )
- $lock : TargetLock (requestID == $event.getRequestID())
- $response : VFCResponse( requestId.toString() == $event.getRequestID().toString() )
+ $operation : ControlLoopOperationManager( onset.closedLoopControlName == $event.getClosedLoopControlName(), onset.getRequestId() == $event.getRequestId() )
+ $opTimer : OperationTimer( closedLoopControlName == $event.getClosedLoopControlName(), requestID == $event.getRequestId().toString() )
+ $lock : TargetLock (requestID == $event.getRequestId())
+ $response : VFCResponse( requestId.toString() == $event.getRequestId().toString() )
then
Logger logger = LoggerFactory.getLogger(drools.getRule().getPackage());
logger.info("{}: {}", $clName, $params.getPolicyName() + "." + drools.getRule().getName());
@@ -1080,10 +1080,10 @@ rule "EVENT.MANAGER.OPERATION.TIMEOUT"
when
$params : ControlLoopParams( $clName : getClosedLoopControlName() )
$event : VirtualControlLoopEvent( closedLoopControlName == $clName )
- $manager : ControlLoopEventManager( closedLoopControlName == $event.getClosedLoopControlName(), requestID == $event.getRequestID() )
- $operation : ControlLoopOperationManager( onset.closedLoopControlName == $event.getClosedLoopControlName(), onset.getRequestID() == $event.getRequestID() )
- $opTimer : OperationTimer( closedLoopControlName == $event.getClosedLoopControlName(), requestID == $event.getRequestID().toString(), $to : getDelay() )
- $lock : TargetLock (requestID == $event.getRequestID())
+ $manager : ControlLoopEventManager( closedLoopControlName == $event.getClosedLoopControlName(), requestID == $event.getRequestId() )
+ $operation : ControlLoopOperationManager( onset.closedLoopControlName == $event.getClosedLoopControlName(), onset.getRequestId() == $event.getRequestId() )
+ $opTimer : OperationTimer( closedLoopControlName == $event.getClosedLoopControlName(), requestID == $event.getRequestId().toString(), $to : getDelay() )
+ $lock : TargetLock (requestID == $event.getRequestId())
then
Logger logger = LoggerFactory.getLogger(drools.getRule().getPackage());
@@ -1145,14 +1145,14 @@ rule "EVENT.MANAGER.TIMEOUT"
when
$params : ControlLoopParams( $clName : getClosedLoopControlName() )
$event : VirtualControlLoopEvent( closedLoopControlName == $clName )
- $manager : ControlLoopEventManager( closedLoopControlName == $event.getClosedLoopControlName(), requestID == $event.getRequestID() )
- $clTimer : ControlLoopTimer ( closedLoopControlName == $event.getClosedLoopControlName(), requestID == $event.getRequestID().toString(), $to : getDelay() )
+ $manager : ControlLoopEventManager( closedLoopControlName == $event.getClosedLoopControlName(), requestID == $event.getRequestId() )
+ $clTimer : ControlLoopTimer ( closedLoopControlName == $event.getClosedLoopControlName(), requestID == $event.getRequestId().toString(), $to : getDelay() )
$operations : LinkedList()
- from collect( ControlLoopOperationManager( onset.closedLoopControlName == $event.getClosedLoopControlName(), onset.getRequestID() == $event.getRequestID() ) )
+ from collect( ControlLoopOperationManager( onset.closedLoopControlName == $event.getClosedLoopControlName(), onset.getRequestId() == $event.getRequestId() ) )
$opTimers : LinkedList()
- from collect( OperationTimer( closedLoopControlName == $event.getClosedLoopControlName(), requestID == $event.getRequestID().toString() ) )
+ from collect( OperationTimer( closedLoopControlName == $event.getClosedLoopControlName(), requestID == $event.getRequestId().toString() ) )
$locks : LinkedList()
- from collect( TargetLock (requestID == $event.getRequestID()) )
+ from collect( TargetLock (requestID == $event.getRequestId()) )
then
Logger logger = LoggerFactory.getLogger(drools.getRule().getPackage());
diff --git a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/ControlLoopFailureTest.java b/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/ControlLoopFailureTest.java
index 826488691..686b3805f 100644
--- a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/ControlLoopFailureTest.java
+++ b/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/ControlLoopFailureTest.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* demo
* ================================================================================
- * 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.
@@ -20,7 +20,10 @@
package org.onap.policy.template.demo;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
import java.io.IOException;
import java.net.URLEncoder;
@@ -35,10 +38,10 @@ import org.junit.BeforeClass;
import org.junit.Test;
import org.kie.api.runtime.KieSession;
import org.kie.api.runtime.rule.FactHandle;
-import org.onap.policy.appclcm.LCMRequest;
-import org.onap.policy.appclcm.LCMRequestWrapper;
-import org.onap.policy.appclcm.LCMResponse;
-import org.onap.policy.appclcm.LCMResponseWrapper;
+import org.onap.policy.appclcm.LcmRequest;
+import org.onap.policy.appclcm.LcmRequestWrapper;
+import org.onap.policy.appclcm.LcmResponse;
+import org.onap.policy.appclcm.LcmResponseWrapper;
import org.onap.policy.controlloop.ControlLoopEventStatus;
import org.onap.policy.controlloop.ControlLoopNotificationType;
import org.onap.policy.controlloop.VirtualControlLoopEvent;
@@ -60,53 +63,59 @@ import org.slf4j.LoggerFactory;
public class ControlLoopFailureTest implements TopicListener {
private static final Logger logger = LoggerFactory.getLogger(VCPEControlLoopTest.class);
-
+
private static List<? extends TopicSink> noopTopics;
-
+
private static KieSession kieSession;
private static Util.Pair<ControlLoopPolicy, String> pair;
private UUID requestId;
private UUID requestId2;
private UUID requestId3;
private int eventCount;
-
+
static {
/* Set environment properties */
Util.setAAIProps();
Util.setGuardProps();
Util.setPUProp();
}
-
+
@BeforeClass
public static void setUpSimulator() {
PolicyEngine.manager.configure(new Properties());
assertTrue(PolicyEngine.manager.start());
Properties noopSinkProperties = new Properties();
noopSinkProperties.put(PolicyProperties.PROPERTY_NOOP_SINK_TOPICS, "APPC-LCM-READ,POLICY-CL-MGT");
- noopSinkProperties.put("noop.sink.topics.APPC-LCM-READ.events", "org.onap.policy.appclcm.LCMRequestWrapper");
- noopSinkProperties.put("noop.sink.topics.APPC-LCM-READ.events.custom.gson", "org.onap.policy.appclcm.util.Serialization,gson");
- noopSinkProperties.put("noop.sink.topics.POLICY-CL-MGT.events", "org.onap.policy.controlloop.VirtualControlLoopNotification");
- noopSinkProperties.put("noop.sink.topics.POLICY-CL-MGT.events.custom.gson", "org.onap.policy.controlloop.util.Serialization,gsonPretty");
+ noopSinkProperties.put("noop.sink.topics.APPC-LCM-READ.events", "org.onap.policy.appclcm.LcmRequestWrapper");
+ noopSinkProperties.put("noop.sink.topics.APPC-LCM-READ.events.custom.gson",
+ "org.onap.policy.appclcm.util.Serialization,gson");
+ noopSinkProperties.put("noop.sink.topics.POLICY-CL-MGT.events",
+ "org.onap.policy.controlloop.VirtualControlLoopNotification");
+ noopSinkProperties.put("noop.sink.topics.POLICY-CL-MGT.events.custom.gson",
+ "org.onap.policy.controlloop.util.Serialization,gsonPretty");
noopTopics = TopicEndpoint.manager.addTopicSinks(noopSinkProperties);
-
- EventProtocolCoder.manager.addEncoder("junit.groupId", "junit.artifactId", "POLICY-CL-MGT", "org.onap.policy.controlloop.VirtualControlLoopNotification", new JsonProtocolFilter(), null, null, 1111);
- EventProtocolCoder.manager.addEncoder("junit.groupId", "junit.artifactId", "APPC-LCM-READ", "org.onap.policy.appclcm.LCMRequestWrapper", new JsonProtocolFilter(), null, null, 1111);
+
+ EventProtocolCoder.manager.addEncoder("junit.groupId", "junit.artifactId", "POLICY-CL-MGT",
+ "org.onap.policy.controlloop.VirtualControlLoopNotification", new JsonProtocolFilter(), null, null,
+ 1111);
+ EventProtocolCoder.manager.addEncoder("junit.groupId", "junit.artifactId", "APPC-LCM-READ",
+ "org.onap.policy.appclcm.LcmRequestWrapper", new JsonProtocolFilter(), null, null, 1111);
try {
Util.buildAaiSim();
Util.buildGuardSim();
} catch (Exception e) {
fail(e.getMessage());
}
-
+
/*
* Start the kie session
*/
try {
- kieSession = startSession("../archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/resources/__closedLoopControlName__.drl",
- "src/test/resources/yaml/policy_ControlLoop_vCPE.yaml",
- "service=ServiceDemo;resource=Res1Demo;type=operational",
- "CL_vCPE",
- "org.onap.closed_loop.ServiceDemo:VNFS:1.0.0");
+ kieSession = startSession(
+ "../archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/resources/__closedLoopControlName__.drl",
+ "src/test/resources/yaml/policy_ControlLoop_vCPE.yaml",
+ "service=ServiceDemo;resource=Res1Demo;type=operational", "CL_vCPE",
+ "org.onap.closed_loop.ServiceDemo:VNFS:1.0.0");
} catch (IOException e) {
e.printStackTrace();
logger.debug("Could not create kieSession");
@@ -116,111 +125,96 @@ public class ControlLoopFailureTest implements TopicListener {
@AfterClass
public static void tearDownSimulator() {
- /*
+ /*
* Gracefully shut down the kie session
*/
kieSession.dispose();
-
+
PolicyEngine.manager.stop();
HttpServletServer.factory.destroy();
PolicyController.factory.shutdown();
TopicEndpoint.manager.shutdown();
}
-
+
/**
- * This test case tests the scenario where 3 events occur
- * and 2 of the requests refer to the same target entity
- * while the 3rd is for another entity. The expected result
- * is that the event with the duplicate target entity will have
- * a final success result for one of the events, and a rejected
- * message for the one that was unable to obtain the lock. The
- * event that is referring to a different target entity should
- * be able to obtain a lock since it is a different target. After
- * processing of all events there should only be the params object
- * left in memory.
+ * This test case tests the scenario where 3 events occur and 2 of the requests refer to the
+ * same target entity while the 3rd is for another entity. The expected result is that the event
+ * with the duplicate target entity will have a final success result for one of the events, and
+ * a rejected message for the one that was unable to obtain the lock. The event that is
+ * referring to a different target entity should be able to obtain a lock since it is a
+ * different target. After processing of all events there should only be the params object left
+ * in memory.
*/
@Test
public void targetLockedTest() {
-
+
/*
- * Allows the PolicyEngine to callback to this object to
- * notify that there is an event ready to be pulled
- * from the queue
+ * Allows the PolicyEngine to callback to this object to notify that there is an event ready
+ * to be pulled from the queue
*/
for (TopicSink sink : noopTopics) {
assertTrue(sink.start());
sink.register(this);
}
-
+
/*
* Create a unique requestId
*/
requestId = UUID.randomUUID();
-
+
/*
* This will be a unique request for another target entity
*/
requestId2 = UUID.randomUUID();
-
+
/*
- * This will be a request duplicating the target entity
- * of the first request
+ * This will be a request duplicating the target entity of the first request
*/
requestId3 = UUID.randomUUID();
-
- /*
- * Simulate an onset event the policy engine will
- * receive from DCAE to kick off processing through
- * the rules
+
+ /*
+ * Simulate an onset event the policy engine will receive from DCAE to kick off processing
+ * through the rules
*/
sendEvent(pair.a, requestId, ControlLoopEventStatus.ONSET, "vnf01");
-
+
/*
* Send a second event requesting an action for a different target entity
*/
sendEvent(pair.a, requestId2, ControlLoopEventStatus.ONSET, "vnf02");
/*
- * Send a second event for a different target to ensure there
- * are no problems with obtaining a lock for a different
+ * Send a second event for a different target to ensure there are no problems with obtaining
+ * a lock for a different
*/
kieSession.fireUntilHalt();
-
+
/*
* The only fact in memory should be Params
*/
assertEquals(1, kieSession.getFactCount());
-
+
/*
* Print what's left in memory
*/
dumpFacts(kieSession);
-
+
}
/**
- * This method will start a kie session and instantiate
- * the Policy Engine.
+ * This method will start a kie session and instantiate the Policy Engine.
*
- * @param droolsTemplate
- * the DRL rules file
- * @param yamlFile
- * the yaml file containing the policies
- * @param policyScope
- * scope for policy
- * @param policyName
- * name of the policy
- * @param policyVersion
- * version of the policy
- * @return the kieSession to be used to insert facts
+ * @param droolsTemplate the DRL rules file
+ * @param yamlFile the yaml file containing the policies
+ * @param policyScope scope for policy
+ * @param policyName name of the policy
+ * @param policyVersion version of the policy
+ * @return the kieSession to be used to insert facts
* @throws IOException
*/
- private static KieSession startSession(String droolsTemplate,
- String yamlFile,
- String policyScope,
- String policyName,
- String policyVersion) throws IOException {
-
+ private static KieSession startSession(String droolsTemplate, String yamlFile, String policyScope,
+ String policyName, String policyVersion) throws IOException {
+
/*
* Load policies from yaml
*/
@@ -230,43 +224,43 @@ public class ControlLoopFailureTest implements TopicListener {
assertNotNull(pair.a.getControlLoop());
assertNotNull(pair.a.getControlLoop().getControlLoopName());
assertTrue(pair.a.getControlLoop().getControlLoopName().length() > 0);
-
- /*
+
+ /*
* Construct a kie session
*/
- final KieSession kieSession = Util.buildContainer(droolsTemplate,
- pair.a.getControlLoop().getControlLoopName(),
- policyScope,
- policyName,
- policyVersion,
- URLEncoder.encode(pair.b, "UTF-8"));
-
+ final KieSession kieSession = Util.buildContainer(droolsTemplate, pair.a.getControlLoop().getControlLoopName(),
+ policyScope, policyName, policyVersion, URLEncoder.encode(pair.b, "UTF-8"));
+
/*
* Retrieve the Policy Engine
*/
-
+
logger.debug("============");
logger.debug(URLEncoder.encode(pair.b, "UTF-8"));
logger.debug("============");
-
+
return kieSession;
}
-
+
/*
* (non-Javadoc)
+ *
* @see org.onap.policy.drools.PolicyEngineListener#newEventNotification(java.lang.String)
*/
+ @Override
public void onTopicEvent(CommInfrastructure commType, String topic, String event) {
/*
- * Pull the object that was sent out to DMAAP and make
- * sure it is a ControlLoopNoticiation of type active
+ * Pull the object that was sent out to DMAAP and make sure it is a ControlLoopNoticiation
+ * of type active
*/
Object obj = null;
if ("POLICY-CL-MGT".equals(topic)) {
- obj = org.onap.policy.controlloop.util.Serialization.gsonJunit.fromJson(event, org.onap.policy.controlloop.VirtualControlLoopNotification.class);
+ obj = org.onap.policy.controlloop.util.Serialization.gsonJunit.fromJson(event,
+ org.onap.policy.controlloop.VirtualControlLoopNotification.class);
+ } else if ("APPC-LCM-READ".equals(topic)) {
+ obj = org.onap.policy.appclcm.util.Serialization.gsonJunit.fromJson(event,
+ org.onap.policy.appclcm.LcmRequestWrapper.class);
}
- else if ("APPC-LCM-READ".equals(topic))
- obj = org.onap.policy.appclcm.util.Serialization.gsonJunit.fromJson(event, org.onap.policy.appclcm.LCMRequestWrapper.class);
assertNotNull(obj);
if (obj instanceof VirtualControlLoopNotification) {
VirtualControlLoopNotification notification = (VirtualControlLoopNotification) obj;
@@ -274,120 +268,106 @@ public class ControlLoopFailureTest implements TopicListener {
if (policyName.endsWith("EVENT")) {
logger.debug("Rule Fired: " + notification.getPolicyName());
assertTrue(ControlLoopNotificationType.ACTIVE.equals(notification.getNotification()));
- }
- else if (policyName.endsWith("GUARD_NOT_YET_QUERIED")) {
+ } else if (policyName.endsWith("GUARD_NOT_YET_QUERIED")) {
logger.debug("Rule Fired: " + notification.getPolicyName());
assertTrue(ControlLoopNotificationType.OPERATION.equals(notification.getNotification()));
assertNotNull(notification.getMessage());
assertTrue(notification.getMessage().startsWith("Sending guard query"));
- }
- else if (policyName.endsWith("GUARD.RESPONSE")) {
+ } else if (policyName.endsWith("GUARD.RESPONSE")) {
logger.debug("Rule Fired: " + notification.getPolicyName());
assertTrue(ControlLoopNotificationType.OPERATION.equals(notification.getNotification()));
assertNotNull(notification.getMessage());
assertTrue(notification.getMessage().toLowerCase().endsWith("permit"));
- }
- else if (policyName.endsWith("GUARD_PERMITTED")) {
+ } else if (policyName.endsWith("GUARD_PERMITTED")) {
logger.debug("Rule Fired: " + notification.getPolicyName());
assertTrue(ControlLoopNotificationType.OPERATION.equals(notification.getNotification()));
assertNotNull(notification.getMessage());
assertTrue(notification.getMessage().startsWith("actor=APPC"));
- }
- else if (policyName.endsWith("OPERATION.TIMEOUT")) {
+ } else if (policyName.endsWith("OPERATION.TIMEOUT")) {
logger.debug("Rule Fired: " + notification.getPolicyName());
kieSession.halt();
logger.debug("The operation timed out");
fail("Operation Timed Out");
- }
- else if (policyName.endsWith("APPC.LCM.RESPONSE")) {
+ } else if (policyName.endsWith("APPC.LCM.RESPONSE")) {
logger.debug("Rule Fired: " + notification.getPolicyName());
assertTrue(ControlLoopNotificationType.OPERATION_SUCCESS.equals(notification.getNotification()));
assertNotNull(notification.getMessage());
assertTrue(notification.getMessage().startsWith("actor=APPC"));
- if (requestId.equals(notification.getRequestID())) {
+ if (requestId.equals(notification.getRequestId())) {
sendEvent(pair.a, requestId, ControlLoopEventStatus.ABATED, "vnf01");
- }
- else if (requestId2.equals(notification.getRequestID())) {
+ } else if (requestId2.equals(notification.getRequestId())) {
sendEvent(pair.a, requestId2, ControlLoopEventStatus.ABATED, "vnf02");
}
- }
- else if (policyName.endsWith("EVENT.MANAGER")) {
+ } else if (policyName.endsWith("EVENT.MANAGER")) {
logger.debug("Rule Fired: " + notification.getPolicyName());
- if (requestId3.equals(notification.getRequestID())) {
+ if (requestId3.equals(notification.getRequestId())) {
/*
* The event with the duplicate target should be rejected
*/
assertTrue(ControlLoopNotificationType.REJECTED.equals(notification.getNotification()));
- }
- else {
+ } else {
assertTrue(ControlLoopNotificationType.FINAL_SUCCESS.equals(notification.getNotification()));
}
if (++eventCount == 3) {
kieSession.halt();
}
- }
- else if (policyName.endsWith("EVENT.MANAGER.TIMEOUT")) {
+ } else if (policyName.endsWith("EVENT.MANAGER.TIMEOUT")) {
logger.debug("Rule Fired: " + notification.getPolicyName());
kieSession.halt();
logger.debug("The control loop timed out");
fail("Control Loop Timed Out");
}
- }
- else if (obj instanceof LCMRequestWrapper) {
+ } else if (obj instanceof LcmRequestWrapper) {
/*
- * The request should be of type LCMRequestWrapper
- * and the subrequestid should be 1
+ * The request should be of type LCMRequestWrapper and the subrequestid should be 1
*/
- LCMRequestWrapper dmaapRequest = (LCMRequestWrapper) obj;
- LCMRequest appcRequest = dmaapRequest.getBody();
+ LcmRequestWrapper dmaapRequest = (LcmRequestWrapper) obj;
+ LcmRequest appcRequest = dmaapRequest.getBody();
assertTrue(appcRequest.getCommonHeader().getSubRequestId().equals("1"));
-
+
logger.debug("\n============ APPC received the request!!! ===========\n");
-
+
/*
- * Simulate a success response from APPC and insert
- * the response into the working memory
+ * Simulate a success response from APPC and insert the response into the working memory
*/
- LCMResponseWrapper dmaapResponse = new LCMResponseWrapper();
- LCMResponse appcResponse = new LCMResponse(appcRequest);
+ LcmResponseWrapper dmaapResponse = new LcmResponseWrapper();
+ LcmResponse appcResponse = new LcmResponse(appcRequest);
appcResponse.getStatus().setCode(400);
appcResponse.getStatus().setMessage("AppC success");
dmaapResponse.setBody(appcResponse);
-
+
/*
- * Interrupting with a different request for the same
- * target entity to check if lock will be denied
+ * Interrupting with a different request for the same target entity to check if lock
+ * will be denied
*/
if (requestId.equals(appcResponse.getCommonHeader().getRequestId())) {
sendEvent(pair.a, requestId3, ControlLoopEventStatus.ONSET, "vnf01");
}
kieSession.insert(dmaapResponse);
- }
+ }
}
-
+
/**
- * This method is used to simulate event messages from DCAE
- * that start the control loop (onset message) or end the
- * control loop (abatement message).
+ * This method is used to simulate event messages from DCAE that start the control loop (onset
+ * message) or end the control loop (abatement message).
*
- * @param policy the controlLoopName comes from the policy
+ * @param policy the controlLoopName comes from the policy
* @param requestID the requestId for this event
* @param status could be onset or abated
* @param target, the target entity to take an action on
*/
- protected void sendEvent(ControlLoopPolicy policy, UUID requestID,
- ControlLoopEventStatus status, String target) {
+ protected void sendEvent(ControlLoopPolicy policy, UUID requestID, ControlLoopEventStatus status, String target) {
VirtualControlLoopEvent event = new VirtualControlLoopEvent();
event.setClosedLoopControlName(policy.getControlLoop().getControlLoopName());
- event.setRequestID(requestID);
+ event.setRequestId(requestID);
event.setTarget("generic-vnf.vnf-id");
event.setClosedLoopAlarmStart(Instant.now());
- event.setAAI(new HashMap<>());
- event.getAAI().put("generic-vnf.vnf-id", target);
+ event.setAai(new HashMap<>());
+ event.getAai().put("generic-vnf.vnf-id", target);
event.setClosedLoopEventStatus(status);
kieSession.insert(event);
}
-
+
/**
* This method will dump all the facts in the working memory.
*
@@ -399,6 +379,6 @@ public class ControlLoopFailureTest implements TopicListener {
logger.debug("FACT: {}", handle);
}
}
-
+
}
diff --git a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VCPEControlLoopTest.java b/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VCPEControlLoopTest.java
index 4a755bffa..9c3410fcb 100644
--- a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VCPEControlLoopTest.java
+++ b/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VCPEControlLoopTest.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* demo
* ================================================================================
- * 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.
@@ -20,7 +20,10 @@
package org.onap.policy.template.demo;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
import java.io.IOException;
import java.net.URLEncoder;
@@ -35,10 +38,10 @@ import org.junit.BeforeClass;
import org.junit.Test;
import org.kie.api.runtime.KieSession;
import org.kie.api.runtime.rule.FactHandle;
-import org.onap.policy.appclcm.LCMRequest;
-import org.onap.policy.appclcm.LCMRequestWrapper;
-import org.onap.policy.appclcm.LCMResponse;
-import org.onap.policy.appclcm.LCMResponseWrapper;
+import org.onap.policy.appclcm.LcmRequest;
+import org.onap.policy.appclcm.LcmRequestWrapper;
+import org.onap.policy.appclcm.LcmResponse;
+import org.onap.policy.appclcm.LcmResponseWrapper;
import org.onap.policy.controlloop.ControlLoopEventStatus;
import org.onap.policy.controlloop.ControlLoopNotificationType;
import org.onap.policy.controlloop.ControlLoopTargetType;
@@ -62,35 +65,41 @@ import org.slf4j.LoggerFactory;
public class VCPEControlLoopTest implements TopicListener {
private static final Logger logger = LoggerFactory.getLogger(VCPEControlLoopTest.class);
-
+
private static List<? extends TopicSink> noopTopics;
-
+
private static KieSession kieSession;
private static Util.Pair<ControlLoopPolicy, String> pair;
private UUID requestID;
-
+
static {
/* Set environment properties */
Util.setAAIProps();
Util.setGuardProps();
Util.setPUProp();
- LoggerUtil.setLevel(LoggerUtil.ROOT_LOGGER, "INFO");
+ LoggerUtil.setLevel(LoggerUtil.ROOT_LOGGER, "INFO");
}
-
+
@BeforeClass
public static void setUpSimulator() {
- PolicyEngine.manager.configure(new Properties());
- assertTrue(PolicyEngine.manager.start());
- Properties noopSinkProperties = new Properties();
- noopSinkProperties.put(PolicyProperties.PROPERTY_NOOP_SINK_TOPICS, "APPC-LCM-READ,POLICY-CL-MGT");
- noopSinkProperties.put("noop.sink.topics.APPC-LCM-READ.events", "org.onap.policy.appclcm.LCMRequestWrapper");
- noopSinkProperties.put("noop.sink.topics.APPC-LCM-READ.events.custom.gson", "org.onap.policy.appclcm.util.Serialization,gson");
- noopSinkProperties.put("noop.sink.topics.POLICY-CL-MGT.events", "org.onap.policy.controlloop.VirtualControlLoopNotification");
- noopSinkProperties.put("noop.sink.topics.POLICY-CL-MGT.events.custom.gson", "org.onap.policy.controlloop.util.Serialization,gsonPretty");
- noopTopics = TopicEndpoint.manager.addTopicSinks(noopSinkProperties);
-
- EventProtocolCoder.manager.addEncoder("junit.groupId", "junit.artifactId", "POLICY-CL-MGT", "org.onap.policy.controlloop.VirtualControlLoopNotification", new JsonProtocolFilter(), null, null, 1111);
- EventProtocolCoder.manager.addEncoder("junit.groupId", "junit.artifactId", "APPC-LCM-READ", "org.onap.policy.appclcm.LCMRequestWrapper", new JsonProtocolFilter(), null, null, 1111);
+ PolicyEngine.manager.configure(new Properties());
+ assertTrue(PolicyEngine.manager.start());
+ Properties noopSinkProperties = new Properties();
+ noopSinkProperties.put(PolicyProperties.PROPERTY_NOOP_SINK_TOPICS, "APPC-LCM-READ,POLICY-CL-MGT");
+ noopSinkProperties.put("noop.sink.topics.APPC-LCM-READ.events", "org.onap.policy.appclcm.LcmRequestWrapper");
+ noopSinkProperties.put("noop.sink.topics.APPC-LCM-READ.events.custom.gson",
+ "org.onap.policy.appclcm.util.Serialization,gson");
+ noopSinkProperties.put("noop.sink.topics.POLICY-CL-MGT.events",
+ "org.onap.policy.controlloop.VirtualControlLoopNotification");
+ noopSinkProperties.put("noop.sink.topics.POLICY-CL-MGT.events.custom.gson",
+ "org.onap.policy.controlloop.util.Serialization,gsonPretty");
+ noopTopics = TopicEndpoint.manager.addTopicSinks(noopSinkProperties);
+
+ EventProtocolCoder.manager.addEncoder("junit.groupId", "junit.artifactId", "POLICY-CL-MGT",
+ "org.onap.policy.controlloop.VirtualControlLoopNotification", new JsonProtocolFilter(), null, null,
+ 1111);
+ EventProtocolCoder.manager.addEncoder("junit.groupId", "junit.artifactId", "APPC-LCM-READ",
+ "org.onap.policy.appclcm.LcmRequestWrapper", new JsonProtocolFilter(), null, null, 1111);
try {
Util.buildAaiSim();
Util.buildGuardSim();
@@ -101,11 +110,11 @@ public class VCPEControlLoopTest implements TopicListener {
* Start the kie session
*/
try {
- kieSession = startSession("../archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/resources/__closedLoopControlName__.drl",
- "src/test/resources/yaml/policy_ControlLoop_vCPE.yaml",
- "service=ServiceDemo;resource=Res1Demo;type=operational",
- "CL_vCPE",
- "org.onap.closed_loop.ServiceDemo:VNFS:1.0.0");
+ kieSession = startSession(
+ "../archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/resources/__closedLoopControlName__.drl",
+ "src/test/resources/yaml/policy_ControlLoop_vCPE.yaml",
+ "service=ServiceDemo;resource=Res1Demo;type=operational", "CL_vCPE",
+ "org.onap.closed_loop.ServiceDemo:VNFS:1.0.0");
} catch (IOException e) {
e.printStackTrace();
logger.debug("Could not create kieSession");
@@ -119,114 +128,101 @@ public class VCPEControlLoopTest implements TopicListener {
* Gracefully shut down the kie session
*/
kieSession.dispose();
-
+
PolicyEngine.manager.stop();
HttpServletServer.factory.destroy();
PolicyController.factory.shutdown();
TopicEndpoint.manager.shutdown();
}
-
+
@Test
public void successTest() {
-
+
/*
- * Allows the PolicyEngine to callback to this object to
- * notify that there is an event ready to be pulled
- * from the queue
+ * Allows the PolicyEngine to callback to this object to notify that there is an event ready
+ * to be pulled from the queue
*/
for (TopicSink sink : noopTopics) {
assertTrue(sink.start());
sink.register(this);
}
-
+
/*
* Create a unique requestId
*/
requestID = UUID.randomUUID();
-
- /*
- * Simulate an onset event the policy engine will
- * receive from DCAE to kick off processing through
- * the rules
+
+ /*
+ * Simulate an onset event the policy engine will receive from DCAE to kick off processing
+ * through the rules
*/
sendEvent(pair.a, requestID, ControlLoopEventStatus.ONSET, "vCPEInfraVNF13", true);
-
+
kieSession.fireUntilHalt();
-
+
/*
* The only fact in memory should be Params
*/
assertEquals(1, kieSession.getFactCount());
-
+
/*
* Print what's left in memory
*/
dumpFacts(kieSession);
}
-
+
@Test
public void aaiGetFailTest() {
-
+
/*
- * Allows the PolicyEngine to callback to this object to
- * notify that there is an event ready to be pulled
- * from the queue
+ * Allows the PolicyEngine to callback to this object to notify that there is an event ready
+ * to be pulled from the queue
*/
for (TopicSink sink : noopTopics) {
assertTrue(sink.start());
sink.register(this);
}
-
+
/*
* Create a unique requestId
*/
requestID = UUID.randomUUID();
-
- /*
- * Simulate an onset event the policy engine will
- * receive from DCAE to kick off processing through
- * the rules
+
+ /*
+ * Simulate an onset event the policy engine will receive from DCAE to kick off processing
+ * through the rules
*/
sendEvent(pair.a, requestID, ControlLoopEventStatus.ONSET, "getFail", false);
-
+
kieSession.fireUntilHalt();
-
+
/*
* The only fact in memory should be Params
*/
assertEquals(1, kieSession.getFactCount());
-
+
/*
* Print what's left in memory
*/
dumpFacts(kieSession);
-
+
}
/**
- * This method will start a kie session and instantiate
- * the Policy Engine.
+ * This method will start a kie session and instantiate the Policy Engine.
*
- * @param droolsTemplate
- * the DRL rules file
- * @param yamlFile
- * the yaml file containing the policies
- * @param policyScope
- * scope for policy
- * @param policyName
- * name of the policy
- * @param policyVersion
- * version of the policy
- * @return the kieSession to be used to insert facts
+ * @param droolsTemplate the DRL rules file
+ * @param yamlFile the yaml file containing the policies
+ * @param policyScope scope for policy
+ * @param policyName name of the policy
+ * @param policyVersion version of the policy
+ * @return the kieSession to be used to insert facts
* @throws IOException
*/
- private static KieSession startSession(String droolsTemplate,
- String yamlFile,
- String policyScope,
- String policyName,
- String policyVersion) throws IOException {
-
+ private static KieSession startSession(String droolsTemplate, String yamlFile, String policyScope,
+ String policyName, String policyVersion) throws IOException {
+
/*
* Load policies from yaml
*/
@@ -236,43 +232,43 @@ public class VCPEControlLoopTest implements TopicListener {
assertNotNull(pair.a.getControlLoop());
assertNotNull(pair.a.getControlLoop().getControlLoopName());
assertTrue(pair.a.getControlLoop().getControlLoopName().length() > 0);
-
- /*
+
+ /*
* Construct a kie session
*/
- final KieSession kieSession = Util.buildContainer(droolsTemplate,
- pair.a.getControlLoop().getControlLoopName(),
- policyScope,
- policyName,
- policyVersion,
- URLEncoder.encode(pair.b, "UTF-8"));
-
+ final KieSession kieSession = Util.buildContainer(droolsTemplate, pair.a.getControlLoop().getControlLoopName(),
+ policyScope, policyName, policyVersion, URLEncoder.encode(pair.b, "UTF-8"));
+
/*
* Retrieve the Policy Engine
*/
-
+
logger.debug("============");
logger.debug(URLEncoder.encode(pair.b, "UTF-8"));
logger.debug("============");
-
+
return kieSession;
}
-
+
/*
* (non-Javadoc)
+ *
* @see org.onap.policy.drools.PolicyEngineListener#newEventNotification(java.lang.String)
*/
+ @Override
public void onTopicEvent(CommInfrastructure commType, String topic, String event) {
/*
- * Pull the object that was sent out to DMAAP and make
- * sure it is a ControlLoopNoticiation of type active
+ * Pull the object that was sent out to DMAAP and make sure it is a ControlLoopNoticiation
+ * of type active
*/
Object obj = null;
if ("POLICY-CL-MGT".equals(topic)) {
- obj = org.onap.policy.controlloop.util.Serialization.gsonJunit.fromJson(event, org.onap.policy.controlloop.VirtualControlLoopNotification.class);
- }
- else if ("APPC-LCM-READ".equals(topic))
- obj = org.onap.policy.appclcm.util.Serialization.gsonJunit.fromJson(event, org.onap.policy.appclcm.LCMRequestWrapper.class);
+ obj = org.onap.policy.controlloop.util.Serialization.gsonJunit.fromJson(event,
+ org.onap.policy.controlloop.VirtualControlLoopNotification.class);
+ } else if ("APPC-LCM-READ".equals(topic)) {
+ obj = org.onap.policy.appclcm.util.Serialization.gsonJunit.fromJson(event,
+ org.onap.policy.appclcm.LcmRequestWrapper.class);
+ }
assertNotNull(obj);
if (obj instanceof VirtualControlLoopNotification) {
VirtualControlLoopNotification notification = (VirtualControlLoopNotification) obj;
@@ -280,126 +276,114 @@ public class VCPEControlLoopTest implements TopicListener {
if (policyName.endsWith("EVENT")) {
logger.debug("Rule Fired: " + notification.getPolicyName());
assertTrue(ControlLoopNotificationType.ACTIVE.equals(notification.getNotification()));
- }
- else if (policyName.endsWith("GUARD_NOT_YET_QUERIED")) {
+ } else if (policyName.endsWith("GUARD_NOT_YET_QUERIED")) {
logger.debug("Rule Fired: " + notification.getPolicyName());
assertTrue(ControlLoopNotificationType.OPERATION.equals(notification.getNotification()));
assertNotNull(notification.getMessage());
assertTrue(notification.getMessage().startsWith("Sending guard query"));
- }
- else if (policyName.endsWith("GUARD.RESPONSE")) {
+ } else if (policyName.endsWith("GUARD.RESPONSE")) {
logger.debug("Rule Fired: " + notification.getPolicyName());
assertTrue(ControlLoopNotificationType.OPERATION.equals(notification.getNotification()));
assertNotNull(notification.getMessage());
assertTrue(notification.getMessage().toLowerCase().endsWith("permit"));
- }
- else if (policyName.endsWith("GUARD_PERMITTED")) {
+ } else if (policyName.endsWith("GUARD_PERMITTED")) {
logger.debug("Rule Fired: " + notification.getPolicyName());
assertTrue(ControlLoopNotificationType.OPERATION.equals(notification.getNotification()));
assertNotNull(notification.getMessage());
assertTrue(notification.getMessage().startsWith("actor=APPC"));
- }
- else if (policyName.endsWith("OPERATION.TIMEOUT")) {
+ } else if (policyName.endsWith("OPERATION.TIMEOUT")) {
logger.debug("Rule Fired: " + notification.getPolicyName());
kieSession.halt();
logger.debug("The operation timed out");
fail("Operation Timed Out");
- }
- else if (policyName.endsWith("APPC.LCM.RESPONSE")) {
+ } else if (policyName.endsWith("APPC.LCM.RESPONSE")) {
logger.debug("Rule Fired: " + notification.getPolicyName());
assertTrue(ControlLoopNotificationType.OPERATION_SUCCESS.equals(notification.getNotification()));
assertNotNull(notification.getMessage());
assertTrue(notification.getMessage().startsWith("actor=APPC"));
sendEvent(pair.a, requestID, ControlLoopEventStatus.ABATED);
- }
- else if (policyName.endsWith("EVENT.MANAGER")) {
+ } else if (policyName.endsWith("EVENT.MANAGER")) {
logger.debug("Rule Fired: " + notification.getPolicyName());
- if ("getFail".equals(notification.getAAI().get("generic-vnf.vnf-name"))) {
+ if ("getFail".equals(notification.getAai().get("generic-vnf.vnf-name"))) {
assertEquals(ControlLoopNotificationType.FINAL_FAILURE, notification.getNotification());
kieSession.halt();
- }
- else {
+ } else {
assertEquals(ControlLoopNotificationType.FINAL_SUCCESS, notification.getNotification());
kieSession.halt();
}
- }
- else if (policyName.endsWith("EVENT.MANAGER.TIMEOUT")) {
+ } else if (policyName.endsWith("EVENT.MANAGER.TIMEOUT")) {
logger.debug("Rule Fired: " + notification.getPolicyName());
kieSession.halt();
logger.debug("The control loop timed out");
fail("Control Loop Timed Out");
}
- }
- else if (obj instanceof LCMRequestWrapper) {
+ } else if (obj instanceof LcmRequestWrapper) {
/*
- * The request should be of type LCMRequestWrapper
- * and the subrequestid should be 1
+ * The request should be of type LcmRequestWrapper and the subrequestid should be 1
*/
- LCMRequestWrapper dmaapRequest = (LCMRequestWrapper) obj;
- LCMRequest appcRequest = dmaapRequest.getBody();
+ LcmRequestWrapper dmaapRequest = (LcmRequestWrapper) obj;
+ LcmRequest appcRequest = dmaapRequest.getBody();
assertTrue(appcRequest.getCommonHeader().getSubRequestId().equals("1"));
assertNotNull(appcRequest.getActionIdentifiers().get("vnf-id"));
-
+
logger.debug("\n============ APPC received the request!!! ===========\n");
-
+
/*
- * Simulate a success response from APPC and insert
- * the response into the working memory
+ * Simulate a success response from APPC and insert the response into the working memory
*/
- LCMResponseWrapper dmaapResponse = new LCMResponseWrapper();
- LCMResponse appcResponse = new LCMResponse(appcRequest);
+ LcmResponseWrapper dmaapResponse = new LcmResponseWrapper();
+ LcmResponse appcResponse = new LcmResponse(appcRequest);
appcResponse.getStatus().setCode(400);
appcResponse.getStatus().setMessage("AppC success");
dmaapResponse.setBody(appcResponse);
kieSession.insert(dmaapResponse);
- }
+ }
}
-
+
/**
- * This method is used to simulate event messages from DCAE
- * that start the control loop (onset message) or end the
- * control loop (abatement message).
+ * This method is used to simulate event messages from DCAE that start the control loop (onset
+ * message) or end the control loop (abatement message).
*
- * @param policy the controlLoopName comes from the policy
+ * @param policy the controlLoopName comes from the policy
* @param requestID the requestId for this event
* @param status could be onset or abated
*/
protected void sendEvent(ControlLoopPolicy policy, UUID requestID, ControlLoopEventStatus status) {
VirtualControlLoopEvent event = new VirtualControlLoopEvent();
event.setClosedLoopControlName(policy.getControlLoop().getControlLoopName());
- event.setRequestID(requestID);
+ event.setRequestId(requestID);
event.setTarget("generic-vnf.vnf-name");
event.setClosedLoopAlarmStart(Instant.now());
- event.setAAI(new HashMap<>());
- event.getAAI().put("generic-vnf.vnf-name", "testGenericVnfName");
+ event.setAai(new HashMap<>());
+ event.getAai().put("generic-vnf.vnf-name", "testGenericVnfName");
event.setClosedLoopEventStatus(status);
kieSession.insert(event);
}
-
- protected void sendEvent(ControlLoopPolicy policy, UUID requestID,
- ControlLoopEventStatus status, String vnfName, boolean isEnriched) {
+
+ protected void sendEvent(ControlLoopPolicy policy, UUID requestID, ControlLoopEventStatus status, String vnfName,
+ boolean isEnriched) {
VirtualControlLoopEvent event = new VirtualControlLoopEvent();
event.setClosedLoopControlName(policy.getControlLoop().getControlLoopName());
- event.setRequestID(requestID);
+ event.setRequestId(requestID);
event.setTarget("generic-vnf.vnf-name");
event.setTargetType(ControlLoopTargetType.VNF);
event.setClosedLoopAlarmStart(Instant.now());
- event.setAAI(new HashMap<>());
- event.getAAI().put("generic-vnf.vnf-name", vnfName);
+ event.setAai(new HashMap<>());
+ event.getAai().put("generic-vnf.vnf-name", vnfName);
if (isEnriched) {
- event.getAAI().put("generic-vnf.in-maint", "false");
- event.getAAI().put("generic-vnf.is-closed-loop-disabled", "false");
- event.getAAI().put("generic-vnf.orchestration-status", "Created");
- event.getAAI().put("generic-vnf.prov-status", "PREPROV");
- event.getAAI().put("generic-vnf.resource-version", "1");
- event.getAAI().put("generic-vnf.service-id", "e8cb8968-5411-478b-906a-f28747de72cd");
- event.getAAI().put("generic-vnf.vnf-id", "63b31229-9a3a-444f-9159-04ce2dca3be9");
- event.getAAI().put("generic-vnf.vnf-type", "vCPEInfraService10/vCPEInfraService10 0");
+ event.getAai().put("generic-vnf.in-maint", "false");
+ event.getAai().put("generic-vnf.is-closed-loop-disabled", "false");
+ event.getAai().put("generic-vnf.orchestration-status", "Created");
+ event.getAai().put("generic-vnf.prov-status", "PREPROV");
+ event.getAai().put("generic-vnf.resource-version", "1");
+ event.getAai().put("generic-vnf.service-id", "e8cb8968-5411-478b-906a-f28747de72cd");
+ event.getAai().put("generic-vnf.vnf-id", "63b31229-9a3a-444f-9159-04ce2dca3be9");
+ event.getAai().put("generic-vnf.vnf-type", "vCPEInfraService10/vCPEInfraService10 0");
}
event.setClosedLoopEventStatus(status);
kieSession.insert(event);
}
-
+
/**
* This method will dump all the facts in the working memory.
*
@@ -411,5 +395,5 @@ public class VCPEControlLoopTest implements TopicListener {
logger.debug("FACT: {}", handle);
}
}
-
+
}
diff --git a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VDNSControlLoopTest.java b/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VDNSControlLoopTest.java
index c8a8c700f..493316915 100644
--- a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VDNSControlLoopTest.java
+++ b/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VDNSControlLoopTest.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* demo
* ================================================================================
- * 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.
@@ -43,10 +43,10 @@ import org.onap.policy.controlloop.ControlLoopNotificationType;
import org.onap.policy.controlloop.VirtualControlLoopEvent;
import org.onap.policy.controlloop.VirtualControlLoopNotification;
import org.onap.policy.controlloop.policy.ControlLoopPolicy;
+import org.onap.policy.drools.event.comm.Topic.CommInfrastructure;
import org.onap.policy.drools.event.comm.TopicEndpoint;
import org.onap.policy.drools.event.comm.TopicListener;
import org.onap.policy.drools.event.comm.TopicSink;
-import org.onap.policy.drools.event.comm.Topic.CommInfrastructure;
import org.onap.policy.drools.http.server.HttpServletServer;
import org.onap.policy.drools.properties.PolicyProperties;
import org.onap.policy.drools.protocol.coders.EventProtocolCoder;
@@ -61,217 +61,203 @@ import org.slf4j.LoggerFactory;
public class VDNSControlLoopTest implements TopicListener {
private static final Logger logger = LoggerFactory.getLogger(VDNSControlLoopTest.class);
-
+
private static List<? extends TopicSink> noopTopics;
-
+
private static KieSession kieSession;
private static Util.Pair<ControlLoopPolicy, String> pair;
private UUID requestID;
-
+
static {
/* Set environment properties */
Util.setAAIProps();
Util.setSOProps();
Util.setGuardProps();
Util.setPUProp();
- LoggerUtil.setLevel(LoggerUtil.ROOT_LOGGER, "INFO");
+ LoggerUtil.setLevel(LoggerUtil.ROOT_LOGGER, "INFO");
}
-
- @BeforeClass
- public static void setUpSimulator() {
- PolicyEngine.manager.configure(new Properties());
- assertTrue(PolicyEngine.manager.start());
- Properties noopSinkProperties = new Properties();
- noopSinkProperties.put(PolicyProperties.PROPERTY_NOOP_SINK_TOPICS, "POLICY-CL-MGT");
- noopSinkProperties.put("noop.sink.topics.POLICY-CL-MGT.events", "org.onap.policy.controlloop.VirtualControlLoopNotification");
- noopSinkProperties.put("noop.sink.topics.POLICY-CL-MGT.events.custom.gson", "org.onap.policy.controlloop.util.Serialization,gsonPretty");
- noopTopics = TopicEndpoint.manager.addTopicSinks(noopSinkProperties);
-
- EventProtocolCoder.manager.addEncoder("junit.groupId", "junit.artifactId", "POLICY-CL-MGT", "org.onap.policy.controlloop.VirtualControlLoopNotification", new JsonProtocolFilter(), null, null, 1111);
-
- try {
- Util.buildAaiSim();
- Util.buildSoSim();
- Util.buildGuardSim();
- } catch (Exception e) {
- fail(e.getMessage());
- }
-
+
+ @BeforeClass
+ public static void setUpSimulator() {
+ PolicyEngine.manager.configure(new Properties());
+ assertTrue(PolicyEngine.manager.start());
+ Properties noopSinkProperties = new Properties();
+ noopSinkProperties.put(PolicyProperties.PROPERTY_NOOP_SINK_TOPICS, "POLICY-CL-MGT");
+ noopSinkProperties.put("noop.sink.topics.POLICY-CL-MGT.events",
+ "org.onap.policy.controlloop.VirtualControlLoopNotification");
+ noopSinkProperties.put("noop.sink.topics.POLICY-CL-MGT.events.custom.gson",
+ "org.onap.policy.controlloop.util.Serialization,gsonPretty");
+ noopTopics = TopicEndpoint.manager.addTopicSinks(noopSinkProperties);
+
+ EventProtocolCoder.manager.addEncoder("junit.groupId", "junit.artifactId", "POLICY-CL-MGT",
+ "org.onap.policy.controlloop.VirtualControlLoopNotification", new JsonProtocolFilter(), null, null,
+ 1111);
+
+ try {
+ Util.buildAaiSim();
+ Util.buildSoSim();
+ Util.buildGuardSim();
+ } catch (Exception e) {
+ fail(e.getMessage());
+ }
+
/*
* Start the kie session
*/
try {
- kieSession = startSession("../archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/resources/__closedLoopControlName__.drl",
- "src/test/resources/yaml/policy_ControlLoop_SO-test.yaml",
- "type=operational",
- "CL_vDNS",
- "v2.0");
+ kieSession = startSession(
+ "../archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/resources/__closedLoopControlName__.drl",
+ "src/test/resources/yaml/policy_ControlLoop_SO-test.yaml", "type=operational", "CL_vDNS", "v2.0");
} catch (IOException e) {
e.printStackTrace();
logger.debug("Could not create kieSession");
fail("Could not create kieSession");
}
- }
+ }
+
+ @AfterClass
+ public static void tearDownSimulator() {
- @AfterClass
- public static void tearDownSimulator() {
-
/*
* Gracefully shut down the kie session
*/
kieSession.dispose();
-
+
PolicyEngine.manager.stop();
HttpServletServer.factory.destroy();
PolicyController.factory.shutdown();
TopicEndpoint.manager.shutdown();
- }
+ }
@Test
public void successTest() {
-
+
/*
- * Allows the PolicyEngine to callback to this object to
- * notify that there is an event ready to be pulled
- * from the queue
+ * Allows the PolicyEngine to callback to this object to notify that there is an event ready
+ * to be pulled from the queue
*/
for (TopicSink sink : noopTopics) {
assertTrue(sink.start());
sink.register(this);
}
-
+
/*
* Create a unique requestId
*/
requestID = UUID.randomUUID();
-
- /*
- * Simulate an onset event the policy engine will
- * receive from DCAE to kick off processing through
- * the rules
+
+ /*
+ * Simulate an onset event the policy engine will receive from DCAE to kick off processing
+ * through the rules
*/
sendEvent(pair.a, requestID, ControlLoopEventStatus.ONSET);
-
+
kieSession.fireUntilHalt();
-
+
/*
* The only fact in memory should be Params
*/
assertEquals(1, kieSession.getFactCount());
-
+
/*
* Print what's left in memory
*/
dumpFacts(kieSession);
}
-
+
@Test
public void namedQueryFailTest() {
-
+
/*
- * Allows the PolicyEngine to callback to this object to
- * notify that there is an event ready to be pulled
- * from the queue
+ * Allows the PolicyEngine to callback to this object to notify that there is an event ready
+ * to be pulled from the queue
*/
for (TopicSink sink : noopTopics) {
assertTrue(sink.start());
sink.register(this);
}
-
+
/*
* Create a unique requestId
*/
requestID = UUID.randomUUID();
-
- /*
- * Simulate an onset event the policy engine will
- * receive from DCAE to kick off processing through
- * the rules
+
+ /*
+ * Simulate an onset event the policy engine will receive from DCAE to kick off processing
+ * through the rules
*/
sendEvent(pair.a, requestID, ControlLoopEventStatus.ONSET, "error");
-
+
kieSession.fireUntilHalt();
-
+
/*
* The only fact in memory should be Params
*/
assertEquals(1, kieSession.getFactCount());
-
+
/*
* Print what's left in memory
*/
dumpFacts(kieSession);
}
-
+
@Test
public void aaiGetFailTest() {
-
+
/*
- * Allows the PolicyEngine to callback to this object to
- * notify that there is an event ready to be pulled
- * from the queue
+ * Allows the PolicyEngine to callback to this object to notify that there is an event ready
+ * to be pulled from the queue
*/
for (TopicSink sink : noopTopics) {
assertTrue(sink.start());
sink.register(this);
}
-
+
/*
* Create a unique requestId
*/
requestID = UUID.randomUUID();
-
- /*
- * Simulate an onset event the policy engine will
- * receive from DCAE to kick off processing through
- * the rules
+
+ /*
+ * Simulate an onset event the policy engine will receive from DCAE to kick off processing
+ * through the rules
*/
sendEvent(pair.a, requestID, ControlLoopEventStatus.ONSET, "getFail");
-
+
try {
- kieSession.fireUntilHalt();
- }
- catch (Exception e) {
- e.printStackTrace();
- logger.warn(e.toString());
- fail(e.getMessage());
+ kieSession.fireUntilHalt();
+ } catch (Exception e) {
+ e.printStackTrace();
+ logger.warn(e.toString());
+ fail(e.getMessage());
}
-
-
+
+
/*
* The only fact in memory should be Params
*/
assertEquals(1, kieSession.getFactCount());
-
+
/*
* Print what's left in memory
*/
dumpFacts(kieSession);
}
-
+
/**
- * This method will start a kie session and instantiate
- * the Policy Engine.
+ * This method will start a kie session and instantiate the Policy Engine.
*
- * @param droolsTemplate
- * the DRL rules file
- * @param yamlFile
- * the yaml file containing the policies
- * @param policyScope
- * scope for policy
- * @param policyName
- * name of the policy
- * @param policyVersion
- * version of the policy
- * @return the kieSession to be used to insert facts
+ * @param droolsTemplate the DRL rules file
+ * @param yamlFile the yaml file containing the policies
+ * @param policyScope scope for policy
+ * @param policyName name of the policy
+ * @param policyVersion version of the policy
+ * @return the kieSession to be used to insert facts
* @throws IOException
*/
- private static KieSession startSession(String droolsTemplate,
- String yamlFile,
- String policyScope,
- String policyName,
- String policyVersion) throws IOException {
-
+ private static KieSession startSession(String droolsTemplate, String yamlFile, String policyScope,
+ String policyName, String policyVersion) throws IOException {
+
/*
* Load policies from yaml
*/
@@ -281,41 +267,40 @@ public class VDNSControlLoopTest implements TopicListener {
assertNotNull(pair.a.getControlLoop());
assertNotNull(pair.a.getControlLoop().getControlLoopName());
assertTrue(pair.a.getControlLoop().getControlLoopName().length() > 0);
-
- /*
+
+ /*
* Construct a kie session
*/
- final KieSession kieSession = Util.buildContainer(droolsTemplate,
- pair.a.getControlLoop().getControlLoopName(),
- policyScope,
- policyName,
- policyVersion,
- URLEncoder.encode(pair.b, "UTF-8"));
-
+ final KieSession kieSession = Util.buildContainer(droolsTemplate, pair.a.getControlLoop().getControlLoopName(),
+ policyScope, policyName, policyVersion, URLEncoder.encode(pair.b, "UTF-8"));
+
/*
* Retrieve the Policy Engine
*/
-
+
logger.debug("============");
logger.debug(URLEncoder.encode(pair.b, "UTF-8"));
logger.debug("============");
-
+
return kieSession;
}
-
+
/*
* (non-Javadoc)
+ *
* @see org.onap.policy.drools.PolicyEngineListener#newEventNotification(java.lang.String)
*/
+ @Override
public void onTopicEvent(CommInfrastructure commType, String topic, String event) {
/*
- * Pull the object that was sent out to DMAAP and make
- * sure it is a ControlLoopNoticiation of type active
+ * Pull the object that was sent out to DMAAP and make sure it is a ControlLoopNoticiation
+ * of type active
*/
- Object obj = null;
+ Object obj = null;
if ("POLICY-CL-MGT".equals(topic)) {
- obj = org.onap.policy.controlloop.util.Serialization.gsonJunit.fromJson(event, org.onap.policy.controlloop.VirtualControlLoopNotification.class);
- }
+ obj = org.onap.policy.controlloop.util.Serialization.gsonJunit.fromJson(event,
+ org.onap.policy.controlloop.VirtualControlLoopNotification.class);
+ }
assertNotNull(obj);
if (obj instanceof VirtualControlLoopNotification) {
VirtualControlLoopNotification notification = (VirtualControlLoopNotification) obj;
@@ -323,96 +308,86 @@ public class VDNSControlLoopTest implements TopicListener {
if (policyName.endsWith("EVENT")) {
logger.debug("Rule Fired: " + notification.getPolicyName());
assertTrue(ControlLoopNotificationType.ACTIVE.equals(notification.getNotification()));
- }
- else if (policyName.endsWith("GUARD_NOT_YET_QUERIED")) {
+ } else if (policyName.endsWith("GUARD_NOT_YET_QUERIED")) {
logger.debug("Rule Fired: " + notification.getPolicyName());
assertTrue(ControlLoopNotificationType.OPERATION.equals(notification.getNotification()));
assertNotNull(notification.getMessage());
assertTrue(notification.getMessage().startsWith("Sending guard query"));
- }
- else if (policyName.endsWith("GUARD.RESPONSE")) {
+ } else if (policyName.endsWith("GUARD.RESPONSE")) {
logger.debug("Rule Fired: " + notification.getPolicyName());
assertTrue(ControlLoopNotificationType.OPERATION.equals(notification.getNotification()));
assertNotNull(notification.getMessage());
assertTrue(notification.getMessage().toLowerCase().endsWith("permit"));
- }
- else if (policyName.endsWith("GUARD_PERMITTED")) {
+ } else if (policyName.endsWith("GUARD_PERMITTED")) {
logger.debug("Rule Fired: " + notification.getPolicyName());
assertTrue(ControlLoopNotificationType.OPERATION.equals(notification.getNotification()));
assertNotNull(notification.getMessage());
assertTrue(notification.getMessage().startsWith("actor=SO"));
- }
- else if (policyName.endsWith("OPERATION.TIMEOUT")) {
+ } else if (policyName.endsWith("OPERATION.TIMEOUT")) {
logger.debug("Rule Fired: " + notification.getPolicyName());
kieSession.halt();
logger.debug("The operation timed out");
fail("Operation Timed Out");
- }
- else if (policyName.endsWith("SO.RESPONSE")) {
+ } else if (policyName.endsWith("SO.RESPONSE")) {
logger.debug("Rule Fired: " + notification.getPolicyName());
assertTrue(ControlLoopNotificationType.OPERATION_SUCCESS.equals(notification.getNotification()));
assertNotNull(notification.getMessage());
assertTrue(notification.getMessage().startsWith("actor=SO"));
- }
- else if (policyName.endsWith("EVENT.MANAGER")) {
+ } else if (policyName.endsWith("EVENT.MANAGER")) {
logger.debug("Rule Fired: " + notification.getPolicyName());
- if ("error".equals(notification.getAAI().get("vserver.vserver-name"))) {
- assertEquals(ControlLoopNotificationType.FINAL_FAILURE, notification.getNotification());
- }
- else if ("getFail".equals(notification.getAAI().get("vserver.vserver-name"))) {
+ if ("error".equals(notification.getAai().get("vserver.vserver-name"))) {
assertEquals(ControlLoopNotificationType.FINAL_FAILURE, notification.getNotification());
- }
- else {
- assertTrue(ControlLoopNotificationType.FINAL_SUCCESS.equals(notification.getNotification()));
+ } else if ("getFail".equals(notification.getAai().get("vserver.vserver-name"))) {
+ assertEquals(ControlLoopNotificationType.FINAL_FAILURE, notification.getNotification());
+ } else {
+ assertTrue(ControlLoopNotificationType.FINAL_SUCCESS.equals(notification.getNotification()));
}
kieSession.halt();
- }
- else if (policyName.endsWith("EVENT.MANAGER.TIMEOUT")) {
+ } else if (policyName.endsWith("EVENT.MANAGER.TIMEOUT")) {
logger.debug("Rule Fired: " + notification.getPolicyName());
kieSession.halt();
logger.debug("The control loop timed out");
fail("Control Loop Timed Out");
}
- }
- else if (obj instanceof SORequest) {
+ } else if (obj instanceof SORequest) {
logger.debug("\n============ SO received the request!!! ===========\n");
- }
+ }
}
-
+
/**
- * This method is used to simulate event messages from DCAE
- * that start the control loop (onset message) or end the
- * control loop (abatement message).
+ * This method is used to simulate event messages from DCAE that start the control loop (onset
+ * message) or end the control loop (abatement message).
*
- * @param policy the controlLoopName comes from the policy
+ * @param policy the controlLoopName comes from the policy
* @param requestID the requestId for this event
* @param status could be onset or abated
*/
protected void sendEvent(ControlLoopPolicy policy, UUID requestID, ControlLoopEventStatus status) {
VirtualControlLoopEvent event = new VirtualControlLoopEvent();
event.setClosedLoopControlName(policy.getControlLoop().getControlLoopName());
- event.setRequestID(requestID);
+ event.setRequestId(requestID);
event.setTarget("vserver.vserver-name");
event.setClosedLoopAlarmStart(Instant.now());
- event.setAAI(new HashMap<>());
- event.getAAI().put("vserver.vserver-name", "dfw1lb01lb01");
- event.getAAI().put("vserver.is-closed-loop-disabled", "false");
+ event.setAai(new HashMap<>());
+ event.getAai().put("vserver.vserver-name", "dfw1lb01lb01");
+ event.getAai().put("vserver.is-closed-loop-disabled", "false");
event.setClosedLoopEventStatus(status);
kieSession.insert(event);
}
-
- protected void sendEvent(ControlLoopPolicy policy, UUID requestID, ControlLoopEventStatus status, String vserverName) {
+
+ protected void sendEvent(ControlLoopPolicy policy, UUID requestID, ControlLoopEventStatus status,
+ String vserverName) {
VirtualControlLoopEvent event = new VirtualControlLoopEvent();
event.setClosedLoopControlName(policy.getControlLoop().getControlLoopName());
- event.setRequestID(requestID);
+ event.setRequestId(requestID);
event.setTarget("vserver.vserver-name");
event.setClosedLoopAlarmStart(Instant.now());
- event.setAAI(new HashMap<>());
- event.getAAI().put("vserver.vserver-name", vserverName);
+ event.setAai(new HashMap<>());
+ event.getAai().put("vserver.vserver-name", vserverName);
event.setClosedLoopEventStatus(status);
kieSession.insert(event);
}
-
+
/**
* This method will dump all the facts in the working memory.
*
diff --git a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VFCControlLoopTest.java b/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VFCControlLoopTest.java
index 0e2a78ada..eedd09ba0 100644
--- a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VFCControlLoopTest.java
+++ b/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VFCControlLoopTest.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* demo
* ================================================================================
- * Copyright (C) 2017 Intel Corp. All rights reserved.
+ * Copyright (C) 2017-2018 Intel Corp. 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.
@@ -44,10 +44,10 @@ import org.onap.policy.controlloop.ControlLoopTargetType;
import org.onap.policy.controlloop.VirtualControlLoopEvent;
import org.onap.policy.controlloop.VirtualControlLoopNotification;
import org.onap.policy.controlloop.policy.ControlLoopPolicy;
+import org.onap.policy.drools.event.comm.Topic.CommInfrastructure;
import org.onap.policy.drools.event.comm.TopicEndpoint;
import org.onap.policy.drools.event.comm.TopicListener;
import org.onap.policy.drools.event.comm.TopicSink;
-import org.onap.policy.drools.event.comm.Topic.CommInfrastructure;
import org.onap.policy.drools.http.server.HttpServletServer;
import org.onap.policy.drools.properties.PolicyProperties;
import org.onap.policy.drools.protocol.coders.EventProtocolCoder;
@@ -62,228 +62,216 @@ import org.slf4j.LoggerFactory;
public class VFCControlLoopTest implements TopicListener {
- private static final Logger logger = LoggerFactory.getLogger(VFCControlLoopTest.class);
-
+ private static final Logger logger = LoggerFactory.getLogger(VFCControlLoopTest.class);
+
private static List<? extends TopicSink> noopTopics;
-
- private static KieSession kieSession;
- private static Util.Pair<ControlLoopPolicy, String> pair;
- private UUID requestID;
- static {
- /* Set environment properties */
+ private static KieSession kieSession;
+ private static Util.Pair<ControlLoopPolicy, String> pair;
+ private UUID requestID;
+
+ static {
+ /* Set environment properties */
Util.setAAIProps();
Util.setVFCProps();
Util.setGuardProps();
Util.setPUProp();
LoggerUtil.setLevel(LoggerUtil.ROOT_LOGGER, "INFO");
- }
-
- @BeforeClass
- public static void setUpSimulator() {
- PolicyEngine.manager.configure(new Properties());
- assertTrue(PolicyEngine.manager.start());
- Properties noopSinkProperties = new Properties();
- noopSinkProperties.put(PolicyProperties.PROPERTY_NOOP_SINK_TOPICS, "POLICY-CL-MGT");
- noopSinkProperties.put("noop.sink.topics.POLICY-CL-MGT.events", "org.onap.policy.controlloop.VirtualControlLoopNotification");
- noopSinkProperties.put("noop.sink.topics.POLICY-CL-MGT.events.custom.gson", "org.onap.policy.controlloop.util.Serialization,gsonPretty");
- noopTopics = TopicEndpoint.manager.addTopicSinks(noopSinkProperties);
-
- EventProtocolCoder.manager.addEncoder("junit.groupId", "junit.artifactId", "POLICY-CL-MGT", "org.onap.policy.controlloop.VirtualControlLoopNotification", new JsonProtocolFilter(), null, null, 1111);
-
- try {
- Util.buildAaiSim();
- Util.buildVfcSim();
- Util.buildGuardSim();
- } catch (Exception e) {
- fail(e.getMessage());
- }
+ }
+
+ @BeforeClass
+ public static void setUpSimulator() {
+ PolicyEngine.manager.configure(new Properties());
+ assertTrue(PolicyEngine.manager.start());
+ Properties noopSinkProperties = new Properties();
+ noopSinkProperties.put(PolicyProperties.PROPERTY_NOOP_SINK_TOPICS, "POLICY-CL-MGT");
+ noopSinkProperties.put("noop.sink.topics.POLICY-CL-MGT.events",
+ "org.onap.policy.controlloop.VirtualControlLoopNotification");
+ noopSinkProperties.put("noop.sink.topics.POLICY-CL-MGT.events.custom.gson",
+ "org.onap.policy.controlloop.util.Serialization,gsonPretty");
+ noopTopics = TopicEndpoint.manager.addTopicSinks(noopSinkProperties);
+
+ EventProtocolCoder.manager.addEncoder("junit.groupId", "junit.artifactId", "POLICY-CL-MGT",
+ "org.onap.policy.controlloop.VirtualControlLoopNotification", new JsonProtocolFilter(), null, null,
+ 1111);
+
+ try {
+ Util.buildAaiSim();
+ Util.buildVfcSim();
+ Util.buildGuardSim();
+ } catch (Exception e) {
+ fail(e.getMessage());
+ }
/*
*
* Start the kie session
*/
try {
- kieSession = startSession("../archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/resources/__closedLoopControlName__.drl",
- "src/test/resources/yaml/policy_ControlLoop_VFC.yaml",
- "type=operational",
- "CL_VoLTE",
- "v2.0");
+ kieSession = startSession(
+ "../archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/resources/__closedLoopControlName__.drl",
+ "src/test/resources/yaml/policy_ControlLoop_VFC.yaml", "type=operational", "CL_VoLTE", "v2.0");
} catch (IOException e) {
e.printStackTrace();
logger.debug("Could not create kieSession");
fail("Could not create kieSession");
}
- }
+ }
+
+ @AfterClass
+ public static void tearDownSimulator() {
- @AfterClass
- public static void tearDownSimulator() {
-
/*
* Gracefully shut down the kie session
*/
kieSession.dispose();
-
+
PolicyEngine.manager.stop();
HttpServletServer.factory.destroy();
PolicyController.factory.shutdown();
TopicEndpoint.manager.shutdown();
- }
+ }
+
+ @Test
+ public void successTest() throws IOException {
- @Test
- public void successTest() throws IOException {
-
/*
- * Allows the PolicyEngine to callback to this object to
- * notify that there is an event ready to be pulled
- * from the queue
+ * Allows the PolicyEngine to callback to this object to notify that there is an event ready
+ * to be pulled from the queue
*/
for (TopicSink sink : noopTopics) {
assertTrue(sink.start());
sink.register(this);
}
-
+
/*
* Create a unique requestId
*/
requestID = UUID.randomUUID();
-
- /*
- * Simulate an onset event the policy engine will
- * receive from DCAE to kick off processing through
- * the rules
+
+ /*
+ * Simulate an onset event the policy engine will receive from DCAE to kick off processing
+ * through the rules
*/
sendEvent(pair.a, requestID, ControlLoopEventStatus.ONSET);
-
+
kieSession.fireUntilHalt();
-
+
/*
* The only fact in memory should be Params
*/
assertEquals(1, kieSession.getFactCount());
-
+
/*
* Print what's left in memory
*/
dumpFacts(kieSession);
- }
-
- @Test
- public void nullRequestTest() throws IOException {
-
+ }
+
+ @Test
+ public void nullRequestTest() throws IOException {
+
/*
- * Allows the PolicyEngine to callback to this object to
- * notify that there is an event ready to be pulled
- * from the queue
+ * Allows the PolicyEngine to callback to this object to notify that there is an event ready
+ * to be pulled from the queue
*/
for (TopicSink sink : noopTopics) {
assertTrue(sink.start());
sink.register(this);
}
-
+
/*
* Create a unique requestId
*/
requestID = UUID.randomUUID();
-
- /*
- * Simulate an onset event the policy engine will
- * receive from DCAE to kick off processing through
- * the rules
+
+ /*
+ * Simulate an onset event the policy engine will receive from DCAE to kick off processing
+ * through the rules
*/
-
+
VirtualControlLoopEvent event = new VirtualControlLoopEvent();
event.setClosedLoopControlName(pair.a.getControlLoop().getControlLoopName());
- event.setRequestID(UUID.randomUUID());
+ event.setRequestId(UUID.randomUUID());
event.setClosedLoopEventClient("tca.instance00009");
event.setTargetType(ControlLoopTargetType.VM);
event.setTarget("vserver.vserver-name");
event.setFrom("DCAE");
event.setClosedLoopAlarmStart(Instant.now());
- event.setAAI(new HashMap<String, String>());
- event.getAAI().put("vserver.vserver-name", "nullRequest");
+ event.setAai(new HashMap<String, String>());
+ event.getAai().put("vserver.vserver-name", "nullRequest");
event.setClosedLoopEventStatus(ControlLoopEventStatus.ONSET);
kieSession.insert(event);
-
+
kieSession.fireUntilHalt();
-
+
/*
* The only fact in memory should be Params
*/
assertEquals(1, kieSession.getFactCount());
-
+
/*
* Print what's left in memory
*/
dumpFacts(kieSession);
- }
-
- /**
- * This method will start a kie session and instantiate
- * the Policy Engine.
- *
- * @param droolsTemplate
- * the DRL rules file
- * @param yamlFile
- * the yaml file containing the policies
- * @param policyScope
- * scope for policy
- * @param policyName
- * name of the policy
- * @param policyVersion
- * version of the policy
- * @return the kieSession to be used to insert facts
- * @throws IOException
- */
- private static KieSession startSession(String droolsTemplate,
- String yamlFile,
- String policyScope,
- String policyName,
- String policyVersion) throws IOException {
+ }
+
+ /**
+ * This method will start a kie session and instantiate the Policy Engine.
+ *
+ * @param droolsTemplate the DRL rules file
+ * @param yamlFile the yaml file containing the policies
+ * @param policyScope scope for policy
+ * @param policyName name of the policy
+ * @param policyVersion version of the policy
+ * @return the kieSession to be used to insert facts
+ * @throws IOException
+ */
+ private static KieSession startSession(String droolsTemplate, String yamlFile, String policyScope,
+ String policyName, String policyVersion) throws IOException {
/*
* Load policies from yaml
*/
- pair = Util.loadYaml(yamlFile);
- assertNotNull(pair);
- assertNotNull(pair.a);
- assertNotNull(pair.a.getControlLoop());
- assertNotNull(pair.a.getControlLoop().getControlLoopName());
- assertTrue(pair.a.getControlLoop().getControlLoopName().length() > 0);
+ pair = Util.loadYaml(yamlFile);
+ assertNotNull(pair);
+ assertNotNull(pair.a);
+ assertNotNull(pair.a.getControlLoop());
+ assertNotNull(pair.a.getControlLoop().getControlLoopName());
+ assertTrue(pair.a.getControlLoop().getControlLoopName().length() > 0);
/*
* Construct a kie session
*/
- final KieSession kieSession = Util.buildContainer(droolsTemplate,
- pair.a.getControlLoop().getControlLoopName(),
- policyScope,
- policyName,
- policyVersion,
- URLEncoder.encode(pair.b, "UTF-8"));
+ final KieSession kieSession = Util.buildContainer(droolsTemplate, pair.a.getControlLoop().getControlLoopName(),
+ policyScope, policyName, policyVersion, URLEncoder.encode(pair.b, "UTF-8"));
/*
* Retrieve the Policy Engine
*/
- logger.debug("============");
- logger.debug(URLEncoder.encode(pair.b, "UTF-8"));
- logger.debug("============");
+ logger.debug("============");
+ logger.debug(URLEncoder.encode(pair.b, "UTF-8"));
+ logger.debug("============");
+
+ return kieSession;
+ }
- return kieSession;
- }
-
- /*
+ /*
* (non-Javadoc)
+ *
* @see org.onap.policy.drools.PolicyEngineListener#newEventNotification(java.lang.String)
*/
- public void onTopicEvent(CommInfrastructure commType, String topic, String event) {
+ @Override
+ public void onTopicEvent(CommInfrastructure commType, String topic, String event) {
/*
- * Pull the object that was sent out to DMAAP and make
- * sure it is a ControlLoopNoticiation of type active
+ * Pull the object that was sent out to DMAAP and make sure it is a ControlLoopNoticiation
+ * of type active
*/
- Object obj = null;
+ Object obj = null;
if ("POLICY-CL-MGT".equals(topic)) {
- obj = org.onap.policy.controlloop.util.Serialization.gsonJunit.fromJson(event, org.onap.policy.controlloop.VirtualControlLoopNotification.class);
- }
+ obj = org.onap.policy.controlloop.util.Serialization.gsonJunit.fromJson(event,
+ org.onap.policy.controlloop.VirtualControlLoopNotification.class);
+ }
assertNotNull(obj);
if (obj instanceof VirtualControlLoopNotification) {
VirtualControlLoopNotification notification = (VirtualControlLoopNotification) obj;
@@ -291,93 +279,83 @@ public class VFCControlLoopTest implements TopicListener {
if (policyName.endsWith("EVENT")) {
logger.debug("Rule Fired: " + notification.getPolicyName());
assertTrue(ControlLoopNotificationType.ACTIVE.equals(notification.getNotification()));
- }
- else if (policyName.endsWith("GUARD_NOT_YET_QUERIED")) {
+ } else if (policyName.endsWith("GUARD_NOT_YET_QUERIED")) {
logger.debug("Rule Fired: " + notification.getPolicyName());
assertTrue(ControlLoopNotificationType.OPERATION.equals(notification.getNotification()));
assertNotNull(notification.getMessage());
assertTrue(notification.getMessage().startsWith("Sending guard query"));
- }
- else if (policyName.endsWith("GUARD.RESPONSE")) {
+ } else if (policyName.endsWith("GUARD.RESPONSE")) {
logger.debug("Rule Fired: " + notification.getPolicyName());
assertTrue(ControlLoopNotificationType.OPERATION.equals(notification.getNotification()));
assertNotNull(notification.getMessage());
assertTrue(notification.getMessage().toLowerCase().endsWith("permit"));
- }
- else if (policyName.endsWith("GUARD_PERMITTED")) {
+ } else if (policyName.endsWith("GUARD_PERMITTED")) {
logger.debug("Rule Fired: " + notification.getPolicyName());
assertTrue(ControlLoopNotificationType.OPERATION.equals(notification.getNotification()));
assertNotNull(notification.getMessage());
assertTrue(notification.getMessage().startsWith("actor=VFC"));
- }
- else if (policyName.endsWith("OPERATION.TIMEOUT")) {
+ } else if (policyName.endsWith("OPERATION.TIMEOUT")) {
logger.debug("Rule Fired: " + notification.getPolicyName());
kieSession.halt();
logger.debug("The operation timed out");
fail("Operation Timed Out");
- }
- else if (policyName.endsWith("VFC.RESPONSE")) {
+ } else if (policyName.endsWith("VFC.RESPONSE")) {
logger.debug("Rule Fired: " + notification.getPolicyName());
assertTrue(ControlLoopNotificationType.OPERATION_SUCCESS.equals(notification.getNotification()));
assertNotNull(notification.getMessage());
assertTrue(notification.getMessage().startsWith("actor=VFC"));
- }
- else if (policyName.endsWith("EVENT.MANAGER")) {
+ } else if (policyName.endsWith("EVENT.MANAGER")) {
logger.debug("Rule Fired: " + notification.getPolicyName());
- if ("nullRequest".equals(notification.getAAI().get("vserver.vserver-name"))){
- assertEquals(ControlLoopNotificationType.FINAL_FAILURE, notification.getNotification());
- }
- else {
- assertEquals(ControlLoopNotificationType.FINAL_SUCCESS, notification.getNotification());
+ if ("nullRequest".equals(notification.getAai().get("vserver.vserver-name"))) {
+ assertEquals(ControlLoopNotificationType.FINAL_FAILURE, notification.getNotification());
+ } else {
+ assertEquals(ControlLoopNotificationType.FINAL_SUCCESS, notification.getNotification());
}
kieSession.halt();
- }
- else if (policyName.endsWith("EVENT.MANAGER.TIMEOUT")) {
+ } else if (policyName.endsWith("EVENT.MANAGER.TIMEOUT")) {
logger.debug("Rule Fired: " + notification.getPolicyName());
kieSession.halt();
logger.debug("The control loop timed out");
fail("Control Loop Timed Out");
}
- }
- else if (obj instanceof VFCRequest) {
+ } else if (obj instanceof VFCRequest) {
logger.debug("\n============ VFC received the request!!! ===========\n");
- }
+ }
+ }
+
+ /**
+ * This method is used to simulate event messages from DCAE that start the control loop (onset
+ * message) or end the control loop (abatement message).
+ *
+ * @param policy the controlLoopName comes from the policy
+ * @param requestID the requestId for this event
+ * @param status could be onset or abated
+ */
+ protected void sendEvent(ControlLoopPolicy policy, UUID requestID, ControlLoopEventStatus status) {
+ VirtualControlLoopEvent event = new VirtualControlLoopEvent();
+ event.setClosedLoopControlName(policy.getControlLoop().getControlLoopName());
+ event.setRequestId(UUID.randomUUID());
+ event.setClosedLoopEventClient("tca.instance00009");
+ event.setTargetType(ControlLoopTargetType.VM);
+ event.setTarget("vserver.vserver-name");
+ event.setFrom("DCAE");
+ event.setClosedLoopAlarmStart(Instant.now());
+ event.setAai(new HashMap<String, String>());
+ event.getAai().put("vserver.vserver-name", "vserver-name-16102016-aai3255-data-11-1");
+ event.getAai().put("vserver.vserver-id", "vserver-id-16102016-aai3255-data-11-1");
+ event.getAai().put("generic-vnf.vnf-id", "vnf-id-16102016-aai3255-data-11-1");
+ event.getAai().put("service-instance.service-instance-id", "service-instance-id-16102016-aai3255-data-11-1");
+ event.getAai().put("vserver.is-closed-loop-disabled", "false");
+ event.setClosedLoopEventStatus(ControlLoopEventStatus.ONSET);
+ kieSession.insert(event);
+ }
+
+ public static void dumpFacts(KieSession kieSession) {
+ logger.debug("Fact Count: " + kieSession.getFactCount());
+ for (FactHandle handle : kieSession.getFactHandles()) {
+ logger.debug("FACT: " + handle);
+ }
}
-
- /**
- * This method is used to simulate event messages from DCAE
- * that start the control loop (onset message) or end the
- * control loop (abatement message).
- *
- * @param policy the controlLoopName comes from the policy
- * @param requestID the requestId for this event
- * @param status could be onset or abated
- */
- protected void sendEvent(ControlLoopPolicy policy, UUID requestID, ControlLoopEventStatus status) {
- VirtualControlLoopEvent event = new VirtualControlLoopEvent();
- event.setClosedLoopControlName(policy.getControlLoop().getControlLoopName());
- event.setRequestID(UUID.randomUUID());
- event.setClosedLoopEventClient("tca.instance00009");
- event.setTargetType(ControlLoopTargetType.VM);
- event.setTarget("vserver.vserver-name");
- event.setFrom("DCAE");
- event.setClosedLoopAlarmStart(Instant.now());
- event.setAAI(new HashMap<String, String>());
- event.getAAI().put("vserver.vserver-name", "vserver-name-16102016-aai3255-data-11-1");
- event.getAAI().put("vserver.vserver-id", "vserver-id-16102016-aai3255-data-11-1");
- event.getAAI().put("generic-vnf.vnf-id", "vnf-id-16102016-aai3255-data-11-1");
- event.getAAI().put("service-instance.service-instance-id", "service-instance-id-16102016-aai3255-data-11-1");
- event.getAAI().put("vserver.is-closed-loop-disabled", "false");
- event.setClosedLoopEventStatus(ControlLoopEventStatus.ONSET);
- kieSession.insert(event);
- }
-
- public static void dumpFacts(KieSession kieSession) {
- logger.debug("Fact Count: " + kieSession.getFactCount());
- for (FactHandle handle : kieSession.getFactHandles()) {
- logger.debug("FACT: " + handle);
- }
- }
}
diff --git a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VFWControlLoopTest.java b/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VFWControlLoopTest.java
index 8c449cebd..9c0cbd716 100644
--- a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VFWControlLoopTest.java
+++ b/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VFWControlLoopTest.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* demo
* ================================================================================
- * 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.
@@ -46,10 +46,10 @@ import org.onap.policy.controlloop.ControlLoopNotificationType;
import org.onap.policy.controlloop.VirtualControlLoopEvent;
import org.onap.policy.controlloop.VirtualControlLoopNotification;
import org.onap.policy.controlloop.policy.ControlLoopPolicy;
+import org.onap.policy.drools.event.comm.Topic.CommInfrastructure;
import org.onap.policy.drools.event.comm.TopicEndpoint;
import org.onap.policy.drools.event.comm.TopicListener;
import org.onap.policy.drools.event.comm.TopicSink;
-import org.onap.policy.drools.event.comm.Topic.CommInfrastructure;
import org.onap.policy.drools.http.server.HttpServletServer;
import org.onap.policy.drools.properties.PolicyProperties;
import org.onap.policy.drools.protocol.coders.EventProtocolCoder;
@@ -63,13 +63,13 @@ import org.slf4j.LoggerFactory;
public class VFWControlLoopTest implements TopicListener {
private static final Logger logger = LoggerFactory.getLogger(VFWControlLoopTest.class);
-
+
private static List<? extends TopicSink> noopTopics;
-
+
private static KieSession kieSession;
private static Util.Pair<ControlLoopPolicy, String> pair;
private UUID requestID;
-
+
static {
/* Set environment properties */
Util.setAAIProps();
@@ -77,21 +77,27 @@ public class VFWControlLoopTest implements TopicListener {
Util.setPUProp();
LoggerUtil.setLevel(LoggerUtil.ROOT_LOGGER, "INFO");
}
-
+
@BeforeClass
public static void setUpSimulator() {
- PolicyEngine.manager.configure(new Properties());
- assertTrue(PolicyEngine.manager.start());
- Properties noopSinkProperties = new Properties();
- noopSinkProperties.put(PolicyProperties.PROPERTY_NOOP_SINK_TOPICS, "APPC-CL,POLICY-CL-MGT");
- noopSinkProperties.put("noop.sink.topics.APPC-CL.events", "org.onap.policy.appc.Response");
- noopSinkProperties.put("noop.sink.topics.APPC-CL.events.custom.gson", "org.onap.policy.appc.util.Serialization,gsonPretty");
- noopSinkProperties.put("noop.sink.topics.POLICY-CL-MGT.events", "org.onap.policy.controlloop.VirtualControlLoopNotification");
- noopSinkProperties.put("noop.sink.topics.POLICY-CL-MGT.events.custom.gson", "org.onap.policy.controlloop.util.Serialization,gsonPretty");
- noopTopics = TopicEndpoint.manager.addTopicSinks(noopSinkProperties);
-
- EventProtocolCoder.manager.addEncoder("junit.groupId", "junit.artifactId", "POLICY-CL-MGT", "org.onap.policy.controlloop.VirtualControlLoopNotification", new JsonProtocolFilter(), null, null, 1111);
- EventProtocolCoder.manager.addEncoder("junit.groupId", "junit.artifactId", "APPC-CL", "org.onap.policy.appc.Request", new JsonProtocolFilter(), null, null, 1111);
+ PolicyEngine.manager.configure(new Properties());
+ assertTrue(PolicyEngine.manager.start());
+ Properties noopSinkProperties = new Properties();
+ noopSinkProperties.put(PolicyProperties.PROPERTY_NOOP_SINK_TOPICS, "APPC-CL,POLICY-CL-MGT");
+ noopSinkProperties.put("noop.sink.topics.APPC-CL.events", "org.onap.policy.appc.Response");
+ noopSinkProperties.put("noop.sink.topics.APPC-CL.events.custom.gson",
+ "org.onap.policy.appc.util.Serialization,gsonPretty");
+ noopSinkProperties.put("noop.sink.topics.POLICY-CL-MGT.events",
+ "org.onap.policy.controlloop.VirtualControlLoopNotification");
+ noopSinkProperties.put("noop.sink.topics.POLICY-CL-MGT.events.custom.gson",
+ "org.onap.policy.controlloop.util.Serialization,gsonPretty");
+ noopTopics = TopicEndpoint.manager.addTopicSinks(noopSinkProperties);
+
+ EventProtocolCoder.manager.addEncoder("junit.groupId", "junit.artifactId", "POLICY-CL-MGT",
+ "org.onap.policy.controlloop.VirtualControlLoopNotification", new JsonProtocolFilter(), null, null,
+ 1111);
+ EventProtocolCoder.manager.addEncoder("junit.groupId", "junit.artifactId", "APPC-CL",
+ "org.onap.policy.appc.Request", new JsonProtocolFilter(), null, null, 1111);
try {
Util.buildAaiSim();
@@ -99,16 +105,16 @@ public class VFWControlLoopTest implements TopicListener {
} catch (Exception e) {
fail(e.getMessage());
}
-
+
/*
* Start the kie session
*/
try {
- kieSession = startSession("../archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/resources/__closedLoopControlName__.drl",
- "src/test/resources/yaml/policy_ControlLoop_vFW.yaml",
- "service=ServiceDemo;resource=Res1Demo;type=operational",
- "CL_vFW",
- "org.onap.closed_loop.ServiceDemo:VNFS:1.0.0");
+ kieSession = startSession(
+ "../archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/resources/__closedLoopControlName__.drl",
+ "src/test/resources/yaml/policy_ControlLoop_vFW.yaml",
+ "service=ServiceDemo;resource=Res1Demo;type=operational", "CL_vFW",
+ "org.onap.closed_loop.ServiceDemo:VNFS:1.0.0");
} catch (IOException e) {
e.printStackTrace();
logger.debug("Could not create kieSession");
@@ -118,162 +124,145 @@ public class VFWControlLoopTest implements TopicListener {
@AfterClass
public static void tearDownSimulator() {
- /*
+ /*
* Gracefully shut down the kie session
*/
kieSession.dispose();
-
+
PolicyEngine.manager.stop();
HttpServletServer.factory.destroy();
PolicyController.factory.shutdown();
TopicEndpoint.manager.shutdown();
}
-
+
@Test
public void successTest() {
-
- /*
- * Allows the PolicyEngine to callback to this object to
- * notify that there is an event ready to be pulled
- * from the queue
+
+ /*
+ * Allows the PolicyEngine to callback to this object to notify that there is an event ready
+ * to be pulled from the queue
*/
for (TopicSink sink : noopTopics) {
assertTrue(sink.start());
sink.register(this);
}
-
+
/*
* Create a unique requestId
*/
requestID = UUID.randomUUID();
-
- /*
- * Simulate an onset event the policy engine will
- * receive from DCAE to kick off processing through
- * the rules
+
+ /*
+ * Simulate an onset event the policy engine will receive from DCAE to kick off processing
+ * through the rules
*/
sendEvent(pair.a, requestID, ControlLoopEventStatus.ONSET);
-
+
try {
- kieSession.fireUntilHalt();
- }
- catch (Exception e) {
- e.printStackTrace();
- logger.warn(e.toString());
- fail("fail");
+ kieSession.fireUntilHalt();
+ } catch (Exception e) {
+ e.printStackTrace();
+ logger.warn(e.toString());
+ fail("fail");
}
-
-
+
+
/*
* The only fact in memory should be Params
*/
assertEquals(1, kieSession.getFactCount());
-
+
/*
* Print what's left in memory
*/
dumpFacts(kieSession);
}
-
+
@Test
public void aaiFailTests() {
-
+
/*
- * Allows the PolicyEngine to callback to this object to
- * notify that there is an event ready to be pulled
- * from the queue
+ * Allows the PolicyEngine to callback to this object to notify that there is an event ready
+ * to be pulled from the queue
*/
for (TopicSink sink : noopTopics) {
assertTrue(sink.start());
sink.register(this);
}
-
+
/*
* Create a unique requestId
*/
requestID = UUID.randomUUID();
-
- /*
- * Simulate an onset event the policy engine will
- * receive from DCAE to kick off processing through
- * the rules
+
+ /*
+ * Simulate an onset event the policy engine will receive from DCAE to kick off processing
+ * through the rules
*/
sendEvent(pair.a, requestID, ControlLoopEventStatus.ONSET, "error");
try {
- kieSession.fireUntilHalt();
- }
- catch (Exception e) {
- e.printStackTrace();
- logger.warn(e.toString());
- fail(e.getMessage());
+ kieSession.fireUntilHalt();
+ } catch (Exception e) {
+ e.printStackTrace();
+ logger.warn(e.toString());
+ fail(e.getMessage());
}
-
+
/*
* The only fact in memory should be Params
*/
assertEquals(1, kieSession.getFactCount());
-
+
/*
* Print what's left in memory
*/
dumpFacts(kieSession);
-
+
/*
* Create a unique requestId
*/
requestID = UUID.randomUUID();
-
- /*
- * Simulate an onset event the policy engine will
- * receive from DCAE to kick off processing through
- * the rules
+
+ /*
+ * Simulate an onset event the policy engine will receive from DCAE to kick off processing
+ * through the rules
*/
-
+
sendEvent(pair.a, requestID, ControlLoopEventStatus.ONSET, "getFail");
-
+
try {
- kieSession.fireUntilHalt();
- }
- catch (Exception e) {
- e.printStackTrace();
- logger.warn(e.toString());
- fail(e.getMessage());
+ kieSession.fireUntilHalt();
+ } catch (Exception e) {
+ e.printStackTrace();
+ logger.warn(e.toString());
+ fail(e.getMessage());
}
-
+
/*
* The only fact in memory should be Params
*/
assertEquals(1, kieSession.getFactCount());
-
+
/*
* Print what's left in memory
*/
dumpFacts(kieSession);
}
-
+
/**
- * This method will start a kie session and instantiate
- * the Policy Engine.
+ * This method will start a kie session and instantiate the Policy Engine.
*
- * @param droolsTemplate
- * the DRL rules file
- * @param yamlFile
- * the yaml file containing the policies
- * @param policyScope
- * scope for policy
- * @param policyName
- * name of the policy
- * @param policyVersion
- * version of the policy
- * @return the kieSession to be used to insert facts
+ * @param droolsTemplate the DRL rules file
+ * @param yamlFile the yaml file containing the policies
+ * @param policyScope scope for policy
+ * @param policyName name of the policy
+ * @param policyVersion version of the policy
+ * @return the kieSession to be used to insert facts
* @throws IOException
*/
- private static KieSession startSession(String droolsTemplate,
- String yamlFile,
- String policyScope,
- String policyName,
- String policyVersion) throws IOException {
-
+ private static KieSession startSession(String droolsTemplate, String yamlFile, String policyScope,
+ String policyName, String policyVersion) throws IOException {
+
/*
* Load policies from yaml
*/
@@ -283,42 +272,41 @@ public class VFWControlLoopTest implements TopicListener {
assertNotNull(pair.a.getControlLoop());
assertNotNull(pair.a.getControlLoop().getControlLoopName());
assertTrue(pair.a.getControlLoop().getControlLoopName().length() > 0);
-
- /*
+
+ /*
* Construct a kie session
*/
- final KieSession kieSession = Util.buildContainer(droolsTemplate,
- pair.a.getControlLoop().getControlLoopName(),
- policyScope,
- policyName,
- policyVersion,
- URLEncoder.encode(pair.b, "UTF-8"));
-
+ final KieSession kieSession = Util.buildContainer(droolsTemplate, pair.a.getControlLoop().getControlLoopName(),
+ policyScope, policyName, policyVersion, URLEncoder.encode(pair.b, "UTF-8"));
+
/*
* Retrieve the Policy Engine
*/
-
+
logger.debug("============");
logger.debug(URLEncoder.encode(pair.b, "UTF-8"));
logger.debug("============");
-
+
return kieSession;
}
-
+
/*
* @see org.onap.policy.drools.PolicyEngineListener#newEventNotification(java.lang.String)
*/
+ @Override
public void onTopicEvent(CommInfrastructure commType, String topic, String event) {
/*
- * Pull the object that was sent out to DMAAP and make
- * sure it is a ControlLoopNoticiation of type active
+ * Pull the object that was sent out to DMAAP and make sure it is a ControlLoopNoticiation
+ * of type active
*/
- Object obj = null;
+ Object obj = null;
if ("POLICY-CL-MGT".equals(topic)) {
- obj = org.onap.policy.controlloop.util.Serialization.gsonJunit.fromJson(event, org.onap.policy.controlloop.VirtualControlLoopNotification.class);
- }
- else if ("APPC-CL".equals(topic))
- obj = org.onap.policy.appc.util.Serialization.gsonPretty.fromJson(event, org.onap.policy.appc.Request.class);
+ obj = org.onap.policy.controlloop.util.Serialization.gsonJunit.fromJson(event,
+ org.onap.policy.controlloop.VirtualControlLoopNotification.class);
+ } else if ("APPC-CL".equals(topic)) {
+ obj = org.onap.policy.appc.util.Serialization.gsonPretty.fromJson(event,
+ org.onap.policy.appc.Request.class);
+ }
assertNotNull(obj);
if (obj instanceof VirtualControlLoopNotification) {
VirtualControlLoopNotification notification = (VirtualControlLoopNotification) obj;
@@ -326,118 +314,105 @@ public class VFWControlLoopTest implements TopicListener {
if (policyName.endsWith("EVENT")) {
logger.debug("Rule Fired: " + notification.getPolicyName());
assertTrue(ControlLoopNotificationType.ACTIVE.equals(notification.getNotification()));
- }
- else if (policyName.endsWith("GUARD_NOT_YET_QUERIED")) {
+ } else if (policyName.endsWith("GUARD_NOT_YET_QUERIED")) {
logger.debug("Rule Fired: " + notification.getPolicyName());
assertTrue(ControlLoopNotificationType.OPERATION.equals(notification.getNotification()));
assertNotNull(notification.getMessage());
assertTrue(notification.getMessage().startsWith("Sending guard query"));
- }
- else if (policyName.endsWith("GUARD.RESPONSE")) {
+ } else if (policyName.endsWith("GUARD.RESPONSE")) {
logger.debug("Rule Fired: " + notification.getPolicyName());
assertTrue(ControlLoopNotificationType.OPERATION.equals(notification.getNotification()));
assertNotNull(notification.getMessage());
assertTrue(notification.getMessage().toLowerCase().endsWith("permit"));
- }
- else if (policyName.endsWith("GUARD_PERMITTED")) {
+ } else if (policyName.endsWith("GUARD_PERMITTED")) {
logger.debug("Rule Fired: " + notification.getPolicyName());
assertTrue(ControlLoopNotificationType.OPERATION.equals(notification.getNotification()));
assertNotNull(notification.getMessage());
assertTrue(notification.getMessage().startsWith("actor=APPC"));
- }
- else if (policyName.endsWith("OPERATION.TIMEOUT")) {
+ } else if (policyName.endsWith("OPERATION.TIMEOUT")) {
logger.debug("Rule Fired: " + notification.getPolicyName());
kieSession.halt();
logger.debug("The operation timed out");
fail("Operation Timed Out");
- }
- else if (policyName.endsWith("APPC.RESPONSE")) {
+ } else if (policyName.endsWith("APPC.RESPONSE")) {
logger.debug("Rule Fired: " + notification.getPolicyName());
assertTrue(ControlLoopNotificationType.OPERATION_SUCCESS.equals(notification.getNotification()));
assertNotNull(notification.getMessage());
assertTrue(notification.getMessage().startsWith("actor=APPC"));
sendEvent(pair.a, requestID, ControlLoopEventStatus.ABATED);
- }
- else if (policyName.endsWith("EVENT.MANAGER")) {
+ } else if (policyName.endsWith("EVENT.MANAGER")) {
logger.debug("Rule Fired: " + notification.getPolicyName());
- if ("error".equals(notification.getAAI().get("generic-vnf.vnf-name"))) {
- assertEquals(ControlLoopNotificationType.FINAL_FAILURE, notification.getNotification());
- assertEquals("Target vnf-id could not be found", notification.getMessage());
- }
- else if ("getFail".equals(notification.getAAI().get("generic-vnf.vnf-name"))) {
+ if ("error".equals(notification.getAai().get("generic-vnf.vnf-name"))) {
assertEquals(ControlLoopNotificationType.FINAL_FAILURE, notification.getNotification());
- }
- else {
+ assertEquals("Target vnf-id could not be found", notification.getMessage());
+ } else if ("getFail".equals(notification.getAai().get("generic-vnf.vnf-name"))) {
+ assertEquals(ControlLoopNotificationType.FINAL_FAILURE, notification.getNotification());
+ } else {
assertTrue(ControlLoopNotificationType.FINAL_SUCCESS.equals(notification.getNotification()));
}
kieSession.halt();
- }
- else if (policyName.endsWith("EVENT.MANAGER.TIMEOUT")) {
+ } else if (policyName.endsWith("EVENT.MANAGER.TIMEOUT")) {
logger.debug("Rule Fired: " + notification.getPolicyName());
kieSession.halt();
logger.debug("The control loop timed out");
fail("Control Loop Timed Out");
}
- }
- else if (obj instanceof Request) {
- assertTrue(((Request)obj).getCommonHeader().getSubRequestID().equals("1"));
- assertNotNull(((Request)obj).getPayload().get("generic-vnf.vnf-id"));
-
+ } else if (obj instanceof Request) {
+ assertTrue(((Request) obj).getCommonHeader().getSubRequestId().equals("1"));
+ assertNotNull(((Request) obj).getPayload().get("generic-vnf.vnf-id"));
+
logger.debug("\n============ APPC received the request!!! ===========\n");
-
+
/*
- * Simulate a success response from APPC and insert
- * the response into the working memory
+ * Simulate a success response from APPC and insert the response into the working memory
*/
- Response appcResponse = new Response((Request)obj);
+ Response appcResponse = new Response((Request) obj);
appcResponse.getStatus().setCode(ResponseCode.SUCCESS.getValue());
appcResponse.getStatus().setValue("SUCCESS");
kieSession.insert(appcResponse);
- }
+ }
}
-
+
/**
- * This method is used to simulate event messages from DCAE
- * that start the control loop (onset message) or end the
- * control loop (abatement message).
+ * This method is used to simulate event messages from DCAE that start the control loop (onset
+ * message) or end the control loop (abatement message).
*
- * @param policy the controlLoopName comes from the policy
+ * @param policy the controlLoopName comes from the policy
* @param requestID the requestId for this event
* @param status could be onset or abated
*/
protected void sendEvent(ControlLoopPolicy policy, UUID requestID, ControlLoopEventStatus status) {
VirtualControlLoopEvent event = new VirtualControlLoopEvent();
event.setClosedLoopControlName(policy.getControlLoop().getControlLoopName());
- event.setRequestID(requestID);
+ event.setRequestId(requestID);
event.setTarget("generic-vnf.vnf-name");
event.setClosedLoopAlarmStart(Instant.now());
- event.setAAI(new HashMap<>());
- event.getAAI().put("generic-vnf.vnf-name", "testGenericVnfID");
+ event.setAai(new HashMap<>());
+ event.getAai().put("generic-vnf.vnf-name", "testGenericVnfID");
event.setClosedLoopEventStatus(status);
kieSession.insert(event);
}
-
+
/**
- * This method is used to simulate event messages from DCAE
- * that start the control loop (onset message) or end the
- * control loop (abatement message).
+ * This method is used to simulate event messages from DCAE that start the control loop (onset
+ * message) or end the control loop (abatement message).
*
- * @param policy the controlLoopName comes from the policy
+ * @param policy the controlLoopName comes from the policy
* @param requestID the requestId for this event
* @param status could be onset or abated
*/
protected void sendEvent(ControlLoopPolicy policy, UUID requestID, ControlLoopEventStatus status, String vnfId) {
VirtualControlLoopEvent event = new VirtualControlLoopEvent();
event.setClosedLoopControlName(policy.getControlLoop().getControlLoopName());
- event.setRequestID(requestID);
+ event.setRequestId(requestID);
event.setTarget("generic-vnf.vnf-name");
event.setClosedLoopAlarmStart(Instant.now());
- event.setAAI(new HashMap<>());
- event.getAAI().put("generic-vnf.vnf-name", vnfId);
+ event.setAai(new HashMap<>());
+ event.getAai().put("generic-vnf.vnf-name", vnfId);
event.setClosedLoopEventStatus(status);
kieSession.insert(event);
}
-
+
/**
* This method will dump all the facts in the working memory.
*