Search in sources :

Example 6 with ResourceList

use of io.crnk.core.resource.list.ResourceList in project crnk-framework by crnk-project.

the class BasicProxyFactoryTest method testCollectionProxy.

@Test
public void testCollectionProxy() {
    Collection<Task> col = factory.createCollectionProxy(Task.class, ResourceList.class, "http://127.0.0.1:99999");
    Assert.assertTrue(col instanceof ResourceList);
    Assert.assertTrue(col instanceof ObjectProxy);
    ObjectProxy proxy = (ObjectProxy) col;
    Assert.assertFalse(proxy.isLoaded());
    Assert.assertEquals("http://127.0.0.1:99999", proxy.getUrl());
}
Also used : Task(io.crnk.test.mock.models.Task) DefaultResourceList(io.crnk.core.resource.list.DefaultResourceList) ResourceList(io.crnk.core.resource.list.ResourceList) ObjectProxy(io.crnk.client.internal.proxy.ObjectProxy) Test(org.junit.Test)

Example 7 with ResourceList

use of io.crnk.core.resource.list.ResourceList in project crnk-framework by crnk-project.

the class OffsetLimitPagingBehaviorTest method testBuild.

@Test
public void testBuild() {
    PagingBehavior pagingBehavior = new OffsetLimitPagingBehavior();
    OffsetLimitPagingSpec pagingSpec = new OffsetLimitPagingSpec(0L, 10L);
    ModuleRegistry moduleRegistry = new ModuleRegistry();
    ResourceRegistry resourceRegistry = new ResourceRegistryImpl(new DefaultResourceRegistryPart(), moduleRegistry);
    QuerySpec spec = new QuerySpec(Task.class);
    QuerySpecAdapter querySpecAdapter = new QuerySpecAdapter(spec, resourceRegistry);
    querySpecAdapter.setPagingSpec(pagingSpec);
    PagingSpecUrlBuilder urlBuilder = mock(PagingSpecUrlBuilder.class);
    when(urlBuilder.build(any(QuerySpecAdapter.class))).thenReturn("http://some.org");
    DefaultPagedMetaInformation pagedMetaInformation = new DefaultPagedMetaInformation();
    pagedMetaInformation.setTotalResourceCount(30L);
    ResourceList resourceList = new DefaultResourceList(pagedMetaInformation, null);
    for (int i = 0; i < 30; i++) {
        resourceList.add(new Task());
    }
    PagedLinksInformation pagedLinksInformation = new DefaultPagedLinksInformation();
    pagingBehavior.build(pagedLinksInformation, resourceList, querySpecAdapter, urlBuilder);
    assertThat(pagedLinksInformation.getFirst(), equalTo("http://some.org"));
    assertThat(pagedLinksInformation.getNext(), equalTo("http://some.org"));
    assertNull(pagedLinksInformation.getPrev());
    assertThat(pagedLinksInformation.getLast(), equalTo("http://some.org"));
}
Also used : Task(io.crnk.core.mock.models.Task) DefaultPagedLinksInformation(io.crnk.core.resource.links.DefaultPagedLinksInformation) ModuleRegistry(io.crnk.core.module.ModuleRegistry) ResourceRegistryImpl(io.crnk.core.engine.internal.registry.ResourceRegistryImpl) ResourceRegistry(io.crnk.core.engine.registry.ResourceRegistry) QuerySpecAdapter(io.crnk.core.queryspec.internal.QuerySpecAdapter) DefaultPagedMetaInformation(io.crnk.core.resource.meta.DefaultPagedMetaInformation) ResourceList(io.crnk.core.resource.list.ResourceList) DefaultResourceList(io.crnk.core.resource.list.DefaultResourceList) DefaultResourceList(io.crnk.core.resource.list.DefaultResourceList) DefaultPagedLinksInformation(io.crnk.core.resource.links.DefaultPagedLinksInformation) PagedLinksInformation(io.crnk.core.resource.links.PagedLinksInformation) DefaultResourceRegistryPart(io.crnk.core.engine.registry.DefaultResourceRegistryPart) QuerySpec(io.crnk.core.queryspec.QuerySpec) Test(org.junit.Test)

Aggregations

ResourceList (io.crnk.core.resource.list.ResourceList)7 DefaultResourceList (io.crnk.core.resource.list.DefaultResourceList)5 QuerySpec (io.crnk.core.queryspec.QuerySpec)3 DefaultPagedLinksInformation (io.crnk.core.resource.links.DefaultPagedLinksInformation)3 PagedLinksInformation (io.crnk.core.resource.links.PagedLinksInformation)3 RegistryEntry (io.crnk.core.engine.registry.RegistryEntry)2 FilterSpec (io.crnk.core.queryspec.FilterSpec)2 QuerySpecAdapter (io.crnk.core.queryspec.internal.QuerySpecAdapter)2 ResourceRepositoryV2 (io.crnk.core.repository.ResourceRepositoryV2)2 LinksInformation (io.crnk.core.resource.links.LinksInformation)2 Test (org.junit.Test)2 ObjectProxy (io.crnk.client.internal.proxy.ObjectProxy)1 ResourceRegistryImpl (io.crnk.core.engine.internal.registry.ResourceRegistryImpl)1 QueryAdapter (io.crnk.core.engine.query.QueryAdapter)1 DefaultResourceRegistryPart (io.crnk.core.engine.registry.DefaultResourceRegistryPart)1 ResourceRegistry (io.crnk.core.engine.registry.ResourceRegistry)1 Task (io.crnk.core.mock.models.Task)1 ModuleRegistry (io.crnk.core.module.ModuleRegistry)1 LinksRepositoryV2 (io.crnk.core.repository.LinksRepositoryV2)1 DefaultPagedMetaInformation (io.crnk.core.resource.meta.DefaultPagedMetaInformation)1