add prov-status check to AAI queries 01/60801/2
authorJim Hahn <jrh3@att.com>
Wed, 15 Aug 2018 20:34:02 +0000 (16:34 -0400)
committerJim Hahn <jrh3@att.com>
Wed, 15 Aug 2018 21:29:16 +0000 (17:29 -0400)
Also had to add prov-status field to AaiGetVnfResponse class.
Removed bogus comment from test.
Verify response is not null in test.
Verify no requery by vnf name in test.
Add prov-status to template.demo tests.
Add prov-status to sample json for archetype-cl's.

Change-Id: I3f36a2bb6de8265ce5b10103690d6d8813c15b1a
Issue-ID: POLICY-964
Signed-off-by: Jim Hahn <jrh3@att.com>
19 files changed:
controlloop/common/eventmanager/pom.xml
controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManager.java
controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManagerTest.java
controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AaiGetVnfResponse.java
controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/AaiGetVnfResponseTest.java
controlloop/common/simulators/src/main/java/org/onap/policy/simulators/AaiSimulatorJaxRs.java
controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/config/dcae.vcpe.abatement.json
controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/config/dcae.vcpe.onset.json
controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/config/dcae.vdns.onset.json
controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/config/dcae.vfw.onset.json
controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/config/dcae.volte.onset.json
controlloop/templates/archetype-cl-casablanca/src/main/resources/archetype-resources/src/main/config/dcae.vcpe.abatement.json
controlloop/templates/archetype-cl-casablanca/src/main/resources/archetype-resources/src/main/config/dcae.vcpe.onset.json
controlloop/templates/archetype-cl-casablanca/src/main/resources/archetype-resources/src/main/config/dcae.vdns.onset.json
controlloop/templates/archetype-cl-casablanca/src/main/resources/archetype-resources/src/main/config/dcae.vfw.onset.json
controlloop/templates/archetype-cl-casablanca/src/main/resources/archetype-resources/src/main/config/dcae.volte.onset.json
controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VCPEControlLoopTest.java
controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VDNSControlLoopTest.java
controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VFCControlLoopTest.java

index 1f35d1c..d1fd4e4 100644 (file)
@@ -2,7 +2,7 @@
   ============LICENSE_START=======================================================
   eventmanager
   ================================================================================
-  Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+  Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
   ================================================================================
   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
       <version>4.12</version>
       <scope>test</scope>
     </dependency>
+    <dependency>
+      <groupId>org.powermock</groupId>
+      <artifactId>powermock-api-mockito</artifactId>
+      <version>1.7.3</version>
+      <scope>test</scope>
+    </dependency>
     <dependency>
       <groupId>com.google.code.gson</groupId>
       <artifactId>gson</artifactId>
index c4affac..ff10534 100644 (file)
@@ -27,6 +27,7 @@ import java.util.ArrayList;
 import java.util.Collection;
 import java.util.LinkedList;
 import java.util.List;
+import java.util.Map;
 import java.util.UUID;
 
 import org.onap.policy.aai.AaiGetVnfResponse;
@@ -54,13 +55,16 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 public class ControlLoopEventManager implements LockCallback, Serializable {
+    public static final String PROV_STATUS_ACTIVE = "ACTIVE";
     private static final String VM_NAME = "VM_NAME";
     private static final String VNF_NAME = "VNF_NAME";
-    private static final String GENERIC_VNF_VNF_ID = "generic-vnf.vnf-id";
-    private static final String GENERIC_VNF_VNF_NAME = "generic-vnf.vnf-name";
-    private static final String VSERVER_VSERVER_NAME = "vserver.vserver-name";
-    private static final String GENERIC_VNF_IS_CLOSED_LOOP_DISABLED = "generic-vnf.is-closed-loop-disabled";
-    private static final String VSERVER_IS_CLOSED_LOOP_DISABLED = "vserver.is-closed-loop-disabled";
+    public static final String GENERIC_VNF_VNF_ID = "generic-vnf.vnf-id";
+    public static final String GENERIC_VNF_VNF_NAME = "generic-vnf.vnf-name";
+    public static final String VSERVER_VSERVER_NAME = "vserver.vserver-name";
+    public static final String GENERIC_VNF_IS_CLOSED_LOOP_DISABLED = "generic-vnf.is-closed-loop-disabled";
+    public static final String VSERVER_IS_CLOSED_LOOP_DISABLED = "vserver.is-closed-loop-disabled";
+    public static final String GENERIC_VNF_PROV_STATUS = "generic-vnf.prov-status";
+    public static final String VSERVER_PROV_STATUS = "vserver.prov-status";
 
     /**
      * Additional time, in seconds, to add to a "lock" request. This ensures that the lock
@@ -661,31 +665,41 @@ public class ControlLoopEventManager implements LockCallback, Serializable {
      * @param event the event
      * @throws AaiException if an error occurs retrieving information from A&AI
      */
-    public void queryAai(VirtualControlLoopEvent event) throws AaiException {        
-        if (event.getAai().get(VSERVER_IS_CLOSED_LOOP_DISABLED) != null
-                || event.getAai().get(GENERIC_VNF_IS_CLOSED_LOOP_DISABLED) != null) {
-            
-            if (isClosedLoopDisabled(event)) {
-                throw new AaiException("is-closed-loop-disabled is set to true on VServer or VNF");
-            }
-            
+    public void queryAai(VirtualControlLoopEvent event) throws AaiException {
+
+        if (isClosedLoopDisabled(event)) {
+            throw new AaiException("is-closed-loop-disabled is set to true on VServer or VNF");
+        }
+
+        if (isProvStatusInactive(event)) {
+            throw new AaiException("prov-status is not ACTIVE on VServer or VNF");
+        }
+
+        Map<String, String> aai = event.getAai();
+
+        if ((aai.containsKey(VSERVER_IS_CLOSED_LOOP_DISABLED) || aai.containsKey(GENERIC_VNF_IS_CLOSED_LOOP_DISABLED))
+                        && (aai.containsKey(VSERVER_PROV_STATUS) || aai.containsKey(GENERIC_VNF_PROV_STATUS))) {
+
             // no need to query, as we already have the data
             return;
         }
-        
+
         if (vnfResponse != null || vserverResponse != null) {
             // query has already been performed
             return;
         }
 
         try {
-            if (event.getAai().get(GENERIC_VNF_VNF_ID) != null || event.getAai().get(GENERIC_VNF_VNF_NAME) != null) {
+            if (aai.containsKey(GENERIC_VNF_VNF_ID) || aai.containsKey(GENERIC_VNF_VNF_NAME)) {
                 vnfResponse = getAAIVnfInfo(event);
-                processVNFResponse(vnfResponse, event.getAai().get(GENERIC_VNF_VNF_ID) != null);
-            } else if (event.getAai().get(VSERVER_VSERVER_NAME) != null) {
+                processVNFResponse(vnfResponse, aai.containsKey(GENERIC_VNF_VNF_ID));
+            } else if (aai.containsKey(VSERVER_VSERVER_NAME)) {
                 vserverResponse = getAAIVserverInfo(event);
                 processVServerResponse(vserverResponse);
             }
+        } catch (AaiException e) {
+            logger.error("Exception from queryAai: ", e);
+            throw e;
         } catch (Exception e) {
             logger.error("Exception from queryAai: ", e);
             throw new AaiException("Exception from queryAai: " + e.toString());
@@ -696,8 +710,8 @@ public class ControlLoopEventManager implements LockCallback, Serializable {
      * Process a response from A&AI for a VNF.
      * 
      * @param aaiResponse the response from A&AI
-     * @param queryByVnfId <code>true</code> if the query was based on vnf-id, <code>false</code> if
-     *        the query was based on vnf-name
+     * @param queryByVnfId <code>true</code> if the query was based on vnf-id,
+     *        <code>false</code> if the query was based on vnf-name
      * @throws AaiException if an error occurs processing the response
      */
     private static void processVNFResponse(AaiGetVnfResponse aaiResponse, boolean queryByVNFID) throws AaiException {
@@ -713,44 +727,77 @@ public class ControlLoopEventManager implements LockCallback, Serializable {
         if (aaiResponse.getIsClosedLoopDisabled()) {
             throw new AaiException("is-closed-loop-disabled is set to true (query by " + queryTypeString + ")");
         }
+
+        if (!PROV_STATUS_ACTIVE.equals(aaiResponse.getProvStatus())) {
+            throw new AaiException("prov-status is not ACTIVE (query by " + queryTypeString + ")");
+        }
     }
 
+    /**
+     * Process a response from A&AI for a VServer.
+     * 
+     * @param aaiResponse the response from A&AI
+     * @throws AaiException if an error occurs processing the response
+     */
     private static void processVServerResponse(AaiGetVserverResponse aaiResponse) throws AaiException {
         if (aaiResponse == null) {
             throw new AaiException("AAI Response is null (query by vserver-name)");
         }
         if (aaiResponse.getRequestError() != null) {
-            throw new AaiException("AAI responded with a request error (query by vserver-name)");
+            throw new AaiException("AAI Responded with a request error (query by vserver-name)");
         }
-        
+
         List<AaiNqVServer> lst = aaiResponse.getVserver();
-        if(lst.isEmpty()) {
+        if (lst.isEmpty()) {
             return;
         }
-        
+
         AaiNqVServer svr = lst.get(0);
         if (svr.getIsClosedLoopDisabled()) {
             throw new AaiException("is-closed-loop-disabled is set to true (query by vserver-name)");
         }
+
+        if (!PROV_STATUS_ACTIVE.equals(svr.getProvStatus())) {
+            throw new AaiException("prov-status is not ACTIVE (query by vserver-name)");
+        }
     }
 
     /**
      * Is closed loop disabled for an event.
      * 
      * @param event the event
-     * @return <code>true</code> if the contol loop is disabled, <code>false</code> otherwise
+     * @return <code>true</code> if the control loop is disabled, <code>false</code>
+     *         otherwise
      */
     public static boolean isClosedLoopDisabled(VirtualControlLoopEvent event) {
-        if ("true".equalsIgnoreCase(event.getAai().get(VSERVER_IS_CLOSED_LOOP_DISABLED))
-                || "T".equalsIgnoreCase(event.getAai().get(VSERVER_IS_CLOSED_LOOP_DISABLED))
-                || "yes".equalsIgnoreCase(event.getAai().get(VSERVER_IS_CLOSED_LOOP_DISABLED))
-                || "Y".equalsIgnoreCase(event.getAai().get(VSERVER_IS_CLOSED_LOOP_DISABLED))) {
-            return true;
-        }
-        return ("true".equalsIgnoreCase(event.getAai().get(GENERIC_VNF_IS_CLOSED_LOOP_DISABLED))
-                || "T".equalsIgnoreCase(event.getAai().get(GENERIC_VNF_IS_CLOSED_LOOP_DISABLED))
-                || "yes".equalsIgnoreCase(event.getAai().get(GENERIC_VNF_IS_CLOSED_LOOP_DISABLED))
-                || "Y".equalsIgnoreCase(event.getAai().get(GENERIC_VNF_IS_CLOSED_LOOP_DISABLED)));
+        Map<String, String> aai = event.getAai();
+        return (isAaiTrue(aai.get(VSERVER_IS_CLOSED_LOOP_DISABLED))
+                        || isAaiTrue(aai.get(GENERIC_VNF_IS_CLOSED_LOOP_DISABLED)));
+    }
+
+    /**
+     * Does provisioning status, for an event, have a value other than ACTIVE?
+     * 
+     * @param event the event
+     * @return {@code true} if the provisioning status is neither ACTIVE nor {@code null},
+     *         {@code false} otherwise
+     */
+    protected static boolean isProvStatusInactive(VirtualControlLoopEvent event) {
+        Map<String, String> aai = event.getAai();
+        return (!PROV_STATUS_ACTIVE.equals(aai.getOrDefault(VSERVER_PROV_STATUS, PROV_STATUS_ACTIVE))
+                        || !PROV_STATUS_ACTIVE.equals(aai.getOrDefault(GENERIC_VNF_PROV_STATUS, PROV_STATUS_ACTIVE)));
+    }
+
+    /**
+     * Determines the boolean value represented by the given AAI field value.
+     * 
+     * @param aaiValue value to be examined
+     * @return the boolean value represented by the field value, or {@code false} if the
+     *         value is {@code null}
+     */
+    protected static boolean isAaiTrue(String aaiValue) {
+        return ("true".equalsIgnoreCase(aaiValue) || "T".equalsIgnoreCase(aaiValue) || "yes".equalsIgnoreCase(aaiValue)
+                        || "Y".equalsIgnoreCase(aaiValue));
     }
 
     /**
index 3755847..1cef78a 100644 (file)
@@ -21,6 +21,7 @@
 package org.onap.policy.controlloop.eventmanager;
 
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertTrue;
@@ -32,14 +33,19 @@ import java.io.InputStream;
 import java.nio.charset.StandardCharsets;
 import java.time.Instant;
 import java.util.HashMap;
+import java.util.Map;
 import java.util.UUID;
 import org.apache.commons.io.IOUtils;
 import org.junit.AfterClass;
+import org.junit.Before;
 import org.junit.BeforeClass;
+import org.junit.Rule;
 import org.junit.Test;
+import org.junit.rules.ExpectedException;
 import org.onap.policy.aai.AaiGetVnfResponse;
 import org.onap.policy.aai.AaiGetVserverResponse;
 import org.onap.policy.aai.AaiNqVServer;
+import org.onap.policy.aai.AaiNqRequestError;
 import org.onap.policy.aai.RelatedToProperty;
 import org.onap.policy.aai.Relationship;
 import org.onap.policy.aai.RelationshipData;
@@ -60,26 +66,17 @@ import org.onap.policy.guard.GuardResult;
 import org.onap.policy.guard.PolicyGuard;
 import org.onap.policy.guard.PolicyGuard.LockResult;
 import org.onap.policy.guard.TargetLock;
+import org.powermock.reflect.Whitebox;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 public class ControlLoopEventManagerTest {
     private static final Logger logger = LoggerFactory.getLogger(ControlLoopEventManagerTest.class);
+    
+    @Rule
+    public ExpectedException thrown = ExpectedException.none();
 
-    private static VirtualControlLoopEvent onset;
-
-    {
-        onset = new VirtualControlLoopEvent();
-        onset.setClosedLoopControlName("ControlLoop-vUSP");
-        onset.setRequestId(UUID.randomUUID());
-        onset.setTarget("VM_NAME");
-        onset.setClosedLoopAlarmStart(Instant.now());
-        onset.setAai(new HashMap<String, String>());
-        onset.getAai().put("cloud-region.identity-url", "foo");
-        onset.getAai().put("vserver.selflink", "bar");
-        onset.getAai().put("generic-vnf.vnf-id", "83f674e8-7555-44d7-9a39-bdc3770b0491");
-        onset.setClosedLoopEventStatus(ControlLoopEventStatus.ONSET);
-    }
+    private VirtualControlLoopEvent onset;
 
     /**
      * Set up test class.
@@ -100,6 +97,22 @@ public class ControlLoopEventManagerTest {
     public static void tearDownSimulator() {
         HttpServletServer.factory.destroy();
     }
+    
+    @Before
+    public void setUp() {
+        onset = new VirtualControlLoopEvent();
+        onset.setClosedLoopControlName("ControlLoop-vUSP");
+        onset.setRequestId(UUID.randomUUID());
+        onset.setTarget("VM_NAME");
+        onset.setClosedLoopAlarmStart(Instant.now());
+        onset.setAai(new HashMap<String, String>());
+        onset.getAai().put("cloud-region.identity-url", "foo");
+        onset.getAai().put("vserver.selflink", "bar");
+        onset.getAai().put("generic-vnf.vnf-id", "83f674e8-7555-44d7-9a39-bdc3770b0491");
+        onset.setClosedLoopEventStatus(ControlLoopEventStatus.ONSET);
+        
+        PolicyEngine.manager.setEnvironmentProperty("aai.url", "http://localhost:6666");
+    }
 
     @Test
     public void testAaiVnfInfo() {
@@ -157,53 +170,7 @@ public class ControlLoopEventManagerTest {
     }
 
     @Test
-    public void testIsClosedLoopDisabled() {
-        //
-        // Load up the policy
-        //
-        final Util.Pair<ControlLoopPolicy, String> pair = Util.loadYaml("src/test/resources/test.yaml");
-        onset.setClosedLoopControlName(pair.key.getControlLoop().getControlLoopName());
-
-        try {
-            logger.info("testIsClosedLoopDisabled --");
-            AaiGetVnfResponse response = getQueryByVnfId2(
-                    PolicyEngine.manager.getEnvironmentProperty("aai.url")
-                            + "/aai/v11/network/generic-vnfs/generic-vnf/",
-                    PolicyEngine.manager.getEnvironmentProperty("aai.username"),
-                    PolicyEngine.manager.getEnvironmentProperty("aai.password"), UUID.randomUUID(),
-                    "5e49ca06-2972-4532-9ed4-6d071588d792");
-            assertNotNull(response);
-
-            // TODO: Handle this
-            // boolean disabled = ControlLoopEventManager.isClosedLoopDisabled(response);
-            // logger.info("QueryByVnfID - isClosedLoopDisabled: " + disabled);
-
-            response = getQueryByVnfName2(
-                    PolicyEngine.manager.getEnvironmentProperty("aai.url")
-                            + "/aai/v11/network/generic-vnfs/generic-vnf?vnf-name=",
-                    PolicyEngine.manager.getEnvironmentProperty("aai.username"),
-                    PolicyEngine.manager.getEnvironmentProperty("aai.password"), UUID.randomUUID(), "lll_vnf_010317");
-            assertNotNull(response);
-            // TODO: Handle this
-            // disabled = ControlLoopEventManager.isClosedLoopDisabled(response);
-            // logger.info("QueryByVnfName - isClosedLoopDisabled: " + disabled);
-
-            AaiGetVserverResponse response2 = getQueryByVserverName2(
-                    PolicyEngine.manager.getEnvironmentProperty("aai.url") + "/aai/v11/nodes/vservers?vserver-name=",
-                    PolicyEngine.manager.getEnvironmentProperty("aai.user"),
-                    PolicyEngine.manager.getEnvironmentProperty("aai.password"), UUID.randomUUID(),
-                    "USMSO1SX7NJ0103UJZZ01-vjunos0");
-            assertNotNull(response2);
-            // TODO: Handle this
-            // disabled = ControlLoopEventManager.isClosedLoopDisabled(response2);
-            // logger.info("QueryByVserverName - isClosedLoopDisabled: " + disabled);
-        } catch (Exception e) {
-            fail(e.getMessage());
-        }
-    }
-
-    @Test
-    public void abatemetCheckEventSyntaxTest() {
+    public void abatementCheckEventSyntaxTest() {
         VirtualControlLoopEvent event = new VirtualControlLoopEvent();
         event.setClosedLoopControlName("abatementAAI");
         event.setRequestId(UUID.randomUUID());
@@ -925,119 +892,350 @@ public class ControlLoopEventManagerTest {
     }
 
     @Test
-    public void testQueryAai() throws IOException, AaiException {
-        InputStream is = new FileInputStream(new File("src/test/resources/test.yaml"));
-        final String yamlString = IOUtils.toString(is, StandardCharsets.UTF_8);
+    public void testQueryAai_AlreadyDisabled() throws AaiException {
+        ControlLoopEventManager mgr = null;
+        
+        try {
+            onset.getAai().put(ControlLoopEventManager.GENERIC_VNF_IS_CLOSED_LOOP_DISABLED, Boolean.TRUE.toString());
+            onset.getAai().put(ControlLoopEventManager.GENERIC_VNF_PROV_STATUS,
+                            ControlLoopEventManager.PROV_STATUS_ACTIVE);
 
-        UUID requestId = UUID.randomUUID();
-        VirtualControlLoopEvent onsetEvent = new VirtualControlLoopEvent();
-        onsetEvent.setClosedLoopControlName("TwoOnsetTest");
-        onsetEvent.setRequestId(requestId);
-        onsetEvent.setTarget("generic-vnf.vnf-id");
-        onsetEvent.setClosedLoopAlarmStart(Instant.now());
-        onsetEvent.setClosedLoopEventStatus(ControlLoopEventStatus.ONSET);
-        onsetEvent.setAai(new HashMap<>());
-        onsetEvent.getAai().put("generic-vnf.vnf-name", "onsetOne");
+            mgr = makeManager(onset);
+            mgr.queryAai(onset);
 
-        ControlLoopEventManager manager = makeManager(onsetEvent);
-        manager.queryAai(onsetEvent);
+            fail("missing exception");
 
-        VirtualControlLoopNotification notification = manager.activate(yamlString, onsetEvent);
-        assertNotNull(notification);
-        assertEquals(ControlLoopNotificationType.ACTIVE, notification.getNotification());
+        } catch (AaiException expected) {
+            assertEquals("is-closed-loop-disabled is set to true on VServer or VNF", expected.getMessage());
+            assertNull(mgr.getVnfResponse());
+            assertNull(mgr.getVserverResponse());
+        }
+    }
 
-        // repeat query with same manager
-        manager.queryAai(onsetEvent);
+    @Test
+    public void testQueryAai_AlreadyInactive() throws AaiException {
+        ControlLoopEventManager mgr = null;
+        
+        try {
+            onset.getAai().put(ControlLoopEventManager.GENERIC_VNF_IS_CLOSED_LOOP_DISABLED, Boolean.FALSE.toString());
+            onset.getAai().put(ControlLoopEventManager.GENERIC_VNF_PROV_STATUS, "not-active2");
 
-        // remaining queries each use their own manager so they will be re-executed
+            mgr = makeManager(onset);
+            mgr.queryAai(onset);
 
-        makeManager(onsetEvent).queryAai(onsetEvent);
+            fail("missing exception");
 
-        onsetEvent.getAai().put("generic-vnf.is-closed-loop-disabled", "true");
-        try {
-            makeManager(onsetEvent).queryAai(onsetEvent);
-            fail("test should throw an exception here");
-        } catch (Exception e) {
-            assertEquals("is-closed-loop-disabled is set to true on VServer or VNF", e.getMessage());
+        } catch (AaiException expected) {
+            assertEquals("prov-status is not ACTIVE on VServer or VNF", expected.getMessage());
+            assertNull(mgr.getVnfResponse());
+            assertNull(mgr.getVserverResponse());
         }
-        onsetEvent.getAai().put("vserver.is-closed-loop-disabled", "true");
+    }
+
+    @Test
+    public void testQueryAai_QueryVnfById() throws AaiException {
+        ControlLoopEventManager mgr = null;
+
+        mgr = makeManager(onset);
+        mgr.queryAai(onset);
+        
+        assertNotNull(mgr.getVnfResponse());
+        assertNull(mgr.getVserverResponse());
+
+        AaiGetVnfResponse vnfresp = mgr.getVnfResponse();
+        
+        // should not re-query
+        mgr.queryAai(onset);
+        
+        assertEquals(vnfresp, mgr.getVnfResponse());
+        assertNull(mgr.getVserverResponse());
+    }
+
+    @Test
+    public void testQueryAai_QueryVnfByName() throws AaiException {
+        ControlLoopEventManager mgr = null;
+        
+        // vnf query by name
+        onset.getAai().remove(ControlLoopEventManager.GENERIC_VNF_VNF_ID);
+        onset.getAai().put(ControlLoopEventManager.GENERIC_VNF_VNF_NAME, "AVNFName");
+
+        mgr = makeManager(onset);
+        mgr.queryAai(onset);
+        
+        assertNotNull(mgr.getVnfResponse());
+        assertNull(mgr.getVserverResponse());
+
+        AaiGetVnfResponse vnfresp = mgr.getVnfResponse();
+        
+        // should not re-query
+        mgr.queryAai(onset);
+        
+        assertEquals(vnfresp, mgr.getVnfResponse());
+        assertNull(mgr.getVserverResponse());
+    }
+
+    @Test
+    public void testQueryAai_QueryVnfById_Disabled() throws AaiException {
+        ControlLoopEventManager mgr = null;
+        
         try {
-            makeManager(onsetEvent).queryAai(onsetEvent);
-            fail("test should throw an exception here");
-        } catch (Exception e) {
-            assertEquals("is-closed-loop-disabled is set to true on VServer or VNF", e.getMessage());
+            onset.getAai().put(ControlLoopEventManager.GENERIC_VNF_VNF_ID, "disableClosedLoop");
+            
+            mgr = makeManager(onset);
+            mgr.queryAai(onset);
+
+            fail("missing exception");
+
+        } catch (AaiException expected) {
+            assertEquals("is-closed-loop-disabled is set to true (query by vnf-id)", expected.getMessage());
+            
+            assertNotNull(mgr.getVnfResponse());
+            assertNull(mgr.getVserverResponse());
         }
-        onsetEvent.getAai().remove("generic-vnf.is-closed-loop-disabled");
+    }
+
+    @Test
+    public void testQueryAai_QueryVserver() throws AaiException {
+        ControlLoopEventManager mgr = null;
+
+        onset.getAai().remove(ControlLoopEventManager.GENERIC_VNF_VNF_ID);
+        onset.getAai().put(ControlLoopEventManager.VSERVER_VSERVER_NAME, "AVserver");
+
+        mgr = makeManager(onset);
+        mgr.queryAai(onset);
+        
+        assertNull(mgr.getVnfResponse());
+        assertNotNull(mgr.getVserverResponse());
+        
+        AaiGetVserverResponse vsvresp = mgr.getVserverResponse();
+
+        // should not re-query
+        mgr.queryAai(onset);
+        
+        assertNull(mgr.getVnfResponse());
+        assertEquals(vsvresp, mgr.getVserverResponse());
+    }
+
+    @Test
+    public void testQueryAai_QueryVserver_Disabled() throws AaiException {
+        ControlLoopEventManager mgr = null;
+        
         try {
-            makeManager(onsetEvent).queryAai(onsetEvent);
-            fail("test should throw an exception here");
-        } catch (Exception e) {
-            assertEquals("is-closed-loop-disabled is set to true on VServer or VNF", e.getMessage());
+            onset.getAai().remove(ControlLoopEventManager.GENERIC_VNF_VNF_ID);
+            onset.getAai().put(ControlLoopEventManager.VSERVER_VSERVER_NAME, "disableClosedLoop");
+            
+            mgr = makeManager(onset);
+            mgr.queryAai(onset);
+
+            fail("missing exception");
+
+        } catch (AaiException expected) {
+            assertEquals("is-closed-loop-disabled is set to true (query by vserver-name)", expected.getMessage());
+            
+            assertNull(mgr.getVnfResponse());
+            assertNotNull(mgr.getVserverResponse());
         }
-        onsetEvent.getAai().remove("vserver.is-closed-loop-disabled");
-        makeManager(onsetEvent).queryAai(onsetEvent);
+    }
 
-        onsetEvent.getAai().put("generic-vnf.is-closed-loop-disabled", "false");
-        makeManager(onsetEvent).queryAai(onsetEvent);
+    @Test(expected = AaiException.class)
+    public void testQueryAai_QueryException() throws AaiException {
+        // Force AAI errors
+        PolicyEngine.manager.setEnvironmentProperty("aai.url", "http://localhost:9999");
+        
+        makeManager(onset).queryAai(onset);
+    }
 
-        onsetEvent.getAai().remove("generic-vnf.is-closed-loop-disabled");
-        onsetEvent.getAai().put("vserver.is-closed-loop-disabled", "false");
-        makeManager(onsetEvent).queryAai(onsetEvent);
+    @Test
+    public void testProcessVNFResponse_Success() throws Exception {
+        AaiGetVnfResponse resp = new AaiGetVnfResponse();
+        resp.setIsClosedLoopDisabled(false);
+        resp.setProvStatus(ControlLoopEventManager.PROV_STATUS_ACTIVE);
+        Whitebox.invokeMethod(ControlLoopEventManager.class, "processVNFResponse", resp, true);
+    }
 
-        onsetEvent.getAai().remove("generic-vnf.vnf-id");
-        onsetEvent.getAai().remove("generic-vnf.vnf-name");
-        onsetEvent.getAai().remove("vserver.vserver-name");
-        onsetEvent.getAai().remove("generic-vnf.is-closed-loop-disabled");
-        onsetEvent.getAai().remove("vserver.is-closed-loop-disabled");
-        makeManager(onsetEvent).queryAai(onsetEvent);
+    @Test
+    public void testProcessVNFResponse_NullResponse() throws Exception {
+        thrown.expect(AaiException.class);
+        thrown.expectMessage("AAI Response is null (query by vnf-id)");
 
-        onsetEvent.getAai().put("vserver.vserver-name", "AVserver");
-        makeManager(onsetEvent).queryAai(onsetEvent);
+        AaiGetVnfResponse resp = null;
+        Whitebox.invokeMethod(ControlLoopEventManager.class, "processVNFResponse", resp, true);
+    }
 
-        onsetEvent.getAai().put("generic-vnf.vnf-name", "AVNFName");
-        makeManager(onsetEvent).queryAai(onsetEvent);
+    @Test
+    public void testProcessVNFResponse_Error() throws Exception {
+        thrown.expect(AaiException.class);
+        thrown.expectMessage("AAI Responded with a request error (query by vnf-name)");
+        
+        AaiGetVnfResponse resp = new AaiGetVnfResponse();
+        
+        resp.setRequestError(new AaiNqRequestError());
+        
+        resp.setIsClosedLoopDisabled(false);
+        resp.setProvStatus(ControlLoopEventManager.PROV_STATUS_ACTIVE);
+        Whitebox.invokeMethod(ControlLoopEventManager.class, "processVNFResponse", resp, false);
+    }
 
-        onsetEvent.getAai().put("generic-vnf.vnf-id", "AVNFID");
-        makeManager(onsetEvent).queryAai(onsetEvent);
+    @Test
+    public void testProcessVNFResponse_Disabled() throws Exception {
+        thrown.expect(AaiException.class);
+        thrown.expectMessage("is-closed-loop-disabled is set to true (query by vnf-id)");
+        
+        AaiGetVnfResponse resp = new AaiGetVnfResponse();
+        resp.setIsClosedLoopDisabled(true);
+        resp.setProvStatus(ControlLoopEventManager.PROV_STATUS_ACTIVE);
+        Whitebox.invokeMethod(ControlLoopEventManager.class, "processVNFResponse", resp, true);
+    }
 
-        onsetEvent.getAai().remove("vserver.vserver-name");
-        makeManager(onsetEvent).queryAai(onsetEvent);
+    @Test
+    public void testProcessVNFResponse_Inactive() throws Exception {
+        thrown.expect(AaiException.class);
+        thrown.expectMessage("prov-status is not ACTIVE (query by vnf-name)");
+
+        AaiGetVnfResponse resp = new AaiGetVnfResponse();
+        resp.setIsClosedLoopDisabled(false);
+        resp.setProvStatus("inactive1");
+        Whitebox.invokeMethod(ControlLoopEventManager.class, "processVNFResponse", resp, false);
+    }
 
-        onsetEvent.getAai().remove("generic-vnf.vnf-name");
-        makeManager(onsetEvent).queryAai(onsetEvent);
+    @Test
+    public void testProcessVserverResponse_Success() throws Exception {
+        AaiGetVserverResponse resp = new AaiGetVserverResponse();
+        
+        AaiNqVServer svr = new AaiNqVServer();
+        resp.getVserver().add(svr);
+        
+        svr.setIsClosedLoopDisabled(false);
+        svr.setProvStatus(ControlLoopEventManager.PROV_STATUS_ACTIVE);
+        Whitebox.invokeMethod(ControlLoopEventManager.class, "processVServerResponse", resp);
+    }
 
-        // Force AAI errors
-        PolicyEngine.manager.setEnvironmentProperty("aai.url", "http://localhost:9999");
+    @Test
+    public void testProcessVserverResponse_NullResponse() throws Exception {
+        thrown.expect(AaiException.class);
+        thrown.expectMessage("AAI Response is null (query by vserver-name)");
 
-        try {
-            makeManager(onsetEvent).queryAai(onsetEvent);
-            fail("test should throw an exception here");
-        } catch (Exception e) {
-            assertEquals("Exception from queryAai: org.onap.policy.aai.util.AaiException: AAI Response is null "
-                    + "(query by vnf-id)", e.getMessage());
-        }
+        AaiGetVserverResponse resp = null;
+        Whitebox.invokeMethod(ControlLoopEventManager.class, "processVServerResponse", resp);
+    }
 
-        onsetEvent.getAai().remove("generic-vnf.vnf-id");
-        onsetEvent.getAai().put("generic-vnf.vnf-name", "AVNFName");
-        try {
-            makeManager(onsetEvent).queryAai(onsetEvent);
-            fail("test should throw an exception here");
-        } catch (Exception e) {
-            assertEquals("Exception from queryAai: org.onap.policy.aai.util.AaiException: AAI Response is null "
-                    + "(query by vnf-name)", e.getMessage());
-        }
+    @Test
+    public void testProcessVserverResponse_Error() throws Exception {
+        thrown.expect(AaiException.class);
+        thrown.expectMessage("AAI Responded with a request error (query by vserver-name)");
 
-        onsetEvent.getAai().remove("generic-vnf.vnf-name");
-        onsetEvent.getAai().put("vserver.vserver-name", "AVserver");
-        try {
-            makeManager(onsetEvent).queryAai(onsetEvent);
-            fail("test should throw an exception here");
-        } catch (Exception e) {
-            assertEquals("Exception from queryAai: org.onap.policy.aai.util.AaiException: AAI Response is null "
-                    + "(query by vserver-name)", e.getMessage());
-        }
+        AaiGetVserverResponse resp = new AaiGetVserverResponse();
+        
+        resp.setRequestError(new AaiNqRequestError());
+        
+        AaiNqVServer svr = new AaiNqVServer();
+        resp.getVserver().add(svr);
+        
+        svr.setIsClosedLoopDisabled(false);
+        svr.setProvStatus(ControlLoopEventManager.PROV_STATUS_ACTIVE);
+        
+        Whitebox.invokeMethod(ControlLoopEventManager.class, "processVServerResponse", resp);
+    }
 
-        PolicyEngine.manager.setEnvironmentProperty("aai.url", "http://localhost:6666");
+    @Test
+    public void testProcessVserverResponse_Disabled() throws Exception {
+        thrown.expect(AaiException.class);
+        thrown.expectMessage("is-closed-loop-disabled is set to true (query by vserver-name)");
+
+        AaiGetVserverResponse resp = new AaiGetVserverResponse();
+        AaiNqVServer svr = new AaiNqVServer();
+        resp.getVserver().add(svr);
+        
+        svr.setIsClosedLoopDisabled(true);
+        svr.setProvStatus(ControlLoopEventManager.PROV_STATUS_ACTIVE);
+        Whitebox.invokeMethod(ControlLoopEventManager.class, "processVServerResponse", resp);
+    }
+
+    @Test
+    public void testProcessVserverResponse_Inactive() throws Exception {
+        thrown.expect(AaiException.class);
+        thrown.expectMessage("prov-status is not ACTIVE (query by vserver-name)");
+
+        AaiGetVserverResponse resp = new AaiGetVserverResponse();
+        AaiNqVServer svr = new AaiNqVServer();
+        resp.getVserver().add(svr);
+        
+        svr.setIsClosedLoopDisabled(false);
+        svr.setProvStatus("inactive1");
+        Whitebox.invokeMethod(ControlLoopEventManager.class, "processVServerResponse", resp);
+    }
+
+    @Test
+    public void testIsClosedLoopDisabled() {
+        Map<String, String> aai = onset.getAai();
+        
+        // null, null
+        aai.remove(ControlLoopEventManager.GENERIC_VNF_IS_CLOSED_LOOP_DISABLED);
+        aai.remove(ControlLoopEventManager.VSERVER_IS_CLOSED_LOOP_DISABLED);
+        assertFalse(ControlLoopEventManager.isClosedLoopDisabled(onset));
+        
+        // null, false
+        aai.remove(ControlLoopEventManager.GENERIC_VNF_IS_CLOSED_LOOP_DISABLED);
+        aai.put(ControlLoopEventManager.VSERVER_IS_CLOSED_LOOP_DISABLED, Boolean.FALSE.toString());
+        assertFalse(ControlLoopEventManager.isClosedLoopDisabled(onset));
+        
+        // false, null
+        aai.put(ControlLoopEventManager.GENERIC_VNF_IS_CLOSED_LOOP_DISABLED, Boolean.FALSE.toString());
+        aai.remove(ControlLoopEventManager.VSERVER_IS_CLOSED_LOOP_DISABLED);
+        assertFalse(ControlLoopEventManager.isClosedLoopDisabled(onset));
+        
+        // null, true
+        aai.remove(ControlLoopEventManager.GENERIC_VNF_IS_CLOSED_LOOP_DISABLED);
+        aai.put(ControlLoopEventManager.VSERVER_IS_CLOSED_LOOP_DISABLED, Boolean.TRUE.toString());
+        assertTrue(ControlLoopEventManager.isClosedLoopDisabled(onset));
+        
+        // true, null
+        aai.put(ControlLoopEventManager.GENERIC_VNF_IS_CLOSED_LOOP_DISABLED, Boolean.TRUE.toString());
+        aai.remove(ControlLoopEventManager.VSERVER_IS_CLOSED_LOOP_DISABLED);
+        assertTrue(ControlLoopEventManager.isClosedLoopDisabled(onset));
+    }
+    
+    @Test
+    public void testIsProvStatusInactive() {
+        Map<String, String> aai = onset.getAai();
+        
+        // null, null
+        aai.remove(ControlLoopEventManager.GENERIC_VNF_PROV_STATUS);
+        aai.remove(ControlLoopEventManager.VSERVER_PROV_STATUS);
+        assertFalse(ControlLoopEventManager.isProvStatusInactive(onset));
+        
+        // null, active
+        aai.remove(ControlLoopEventManager.GENERIC_VNF_PROV_STATUS);
+        aai.put(ControlLoopEventManager.VSERVER_PROV_STATUS, ControlLoopEventManager.PROV_STATUS_ACTIVE);
+        assertFalse(ControlLoopEventManager.isProvStatusInactive(onset));
+        
+        // active, null
+        aai.put(ControlLoopEventManager.GENERIC_VNF_PROV_STATUS, ControlLoopEventManager.PROV_STATUS_ACTIVE);
+        aai.remove(ControlLoopEventManager.VSERVER_PROV_STATUS);
+        assertFalse(ControlLoopEventManager.isProvStatusInactive(onset));
+        
+        // null, inactive
+        aai.remove(ControlLoopEventManager.GENERIC_VNF_PROV_STATUS);
+        aai.put(ControlLoopEventManager.VSERVER_PROV_STATUS, "other1");
+        assertTrue(ControlLoopEventManager.isProvStatusInactive(onset));
+        
+        // inactive, null
+        aai.put(ControlLoopEventManager.GENERIC_VNF_PROV_STATUS, "other2");
+        aai.remove(ControlLoopEventManager.VSERVER_PROV_STATUS);
+        assertTrue(ControlLoopEventManager.isProvStatusInactive(onset));
+    }
+    
+    @Test
+    public void testIsAaiTrue() {
+        assertTrue(ControlLoopEventManager.isAaiTrue("tRuE"));
+        assertTrue(ControlLoopEventManager.isAaiTrue("T"));
+        assertTrue(ControlLoopEventManager.isAaiTrue("t"));
+        assertTrue(ControlLoopEventManager.isAaiTrue("yES"));
+        assertTrue(ControlLoopEventManager.isAaiTrue("Y"));
+        assertTrue(ControlLoopEventManager.isAaiTrue("y"));
+        
+        assertFalse(ControlLoopEventManager.isAaiTrue("no"));
+        assertFalse(ControlLoopEventManager.isAaiTrue(null));
     }
 
     private ControlLoopEventManager makeManager(VirtualControlLoopEvent event) {
index 8db3a76..b6c3847 100644 (file)
@@ -52,6 +52,9 @@ public class AaiGetVnfResponse extends AaiGetResponse implements Serializable {
     @SerializedName("model-invariant-id")
     private String modelInvariantId;
 
+    @SerializedName("prov-status")
+    private String provStatus;
+
     @SerializedName("resource-version")
     private String resourceVersion;
 
@@ -90,6 +93,10 @@ public class AaiGetVnfResponse extends AaiGetResponse implements Serializable {
         return modelInvariantId;
     }
 
+    public String getProvStatus() {
+        return provStatus;
+    }
+
     public String getResourceVersion() {
         return resourceVersion;
     }
@@ -130,6 +137,10 @@ public class AaiGetVnfResponse extends AaiGetResponse implements Serializable {
         this.modelInvariantId = modelInvariantId;
     }
 
+    public void setProvStatus(String provStatus) {
+        this.provStatus = provStatus;
+    }
+
     public void setResourceVersion(String resourceVersion) {
         this.resourceVersion = resourceVersion;
     }
index d56aaae..26f3ca2 100644 (file)
@@ -49,6 +49,7 @@ public class AaiGetVnfResponseTest {
         assertEquals(false, resp.getInMaint());
         assertEquals(true, resp.getIsClosedLoopDisabled());
         assertEquals("53638a85-361a-437d-8830-4b0d5329225e", resp.getModelInvariantId());
+        assertEquals("PROV", resp.getProvStatus());
         assertEquals("Active", resp.getOrchestrationStatus());
         assertEquals("50e1b0be-e0c9-48e2-9f42-15279a783ee8", resp.getServiceId());
 
@@ -72,6 +73,7 @@ public class AaiGetVnfResponseTest {
         resp.setIsClosedLoopDisabled(false);
         resp.setModelInvariantId("modiv");
         resp.setOrchestrationStatus("orch");
+        resp.setProvStatus("mystatus");
         resp.setRelationshipList(relationshipList);
         resp.setResourceVersion("vers");
         resp.setServiceId("svc");
@@ -86,6 +88,7 @@ public class AaiGetVnfResponseTest {
         assertEquals(true, resp.getInMaint());
         assertEquals(false, resp.getIsClosedLoopDisabled());
         assertEquals("modiv", resp.getModelInvariantId());
+        assertEquals("mystatus", resp.getProvStatus());
         assertEquals("orch", resp.getOrchestrationStatus());
         assertEquals("svc", resp.getServiceId());
         assertEquals(relationshipList, resp.getRelationshipList());
index 3f5651b..8d651f2 100644 (file)
@@ -81,7 +81,7 @@ public class AaiSimulatorJaxRs {
                         + "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"
+                        + "6ed3642c-f7a1-4a7c-9290-3d51fe1531eb\",\"in-maint\":false,\"prov-status\":\"ACTIVE\",\"is-closed-loop-disabled\":false"
                         + ",\"resource-version\":\"1510606403522\"},\"extra-properties\":{},\"inventory-response-items"
                         + "\":{\"inventory-response-item\":[{\"model-name\":\"vLoadBalancer\",\"generic-vnf\":{\"vnf-id"
                         + "\":\"db373a8d-f7be-4d02-8ac8-6ca4c305d144\",\"vnf-name\":\"Vfmodule_vLB1113\",\"vnf-type"
@@ -159,7 +159,7 @@ public class AaiSimulatorJaxRs {
                 return "{\"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\",\""
-                        + "orchestration-status\": \"active\",\"in-maint\": false,\"is-closed-loop-disabled\": false"
+                        + "orchestration-status\": \"active\",\"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\": {},\""
@@ -212,7 +212,7 @@ public class AaiSimulatorJaxRs {
                     + "equipment-role\": \"UCPE\", \"orchestration-status\": \"created\", \"management-option\": \""
                     + "ATT\", \"ipv4-oam-address\": \"32.40.68.35\", \"ipv4-loopback0-address\": \"32.40.64.57\", \""
                     + "nm-lan-v6-address\": \"2001:1890:e00e:fffe::1345\", \"management-v6-address\": \""
-                    + "2001:1890:e00e:fffd::36\", \"in-maint\": false, \"is-closed-loop-disabled\": " + isDisabled
+                    + "2001:1890:e00e:fffd::36\", \"in-maint\": false, \"prov-status\":\"ACTIVE\", \"is-closed-loop-disabled\": " + isDisabled
                     + ", \"resource-version\": \"1493389458092\", \"relationship-list\": {\"relationship\":[{ \""
                     + "related-to\": \"service-instance\", \"related-link\": \"/aai/v11/business/customers/customer/"
                     + "1610_Func_Global_20160817084727/service-subscriptions/service-subscription/uCPE-VMS/"
@@ -240,7 +240,7 @@ public class AaiSimulatorJaxRs {
                 + "equipment-role\": \"UCPE\", \"orchestration-status\": \"created\", \"management-option\": \"ATT"
                 + "\", \"ipv4-oam-address\": \"32.40.68.35\", \"ipv4-loopback0-address\": \"32.40.64.57\", \""
                 + "nm-lan-v6-address\": \"2001:1890:e00e:fffe::1345\", \"management-v6-address\": \""
-                + "2001:1890:e00e:fffd::36\", \"in-maint\": false, \"is-closed-loop-disabled\": " + isDisabled
+                + "2001:1890:e00e:fffd::36\", \"in-maint\": false, \"prov-status\":\"ACTIVE\", \"is-closed-loop-disabled\": " + isDisabled
                 + ", \"resource-version\": \"1493389458092\", \"relationship-list\": {\"relationship\":[{ \""
                 + "related-to\": \"service-instance\", \"related-link\": \"/aai/v11/business/customers/customer"
                 + "/1610_Func_Global_20160817084727/service-subscriptions/service-subscription/uCPE-VMS/"
@@ -285,7 +285,7 @@ public class AaiSimulatorJaxRs {
                 + "d7bb0a21-66f2-4e6d-87d9-9ef3ced63ae4\", \"equipment-role\": \"UCPE\", \"orchestration-status"
                 + "\": \"created\", \"management-option\": \"ATT\", \"ipv4-oam-address\": \"32.40.68.35\", \""
                 + "ipv4-loopback0-address\": \"32.40.64.57\", \"nm-lan-v6-address\": \"2001:1890:e00e:fffe::1345"
-                + "\", \"management-v6-address\": \"2001:1890:e00e:fffd::36\", \"in-maint\": false, \"" + ""
+                + "\", \"management-v6-address\": \"2001:1890:e00e:fffd::36\", \"in-maint\": false, \"prov-status\":\"ACTIVE\", \"" + ""
                 + "is-closed-loop-disabled\": " + isDisabled + ", \"resource-version\": \"1493389458092\", \""
                 + "relationship-list\": {\"relationship\":[{ \"related-to\": \"service-instance\", \"related-link"
                 + "\": \"/aai/v11/business/customers/customer/1610_Func_Global_20160817084727/service-subscriptions"
@@ -327,7 +327,7 @@ public class AaiSimulatorJaxRs {
         return "{\"vserver\": [{ \"vserver-id\": \"" + vserverId + "\", \"vserver-name\": \"" + vserverName
                 + "\", \"vserver-name2\": \"vjunos0\", \"vserver-selflink\": \"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\", \"in-maint\": false, \"is-closed-loop-disabled\": "
                 + isDisabled
-                + ", \"resource-version\": \"1494001931513\", \"relationship-list\": {\"relationship\":[{ \"related-to"
+                + ", \"prov-status\":\"ACTIVE\", \"resource-version\": \"1494001931513\", \"relationship-list\": {\"relationship\":[{ \"related-to"
                 + "\": \"generic-vnf\", \"related-link\": \"/aai/v11/network/generic-vnfs/generic-vnf/"
                 + "e1a41e99-4ede-409a-8f9d-b5e12984203a\", \"relationship-data\": [ {\"relationship-key\": \""
                 + "generic-vnf.vnf-id\",\"relationship-value\": \"e1a41e99-4ede-409a-8f9d-b5e12984203a\" }], \""
index 1519129..b5bb6e7 100644 (file)
@@ -8,6 +8,7 @@
     "target": "vserver.vserver-name",
     "AAI": {
        "vserver.is-closed-loop-disabled": "false",
+        "vserver.prov-status": "ACTIVE",
         "vserver.vserver-name": "dfw1lb01lb01",
         "service-instance.service-instance-id" : "vserver-name-16102016-aai3255-data-11-1",
         "generic-vnf.vnf-id" : "vnf-id-16102016-aai3255-data-11-1",
index 2cf28fb..f17a1ea 100644 (file)
@@ -8,6 +8,7 @@
     "target": "vserver.vserver-name",
     "AAI": {
        "vserver.is-closed-loop-disabled": "false",
+        "vserver-vnf.prov-status": "ACTIVE",
         "vserver.vserver-name": "dfw1lb01lb01",
         "service-instance.service-instance-id" : "vserver-name-16102016-aai3255-data-11-1",
         "generic-vnf.vnf-id" : "vnf-id-16102016-aai3255-data-11-1",
index 19c33ac..785be99 100644 (file)
@@ -374,7 +374,7 @@ public class VCPEControlLoopTest implements TopicListener {
             event.getAai().put("generic-vnf.in-maint", "false");
             event.getAai().put("generic-vnf.is-closed-loop-disabled", "false");
             event.getAai().put("generic-vnf.orchestration-status", "Created");
-            event.getAai().put("generic-vnf.prov-status", "PREPROV");
+            event.getAai().put("generic-vnf.prov-status", "ACTIVE");
             event.getAai().put("generic-vnf.resource-version", "1");
             event.getAai().put("generic-vnf.service-id", "e8cb8968-5411-478b-906a-f28747de72cd");
             event.getAai().put("generic-vnf.vnf-id", "63b31229-9a3a-444f-9159-04ce2dca3be9");
index 2785e3d..630ade8 100644 (file)
@@ -371,6 +371,7 @@ public class VDNSControlLoopTest implements TopicListener {
         event.setAai(new HashMap<>());
         event.getAai().put("vserver.vserver-name", "dfw1lb01lb01");
         event.getAai().put("vserver.is-closed-loop-disabled", "false");
+        event.getAai().put("vserver.prov-status", "ACTIVE");
         event.setClosedLoopEventStatus(status);
         kieSession.insert(event);
     }
index 5db0e3f..6f11bc6 100644 (file)
@@ -346,6 +346,7 @@ public class VFCControlLoopTest implements TopicListener {
         event.getAai().put("generic-vnf.vnf-id", "vnf-id-16102016-aai3255-data-11-1");
         event.getAai().put("service-instance.service-instance-id", "service-instance-id-16102016-aai3255-data-11-1");
         event.getAai().put("vserver.is-closed-loop-disabled", "false");
+        event.getAai().put("vserver.prov-status", "ACTIVE");
         event.setClosedLoopEventStatus(ControlLoopEventStatus.ONSET);
         kieSession.insert(event);
     }