Search in sources :

Example 1 with ResourceAndUrl

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;
}
Also used : GraphInventoryResultWrapper(org.onap.aaiclient.client.graphinventory.entities.GraphInventoryResultWrapper) ResourceAndUrl(org.onap.aaiclient.client.graphinventory.entities.ResourceAndUrl) ArrayList(java.util.ArrayList) Results(org.onap.aaiclient.client.aai.entities.Results) Map(java.util.Map) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 2 with ResourceAndUrl

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());
}
Also used : CustomQuery(org.onap.aaiclient.client.aai.entities.CustomQuery) ResourceAndUrl(org.onap.aaiclient.client.graphinventory.entities.ResourceAndUrl) Test(org.junit.Test)

Aggregations

ResourceAndUrl (org.onap.aaiclient.client.graphinventory.entities.ResourceAndUrl)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 ArrayList (java.util.ArrayList)1 Map (java.util.Map)1 Test (org.junit.Test)1 CustomQuery (org.onap.aaiclient.client.aai.entities.CustomQuery)1 Results (org.onap.aaiclient.client.aai.entities.Results)1 GraphInventoryResultWrapper (org.onap.aaiclient.client.graphinventory.entities.GraphInventoryResultWrapper)1