Adding AAI ESR endpoints
[integration/csit.git] / plans / so / integration-etsi-testing / so-simulators / aai-simulator / src / test / java / org / onap / so / aaisimulator / controller / GenericVnfsControllerTest.java
index 1acd1f2..4b9cad3 100644 (file)
@@ -46,6 +46,7 @@ import java.util.Optional;
 import org.junit.After;
 import org.junit.Test;
 import org.onap.aai.domain.yang.GenericVnf;
+import org.onap.aai.domain.yang.GenericVnfs;
 import org.onap.aai.domain.yang.RelatedToProperty;
 import org.onap.aai.domain.yang.Relationship;
 import org.onap.aai.domain.yang.RelationshipData;
@@ -364,6 +365,28 @@ public class GenericVnfsControllerTest extends AbstractSpringBootTest {
 
     }
 
+    @Test
+    public void test_getGenericVnfs_usingSelfLink_getAllGenericVnfsInCache() throws Exception {
+
+        addCustomerServiceAndGenericVnf();
+
+        final String selfLink = "http://localhost:9921/generic-vnf/" + VNF_ID;
+        final String url = getUrl(Constants.GENERIC_VNFS_URL) + "?selflink=" + selfLink;
+        final ResponseEntity<GenericVnfs> response = testRestTemplateService.invokeHttpGet(url, GenericVnfs.class);
+        assertEquals(HttpStatus.OK, response.getStatusCode());
+
+        assertTrue(response.hasBody());
+
+        final GenericVnfs actualGenericVnfs = response.getBody();
+        final List<GenericVnf> genericVnfList = actualGenericVnfs.getGenericVnf();
+        assertNotNull(genericVnfList);
+        assertEquals(1, genericVnfList.size());
+        final GenericVnf actualGenericVnf = genericVnfList.get(0);
+        assertEquals(selfLink, actualGenericVnf.getSelflink());
+        assertEquals(GENERIC_VNF_NAME, actualGenericVnf.getVnfName());
+        assertEquals(VNF_ID, actualGenericVnf.getVnfId());
+    }
+
     private void addCustomerServiceAndGenericVnf() throws Exception, IOException {
         final ResponseEntity<Void> customerResponse =
                 testRestTemplateService.invokeHttpPut(getUrl(CUSTOMERS_URL), TestUtils.getCustomer(), Void.class);