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());
}
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);
}
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());
}
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);
}
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());
}
Aggregations