Add new method to retrieve vnf-id 16/112016/4
authorPamela Dragosh <pdragosh@research.att.com>
Tue, 1 Sep 2020 20:38:15 +0000 (16:38 -0400)
committerPamela Dragosh <pdragosh@research.att.com>
Wed, 2 Sep 2020 11:27:22 +0000 (07:27 -0400)
For guard filters, once the vnf-id is found. Then this convenience
method helps to retrieve the correct vnf information.

Issue-ID: POLICY-2590
Change-Id: I0b55b15582ddc58bbc5b2c0c2c2b130f3cdc88c3
Signed-off-by: Pamela Dragosh <pdragosh@research.att.com>
Signed-off-by: Jim Hahn <jrh3@att.com>
Signed-off-by: Pamela Dragosh <pdragosh@research.att.com>
models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiCqResponse.java
models-interactions/model-simulators/src/main/java/org/onap/policy/simulators/AaiSimulatorJaxRs.java
models-interactions/model-simulators/src/test/java/org/onap/policy/simulators/AaiSimulatorTest.java

index 1b18e43..2648959 100644 (file)
@@ -382,6 +382,24 @@ public class AaiCqResponse implements Serializable {
         return null;
     }
 
+    /**
+     * Returns the VNF given the vnf-id.
+     *
+     * @param vnfId The vnf-id
+     * @return generic Vnf
+     */
+    public GenericVnf getGenericVnfByVnfId(String vnfId) {
+        List<GenericVnf> genericVnfList = this.getGenericVnfs();
+
+        for (GenericVnf genVnf : genericVnfList) {
+            if (vnfId.equals(genVnf.getVnfId())) {
+                return genVnf;
+            }
+        }
+
+        return null;
+    }
+
     /**
      * Get the generic vnf associated with the vserver in the custom query.
      *
index 8a3d6a8..27afb7b 100644 (file)
@@ -68,6 +68,7 @@ public class AaiSimulatorJaxRs {
     @Produces("application/json")
     public String aaiGetVserverQuery(@QueryParam("filter") final String filter) {
         if (filter.equals("vserver-name:EQUALS:f953c499-4b1e-426b-8c6d-e9e9f1fc730f")
+            || filter.equals("vserver-name:EQUALS:Ete_vFWCLvFWSNK_7ba1fbde_0")
             || filter.equals("vserver-name:EQUALS:OzVServer")
             || filter.equals("vserver-name:EQUALS:testVserverName")) {
             return "{\"result-data\":[{\"resource-type\": \"vserver\",\"resource-link\":\"/aai/v15/"
index e8d2f7d..d5d93e0 100644 (file)
@@ -56,7 +56,7 @@ public class AaiSimulatorTest {
     @Test
     public void testCqGet() {
         final AaiCqResponse response = new AaiManager(new RestManager()).getCustomQueryResponse("http://localhost:6666",
-                "testUser", "testPass", UUID.randomUUID(), "f953c499-4b1e-426b-8c6d-e9e9f1fc730f");
+                "testUser", "testPass", UUID.randomUUID(), "Ete_vFWCLvFWSNK_7ba1fbde_0");
         assertNotNull(response);
         assertEquals("f953c499-4b1e-426b-8c6d-e9e9f1fc730f", response.getVserver().getVserverId());
     }