Search in sources :

Example 6 with OffsetLimitPagingSpec

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);
}
Also used : Serializable(java.io.Serializable) RepositoryRequestSpec(io.crnk.core.engine.dispatcher.RepositoryRequestSpec) OffsetLimitPagingSpec(io.crnk.core.queryspec.pagingspec.OffsetLimitPagingSpec) QuerySpecAdapter(io.crnk.core.queryspec.internal.QuerySpecAdapter) RegistryEntry(io.crnk.core.engine.registry.RegistryEntry) Schedule(io.crnk.core.mock.models.Schedule) QuerySpec(io.crnk.core.queryspec.QuerySpec) ResourceRegistryTest(io.crnk.core.resource.registry.ResourceRegistryTest) Test(org.junit.Test)

Example 7 with OffsetLimitPagingSpec

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;
}
Also used : OffsetLimitPagingSpec(io.crnk.core.queryspec.pagingspec.OffsetLimitPagingSpec)

Aggregations

OffsetLimitPagingSpec (io.crnk.core.queryspec.pagingspec.OffsetLimitPagingSpec)7 Test (org.junit.Test)4 RegistryEntry (io.crnk.core.engine.registry.RegistryEntry)3 QuerySpec (io.crnk.core.queryspec.QuerySpec)3 QuerySpecAdapter (io.crnk.core.queryspec.internal.QuerySpecAdapter)3 CrnkBoot (io.crnk.core.boot.CrnkBoot)1 RepositoryRequestSpec (io.crnk.core.engine.dispatcher.RepositoryRequestSpec)1 ResourceInformation (io.crnk.core.engine.information.resource.ResourceInformation)1 ResourceRepositoryInformationImpl (io.crnk.core.engine.internal.information.repository.ResourceRepositoryInformationImpl)1 ResourceRegistryImpl (io.crnk.core.engine.internal.registry.ResourceRegistryImpl)1 DefaultResourceRegistryPart (io.crnk.core.engine.registry.DefaultResourceRegistryPart)1 ResourceRegistry (io.crnk.core.engine.registry.ResourceRegistry)1 ConstantServiceUrlProvider (io.crnk.core.engine.url.ConstantServiceUrlProvider)1 Project (io.crnk.core.mock.models.Project)1 Schedule (io.crnk.core.mock.models.Schedule)1 User (io.crnk.core.mock.models.User)1 UserRepository (io.crnk.core.mock.repository.UserRepository)1 UserToProjectRepository (io.crnk.core.mock.repository.UserToProjectRepository)1 UserToTaskRepository (io.crnk.core.mock.repository.UserToTaskRepository)1 ModuleRegistry (io.crnk.core.module.ModuleRegistry)1