Search in sources :

Example 1 with CustomQuery

use of org.onap.aaiclient.client.aai.entities.CustomQuery in project so by onap.

the class AAIQueryClientTest method querySingleResourceTest.

@Test
public void querySingleResourceTest() throws IOException {
    doReturn(getJson("single-query-result.json")).when(aaiQueryClient).query(eq(Format.RESOURCE_AND_URL), any(CustomQuery.class));
    List<Complex> result = aaiQueryClient.querySingleResource(new CustomQuery(Arrays.asList(AAIUriFactory.createNodesUri(Types.COMPLEX.getFragment("test")))), Complex.class);
    assertEquals(2, result.size());
    assertEquals("complex-id-15100-jc689q2", result.get(1).getPhysicalLocationId());
}
Also used : CustomQuery(org.onap.aaiclient.client.aai.entities.CustomQuery) Complex(org.onap.aai.domain.yang.Complex) Test(org.junit.Test)

Example 2 with CustomQuery

use of org.onap.aaiclient.client.aai.entities.CustomQuery in project so by onap.

the class AAIRestClientImpl method getPhysicalServerByVnfId.

@Override
public List<Pserver> getPhysicalServerByVnfId(String vnfId) throws IOException {
    List<AAIResourceUri> startNodes = new ArrayList<>();
    startNodes.add(AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf(vnfId)));
    String jsonInput = new AAIQueryClient().query(Format.RESOURCE, new CustomQuery(startNodes, PSERVER_VNF_QUERY));
    return this.getListOfPservers(jsonInput);
}
Also used : CustomQuery(org.onap.aaiclient.client.aai.entities.CustomQuery) ArrayList(java.util.ArrayList) AAIResourceUri(org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri)

Example 3 with CustomQuery

use of org.onap.aaiclient.client.aai.entities.CustomQuery in project so by onap.

the class AAIQueryClientTest method querySingleTypeTest.

@Test
public void querySingleTypeTest() throws IOException {
    when(client.createClient(isA(AAIResourceUri.class))).thenReturn(restClient);
    when(restClient.put(any(Object.class), any(GenericType.class))).thenReturn(mapper.readValue(getJson("pathed-result.json"), new TypeReference<Results<Map<String, Object>>>() {
    }));
    List<Pathed> results = aaiQueryClient.queryPathed(new CustomQuery(Arrays.asList(AAIUriFactory.createNodesUri(Types.COMPLEX.getFragment("test")))));
    assertEquals(2, results.size());
    assertEquals("service-instance", results.get(1).getResourceType());
}
Also used : GenericType(javax.ws.rs.core.GenericType) Pathed(org.onap.aaiclient.client.graphinventory.entities.Pathed) CustomQuery(org.onap.aaiclient.client.aai.entities.CustomQuery) AAIResourceUri(org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri) TypeReference(com.fasterxml.jackson.core.type.TypeReference) Map(java.util.Map) Test(org.junit.Test)

Example 4 with CustomQuery

use of org.onap.aaiclient.client.aai.entities.CustomQuery in project so by onap.

the class AAIQueryClientTest method testQuery.

@Test
public void testQuery() {
    List<AAIResourceUri> uris = Arrays.asList(AAIUriFactory.createResourceUri(AAIObjectType.CUSTOM_QUERY));
    Format format = Format.SIMPLE;
    CustomQuery query = new CustomQuery(uris);
    doReturn(restClient).when(client).createClient(isA(AAIResourceUri.class));
    aaiQueryClient.query(format, query);
    verify(client, times(1)).createClient(AAIUriFactory.createResourceUri(AAIObjectType.CUSTOM_QUERY).format(format));
    verify(restClient, times(1)).put(query, String.class);
}
Also used : Format(org.onap.aaiclient.client.graphinventory.Format) CustomQuery(org.onap.aaiclient.client.aai.entities.CustomQuery) AAIResourceUri(org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri) Test(org.junit.Test)

Example 5 with CustomQuery

use of org.onap.aaiclient.client.aai.entities.CustomQuery in project so by onap.

the class AAIQueryClientTest method getResourceAndUrlTest.

@Test
public void getResourceAndUrlTest() throws IOException {
    doReturn(getJson("single-query-result.json")).when(aaiQueryClient).query(eq(Format.RESOURCE_AND_URL), any(CustomQuery.class));
    List<ResourceAndUrl<AAIResultWrapper>> result = aaiQueryClient.getResourceAndUrl(new CustomQuery(Arrays.asList(AAIUriFactory.createNodesUri(Types.COMPLEX.getFragment("test")))));
    assertEquals(2, result.size());
    assertEquals(1, result.get(1).getWrapper().getRelationships().get().getRelatedUris(Types.PSERVER).size());
}
Also used : CustomQuery(org.onap.aaiclient.client.aai.entities.CustomQuery) ResourceAndUrl(org.onap.aaiclient.client.graphinventory.entities.ResourceAndUrl) Test(org.junit.Test)

Aggregations

CustomQuery (org.onap.aaiclient.client.aai.entities.CustomQuery)5 Test (org.junit.Test)4 AAIResourceUri (org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri)3 TypeReference (com.fasterxml.jackson.core.type.TypeReference)1 ArrayList (java.util.ArrayList)1 Map (java.util.Map)1 GenericType (javax.ws.rs.core.GenericType)1 Complex (org.onap.aai.domain.yang.Complex)1 Format (org.onap.aaiclient.client.graphinventory.Format)1 Pathed (org.onap.aaiclient.client.graphinventory.entities.Pathed)1 ResourceAndUrl (org.onap.aaiclient.client.graphinventory.entities.ResourceAndUrl)1