use of io.crnk.core.resource.list.DefaultResourceList in project crnk-framework by crnk-project.
the class InMemoryEvaluatorTest method testNextPageMetaInformationIsTrue.
@Test
public void testNextPageMetaInformationIsTrue() {
QuerySpec spec = new QuerySpec(Task.class);
DefaultResourceList<Task> results = new DefaultResourceList<>();
results.setMeta(new DefaultHasMoreResourcesMetaInformation());
spec.setLimit(2L);
spec.apply(tasks, results);
Assert.assertEquals(2, results.size());
HasMoreResourcesMetaInformation meta = results.getMeta(HasMoreResourcesMetaInformation.class);
Assert.assertTrue(meta.getHasMoreResources());
}
use of io.crnk.core.resource.list.DefaultResourceList in project crnk-framework by crnk-project.
the class InMemoryEvaluatorTest method testNextPageMetaInformationIsFalse.
@Test
public void testNextPageMetaInformationIsFalse() {
QuerySpec spec = new QuerySpec(Task.class);
DefaultResourceList<Task> results = new DefaultResourceList<>();
results.setMeta(new DefaultHasMoreResourcesMetaInformation());
spec.setLimit(5L);
spec.apply(tasks, results);
HasMoreResourcesMetaInformation meta = results.getMeta(HasMoreResourcesMetaInformation.class);
Assert.assertEquals(5, results.size());
Assert.assertFalse(meta.getHasMoreResources());
}
use of io.crnk.core.resource.list.DefaultResourceList in project crnk-framework by crnk-project.
the class ResponseRepositoryAdapter method doGetLinksInformation.
@SuppressWarnings({ "unchecked", "rawtypes" })
private LinksInformation doGetLinksInformation(Object repository, Iterable<?> resources, RepositoryRequestSpec requestSpec) {
if (resources instanceof ResourceList) {
ResourceList<?> resourceList = (ResourceList<?>) resources;
boolean createLinksInformation = resourceList instanceof DefaultResourceList;
LinksInformation newLinksInfo = enrichLinksInformation(resourceList.getLinks(), resources, requestSpec);
if (createLinksInformation) {
((DefaultResourceList) resources).setLinks(newLinksInfo);
}
return resourceList.getLinks();
}
LinksInformation linksInformation = null;
if (repository instanceof AnnotatedRepositoryAdapter) {
if (((AnnotatedRepositoryAdapter) repository).linksRepositoryAvailable()) {
linksInformation = ((LinksRepository) repository).getLinksInformation(resources, requestSpec.getQueryParams());
}
} else if (repository instanceof LinksRepositoryV2) {
linksInformation = ((LinksRepositoryV2) repository).getLinksInformation(resources, requestSpec.getResponseQuerySpec());
} else if (repository instanceof LinksRepository) {
linksInformation = ((LinksRepository) repository).getLinksInformation(resources, requestSpec.getQueryParams());
}
// everything deprecated anyway
return enrichLinksInformation(linksInformation, resources, requestSpec);
}
use of io.crnk.core.resource.list.DefaultResourceList in project crnk-framework by crnk-project.
the class RegistryEntry method toResources.
private ResourceList toResources(JsonApiResponse response) {
Collection elements = (Collection) toResource(response);
DefaultResourceList result = new DefaultResourceList();
result.addAll(elements);
result.setMeta(response.getMetaInformation());
result.setLinks(response.getLinksInformation());
return result;
}
use of io.crnk.core.resource.list.DefaultResourceList in project crnk-framework by crnk-project.
the class HistoryResourceRepository method findAll.
@Override
public ResourceList<History> findAll(Iterable<UUID> ids, QuerySpec querySpec) {
DefaultResourceList list = new DefaultResourceList();
for (UUID id : ids) {
History history = new History();
history.setId(id);
history.setName("test");
list.add(history);
}
return list;
}
Aggregations