use of org.onap.aaiclient.client.graphinventory.entities.ResourceAndUrl in project so by onap.
the class GraphInventoryQueryClient method getResourceAndUrl.
public List<ResourceAndUrl<Wrapper>> getResourceAndUrl(I query) throws IOException {
List<ResourceAndUrl<Wrapper>> result = new ArrayList<>();
ObjectMapper mapper = mapperProvider.getMapper();
Results<Map<String, Object>> resultsFromJson = mapper.readValue(query(Format.RESOURCE_AND_URL, query), new TypeReference<Results<Map<String, Object>>>() {
});
for (Map<String, Object> m : resultsFromJson.getResult()) {
for (Entry<String, Object> entrySet : m.entrySet()) {
if (!entrySet.getKey().equals("url")) {
String url = (String) m.get("url");
String stringJson = mapper.writeValueAsString(entrySet.getValue());
result.add(new ResourceAndUrl<Wrapper>(url, createType(entrySet.getKey(), url), createWrapper(stringJson)));
}
}
}
return result;
}
use of org.onap.aaiclient.client.graphinventory.entities.ResourceAndUrl 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