@Test public void testFindUrisBySummary() { final Query queryResult = mock(Query.class); final Entry resultEntry1 = mock(Entry.class); final Entry resultEntry2 = mock(Entry.class); final String summary = "mySummary"; final String uri1 = "uri1"; final String uri2 = "uri2"; when(restTemplate.getForObject(Query.URI, Query.class, project.getId(), "queryables")).thenReturn(queryResult); when(queryResult.getEntries()).thenReturn(asList(resultEntry1, resultEntry2)); when(resultEntry1.getSummary()).thenReturn(summary); when(resultEntry2.getSummary()).thenReturn(summary); when(resultEntry1.getUri()).thenReturn(uri1); when(resultEntry2.getUri()).thenReturn(uri2); final Collection<String> results = service.findUris(project, Queryable.class, Restriction.summary(summary)); assertThat(results, allOf(hasItem(uri1), hasItem(uri2))); }
public <T extends Queryable> Collection<String> findUris(Project project, Class<T> cls, Restriction... restrictions) { final Collection<Entry> entries = find(project, cls, restrictions); final Collection<String> result = new ArrayList<>(entries.size()); result.addAll(entries.stream().map(Entry::getUri).collect(Collectors.toList())); return result; }
MetadataService extends AbstractService { public <T extends Queryable> Collection<String> findUris(Project project, Class<T> cls, Restriction... restrictions) { final Collection<Entry> entries = find(project, cls, restrictions); final Collection<String> result = new ArrayList<>(entries.size()); result.addAll(entries.stream().map(Entry::getUri).collect(Collectors.toList())); return result; } }
MetadataService extends AbstractService { public <T extends Queryable> Collection<String> findUris(Project project, Class<T> cls, Restriction... restrictions) { final Collection<Entry> entries = find(project, cls, restrictions); final Collection<String> result = new ArrayList<>(entries.size()); result.addAll(entries.stream().map(Entry::getUri).collect(Collectors.toList())); return result; } MetadataService(final RestTemplate restTemplate, final GoodDataSettings settings); }
MetadataService extends AbstractService { public <T extends Queryable> Collection<String> findUris(Project project, Class<T> cls, Restriction... restrictions) { final Collection<Entry> entries = find(project, cls, restrictions); final Collection<String> result = new ArrayList<>(entries.size()); result.addAll(entries.stream().map(Entry::getUri).collect(Collectors.toList())); return result; } MetadataService(final RestTemplate restTemplate, final GoodDataSettings settings); @SuppressWarnings("unchecked") T createObj(Project project, T obj); T getObjByUri(String uri, Class<T> cls); Collection<Obj> getObjsByUris(Project project, Collection<String> uris); @SuppressWarnings("unchecked") T updateObj(T obj); void removeObj(Obj obj); void removeObjByUri(String uri); T getObjById(Project project, String id, Class<T> cls); String getObjUri(Project project, Class<T> cls, Restriction... restrictions); T getObj(Project project, Class<T> cls, Restriction... restrictions); Collection<Entry> find(Project project, Class<T> cls, Restriction... restrictions); Collection<String> findUris(Project project,
                                                             Class<T> cls,
                                                             Restriction... restrictions); @SuppressWarnings("unchecked") Collection<Entry> usedBy(Project project, Obj obj, boolean nearest, Class<? extends Obj>... types); @SuppressWarnings("unchecked") Collection<Entry> usedBy(Project project, String uri, boolean nearest, Class<? extends Obj>... types); @SuppressWarnings("unchecked") Collection<Usage> usedBy(Project project, Collection<String> uris, boolean nearest, Class<? extends Obj>... types); Collection<String> findUris(Project project, Restriction... restrictions); Map<String, String> identifiersToUris(Project project, Collection<String> identifiers); List<AttributeElement> getAttributeElements(Attribute attribute); List<AttributeElement> getAttributeElements(DisplayForm displayForm); }
MetadataService extends AbstractService { public <T extends Queryable> Collection<String> findUris(Project project, Class<T> cls, Restriction... restrictions) { final Collection<Entry> entries = find(project, cls, restrictions); final Collection<String> result = new ArrayList<>(entries.size()); result.addAll(entries.stream().map(Entry::getUri).collect(Collectors.toList())); return result; } MetadataService(final RestTemplate restTemplate, final GoodDataSettings settings); @SuppressWarnings("unchecked") T createObj(Project project, T obj); T getObjByUri(String uri, Class<T> cls); Collection<Obj> getObjsByUris(Project project, Collection<String> uris); @SuppressWarnings("unchecked") T updateObj(T obj); void removeObj(Obj obj); void removeObjByUri(String uri); T getObjById(Project project, String id, Class<T> cls); String getObjUri(Project project, Class<T> cls, Restriction... restrictions); T getObj(Project project, Class<T> cls, Restriction... restrictions); Collection<Entry> find(Project project, Class<T> cls, Restriction... restrictions); Collection<String> findUris(Project project,
                                                             Class<T> cls,
                                                             Restriction... restrictions); @SuppressWarnings("unchecked") Collection<Entry> usedBy(Project project, Obj obj, boolean nearest, Class<? extends Obj>... types); @SuppressWarnings("unchecked") Collection<Entry> usedBy(Project project, String uri, boolean nearest, Class<? extends Obj>... types); @SuppressWarnings("unchecked") Collection<Usage> usedBy(Project project, Collection<String> uris, boolean nearest, Class<? extends Obj>... types); Collection<String> findUris(Project project, Restriction... restrictions); Map<String, String> identifiersToUris(Project project, Collection<String> identifiers); List<AttributeElement> getAttributeElements(Attribute attribute); List<AttributeElement> getAttributeElements(DisplayForm displayForm); static final UriTemplate OBJ_TEMPLATE; }