aboutsummaryrefslogtreecommitdiffstats
path: root/controlloop/common/eventmanager
diff options
context:
space:
mode:
authorDaniel Cruz <dc443y@att.com>2019-10-23 18:18:07 -0500
committerJorge Hernandez <jorge.hernandez-herrero@att.com>2019-10-29 13:53:48 +0000
commit25628c56e5fc6b1d6e2e3b761f435fc9596ce1b3 (patch)
tree743e0d540f3ff9a7630caeb74da95b9d874d4ea5 /controlloop/common/eventmanager
parent1be8ef842916c239ab840cf1d22b3c7d017363cd (diff)
Update APPC LCM Model references
Updates to all references of APPC LCM model code based on changes in policy models for APPC LCM. Issue-ID: POLICY-2043 Change-Id: I0102eb27f449578636cfc0bf22124fa863f05724 Signed-off-by: Daniel Cruz <dc443y@att.com>
Diffstat (limited to 'controlloop/common/eventmanager')
-rw-r--r--controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManager.java10
-rw-r--r--controlloop/common/eventmanager/src/main/java/org/onap/policy/drools/impl/PolicyEngineJUnitImpl.java22
-rw-r--r--controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManagerTest.java80
-rw-r--r--controlloop/common/eventmanager/src/test/java/org/onap/policy/drools/DroolsPolicyEngineTest.java20
4 files changed, 72 insertions, 60 deletions
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 62bd0c1e9..87e76c34f 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
@@ -45,7 +45,7 @@ import org.onap.policy.aai.AaiCqResponse;
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.AppcLcmDmaapWrapper;
import org.onap.policy.cds.CdsResponse;
import org.onap.policy.controlloop.ControlLoopEvent;
import org.onap.policy.controlloop.ControlLoopException;
@@ -507,11 +507,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 AppcLcmDmaapWrapper) {
//
// Cast LCM response and handle it
//
- return onResponse((LcmResponseWrapper) response);
+ return onResponse(( AppcLcmDmaapWrapper) response);
} else if (response instanceof PciResponseWrapper) {
//
// Cast SDNR response and handle it
@@ -633,12 +633,12 @@ 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(AppcLcmDmaapWrapper dmaapResponse) {
/*
* Parse out the operation attempt using the subrequestid
*/
Integer operationAttempt = AppcLcmActorServiceProvider
- .parseOperationAttempt(dmaapResponse.getBody().getCommonHeader().getSubRequestId());
+ .parseOperationAttempt(dmaapResponse.getBody().getOutput().getCommonHeader().getSubRequestId());
if (operationAttempt == null) {
this.completeOperation(operationAttempt, "Policy was unable to parse APP-C SubRequestID (it was null).",
PolicyResult.FAILURE_EXCEPTION);
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 773299dc2..6a3be2d6a 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
@@ -2,14 +2,14 @@
* ============LICENSE_START=======================================================
* policy engine
* ================================================================================
- * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2019 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.
@@ -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.AppcLcmDmaapWrapper;
import org.onap.policy.controlloop.ControlLoopNotification;
import org.onap.policy.controlloop.util.Serialization;
import org.onap.policy.drools.PolicyEngine;
@@ -45,7 +45,7 @@ public class PolicyEngineJUnitImpl implements PolicyEngine {
/**
* Adds all objects that implement PolicyEngineListener to the notification list when an event
* occurs.
- *
+ *
* @param listener an object that is interest in knowing about events published to the
* PolicyEngine
*/
@@ -55,7 +55,7 @@ public class PolicyEngineJUnitImpl implements PolicyEngine {
/**
* Notifies all listeners about a new event.
- *
+ *
* @param topic the topic in which the notification was sent to
*/
public void notifyListeners(String topic) {
@@ -75,10 +75,10 @@ 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 {}", dmaapRequest.getBody().getAction(),
- dmaapRequest.getBody().getCommonHeader().getSubRequestId());
+ } else if (obj instanceof AppcLcmDmaapWrapper) {
+ AppcLcmDmaapWrapper dmaapRequest = (AppcLcmDmaapWrapper) obj;
+ logger.debug("Request: {} subrequest {}", dmaapRequest.getBody().getInput().getAction(),
+ dmaapRequest.getBody().getInput().getCommonHeader().getSubRequestId());
}
//
// Does the bus exist?
@@ -115,7 +115,7 @@ public class PolicyEngineJUnitImpl implements PolicyEngine {
/**
* Subscribe to a topic on a bus.
- *
+ *
* @param busType the bus type
* @param topic the topic
* @return the head of the queue, or <code>null</code> if the queue or bus does not exist or the
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 914eb7664..480bc290e 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
@@ -50,11 +50,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.AppcLcmBody;
+import org.onap.policy.appclcm.AppcLcmCommonHeader;
+import org.onap.policy.appclcm.AppcLcmDmaapWrapper;
+import org.onap.policy.appclcm.AppcLcmInput;
+import org.onap.policy.appclcm.AppcLcmOutput;
import org.onap.policy.common.endpoints.http.server.HttpServletServerFactoryInstance;
import org.onap.policy.common.utils.io.Serializer;
import org.onap.policy.controlloop.ControlLoopEventStatus;
@@ -201,20 +201,22 @@ 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 AppcLcmDmaapWrapper);
+ AppcLcmDmaapWrapper dmaapRequest = (AppcLcmDmaapWrapper) request;
+ AppcLcmInput appcRequest = dmaapRequest.getBody().getInput();
assertTrue(appcRequest.getCommonHeader().getSubRequestId().contentEquals("1"));
assertFalse(manager.isOperationComplete());
assertTrue(manager.isOperationRunning());
//
// Accept
//
- LcmResponseWrapper dmaapResponse = new LcmResponseWrapper();
- LcmResponse appcResponse = new LcmResponse(appcRequest);
+ AppcLcmOutput appcResponse = new AppcLcmOutput(appcRequest);
appcResponse.getStatus().setCode(100);
appcResponse.getStatus().setMessage(ACCEPT);
- dmaapResponse.setBody(appcResponse);
+ AppcLcmBody outputBody = new AppcLcmBody();
+ outputBody.setOutput(appcResponse);
+ AppcLcmDmaapWrapper dmaapResponse = new AppcLcmDmaapWrapper();
+ dmaapResponse.setBody(outputBody);
//
//
//
@@ -226,10 +228,11 @@ public class ControlLoopOperationManagerTest {
//
// Now we are going to Fail it
//
- appcResponse = new LcmResponse(appcRequest);
+ appcResponse = new AppcLcmOutput(appcRequest);
appcResponse.getStatus().setCode(401);
appcResponse.getStatus().setMessage(APPC_FAILURE_REASON);
- dmaapResponse.setBody(appcResponse);
+ outputBody.setOutput(appcResponse);
+ dmaapResponse.setBody(outputBody);
result = manager.onResponse(dmaapResponse);
logger.debug("{}", manager);
assertTrue(result.equals(PolicyResult.FAILURE));
@@ -241,20 +244,21 @@ public class ControlLoopOperationManagerTest {
request = manager.startOperation(onset);
logger.debug("{}", manager);
assertNotNull(request);
- assertTrue(request instanceof LcmRequestWrapper);
- dmaapRequest = (LcmRequestWrapper) request;
- appcRequest = dmaapRequest.getBody();
+ assertTrue(request instanceof AppcLcmDmaapWrapper);
+ dmaapRequest = (AppcLcmDmaapWrapper) request;
+ appcRequest = dmaapRequest.getBody().getInput();
assertTrue(appcRequest.getCommonHeader().getSubRequestId().contentEquals("2"));
assertFalse(manager.isOperationComplete());
assertTrue(manager.isOperationRunning());
//
//
//
- appcResponse = new LcmResponse(appcRequest);
+ appcResponse = new AppcLcmOutput(appcRequest);
logger.debug("{}", manager);
appcResponse.getStatus().setCode(100);
appcResponse.getStatus().setMessage(ACCEPT);
- dmaapResponse.setBody(appcResponse);
+ outputBody.setOutput(appcResponse);
+ dmaapResponse.setBody(outputBody);
//
//
//
@@ -266,10 +270,11 @@ public class ControlLoopOperationManagerTest {
//
// Now we are going to Fail it
//
- appcResponse = new LcmResponse(appcRequest);
+ appcResponse = new AppcLcmOutput(appcRequest);
appcResponse.getStatus().setCode(401);
appcResponse.getStatus().setMessage(APPC_FAILURE_REASON);
- dmaapResponse.setBody(appcResponse);
+ outputBody.setOutput(appcResponse);
+ dmaapResponse.setBody(outputBody);
result = manager.onResponse(dmaapResponse);
logger.debug("{}", manager);
assertTrue(result.equals(PolicyResult.FAILURE));
@@ -323,18 +328,20 @@ 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 AppcLcmDmaapWrapper);
+ AppcLcmDmaapWrapper dmaapRequest = (AppcLcmDmaapWrapper) request;
+ AppcLcmInput appcRequest = dmaapRequest.getBody().getInput();
assertTrue((appcRequest).getCommonHeader().getSubRequestId().contentEquals("1"));
assertFalse(manager.isOperationComplete());
assertTrue(manager.isOperationRunning());
//
// Accept
//
- LcmResponseWrapper dmaapResponse = new LcmResponseWrapper();
- LcmResponse appcResponse = new LcmResponse(appcRequest);
- dmaapResponse.setBody(appcResponse);
+ AppcLcmDmaapWrapper dmaapResponse = new AppcLcmDmaapWrapper();
+ AppcLcmOutput appcResponse = new AppcLcmOutput(appcRequest);
+ AppcLcmBody outputBody = new AppcLcmBody();
+ outputBody.setOutput(appcResponse);
+ dmaapResponse.setBody(outputBody);
appcResponse.getStatus().setCode(100);
appcResponse.getStatus().setMessage(ACCEPT);
//
@@ -357,10 +364,11 @@ public class ControlLoopOperationManagerTest {
//
// Now we are going to Fail the previous request
//
- appcResponse = new LcmResponse(appcRequest);
+ appcResponse = new AppcLcmOutput(appcRequest);
appcResponse.getStatus().setCode(401);
appcResponse.getStatus().setMessage(APPC_FAILURE_REASON);
- dmaapResponse.setBody(appcResponse);
+ outputBody.setOutput(appcResponse);
+ dmaapResponse.setBody(outputBody);
manager.onResponse(dmaapResponse);
logger.debug("{}", manager);
//
@@ -671,17 +679,19 @@ 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();
- body.setCommonHeader(lcmCh);
- lrw.setBody(body);
+ AppcLcmDmaapWrapper dmaapWrapper = new AppcLcmDmaapWrapper();
+ AppcLcmBody body = new AppcLcmBody();
+ AppcLcmOutput output = new AppcLcmOutput();
+ AppcLcmCommonHeader lcmCh = new AppcLcmCommonHeader();
+ output.setCommonHeader(lcmCh);
+ body.setOutput(output);
+ dmaapWrapper.setBody(body);
lcmCh.setSubRequestId("NotANumber");
- assertEquals(PolicyResult.FAILURE_EXCEPTION, clom.onResponse(lrw));
+ assertEquals(PolicyResult.FAILURE_EXCEPTION, clom.onResponse(dmaapWrapper));
lcmCh.setSubRequestId("12345");
- assertEquals(PolicyResult.FAILURE_EXCEPTION, clom.onResponse(lrw));
+ assertEquals(PolicyResult.FAILURE_EXCEPTION, clom.onResponse(dmaapWrapper));
SoResponse soResponse = new SoResponse();
SoResponseWrapper soRw = new SoResponseWrapper(soResponse, null);
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 cc5302f61..3b61faaf2 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
@@ -8,9 +8,9 @@
* 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.
@@ -27,9 +27,10 @@ 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.AppcLcmBody;
+import org.onap.policy.appclcm.AppcLcmCommonHeader;
+import org.onap.policy.appclcm.AppcLcmDmaapWrapper;
+import org.onap.policy.appclcm.AppcLcmInput;
import org.onap.policy.controlloop.ControlLoopNotification;
import org.onap.policy.controlloop.VirtualControlLoopNotification;
import org.onap.policy.drools.impl.PolicyEngineJUnitImpl;
@@ -61,10 +62,11 @@ public class DroolsPolicyEngineTest {
request.getCommonHeader().setSubRequestId("12321");
pe.deliver(OMNI_BUS, TOPIC, request);
- LcmRequestWrapper lcmRw = new LcmRequestWrapper();
- lcmRw.setBody(new LcmRequest());
- lcmRw.getBody().setCommonHeader(new LcmCommonHeader());
- lcmRw.getBody().getCommonHeader().setSubRequestId("54321");
+ AppcLcmDmaapWrapper lcmRw = new AppcLcmDmaapWrapper();
+ lcmRw.setBody(new AppcLcmBody());
+ lcmRw.getBody().setInput(new AppcLcmInput());
+ lcmRw.getBody().getInput().setCommonHeader(new AppcLcmCommonHeader());
+ lcmRw.getBody().getInput().getCommonHeader().setSubRequestId("54321");
pe.deliver(OMNI_BUS, TOPIC, lcmRw);
}