summaryrefslogtreecommitdiffstats
path: root/controlloop/common/eventmanager/src/test/java
diff options
context:
space:
mode:
authorJoseph Chou <jc2555@att.com>2017-09-06 16:54:33 -0400
committerJoseph Chou <jc2555@att.com>2017-09-12 17:15:44 -0400
commit5bd93f34b7221c8c141785574082253fcb61d276 (patch)
tree7d39dc59ed0118f56de79634f078476020fb078c /controlloop/common/eventmanager/src/test/java
parent045198cd1a5a73ffe6630e6833e1d021585fb82f (diff)
ONAP code for AAI, consolidate name and get query
Adding AAI GET query feature to support ONAP project (1 commit) Issue-ID: POLICY-103 Change-Id: I0a55f41c3edd7a0bc0562ae4e12a19f262a50d74 Signed-off-by: Joseph Chou <jc2555@att.com>
Diffstat (limited to 'controlloop/common/eventmanager/src/test/java')
-rw-r--r--controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManagerTest.java251
1 files changed, 248 insertions, 3 deletions
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 fa52e8557..ef7a1a94c 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
@@ -20,14 +20,259 @@
package org.onap.policy.controlloop.eventmanager;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.time.Instant;
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.UUID;
import org.junit.Test;
+import org.onap.policy.aai.AAIGETVserverResponse;
+import org.onap.policy.aai.AAIGETVnfResponse;
+import org.onap.policy.aai.RelatedToPropertyItem;
+import org.onap.policy.aai.Relationship;
+import org.onap.policy.aai.RelationshipData;
+import org.onap.policy.aai.RelationshipDataItem;
+import org.onap.policy.aai.RelationshipList;
+import org.onap.policy.aai.AAIManager;
+import org.onap.policy.aai.RelatedToProperty;
+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.controlloop.ControlLoopEventStatus;
+
+import org.onap.policy.controlloop.VirtualControlLoopEvent;
+import org.onap.policy.controlloop.ControlLoopException;
+import org.onap.policy.controlloop.Util;
+import org.onap.policy.controlloop.policy.ControlLoopPolicy;
+import org.onap.policy.controlloop.policy.PolicyResult;
+import org.onap.policy.controlloop.processor.ControlLoopProcessor;
+import org.onap.policy.controlloop.processor.ControlLoopProcessorTest;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class ControlLoopEventManagerTest {
+ private static final Logger logger = LoggerFactory.getLogger(ControlLoopEventManagerTest.class);
+
+ private static VirtualControlLoopEvent onset;
+ static {
+ onset = new VirtualControlLoopEvent();
+ onset.closedLoopControlName = "ControlLoop-vUSP";
+ onset.requestID = UUID.randomUUID();
+ onset.target = "VM_NAME";
+ onset.closedLoopAlarmStart = Instant.now();
+ onset.AAI = new HashMap<String, String>();
+ onset.AAI.put("cloud-region.identity-url", "foo");
+ onset.AAI.put("vserver.selflink", "bar");
+ onset.AAI.put("generic-vnf.vnf-id", "83f674e8-7555-44d7-9a39-bdc3770b0491");
+ onset.closedLoopEventStatus = ControlLoopEventStatus.ONSET;
+ }
+
+ @Test
+ public void testGetAAIInfo() {
+ final Util.Pair<ControlLoopPolicy, String> pair = Util.loadYaml("src/test/resources/test.yaml");
+ onset.closedLoopControlName = pair.a.getControlLoop().getControlLoopName();
+ try {
+ ControlLoopEventManager eventManager = new ControlLoopEventManager(onset.closedLoopControlName, onset.requestID);
+ onset.closedLoopEventStatus = ControlLoopEventStatus.ONSET;
+
+ String user = "POLICY";
+ String password = "POLICY";
+ String vnfID = "83f674e8-7555-44d7-9a39-bdc3770b0491";
+ String url = "https://aai-ext1.test.att.com:8443/aai/v11/network/generic-vnfs/generic-vnf/";
+ AAIGETVnfResponse response = getQueryByVnfID2(url, user, password, onset.requestID, vnfID);
+ assertNotNull(response);
+ logger.info("testGetAAIInfo test result is " + (response == null ? "null" : "not null"));
+ } catch (Exception e) {
+ fail(e.getMessage());
+ logger.error("testGetAAIInfo Exception: ", e);
+ }
+ }
@Test
- public void test() {
- //fail("MICHAEL - Not yet implemented");
+ public void testIsClosedLoopDisabled() {
+ //
+ // Load up the policy
+ //
+ final Util.Pair<ControlLoopPolicy, String> pair = Util.loadYaml("src/test/resources/test.yaml");
+ onset.closedLoopControlName = pair.a.getControlLoop().getControlLoopName();
+
+ try {
+ ControlLoopEventManager eventManager = new ControlLoopEventManager(onset.closedLoopControlName, onset.requestID);
+ onset.closedLoopEventStatus = ControlLoopEventStatus.ONSET;
+
+ logger.info("testIsClosedLoopDisabled --");
+ AAIManager manager = new AAIManager();
+ String user = "POLICY";
+ String password = "POLICY";
+ String vnfID = "83f674e8-7555-44d7-9a39-bdc3770b0491";
+ String url = "https://aai-ext1.test.att.com:8443/aai/v11/network/generic-vnfs/generic-vnf/";
+ AAIGETVnfResponse response = getQueryByVnfID2(url, user, password, onset.requestID, vnfID);
+ assertNotNull(response);
+ boolean disabled = eventManager.isClosedLoopDisabled(response);
+ logger.info("QueryByVnfID - isClosedLoopDisabled: " + disabled);
+
+ String vnfName = "lll_vnf_010317";
+ url = "https://aai-ext1.test.att.com:8443/aai/v11/network/generic-vnfs/generic-vnf?vnf-name=";
+ response = getQueryByVnfName2(url, user, password, onset.requestID, vnfName);
+ assertNotNull(response);
+ disabled = eventManager.isClosedLoopDisabled(response);
+ logger.info("QueryByVnfName2 - isClosedLoopDisabled: " + disabled);
+
+ String vserverName = "USMSO1SX7NJ0103UJZZ01-vjunos0";
+ url = "https://aai-ext1.test.att.com:8443//aai/v11/nodes/vservers?vserver-name=";
+ AAIGETVserverResponse response2 = getQueryByVserverName2(url, user, password, onset.requestID, vserverName);
+ assertNotNull(response);
+ disabled = eventManager.isClosedLoopDisabled(response);
+ logger.info("QueryByVserverName - isClosedLoopDisabled: " + disabled);
+ } catch (Exception e) {
+ fail(e.getMessage());
+ }
+ }
+
+ // Simulate a response
+ public static AAIGETVnfResponse getQueryByVnfID2(String urlGet, String username, String password, UUID requestID, String key) {
+ AAIGETVnfResponse response = new AAIGETVnfResponse();
+
+ response.vnfID = "83f674e8-7555-44d7-9a39-bdc3770b0491";
+ response.vnfName = "lll_vnf_010317";
+ response.vnfType = "Basa-122216-Service/VidVsamp12BaseVolume 1";
+ response.serviceId = "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb";
+ response.orchestrationStatus = "Created";
+ response.inMaint = "false";
+ response.isClosedLoopDisabled = "false";
+ response.resourceVersion = "1494001988835";
+ response.modelInvariantId = "f18be3cd-d446-456e-9109-121d9b62feaa";
+
+ RelationshipList relationshipList = new RelationshipList();
+ Relationship relationship = new Relationship();
+ RelationshipData relationshipData = new RelationshipData();
+ RelationshipDataItem relationshipDataItem = new RelationshipDataItem();
+
+ relationshipDataItem.relationshipKey = "customer.global-customer-id";
+ relationshipDataItem.relationshipValue = "MSO_1610_ST";
+ relationshipData.relationshipData.add(relationshipDataItem);
+
+ relationshipDataItem.relationshipKey = "service-subscription.service-type";
+ relationshipDataItem.relationshipValue = "MSO-dev-service-type";
+ relationshipData.relationshipData.add(relationshipDataItem);
+
+ relationshipDataItem.relationshipKey = "service-instance.service-instance-id";
+ relationshipDataItem.relationshipValue = "e1e9c97c-02c0-4919-9b4c-eb5d5ef68970";
+ relationshipData.relationshipData.add(relationshipDataItem);
+
+ RelatedToProperty relatedToProperty = new RelatedToProperty();
+ RelatedToPropertyItem item = new RelatedToPropertyItem();
+ item.propertyKey = "service-instance.service-instance-name";
+ item.propertyValue = "lll_svc_010317";
+ relatedToProperty.relatedTo.add(item);
+
+ relationship.relatedTo = "service-instance";
+ relationship.relatedLink = "/aai/v11/business/customers/customer/MSO_1610_ST/service-subscriptions/service-subscription/MSO-dev-service-type/service-instances/service-instance/e1e9c97c-02c0-4919-9b4c-eb5d5ef68970";
+ relationship.relationshipData = relationshipData;
+ relationship.relatedToProperty = relatedToProperty;
+
+ relationshipList.relationshipList.add(relationship);
+ response.relationshipList = relationshipList;
+
+ return response;
+ }
+
+ public static AAIGETVnfResponse getQueryByVnfName2(String urlGet, String username, String password, UUID requestID, String key) {
+ AAIGETVnfResponse response = new AAIGETVnfResponse();
+
+ response.vnfID = "83f674e8-7555-44d7-9a39-bdc3770b0491";
+ response.vnfName = "lll_vnf_010317";
+ response.vnfType = "Basa-122216-Service/VidVsamp12BaseVolume 1";
+ response.serviceId = "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb";
+ response.orchestrationStatus = "Created";
+ response.inMaint = "false";
+ response.isClosedLoopDisabled = "false";
+ response.resourceVersion = "1494001988835";
+ response.modelInvariantId = "f18be3cd-d446-456e-9109-121d9b62feaa";
+
+ RelationshipList relationshipList = new RelationshipList();
+ Relationship relationship = new Relationship();
+ RelationshipData relationshipData = new RelationshipData();
+ RelationshipDataItem relationshipDataItem = new RelationshipDataItem();
+
+ relationshipDataItem.relationshipKey = "customer.global-customer-id";
+ relationshipDataItem.relationshipValue = "MSO_1610_ST";
+ relationshipData.relationshipData.add(relationshipDataItem);
+
+ relationshipDataItem.relationshipKey = "service-subscription.service-type";
+ relationshipDataItem.relationshipValue = "MSO-dev-service-type";
+ relationshipData.relationshipData.add(relationshipDataItem);
+
+ relationshipDataItem.relationshipKey = "service-instance.service-instance-id";
+ relationshipDataItem.relationshipValue = "e1e9c97c-02c0-4919-9b4c-eb5d5ef68970";
+ relationshipData.relationshipData.add(relationshipDataItem);
+
+ RelatedToProperty relatedToProperty = new RelatedToProperty();
+ RelatedToPropertyItem item = new RelatedToPropertyItem();
+ item.propertyKey = "service-instance.service-instance-name";
+ item.propertyValue = "lll_svc_010317";
+ relatedToProperty.relatedTo.add(item);
+
+ relationship.relatedTo = "service-instance";
+ relationship.relatedLink = "/aai/v11/business/customers/customer/MSO_1610_ST/service-subscriptions/service-subscription/MSO-dev-service-type/service-instances/service-instance/e1e9c97c-02c0-4919-9b4c-eb5d5ef68970";
+ relationship.relationshipData = relationshipData;
+ relationship.relatedToProperty = relatedToProperty;
+
+ relationshipList.relationshipList.add(relationship);
+ response.relationshipList = relationshipList;
+
+ return response;
}
-}
+ public static AAIGETVserverResponse getQueryByVserverName2(String urlGet, String username, String password, UUID requestID, String key) {
+ AAIGETVserverResponse response = new AAIGETVserverResponse();
+
+ response.vserverID = "d0668d4f-c25e-4a1b-87c4-83845c01efd8";
+ response.vserverName = "USMSO1SX7NJ0103UJZZ01-vjunos0";
+ response.vserverName2 = "vjunos0";
+ response.vserverSelflink = "https://aai-ext1.test.att.com:8443/aai/v7/cloud-infrastructure/cloud-regions/cloud-region/att-aic/AAIAIC25/tenants/tenant/USMSO1SX7NJ0103UJZZ01%3A%3AuCPE-VMS/vservers/vserver/d0668d4f-c25e-4a1b-87c4-83845c01efd8";
+ response.inMaint = "false";
+ response.isClosedLoopDisabled = "false";
+ response.resourceVersion = "1494001931513";
+
+ RelationshipList relationshipList = new RelationshipList();
+ Relationship relationship = new Relationship();
+ RelationshipData relationshipData = new RelationshipData();
+ RelationshipDataItem relationshipDataItem = new RelationshipDataItem();
+
+ relationshipDataItem.relationshipKey = "customer.global-customer-id";
+ relationshipDataItem.relationshipValue = "MSO_1610_ST";
+ relationshipData.relationshipData.add(relationshipDataItem);
+
+ relationshipDataItem.relationshipKey = "service-subscription.service-type";
+ relationshipDataItem.relationshipValue = "MSO-dev-service-type";
+ relationshipData.relationshipData.add(relationshipDataItem);
+
+ relationshipDataItem.relationshipKey = "service-instance.service-instance-id";
+ relationshipDataItem.relationshipValue = "e1e9c97c-02c0-4919-9b4c-eb5d5ef68970";
+ relationshipData.relationshipData.add(relationshipDataItem);
+
+ RelatedToProperty relatedToProperty = new RelatedToProperty();
+ RelatedToPropertyItem item = new RelatedToPropertyItem();
+ item.propertyKey = "service-instance.service-instance-name";
+ item.propertyValue = "lll_svc_010317";
+ relatedToProperty.relatedTo.add(item);
+
+ relationship.relatedTo = "service-instance";
+ relationship.relatedLink = "/aai/v11/business/customers/customer/MSO_1610_ST/service-subscriptions/service-subscription/MSO-dev-service-type/service-instances/service-instance/e1e9c97c-02c0-4919-9b4c-eb5d5ef68970";
+ relationship.relationshipData = relationshipData;
+ relationship.relatedToProperty = relatedToProperty;
+
+ relationshipList.relationshipList.add(relationship);
+ response.relationshipList = relationshipList;
+
+ return response;
+ }
+} \ No newline at end of file