aboutsummaryrefslogtreecommitdiffstats
path: root/controlloop/common/eventmanager/src/test
diff options
context:
space:
mode:
authordaniel <dc443y@att.com>2017-08-11 11:36:09 -0500
committerdaniel <dc443y@att.com>2017-09-06 17:14:59 -0500
commit7576237fd14304e987eb3c907d481f503dab8232 (patch)
treeddc75f000cb86e3a426cf34d6031efbc14c8735e /controlloop/common/eventmanager/src/test
parentb2bdc20c1ce3a390dd7928144c2ccb17a98b1363 (diff)
Add APPC LCM Interface
The LCM model code and service provider code is implemented. This model code is now used for the vCPE use case scenario. The vFW use case is still using the legacy APPC API as request by APPC for Policy to use in R1. The APPC service provider now generates a demo legacy APPC request with pg-streams. An A&AI named query is implemented for the vFW use case. The code for obtaining the generic-vnf.vnf-id is not in use until we set up the A&AI simulator to work without having cyclical depenncies inside the POMs. JUnits for the vFW and vCPE use cases are now supported. These JUnits test the complete flow of each scenario. A&AI testing is not supported in the JUnit test yet. These JUnits use a target type of VM as VNF is not supported yet. This will be changed when the Target Lock supports VNF. Amended to fix Sonar blockers. Issue-ID: POLICY-104 Change-Id: I46869c5fd5094919da55ad563d608fe6d4b6fea7 Signed-off-by: Daniel Cruz <dc443y@att.com>
Diffstat (limited to 'controlloop/common/eventmanager/src/test')
-rw-r--r--controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManagerTest.java87
1 files changed, 49 insertions, 38 deletions
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 6116d987e..90f61e0c9 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
@@ -30,10 +30,10 @@ import java.util.HashMap;
import java.util.UUID;
import org.junit.Test;
-import org.onap.policy.appc.Request;
-import org.onap.policy.appc.Response;
-import org.onap.policy.appc.ResponseCode;
-import org.onap.policy.appc.ResponseValue;
+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.VirtualControlLoopEvent;
@@ -53,7 +53,7 @@ public class ControlLoopOperationManagerTest {
onset.requestID = UUID.randomUUID();
onset.target = "vserver.selflink";
onset.closedLoopAlarmStart = Instant.now();
- onset.AAI = new HashMap<String, String>();
+ onset.AAI = new HashMap<>();
onset.AAI.put("cloud-region.identity-url", "foo");
onset.AAI.put("vserver.selflink", "bar");
onset.AAI.put("vserver.is-closed-loop-disabled", "false");
@@ -91,20 +91,24 @@ public class ControlLoopOperationManagerTest {
Object request = manager.startOperation(onset);
logger.debug("{}",manager);
assertNotNull(request);
- assertTrue(request instanceof Request);
- assertTrue(((Request)request).CommonHeader.SubRequestID.contentEquals("1"));
+ 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
//
- Response response = new Response((Request) request);
- response.Status.Code = ResponseCode.ACCEPT.getValue();
- response.Status.Value = ResponseValue.ACCEPT.toString();
+ LCMResponseWrapper dmaapResponse = new LCMResponseWrapper();
+ LCMResponse appcResponse = new LCMResponse((LCMRequest) appcRequest);
+ appcResponse.getStatus().setCode(100);
+ appcResponse.getStatus().setMessage("ACCEPT");
+ dmaapResponse.setBody(appcResponse);
//
//
//
- PolicyResult result = manager.onResponse(response);
+ PolicyResult result = manager.onResponse(dmaapResponse);
logger.debug("{}",manager);
assertTrue(result == null);
assertFalse(manager.isOperationComplete());
@@ -112,11 +116,11 @@ public class ControlLoopOperationManagerTest {
//
// Now we are going to Fail it
//
- response = new Response((Request) request);
- response.Status.Code = ResponseCode.FAILURE.getValue();
- response.Status.Value = ResponseValue.FAILURE.toString();
- response.Status.Description = "AppC failed for some reason";
- result = manager.onResponse(response);
+ appcResponse = new LCMResponse(appcRequest);
+ appcResponse.getStatus().setCode(401);
+ appcResponse.getStatus().setMessage("AppC failed for some reason");
+ dmaapResponse.setBody(appcResponse);
+ result = manager.onResponse(dmaapResponse);
logger.debug("{}",manager);
assertTrue(result.equals(PolicyResult.FAILURE));
assertFalse(manager.isOperationComplete());
@@ -127,21 +131,24 @@ public class ControlLoopOperationManagerTest {
request = manager.startOperation(onset);
logger.debug("{}",manager);
assertNotNull(request);
- assertTrue(request instanceof Request);
- assertTrue(((Request)request).CommonHeader.SubRequestID.contentEquals("2"));
+ assertTrue(request instanceof LCMRequestWrapper);
+ dmaapRequest = (LCMRequestWrapper) request;
+ appcRequest = dmaapRequest.getBody();
+ assertTrue(appcRequest.getCommonHeader().getSubRequestId().contentEquals("2"));
assertFalse(manager.isOperationComplete());
assertTrue(manager.isOperationRunning());
//
//
//
- response = new Response((Request) request);
+ appcResponse = new LCMResponse((LCMRequest) appcRequest);
logger.debug("{}",manager);
- response.Status.Code = ResponseCode.ACCEPT.getValue();
- response.Status.Value = ResponseValue.ACCEPT.toString();
+ appcResponse.getStatus().setCode(100);
+ appcResponse.getStatus().setMessage("ACCEPT");
+ dmaapResponse.setBody(appcResponse);
//
//
//
- result = manager.onResponse(response);
+ result = manager.onResponse(dmaapResponse);
logger.debug("{}",manager);
assertTrue(result == null);
assertFalse(manager.isOperationComplete());
@@ -149,11 +156,11 @@ public class ControlLoopOperationManagerTest {
//
// Now we are going to Fail it
//
- response = new Response((Request) request);
- response.Status.Code = ResponseCode.FAILURE.getValue();
- response.Status.Value = ResponseValue.FAILURE.toString();
- response.Status.Description = "AppC failed for some reason";
- result = manager.onResponse(response);
+ appcResponse = new LCMResponse((LCMRequest) appcRequest);
+ appcResponse.getStatus().setCode(401);
+ appcResponse.getStatus().setMessage("AppC failed for some reason");
+ dmaapResponse.setBody(appcResponse);
+ result = manager.onResponse(dmaapResponse);
logger.debug("{}",manager);
assertTrue(result.equals(PolicyResult.FAILURE));
//
@@ -199,20 +206,24 @@ public class ControlLoopOperationManagerTest {
Object request = manager.startOperation(onset);
logger.debug("{}",manager);
assertNotNull(request);
- assertTrue(request instanceof Request);
- assertTrue(((Request)request).CommonHeader.SubRequestID.contentEquals("1"));
+ 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
//
- Response response = new Response((Request) request);
- response.Status.Code = ResponseCode.ACCEPT.getValue();
- response.Status.Value = ResponseValue.ACCEPT.toString();
+ LCMResponseWrapper dmaapResponse = new LCMResponseWrapper();
+ LCMResponse appcResponse = new LCMResponse(appcRequest);
+ dmaapResponse.setBody(appcResponse);
+ appcResponse.getStatus().setCode(100);
+ appcResponse.getStatus().setMessage("ACCEPT");
//
//
//
- PolicyResult result = manager.onResponse(response);
+ PolicyResult result = manager.onResponse(dmaapResponse);
logger.debug("{}",manager);
assertTrue(result == null);
assertFalse(manager.isOperationComplete());
@@ -229,11 +240,11 @@ public class ControlLoopOperationManagerTest {
//
// Now we are going to Fail the previous request
//
- response = new Response((Request) request);
- response.Status.Code = ResponseCode.FAILURE.getValue();
- response.Status.Value = ResponseValue.FAILURE.toString();
- response.Status.Description = "AppC failed for some reason";
- result = manager.onResponse(response);
+ appcResponse = new LCMResponse(appcRequest);
+ appcResponse.getStatus().setCode(401);
+ appcResponse.getStatus().setMessage("AppC failed for some reason");
+ dmaapResponse.setBody(appcResponse);
+ result = manager.onResponse(dmaapResponse);
logger.debug("{}",manager);
//
//