diff options
author | Jorge Hernandez <jh1730@att.com> | 2018-01-18 19:49:37 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2018-01-18 19:49:37 +0000 |
commit | def409f0065bd7e892833dfce8f5a60dcffdf97d (patch) | |
tree | d3e2b3e1a21af6c613b52a38ae6af20b1640b824 | |
parent | cebad66213ff84469971b253320f72fa3a41b3cd (diff) | |
parent | b2a9a8adbcf036780bf47c5c94dbf65a088ab540 (diff) |
Merge "Fix Tech Debt/JUnit on control loop event POJOs"
25 files changed, 989 insertions, 669 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 41a99496c..c0bbfe8f3 100644 --- a/controlloop/common/actors/actor.appc/src/main/java/org/onap/policy/controlloop/actor/appc/APPCActorServiceProvider.java +++ b/controlloop/common/actors/actor.appc/src/main/java/org/onap/policy/controlloop/actor/appc/APPCActorServiceProvider.java @@ -94,8 +94,8 @@ public class APPCActorServiceProvider implements Actor { */ Request request = new Request(); request.setCommonHeader(new CommonHeader()); - request.getCommonHeader().setRequestID(onset.requestID); - request.getCommonHeader().setSubRequestID(operation.subRequestId); + request.getCommonHeader().setRequestID(onset.getRequestID()); + request.getCommonHeader().setSubRequestID(operation.getSubRequestId()); request.setAction(policy.getRecipe().substring(0, 1).toUpperCase() + policy.getRecipe().substring(1)); diff --git a/controlloop/common/actors/actor.appc/src/test/java/org/onap/policy/controlloop/actor/appc/AppcServiceProviderTest.java b/controlloop/common/actors/actor.appc/src/test/java/org/onap/policy/controlloop/actor/appc/AppcServiceProviderTest.java index e07589081..89de717fb 100644 --- a/controlloop/common/actors/actor.appc/src/test/java/org/onap/policy/controlloop/actor/appc/AppcServiceProviderTest.java +++ b/controlloop/common/actors/actor.appc/src/test/java/org/onap/policy/controlloop/actor/appc/AppcServiceProviderTest.java @@ -60,24 +60,24 @@ public class AppcServiceProviderTest { * generic-vnf.vnf-id and a target type of VM. */ onsetEvent = new VirtualControlLoopEvent(); - onsetEvent.closedLoopControlName = "closedLoopControlName-Test"; - onsetEvent.requestID = UUID.randomUUID(); - onsetEvent.closedLoopEventClient = "tca.instance00001"; - onsetEvent.target_type = ControlLoopTargetType.VNF; - onsetEvent.target = "generic-vnf.vnf-name"; - onsetEvent.from = "DCAE"; - onsetEvent.closedLoopAlarmStart = Instant.now(); - onsetEvent.AAI = new HashMap<>(); - onsetEvent.AAI.put("generic-vnf.vnf-name", "fw0001vm001fw001"); - onsetEvent.closedLoopEventStatus = ControlLoopEventStatus.ONSET; + onsetEvent.setClosedLoopControlName("closedLoopControlName-Test"); + onsetEvent.setRequestID(UUID.randomUUID()); + onsetEvent.setClosedLoopEventClient("tca.instance00001"); + onsetEvent.setTargetType(ControlLoopTargetType.VNF); + onsetEvent.setTarget("generic-vnf.vnf-name"); + onsetEvent.setFrom("DCAE"); + onsetEvent.setClosedLoopAlarmStart(Instant.now()); + onsetEvent.setAAI(new HashMap<>()); + onsetEvent.getAAI().put("generic-vnf.vnf-name", "fw0001vm001fw001"); + onsetEvent.setClosedLoopEventStatus(ControlLoopEventStatus.ONSET); /* Construct an operation with an APPC actor and ModifyConfig operation. */ operation = new ControlLoopOperation(); - operation.actor = "APPC"; - operation.operation = "ModifyConfig"; - operation.target = "VNF"; - operation.end = Instant.now(); - operation.subRequestId = "1"; + operation.setActor("APPC"); + operation.setOperation("ModifyConfig"); + operation.setTarget("VNF"); + operation.setEnd(Instant.now()); + operation.setSubRequestId("1"); /* Construct a policy specifying to modify configuration. */ policy = new Policy(); @@ -123,7 +123,7 @@ public class AppcServiceProviderTest { /* A common header is required and cannot be null */ assertNotNull(appcRequest.getCommonHeader()); - assertEquals(appcRequest.getCommonHeader().getRequestID(), onsetEvent.requestID); + assertEquals(appcRequest.getCommonHeader().getRequestID(), onsetEvent.getRequestID()); /* An action is required and cannot be null */ assertNotNull(appcRequest.getAction()); 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 0f4a00423..8e416cb63 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 @@ -211,7 +211,7 @@ public class AppcLcmActorServiceProvider implements Actor { */ LCMRequestWrapper dmaapRequest = new LCMRequestWrapper(); dmaapRequest.setVersion("2.0"); - dmaapRequest.setCorrelationId(onset.requestID + "-" + operation.subRequestId); + dmaapRequest.setCorrelationId(onset.getRequestID() + "-" + operation.getSubRequestId()); dmaapRequest.setRpcName(policy.getRecipe().toLowerCase()); dmaapRequest.setType("request"); @@ -220,9 +220,9 @@ public class AppcLcmActorServiceProvider implements Actor { /* The common header is a required field for all APPC requests. */ LCMCommonHeader requestCommonHeader = new LCMCommonHeader(); - requestCommonHeader.setOriginatorId(onset.requestID.toString()); - requestCommonHeader.setRequestId(onset.requestID); - requestCommonHeader.setSubRequestId(operation.subRequestId); + requestCommonHeader.setOriginatorId(onset.getRequestID().toString()); + requestCommonHeader.setRequestId(onset.getRequestID()); + requestCommonHeader.setSubRequestId(operation.getSubRequestId()); appcRequest.setCommonHeader(requestCommonHeader); 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 d446968ef..b498566da 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 @@ -66,24 +66,24 @@ public class AppcLcmServiceProviderTest { * generic-vnf.vnf-id and a target type of VM. */ onsetEvent = new VirtualControlLoopEvent(); - onsetEvent.closedLoopControlName = "closedLoopControlName-Test"; - onsetEvent.requestID = UUID.randomUUID(); - onsetEvent.closedLoopEventClient = "tca.instance00001"; - onsetEvent.target_type = ControlLoopTargetType.VM; - onsetEvent.target = "generic-vnf.vnf-name"; - onsetEvent.from = "DCAE"; - onsetEvent.closedLoopAlarmStart = Instant.now(); - onsetEvent.AAI = new HashMap<>(); - onsetEvent.AAI.put("generic-vnf.vnf-name", "fw0001vm001fw001"); - onsetEvent.closedLoopEventStatus = ControlLoopEventStatus.ONSET; + onsetEvent.setClosedLoopControlName("closedLoopControlName-Test"); + onsetEvent.setRequestID(UUID.randomUUID()); + onsetEvent.setClosedLoopEventClient("tca.instance00001"); + onsetEvent.setTargetType(ControlLoopTargetType.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.setClosedLoopEventStatus(ControlLoopEventStatus.ONSET); /* Construct an operation with an APPC actor and restart operation. */ operation = new ControlLoopOperation(); - operation.actor = "APPC"; - operation.operation = "Restart"; - operation.target = "VM"; - operation.end = Instant.now(); - operation.subRequestId = "1"; + operation.setActor("APPC"); + operation.setOperation("Restart"); + operation.setTarget("VM"); + operation.setEnd(Instant.now()); + operation.setSubRequestId("1"); /* Construct a policy specifying to restart vm. */ policy = new Policy(); @@ -98,13 +98,13 @@ public class AppcLcmServiceProviderTest { /* A sample DMAAP request wrapper. */ dmaapRequest = new LCMRequestWrapper(); - dmaapRequest.setCorrelationId(onsetEvent.requestID.toString() + "-" + "1"); + 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.requestID.toString() + "-" + "1"); + dmaapResponse.setCorrelationId(onsetEvent.getRequestID().toString() + "-" + "1"); dmaapResponse.setRpcName(policy.getRecipe().toLowerCase()); dmaapResponse.setType("response"); @@ -125,9 +125,9 @@ public class AppcLcmServiceProviderTest { appcRequest.setActionIdentifiers(actionIdentifiers); LCMCommonHeader commonHeader = new LCMCommonHeader(); - commonHeader.setRequestId(onsetEvent.requestID); + commonHeader.setRequestId(onsetEvent.getRequestID()); commonHeader.setSubRequestId("1"); - commonHeader.setOriginatorId(onsetEvent.requestID.toString()); + commonHeader.setOriginatorId(onsetEvent.getRequestID().toString()); appcRequest.setCommonHeader(commonHeader); @@ -184,7 +184,7 @@ public class AppcLcmServiceProviderTest { /* A common header is required and cannot be null */ assertNotNull(appcRequest.getCommonHeader()); - assertEquals(appcRequest.getCommonHeader().getRequestId(), onsetEvent.requestID); + assertEquals(appcRequest.getCommonHeader().getRequestId(), onsetEvent.getRequestID()); /* An action is required and cannot be null */ assertNotNull(appcRequest.getAction()); 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 ad27a0201..6fe1c7f36 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 @@ -158,7 +158,7 @@ public class SOActorServiceProvider implements Actor { // Map<String, Map<String, String>> aainqinstancefiltermap = new HashMap<>(); Map<String, String> aainqinstancefiltermapitem = new HashMap<>(); - aainqinstancefiltermapitem.put("vserver-name", onset.AAI.get("vserver.vserver-name")); // TO DO: get vserver.vname from dcae onset.AAI.get("vserver.vserver-name") + aainqinstancefiltermapitem.put("vserver-name", onset.getAAI().get("vserver.vserver-name")); // TO DO: get vserver.vname from dcae onset.AAI.get("vserver.vserver-name") aainqinstancefiltermap.put("vserver", aainqinstancefiltermapitem); aainqinstancefilter.getInstanceFilter().add(aainqinstancefiltermap); aainqrequest.setInstanceFilters(aainqinstancefilter); @@ -186,7 +186,7 @@ public class SOActorServiceProvider implements Actor { //***** send the request *****\\ AAINQResponse aainqresponse = new AAIManager(new RESTManager()).postQuery(aaiUrl, aaiUsername, aaiPassword, - aainqrequest, onset.requestID); + aainqrequest, onset.getRequestID()); // Check AAI response if (aainqresponse == null) { @@ -196,7 +196,7 @@ public class SOActorServiceProvider implements Actor { return null; } else { // Create AAINQResponseWrapper - AAINQResponseWrapper aainqResponseWrapper = new AAINQResponseWrapper(onset.requestID, aainqresponse); + AAINQResponseWrapper aainqResponseWrapper = new AAINQResponseWrapper(onset.getRequestID(), aainqresponse); // insert aainqResponseWrapper to memory -- Is this needed? // insert(aainqResponseWrapper); 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 efa3dba1f..dae60cb82 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 @@ -70,7 +70,7 @@ public class VFCActorServiceProvider implements Actor { Policy policy, AAIGETVnfResponse vnfResponse) { // Construct an VFC request VFCRequest request = new VFCRequest(); - String serviceInstance = onset.AAI.get("service-instance.service-instance-id"); + String serviceInstance = onset.getAAI().get("service-instance.service-instance-id"); if (serviceInstance == null || "".equals(serviceInstance)) { AAIGETVnfResponse tempVnfResp = vnfResponse; @@ -83,18 +83,18 @@ public class VFCActorServiceProvider implements Actor { serviceInstance = tempVnfResp.getServiceId(); } request.nsInstanceId = serviceInstance; - request.requestId = onset.requestID; + request.requestId = onset.getRequestID(); request.healRequest = new VFCHealRequest(); - request.healRequest.vnfInstanceId = onset.AAI.get("generic-vnf.vnf-id"); - request.healRequest.cause = operation.message; + request.healRequest.vnfInstanceId = onset.getAAI().get("generic-vnf.vnf-id"); + request.healRequest.cause = operation.getMessage(); request.healRequest.additionalParams = new VFCHealAdditionalParams(); switch (policy.getRecipe().toLowerCase()) { case "restart": request.healRequest.additionalParams.action = "restartvm"; request.healRequest.additionalParams.actionInfo = new VFCHealActionVmInfo(); - request.healRequest.additionalParams.actionInfo.vmid = onset.AAI.get("vserver.vserver-id"); - request.healRequest.additionalParams.actionInfo.vmname = onset.AAI.get("vserver.vserver-name"); + request.healRequest.additionalParams.actionInfo.vmid = onset.getAAI().get("vserver.vserver-id"); + request.healRequest.additionalParams.actionInfo.vmname = onset.getAAI().get("vserver.vserver-name"); break; default: return null; @@ -105,9 +105,9 @@ public class VFCActorServiceProvider implements Actor { private static AAIGETVnfResponse getAAIServiceInstance(VirtualControlLoopEvent event) { AAIGETVnfResponse response = null; - UUID requestID = event.requestID; - String vnfName = event.AAI.get("generic-vnf.vnf-name"); - String vnfID = event.AAI.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/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 559eab9d9..2b296616d 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 @@ -157,15 +157,15 @@ public class ControlLoopEventManager implements LockCallback, Serializable { this.onset = event; this.numOnsets = 1; // - notification.notification = ControlLoopNotificationType.ACTIVE; + notification.setNotification(ControlLoopNotificationType.ACTIVE); // // Set ourselves as active // this.isActivated = true; } catch (ControlLoopException e) { logger.error("{}: activate threw: ",this, e); - notification.notification = ControlLoopNotificationType.REJECTED; - notification.message = e.getMessage(); + notification.setNotification(ControlLoopNotificationType.REJECTED); + notification.setMessage(e.getMessage()); } return notification; } @@ -214,15 +214,15 @@ public class ControlLoopEventManager implements LockCallback, Serializable { // // // - notification.notification = ControlLoopNotificationType.ACTIVE; + notification.setNotification(ControlLoopNotificationType.ACTIVE); // // Set ourselves as active // this.isActivated = true; } catch (ControlLoopException e) { logger.error("{}: activate threw: ",this, e); - notification.notification = ControlLoopNotificationType.REJECTED; - notification.message = e.getMessage(); + notification.setNotification(ControlLoopNotificationType.REJECTED); + notification.setMessage(e.getMessage()); } return notification; } @@ -251,9 +251,9 @@ public class ControlLoopEventManager implements LockCallback, Serializable { // // Yes we have timed out // - notification.notification = ControlLoopNotificationType.FINAL_FAILURE; - notification.message = "Control Loop timed out"; - notification.history.addAll(this.controlLoopHistory); + notification.setNotification(ControlLoopNotificationType.FINAL_FAILURE); + notification.setMessage("Control Loop timed out"); + notification.getHistory().addAll(this.controlLoopHistory); return notification; } // @@ -269,18 +269,18 @@ public class ControlLoopEventManager implements LockCallback, Serializable { switch (result) { case FINAL_FAILURE_EXCEPTION: - notification.message = "Exception in processing closed loop"; + notification.setMessage("Exception in processing closed loop"); case FINAL_FAILURE: case FINAL_FAILURE_RETRIES: case FINAL_FAILURE_TIMEOUT: case FINAL_FAILURE_GUARD: - notification.notification = ControlLoopNotificationType.FINAL_FAILURE; + notification.setNotification(ControlLoopNotificationType.FINAL_FAILURE); break; case FINAL_OPENLOOP: - notification.notification = ControlLoopNotificationType.FINAL_OPENLOOP; + notification.setNotification(ControlLoopNotificationType.FINAL_OPENLOOP); break; case FINAL_SUCCESS: - notification.notification = ControlLoopNotificationType.FINAL_SUCCESS; + notification.setNotification(ControlLoopNotificationType.FINAL_SUCCESS); break; default: return null; @@ -288,7 +288,7 @@ public class ControlLoopEventManager implements LockCallback, Serializable { // // Be sure to add all the history // - notification.history.addAll(this.controlLoopHistory); + notification.getHistory().addAll(this.controlLoopHistory); return notification; } @@ -401,7 +401,7 @@ public class ControlLoopEventManager implements LockCallback, Serializable { LockResult<GuardResult, TargetLock> lockResult = PolicyGuard.lockTarget( this.currentOperation.policy.getTarget().getType(), this.currentOperation.getTargetEntity(), - this.onset.requestID, + this.onset.getRequestID(), this); // // Was it acquired? @@ -440,7 +440,7 @@ public class ControlLoopEventManager implements LockCallback, Serializable { public NEW_EVENT_STATUS onNewEvent(VirtualControlLoopEvent event) throws AAIException { try { this.checkEventSyntax(event); - if (event.closedLoopEventStatus == ControlLoopEventStatus.ONSET) { + if (event.getClosedLoopEventStatus() == ControlLoopEventStatus.ONSET) { // // Check if this is our original ONSET // @@ -460,7 +460,7 @@ public class ControlLoopEventManager implements LockCallback, Serializable { // this.numOnsets++; return NEW_EVENT_STATUS.SUBSEQUENT_ONSET; - } else if (event.closedLoopEventStatus == ControlLoopEventStatus.ABATED) { + } else if (event.getClosedLoopEventStatus() == ControlLoopEventStatus.ABATED) { // // Have we already got an abatement? // @@ -499,9 +499,9 @@ public class ControlLoopEventManager implements LockCallback, Serializable { public VirtualControlLoopNotification setControlLoopTimedOut() { this.controlLoopTimedOut = FinalResult.FINAL_FAILURE_TIMEOUT; VirtualControlLoopNotification notification = new VirtualControlLoopNotification(this.onset); - notification.notification = ControlLoopNotificationType.FINAL_FAILURE; - notification.message = "Control Loop timed out"; - notification.history.addAll(this.controlLoopHistory); + notification.setNotification(ControlLoopNotificationType.FINAL_FAILURE); + notification.setMessage("Control Loop timed out"); + notification.getHistory().addAll(this.controlLoopHistory); return notification; } @@ -528,43 +528,43 @@ public class ControlLoopEventManager implements LockCallback, Serializable { } public void checkEventSyntax(VirtualControlLoopEvent event) throws ControlLoopException { - if (event.closedLoopEventStatus == null || - (event.closedLoopEventStatus != ControlLoopEventStatus.ONSET && - event.closedLoopEventStatus != ControlLoopEventStatus.ABATED)) { + if (event.getClosedLoopEventStatus() == null || + (event.getClosedLoopEventStatus() != ControlLoopEventStatus.ONSET && + event.getClosedLoopEventStatus() != ControlLoopEventStatus.ABATED)) { throw new ControlLoopException("Invalid value in closedLoopEventStatus"); } - if (event.closedLoopControlName == null || event.closedLoopControlName.length() < 1) { + if (event.getClosedLoopControlName() == null || event.getClosedLoopControlName().length() < 1) { throw new ControlLoopException("No control loop name"); } - if (event.requestID == null) { + if (event.getRequestID() == null) { throw new ControlLoopException("No request ID"); } - if (event.closedLoopEventStatus == ControlLoopEventStatus.ABATED) { + if (event.getClosedLoopEventStatus() == ControlLoopEventStatus.ABATED) { return; } - if (event.target == null || event.target.length() < 1) { + if (event.getTarget() == null || event.getTarget().length() < 1) { throw new ControlLoopException("No target field"); - } else if (! "VM_NAME".equalsIgnoreCase(event.target) && - ! "VNF_NAME".equalsIgnoreCase(event.target) && - ! "vserver.vserver-name".equalsIgnoreCase(event.target) && - ! "generic-vnf.vnf-id".equalsIgnoreCase(event.target) && - ! "generic-vnf.vnf-name".equalsIgnoreCase(event.target) ) { + } else if (! "VM_NAME".equalsIgnoreCase(event.getTarget()) && + ! "VNF_NAME".equalsIgnoreCase(event.getTarget()) && + ! "vserver.vserver-name".equalsIgnoreCase(event.getTarget()) && + ! "generic-vnf.vnf-id".equalsIgnoreCase(event.getTarget()) && + ! "generic-vnf.vnf-name".equalsIgnoreCase(event.getTarget()) ) { throw new ControlLoopException("target field invalid - expecting VM_NAME or VNF_NAME"); } - if (event.AAI == null) { + if (event.getAAI() == null) { throw new ControlLoopException("AAI is null"); } - if (event.AAI.get("generic-vnf.vnf-id") == null && event.AAI.get("vserver.vserver-name") == null && - event.AAI.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"); } } public void queryAai(VirtualControlLoopEvent event) throws AAIException { - if (event.AAI.get("vserver.is-closed-loop-disabled") == null && - event.AAI.get("generic-vnf.is-closed-loop-disabled") == null) { + if (event.getAAI().get("vserver.is-closed-loop-disabled") == null && + event.getAAI().get("generic-vnf.is-closed-loop-disabled") == null) { try { - if (event.AAI.get("generic-vnf.vnf-id") != null) { + if (event.getAAI().get("generic-vnf.vnf-id") != null) { vnfResponse = getAAIVnfInfo(event); if (vnfResponse == null) { throw new AAIException("AAI Response is null (query by vnf-id)"); @@ -575,7 +575,7 @@ public class ControlLoopEventManager implements LockCallback, Serializable { if (isClosedLoopDisabled(vnfResponse) == true) { throw new AAIException("is-closed-loop-disabled is set to true"); } - } else if (event.AAI.get("generic-vnf.vnf-name") != null) { + } else if (event.getAAI().get("generic-vnf.vnf-name") != null) { vnfResponse = getAAIVnfInfo(event); if (vnfResponse == null) { throw new AAIException("AAI Response is null (query by vnf-name)"); @@ -586,7 +586,7 @@ public class ControlLoopEventManager implements LockCallback, Serializable { if (isClosedLoopDisabled(vnfResponse) == true) { throw new AAIException("is-closed-loop-disabled is set to true"); } - } else if (event.AAI.get("vserver.vserver-name") != null) { + } else if (event.getAAI().get("vserver.vserver-name") != null) { vserverResponse = getAAIVserverInfo(event); if (vserverResponse == null) { throw new AAIException("AAI Response is null (query by vserver-name)"); @@ -632,25 +632,25 @@ public class ControlLoopEventManager implements LockCallback, Serializable { } public static boolean isClosedLoopDisabled(VirtualControlLoopEvent event) { - if ("true".equalsIgnoreCase(event.AAI.get("vserver.is-closed-loop-disabled")) || - "T".equalsIgnoreCase(event.AAI.get("vserver.is-closed-loop-disabled")) || - "yes".equalsIgnoreCase(event.AAI.get("vserver.is-closed-loop-disabled")) || - "Y".equalsIgnoreCase(event.AAI.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; } - else if ("true".equalsIgnoreCase(event.AAI.get("generic-vnf.is-closed-loop-disabled")) || - "T".equalsIgnoreCase(event.AAI.get("generic-vnf.is-closed-loop-disabled")) || - "yes".equalsIgnoreCase(event.AAI.get("generic-vnf.is-closed-loop-disabled")) || - "Y".equalsIgnoreCase(event.AAI.get("generic-vnf.is-closed-loop-disabled"))) { + else if ("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; } return false; } public static AAIGETVserverResponse getAAIVserverInfo(VirtualControlLoopEvent event) t - if (!NetworkUtil.isTcpPortOpen(LOCALHOST, testServer.getPort(), 5, 10000L)) { - throw new IllegalStateException(CANNOT_CONNECT + testServer.getPort()); - } - return testServer; - } - - /** - * Build an SDNC simulator. - * - * @return the simulator - * @throws InterruptedException if a thread is interrupted - * @throws IOException if an IO errror occurs - */ - public static HttpServletServer buildSdncSim() throws InterruptedException, IOException { - final HttpServletServer testServer = - HttpServletServer.factory.build(SDNCSIM_SERVER_NAME, LOCALHOST, SDNCSIM_SERVER_PORT, "/", false, true); - testServer.addServletClass("/*", SdncSimulatorJaxRs.class.getName()); - testServer.waitedStart(5000); - if (!NetworkUtil.isTcpPortOpen(LOCALHOST, testServer.getPort(), 5, 10000L)) { - throw new IllegalStateException(CANNOT_CONNECT + testServer.getPort()); - } - return testServer; - } - - - /** - * Build an SO simulator. - * - * @return the simulator - * @throws InterruptedException if a thread is interrupted - * @throws IOException if an IO errror occurs - */ - public static HttpServletServer buildSoSim() throws InterruptedException, IOException { - final HttpServletServer testServer = - HttpServletServer.factory.build(SOSIM_SERVER_NAME, LOCALHOST, SOSIM_SERVER_PORT, "/", false, true); - testServer.addServletClass("/*", SoSimulatorJaxRs.class.getName()); - testServer.waitedStart(5000); - if (!NetworkUtil.isTcpPortOpen(LOCALHOST, testServer.getPort(), 5, 10000L)) { - throw new IllegalStateException(CANNOT_CONNECT + testServer.getPort()); - } - return testServer; - } - - /** - * Build a VFC simulator. - * - * @return the simulator - * @throws InterruptedException if a thread is interrupted - * @throws IOException if an IO errror occurs - */ - public static HttpServletServer buildVfcSim() throws InterruptedException, IOException { - final HttpServletServer testServer = - HttpServletServer.factory.build(VFCSIM_SERVER_NAME,LOCALHOST, VFCSIM_SERVER_PORT, "/", false, true); - testServer.addServletClass("/*", VfcSimulatorJaxRs.class.getName()); - testServer.waitedStart(5000); - if (!NetworkUtil.isTcpPortOpen(LOCALHOST, testServer.getPort(), 5, 10000L)) { - throw new IllegalStateException(CANNOT_CONNECT + testServer.getPort()); - } - return testServer; - } - - /** - * Build a guard simulator. - * - * @return the simulator - * @throws InterruptedException if a thread is interrupted - * @throws IOException if an IO errror occurs - */ - public static HttpServletServer buildGuardSim() throws InterruptedException, IOException { - HttpServletServer testServer = HttpServletServer.factory.build(GUARDSIM_SERVER_NAME, LOCALHOST, - GUARDSIM_SERVER_PORT, "/", false, true); - testServer.addServletClass("/*", GuardSimulatorJaxRs.class.getName()); - testServer.waitedStart(5000); - if (!NetworkUtil.isTcpPortOpen(LOCALHOST, testServer.getPort(), 5, 10000L)) { - throw new IllegalStateException(CANNOT_CONNECT + testServer.getPort()); - } - return testServer; - } -} diff --git a/controlloop/common/simulators/src/main/java/org/onap/policy/simulators/VfcSimulatorJaxRs.java b/controlloop/common/simulators/src/main/java/org/onap/policy/simulators/VfcSimulatorJaxRs.java deleted file mode 100644 index 101184d69..000000000 --- a/controlloop/common/simulators/src/main/java/org/onap/policy/simulators/VfcSimulatorJaxRs.java +++ /dev/null @@ -1,85 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * simulators - * ================================================================================ - * 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.simulators; - -import javax.servlet.http.HttpServletResponse; -import javax.ws.rs.Consumes; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.core.Context; -import javax.ws.rs.core.MediaType; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -@Path("/api/nslcm/v1") -public class VfcSimulatorJaxRs { - - /** - * VFC post query. - * - * @param nsInstanceId the NS instance - * @param response the response - * @return the response - */ - @POST - @Path("/ns/{nsInstanceId}/heal") - @Consumes(MediaType.APPLICATION_JSON) - @Produces("application/json") - public String vfcPostQuery(@PathParam("nsInstanceId") String nsInstanceId, - @Context final HttpServletResponse response) { - response.setStatus(HttpServletResponse.SC_ACCEPTED); - try { - response.flushBuffer(); - } catch (Exception e) { - final Logger logger = LoggerFactory.getLogger(VfcSimulatorJaxRs.class); - logger.error("flushBuffer threw: ", e); - return ""; - } - - return "{\"jobId\":\"1\"}"; - } - - /** - * VFC get query. - * - * @param jobId tthe job id - * @return the response - */ - @GET - @Path("/jobs/{jobId}") - @Consumes(MediaType.APPLICATION_JSON) - @Produces("application/json") - public String vfcGetQuery(@PathParam("jobId") String jobId) { - return "{\"jobId\" : " + jobId - + ",\"responseDescriptor\" : {\"progress\" : \"40\",\"status\" : \"finished\",\"statusDescription" - + "\" : \"OMC VMs are decommissioned in VIM\",\"errorCode\" : null,\"responseId\": 101 ,\"" - + "responseHistoryList\": [{\"progress\" : \"40\",\"status\" : \"proccessing\",\"statusDescription" - + "\" : \"OMC VMs are decommissioned in VIM\",\"errorCode\" : null,\"responseId\" : \"1\"}, {\"" - + "progress\" : \"41\",\"status\" : \"proccessing\",\"statusDescription\" : \"OMC VMs are " - + "decommissioned in VIM\",\"errorCode\" : null,\"responseId\" : \"2\"}]}}"; - } - -} - diff --git a/controlloop/common/simulators/src/main/resources/org/onap/policy/simulators/aai/AaiNqResponse-Error.json b/controlloop/common/simulators/src/main/resources/org/onap/policy/simulators/aai/AaiNqResponse-Error.json deleted file mode 100644 index 77b30bdb1..000000000 --- a/controlloop/common/simulators/src/main/resources/org/onap/policy/simulators/aai/AaiNqResponse-Error.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "inventory-response-item": [], - "requestError": { - "serviceException": { - "messageId": "SVC3001", - "text": "Resource not found for %1 using id %2 (msg=%3) (ec=%4)", - "variables": [ - "POST Search", - "getNamedQueryResponse", - "Node Not Found:No Node of type ${type} found for properties", - "ERR.5.4.6114" - ] - } - } -} diff --git a/controlloop/common/simulators/src/main/resources/org/onap/policy/simulators/aai/AaiNqResponse-GenericVnf.json b/controlloop/common/simulators/src/main/resources/org/onap/policy/simulators/aai/AaiNqResponse-GenericVnf.json deleted file mode 100644 index 906e4afbb..000000000 --- a/controlloop/common/simulators/src/main/resources/org/onap/policy/simulators/aai/AaiNqResponse-GenericVnf.json +++ /dev/null @@ -1,77 +0,0 @@ -{ - "inventory-response-item": [ - { - "model-name": "service-instance", - "generic-vnf": { - "vnf-id": "${vnfId}", - "vnf-name": "${vnfName}", - "vnf-type": "vMME Svc Jul 14/vMME VF Jul 14 1", - "service-id": "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb", - "prov-status": "ACTIVE", - "in-maint": false, - "is-closed-loop-disabled": false, - "resource-version": "1503082370097", - "model-invariant-id": "82194af1-3c2c-485a-8f44-420e22a9eaa4", - "model-version-id": "46b92144-923a-4d20-b85a-3cbd847668a9" - }, - "extra-properties": { - "extra-property": [] - }, - "inventory-response-items": { - "inventory-response-item": [ - { - "model-name": "service-instance", - "service-instance": { - "service-instance-id": "37b8cdb7-94eb-468f-a0c2-4e3c3546578e", - "service-instance-name": "Changed Service Instance NAME", - "resource-version": "1503082993532", - "model-invariant-id": "82194af1-3c2c-485a-8f44-420e22a9eaa4", - "model-version-id": "46b92144-923a-4d20-b85a-3cbd847668a9" - }, - "extra-properties": { - "extra-property": [] - }, - "inventory-response-items": { - "inventory-response-item": [ - { - "model-name": "pnf", - "generic-vnf": { - "vnf-id": "${pnfVnfId}", - "vnf-name": "${pnfVndName}", - "vnf-type": "vMME Svc Jul 14/vMME VF Jul 14 1", - "service-id": "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb", - "in-maint": false, - "is-closed-loop-disabled": false, - "resource-version": "1504013830207", - "model-invariant-id": "862b25a1-262a-4961-bdaa-cdc55d69785a", - "model-version-id": "e9f1fa7d-c839-418a-9601-03dc0d2ad687" - }, - "extra-properties": { - "extra-property": [] - } - }, - { - "model-name": "service-instance", - "generic-vnf": { - "vnf-id": "${serviceInstanceVnfId}", - "vnf-name": "${serviceInstanceVnfName}", - "vnf-type": "vMME Svc Jul 14/vMME VF Jul 14 1", - "service-id": "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb", - "in-maint": false, - "is-closed-loop-disabled": false, - "resource-version": "1504014833841", - "model-invariant-id": "Eace933104d443b496b8.nodes.heat.vpg", - "model-version-id": "46b92144-923a-4d20-b85a-3cbd847668a9" - }, - "extra-properties": { - "extra-property": [] - } - } - ] - } - } - ] - } - } - ] -} diff --git a/controlloop/common/simulators/src/main/resources/org/onap/policy/simulators/aai/AaiNqResponse-Vserver.json b/controlloop/common/simulators/src/main/resources/org/onap/policy/simulators/aai/AaiNqResponse-Vserver.json deleted file mode 100644 index af40be948..000000000 --- a/controlloop/common/simulators/src/main/resources/org/onap/policy/simulators/aai/AaiNqResponse-Vserver.json +++ /dev/null @@ -1,267 +0,0 @@ -{ - "inventory-response-item": [ - { - "vserver": { - "vserver-id": "6ed3642c-f7a1-4a7c-9290-3d51fe1531eb", - "vserver-name": "zdfw1lb01lb02", - "vserver-name2": "zdfw1lb01lb02", - "prov-status": "ACTIVE", - "vserver-selflink": "http://10.12.25.2:8774/v2.1/41d6d38489bd40b09ea8a6b6b852dcbd/servers/6ed3642c-f7a1-4a7c-9290-3d51fe1531eb", - "in-maint": false, - "is-closed-loop-disabled": false, - "resource-version": "1510606403522" - }, - "extra-properties": { - "extra-property": [] - }, - "inventory-response-items": { - "inventory-response-item": [ - { - "model-name": "vLoadBalancer", - "generic-vnf": { - "vnf-id": "db373a8d-f7be-4d02-8ac8-6ca4c305d144", - "vnf-name": "Vfmodule_vLB1113", - "vnf-type": "vLoadBalancer-1106/vLoadBalancer 0", - "service-id": "66f157fc-4148-4880-95f5-e120677e98d1", - "prov-status": "PREPROV", - "in-maint": false, - "is-closed-loop-disabled": false, - "resource-version": "1510604011851", - "model-invariant-id": "cee050ed-92a5-494f-ab04-234307a846dc", - "model-version-id": "fd65becc-6b2c-4fe8-ace9-cc29db9a3da2" - }, - "extra-properties": { - "extra-property": [ - { - "property-name": "model-ver.model-version-id", - "property-value": "fd65becc-6b2c-4fe8-ace9-cc29db9a3da2" - }, - { - "property-name": "model-ver.model-name", - "property-value": "vLoadBalancer" - }, - { - "property-name": "model.model-type", - "property-value": "resource" - }, - { - "property-name": "model.model-invariant-id", - "property-value": "cee050ed-92a5-494f-ab04-234307a846dc" - }, - { - "property-name": "model-ver.model-version", - "property-value": "1.0" - } - ] - }, - "inventory-response-items": { - "inventory-response-item": [ - { - "model-name": "vLoadBalancer-1106", - "service-instance": { - "service-instance-id": "3b12f31f-8f2d-4f5c-b875-61ff1194b941", - "service-instance-name": "vLoadBalancer-1113", - "resource-version": "1510603936425", - "model-invariant-id": "1321d60d-f7ff-4300-96c2-6bf0b3268b7a", - "model-version-id": "732d4692-4b97-46f9-a996-0b3339e88c50" - }, - "extra-properties": { - "extra-property": [ - { - "property-name": "model-ver.model-version-id", - "property-value": "732d4692-4b97-46f9-a996-0b3339e88c50" - }, - { - "property-name": "model-ver.model-name", - "property-value": "vLoadBalancer-1106" - }, - { - "property-name": "model.model-type", - "property-value": "service" - }, - { - "property-name": "model.model-invariant-id", - "property-value": "1321d60d-f7ff-4300-96c2-6bf0b3268b7a" - }, - { - "property-name": "model-ver.model-version", - "property-value": "1.0" - } - ] - } - }, - { - "model-name": "Vloadbalancer..base_vlb..module-0", - "vf-module": { - "vf-module-id": "e6b3e3eb-34e1-4c00-b8c1-2a4fbe479b12", - "vf-module-name": "Vfmodule_vLB1113-1", - "heat-stack-id": "Vfmodule_vLB1113-1/3dd6d900-772f-4fcc-a0cb-e250ab2bb4db", - "orchestration-status": "active", - "is-base-vf-module": true, - "resource-version": "1510604612557", - "model-invariant-id": "6d760188-9a24-451a-b05b-e08b86cb94f2", - "model-version-id": "93facad9-55f2-4fe0-9574-814c2bc2d071" - }, - "extra-properties": { - "extra-property": [ - { - "property-name": "model-ver.model-version-id", - "property-value": "93facad9-55f2-4fe0-9574-814c2bc2d071" - }, - { - "property-name": "model-ver.model-name", - "property-value": "Vloadbalancer..base_vlb..module-0" - }, - { - "property-name": "model.model-type", - "property-value": "resource" - }, - { - "property-name": "model.model-invariant-id", - "property-value": "6d760188-9a24-451a-b05b-e08b86cb94f2" - }, - { - "property-name": "model-ver.model-version", - "property-value": "1" - } - ] - } - }, - { - "model-name": "Vloadbalancer..dnsscaling..module-1", - "vf-module": { - "vf-module-id": "dummy_db373a8d-f7be-4d02-8ac8-6ca4c305d144", - "vf-module-name": "dummy_db373a8d-f7be-4d02-8ac8-6ca4c305d144", - "is-base-vf-module": false, - "resource-version": "1510610079687", - "model-invariant-id": "356a1cff-71f2-4086-9980-a2927ce11c1c", - "model-version-id": "6b93d804-cfc8-4be3-92cc-9336d135859a" - }, - "extra-properties": { - "extra-property": [ - { - "property-name": "model-ver.model-version-id", - "property-value": "6b93d804-cfc8-4be3-92cc-9336d135859a" - }, - { - "property-name": "model-ver.model-name", - "property-value": "Vloadbalancer..dnsscaling..module-1" - }, - { - "property-name": "model.model-type", - "property-value": "resource" - }, - { - "property-name": "model.model-invariant-id", - "property-value": "356a1cff-71f2-4086-9980-a2927ce11c1c" - }, - { - "property-name": "model-ver.model-version", - "property-value": "1" - } - ] - } - }, - { - "model-name": "Vloadbalancer..dnsscaling..module-1", - "vf-module": { - "vf-module-id": "my_module_db373a8d-f7be-4d02-8ac8-6ca4c305d144", - "vf-module-name": "my_module_1", - "is-base-vf-module": false, - "resource-version": "1510610079687", - "model-invariant-id": "356a1cff-71f2-4086-9980-a2927ce11c1c", - "model-version-id": "6b93d804-cfc8-4be3-92cc-9336d135859a" - }, - "extra-properties": { - "extra-property": [ - { - "property-name": "model-ver.model-version-id", - "property-value": "6b93d804-cfc8-4be3-92cc-9336d135859a" - }, - { - "property-name": "model-ver.model-name", - "property-value": "Vloadbalancer..dnsscaling..module-1" - }, - { - "property-name": "model.model-type", - "property-value": "resource" - }, - { - "property-name": "model.model-invariant-id", - "property-value": "356a1cff-71f2-4086-9980-a2927ce11c1c" - }, - { - "property-name": "model-ver.model-version", - "property-value": "1" - } - ] - } - }, - { - "model-name": "Vloadbalancer..dnsscaling..module-1", - "vf-module": { - "vf-module-id": "my_module_db373a8d-f7be-4d02-8ac8-6ca4c305d144", - "vf-module-name": "my_module_2", - "is-base-vf-module": false, - "resource-version": "1510610079687", - "model-invariant-id": "356a1cff-71f2-4086-9980-a2927ce11c1c", - "model-version-id": "6b93d804-cfc8-4be3-92cc-9336d135859a" - }, - "extra-properties": { - "extra-property": [ - { - "property-name": "model-ver.model-version-id", - "property-value": "6b93d804-cfc8-4be3-92cc-9336d135859a" - }, - { - "property-name": "model-ver.model-name", - "property-value": "Vloadbalancer..dnsscaling..module-1" - }, - { - "property-name": "model.model-type", - "property-value": "resource" - }, - { - "property-name": "model.model-invariant-id", - "property-value": "356a1cff-71f2-4086-9980-a2927ce11c1c" - }, - { - "property-name": "model-ver.model-version", - "property-value": "1" - } - ] - } - } - ] - } - }, - { - "tenant": { - "tenant-id": "41d6d38489bd40b09ea8a6b6b852dcbd", - "tenant-name": "Integration-SB-00", - "resource-version": "1509587770200" - }, - "extra-properties": { - "extra-property": [] - }, - "inventory-response-items": { - "inventory-response-item": [ - { - "cloud-region": { - "cloud-owner": "CloudOwner", - "cloud-region-id": "RegionOne", - "cloud-region-version": "v1", - "resource-version": "1509587770092" - }, - "extra-properties": { - "extra-property": [] - } - } - ] - } - } - ] - } - } - ] -} diff --git a/controlloop/common/simulators/src/test/java/org/onap/policy/simulators/AaiSimulatorTest.java b/controlloop/common/simulators/src/test/java/org/onap/policy/simulators/AaiSimulatorTest.java deleted file mode 100644 index b18e3da9d..000000000 --- a/controlloop/common/simulators/src/test/java/org/onap/policy/simulators/AaiSimulatorTest.java +++ /dev/null @@ -1,140 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * simulators - * ================================================================================ - * 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. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.simulators; - -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -import java.util.HashMap; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.UUID; - -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Test; -import org.onap.policy.aai.AaiGetVnfResponse; -import org.onap.policy.aai.AaiManager; -import org.onap.policy.aai.AaiNqInstanceFilters; -import org.onap.policy.aai.AaiNqNamedQuery; -import org.onap.policy.aai.AaiNqQueryParameters; -import org.onap.policy.aai.AaiNqRequest; -import org.onap.policy.aai.AaiNqResponse; -import org.onap.policy.common.endpoints.http.server.HttpServletServer; -import org.onap.policy.drools.utils.logging.LoggerUtil; -import org.onap.policy.rest.RestManager; - -public class AaiSimulatorTest { - - /** - * Set up test class. - */ - @BeforeClass - public static void setUpSimulator() { - LoggerUtil.setLevel("ROOT", "INFO"); - LoggerUtil.setLevel("org.eclipse.jetty", "WARN"); - try { - Util.buildAaiSim(); - } catch (final Exception e) { - fail(e.getMessage()); - } - } - - @AfterClass - public static void tearDownSimulator() { - HttpServletServer.factory.destroy(); - } - - @Test - public void testGet() { - final AaiGetVnfResponse response = new AaiManager(new RestManager()).getQueryByVnfId( - "http://localhost:6666/aai/v11/network/generic-vnfs/generic-vnf/", "testUser", "testPass", - UUID.randomUUID(), "5e49ca06-2972-4532-9ed4-6d071588d792"); - assertNotNull(response); - assertNotNull(response.getRelationshipList()); - } - - @Test - public void testPost() { - // check vserver named query - final AaiNqRequest request = new AaiNqRequest(); - final AaiNqQueryParameters tempQueryParameters = new AaiNqQueryParameters(); - final AaiNqNamedQuery tempNamedQuery = new AaiNqNamedQuery(); - tempNamedQuery.setNamedQueryUuid(UUID.fromString("4ff56a54-9e3f-46b7-a337-07a1d3c6b469")); - tempQueryParameters.setNamedQuery(tempNamedQuery); - request.setQueryParameters(tempQueryParameters); - Map<String, String> tempInnerMap = new HashMap<>(); - tempInnerMap.put("vserver-name", "vserver-name-16102016-aai3255-data-11-1"); - Map<String, Map<String, String>> tempOuterMap = new HashMap<>(); - tempOuterMap.put("vserver", tempInnerMap); - List<Map<String, Map<String, String>>> tempInstanceFilter = new LinkedList<>(); - tempInstanceFilter.add(tempOuterMap); - AaiNqInstanceFilters tempInstanceFilters = new AaiNqInstanceFilters(); - tempInstanceFilters.setInstanceFilter(tempInstanceFilter); - request.setInstanceFilters(tempInstanceFilters); - - AaiNqResponse response = new AaiManager(new RestManager()).postQuery("http://localhost:6666", "testUser", - "testPass", request, UUID.randomUUID()); - assertNotNull(response); - assertNotNull(response.getInventoryResponseItems()); - - // check error response for vserver query - tempInnerMap.put("vserver-name", "error"); - - response = new AaiManager(new RestManager()).postQuery("http://localhost:6666", "testUser", "testPass", request, - UUID.randomUUID()); - assertNotNull(response); - assertNotNull(response.getRequestError()); - assertTrue(response.getRequestError().getServiceExcept().getVariables()[2].contains("vserver")); - - // check generic-vnf named query - tempNamedQuery.setNamedQueryUuid(UUID.fromString("a93ac487-409c-4e8c-9e5f-334ae8f99087")); - tempQueryParameters.setNamedQuery(tempNamedQuery); - request.setQueryParameters(tempQueryParameters); - tempInnerMap = new HashMap<>(); - tempInnerMap.put("vnf-id", "de7cc3ab-0212-47df-9e64-da1c79234deb"); - tempOuterMap = new HashMap<>(); - tempOuterMap.put("generic-vnf", tempInnerMap); - tempInstanceFilter = new LinkedList<>(); - tempInstanceFilter.add(tempOuterMap); - tempInstanceFilters = new AaiNqInstanceFilters(); - tempInstanceFilters.setInstanceFilter(tempInstanceFilter); - request.setInstanceFilters(tempInstanceFilters); - - response = new AaiManager(new RestManager()).postQuery("http://localhost:6666", "testUser", "testPass", request, - UUID.randomUUID()); - assertNotNull(response); - assertNotNull(response.getInventoryResponseItems()); - assertNull(response.getRequestError()); - - // check error response for generic-vnf query - tempInnerMap.put("vnf-id", "error"); - - response = new AaiManager(new RestManager()).postQuery("http://localhost:6666", "testUser", "testPass", request, - UUID.randomUUID()); - assertNotNull(response); - assertNotNull(response.getRequestError()); - assertTrue(response.getRequestError().getServiceExcept().getVariables()[2].contains("generic-vnf")); - } -} diff --git a/controlloop/common/simulators/src/test/java/org/onap/policy/simulators/GuardSimulatorTest.java b/controlloop/common/simulators/src/test/java/org/onap/policy/simulators/GuardSimulatorTest.java deleted file mode 100644 index c02f14334..000000000 --- a/controlloop/common/simulators/src/test/java/org/onap/policy/simulators/GuardSimulatorTest.java +++ /dev/null @@ -1,79 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * simulators - * ================================================================================ - * 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. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.simulators; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.fail; - -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Test; -import org.onap.policy.common.endpoints.http.server.HttpServletServer; -import org.onap.policy.drools.utils.logging.LoggerUtil; -import org.onap.policy.rest.RestManager; -import org.onap.policy.rest.RestManager.Pair; - -public class GuardSimulatorTest { - - /** - * Set up test class. - */ - @BeforeClass - public static void setupSimulator() { - LoggerUtil.setLevel("ROOT", "INFO"); - LoggerUtil.setLevel("org.eclipse.jetty", "WARN"); - try { - org.onap.policy.simulators.Util.buildGuardSim(); - } catch (Exception e) { - fail(e.getMessage()); - } - } - - @AfterClass - public static void tearDownSimulator() { - HttpServletServer.factory.destroy(); - } - - @Test - public void testGuard() { - String request = makeRequest("test_actor_id", "test_op_id", "test_target", "test_clName"); - String url = "http://localhost:" + Util.GUARDSIM_SERVER_PORT + "/pdp/api/getDecision"; - Pair<Integer, String> response = - new RestManager().post(url, "testUname", "testPass", null, "application/json", request); - assertNotNull(response); - assertNotNull(response.first); - assertNotNull(response.second); - assertEquals("{\"decision\": \"PERMIT\", \"details\": \"Decision Permit. OK!\"}", response.second); - - request = makeRequest("test_actor_id", "test_op_id", "test_target", "denyGuard"); - response = new RestManager().post(url, "testUname", "testPass", null, "application/json", request); - assertNotNull(response); - assertNotNull(response.first); - assertNotNull(response.second); - assertEquals("{\"decision\": \"DENY\", \"details\": \"Decision Deny. You asked for it\"}", response.second); - } - - private static String makeRequest(String actor, String recipe, String target, String clName) { - return "{\"decisionAttributes\": {\"actor\": \"" + actor + "\", \"recipe\": \"" + recipe + "\"" - + ", \"target\": \"" + target + "\", \"clname\": \"" + clName + "\"}, \"onapName\": \"PDPD\"}"; - } -} diff --git a/controlloop/common/simulators/src/test/java/org/onap/policy/simulators/SoSimulatorTest.java b/controlloop/common/simulators/src/test/java/org/onap/policy/simulators/SoSimulatorTest.java deleted file mode 100644 index c7545b005..000000000 --- a/controlloop/common/simulators/src/test/java/org/onap/policy/simulators/SoSimulatorTest.java +++ /dev/null @@ -1,149 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * simulators - * ================================================================================ - * 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. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.simulators; - -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.fail; - -import java.util.HashMap; -import java.util.UUID; -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Test; -import org.onap.policy.common.endpoints.http.server.HttpServletServer; -import org.onap.policy.drools.utils.logging.LoggerUtil; -import org.onap.policy.rest.RestManager; -import org.onap.policy.rest.RestManager.Pair; -import org.onap.policy.so.SoCloudConfiguration; -import org.onap.policy.so.SoModelInfo; -import org.onap.policy.so.SoRelatedInstance; -import org.onap.policy.so.SoRelatedInstanceListElement; -import org.onap.policy.so.SoRequest; -import org.onap.policy.so.SoRequestDetails; -import org.onap.policy.so.SoRequestInfo; -import org.onap.policy.so.SoRequestParameters; -import org.onap.policy.so.SoResponse; -import org.onap.policy.so.util.Serialization; - -public class SoSimulatorTest { - - /** - * Set up test class. - */ - @BeforeClass - public static void setUpSimulator() { - LoggerUtil.setLevel("ROOT", "INFO"); - LoggerUtil.setLevel("org.eclipse.jetty", "WARN"); - try { - Util.buildSoSim(); - } catch (final Exception e) { - fail(e.getMessage()); - } - } - - @AfterClass - public static void tearDownSimulator() { - HttpServletServer.factory.destroy(); - } - - /** - * Create dummy SO request for TestResponse() junit. - */ - private SoRequest createTestRequest() { - - // Construct SO Request - final SoRequest request = new SoRequest(); - request.setRequestId(UUID.randomUUID()); - request.setRequestDetails(new SoRequestDetails()); - request.getRequestDetails().setModelInfo(new SoModelInfo()); - request.getRequestDetails().setCloudConfiguration(new SoCloudConfiguration()); - request.getRequestDetails().setRequestInfo(new SoRequestInfo()); - request.getRequestDetails().setRequestParameters(new SoRequestParameters()); - request.getRequestDetails().getRequestParameters().setUserParams(null); - // - // cloudConfiguration - // - request.getRequestDetails().getCloudConfiguration().setLcpCloudRegionId("DFW"); - request.getRequestDetails().getCloudConfiguration().setTenantId("1015548"); - // - // modelInfo - // - request.getRequestDetails().getModelInfo().setModelType("vfModule"); - request.getRequestDetails().getModelInfo().setModelInvariantId("f32568ec-2f1c-458a-864b-0593d53d141a"); - request.getRequestDetails().getModelInfo().setModelVersionId("69615025-879d-4f0d-afe3-b7d1a7eeed1f"); - request.getRequestDetails().getModelInfo().setModelName("C15ce9e1E9144c8fB8bb..dnsscaling..module-1"); 'del'>- public Map<String, String> AAI = new HashMap<>();+ private Instant closedLoopAlarmStart; + private Instant closedLoopAlarmEnd; + private Map<String, String> aai = new HashMap<>(); public VirtualControlLoopEvent() { } @@ -42,11 +42,34 @@ public class VirtualControlLoopEvent extends ControlLoopEvent { if (event == null) { return; } - if (event.AAI != null) { - this.AAI = new HashMap<>(event.AAI); + if (event.aai != null) { + this.aai = new HashMap<>(event.aai); } this.closedLoopAlarmStart = event.closedLoopAlarmStart; this.closedLoopAlarmEnd = event.closedLoopAlarmEnd; } + public Instant getClosedLoopAlarmStart() { + return closedLoopAlarmStart; + } + + public void setClosedLoopAlarmStart(Instant closedLoopAlarmStart) { + this.closedLoopAlarmStart = closedLoopAlarmStart; + } + + public Instant getClosedLoopAlarmEnd() { + return closedLoopAlarmEnd; + } + + public void setClosedLoopAlarmEnd(Instant closedLoopAlarmEnd) { + this.closedLoopAlarmEnd = closedLoopAlarmEnd; + } + + public Map<String, String> getAAI() { + return 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 7415fccf0..c99e3a1b0 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 @@ -31,9 +31,9 @@ public class VirtualControlLoopNotification extends ControlLoopNotification { */ private static final long serialVersionUID = 5354756047932144017L; - public Map<String, String> AAI = new HashMap<>(); - public Instant closedLoopAlarmStart; - public Instant closedLoopAlarmEnd; + private Map<String, String> aai = new HashMap<>(); + private Instant closedLoopAlarmStart; + private Instant closedLoopAlarmEnd; public VirtualControlLoopNotification() { } @@ -43,11 +43,34 @@ public class VirtualControlLoopNotification extends ControlLoopNotification { if (event == null) { return; } - if (event.AAI != null) { - this.AAI = new HashMap<>(event.AAI); + if (event.getAAI() != null) { + this.setAAI(new HashMap<>(event.getAAI())); } - this.closedLoopAlarmStart = event.closedLoopAlarmStart; - this.closedLoopAlarmEnd = event.closedLoopAlarmEnd; + this.closedLoopAlarmStart = event.getClosedLoopAlarmStart(); + this.closedLoopAlarmEnd = event.getClosedLoopAlarmEnd(); } + public Map<String, String> getAAI() { + return aai; + } + + public void setAAI(Map<String, String> aAI) { + this.aai = aAI; + } + + public Instant getClosedLoopAlarmStart() { + return closedLoopAlarmStart; + } + + public void setClosedLoopAlarmStart(Instant closedLoopAlarmStart) { + this.closedLoopAlarmStart = closedLoopAlarmStart; + } + + public Instant getClosedLoopAlarmEnd() { + return closedLoopAlarmEnd; + } + + public void setClosedLoopAlarmEnd(Instant closedLoopAlarmEnd) { + this.closedLoopAlarmEnd = closedLoopAlarmEnd; + } } 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 858dc82b9..d2a51f770 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 @@ -35,17 +35,15 @@ import com.google.gson.GsonBuilder; import com.google.gson.JsonDeserializationContext; import com.google.gson.JsonDeserializer; import com.google.gson.JsonElemdel'>-import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -import java.util.HashMap; - -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Test; -import org.onap.policy.common.endpoints.http.server.HttpServletServer; -import org.onap.policy.drools.utils.logging.LoggerUtil; -import org.onap.policy.rest.RestManager; -import org.onap.policy.rest.RestManager.Pair; -import org.onap.policy.vfc.VfcResponse; -import org.onap.policy.vfc.util.Serialization; - -public class VfcSimulatorTest { - - /** - * Set up test class. - */ - @BeforeClass - public static void setUpSimulator() { - LoggerUtil.setLevel("ROOT", "INFO"); - LoggerUtil.setLevel("org.eclipse.jetty", "WARN"); - try { - Util.buildVfcSim(); - } catch (final Exception e) { - fail(e.getMessage()); - } - } - - @AfterClass - public static void tearDownSimulator() { - HttpServletServer.factory.destroy(); - } - - @Test - public void testPost() { - final Pair<Integer, String> httpDetails = - new RestManager().post("http://localhost:6668/api/nslcm/v1/ns/1234567890/heal", "username", "password", - new HashMap<String, String>(), "application/json", "Some Request Here"); - assertNotNull(httpDetails); - assertTrue(httpDetails.first == 202); - final VfcResponse response = Serialization.gsonPretty.fromJson(httpDetails.second, VfcResponse.class); - assertNotNull(response); - } - - @Test - public void testGet() { - final Pair<Integer, String> httpDetails = new RestManager().get("http://localhost:6668/api/nslcm/v1/jobs/1234", - "username", "password", new HashMap<String, String>()); - assertNotNull(httpDetails); - final VfcResponse response = Serialization.gsonPretty.fromJson(httpDetails.second, VfcResponse.class); - assertNotNull(response); - } -} |