use of io.crnk.core.queryspec.pagingspec.OffsetLimitPagingSpec in project crnk-framework by crnk-project.
the class RepositoryFilterTest method findAllWithResourceListResult.
@SuppressWarnings({ "rawtypes", "unchecked" })
@Test
public void findAllWithResourceListResult() throws Exception {
RegistryEntry scheduleRegistry = resourceRegistry.getEntry(Schedule.class);
ResourceRepositoryAdapter<Schedule, Serializable> scheduleResourceAdapter = scheduleRegistry.getResourceRepository(null);
querySpec = new QuerySpec(Schedule.class);
querySpec.setPagingSpec(new OffsetLimitPagingSpec());
queryAdapter = new QuerySpecAdapter(querySpec, resourceRegistry);
scheduleResourceAdapter.findAll(queryAdapter);
ArgumentCaptor<Iterable> linksResources = ArgumentCaptor.forClass(Iterable.class);
ArgumentCaptor<Iterable> metaResources = ArgumentCaptor.forClass(Iterable.class);
ArgumentCaptor<RepositoryFilterContext> contexts = ArgumentCaptor.forClass(RepositoryFilterContext.class);
Mockito.verify(filter, Mockito.times(1)).filterRequest(contexts.capture(), Mockito.any(RepositoryRequestFilterChain.class));
Mockito.verify(filter, Mockito.times(1)).filterResult(Mockito.any(RepositoryFilterContext.class), Mockito.any(RepositoryResultFilterChain.class));
Mockito.verify(filter, Mockito.times(1)).filterLinks(Mockito.any(RepositoryFilterContext.class), linksResources.capture(), Mockito.any(RepositoryLinksFilterChain.class));
Mockito.verify(filter, Mockito.times(1)).filterMeta(Mockito.any(RepositoryFilterContext.class), metaResources.capture(), Mockito.any(RepositoryMetaFilterChain.class));
Assert.assertEquals(1, linksResources.getAllValues().size());
Assert.assertEquals(1, metaResources.getAllValues().size());
Assert.assertEquals(1, contexts.getAllValues().size());
RepositoryFilterContext context = contexts.getAllValues().iterator().next();
RepositoryRequestSpec requestSpec = context.getRequest();
Assert.assertEquals(queryAdapter, requestSpec.getQueryAdapter());
Assert.assertNull(requestSpec.getId());
Assert.assertNull(requestSpec.getIds());
QuerySpec actualQuerySpec = requestSpec.getQuerySpec(scheduleInfo);
Assert.assertSame(querySpec, actualQuerySpec);
}
use of io.crnk.core.queryspec.pagingspec.OffsetLimitPagingSpec in project crnk-framework by crnk-project.
the class AbstractQuerySpecTest method querySpec.
protected QuerySpec querySpec(Long offset, Long limit) {
QuerySpec querySpec = new QuerySpec(Task.class);
querySpec.setPagingSpec(new OffsetLimitPagingSpec(offset, limit));
return querySpec;
}
Aggregations