当前位置: 首页>>代码示例>>Java>>正文


Java ReadFilter.setLimit方法代码示例

本文整理汇总了Java中org.jboss.aerogear.android.core.ReadFilter.setLimit方法的典型用法代码示例。如果您正苦于以下问题:Java ReadFilter.setLimit方法的具体用法?Java ReadFilter.setLimit怎么用?Java ReadFilter.setLimit使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.jboss.aerogear.android.core.ReadFilter的用法示例。


在下文中一共展示了ReadFilter.setLimit方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testReadWithFilterPerPage

import org.jboss.aerogear.android.core.ReadFilter; //导入方法依赖的package包/类
@Test
public void testReadWithFilterPerPage() {
    store.save(new Data("foo", "desc of foo"));
    store.save(new Data("bar", "desc of bar"));

    ReadFilter filter = new ReadFilter();
    filter.setLimit(1);

    Collection<Data> datas = store.readWithFilter(filter);
    Assert.assertNotNull("datas could not be null", datas);
    Assert.assertEquals("datas should 1 data", 1, datas.size());
    Assert.assertEquals("foo", datas.iterator().next().getName());

    filter.setOffset(1);
    datas = store.readWithFilter(filter);
    Assert.assertEquals("bar", datas.iterator().next().getName());
}
 
开发者ID:aerogear,项目名称:aerogear-android-store,代码行数:18,代码来源:MemoryStoreTest.java

示例2: testLinkPagingReturnsData

import org.jboss.aerogear.android.core.ReadFilter; //导入方法依赖的package包/类
/**
 * This test tests the default paging configuration.
 *
 * @throws NoSuchFieldException If this is thrown then the test is
 * broken.
 * @throws IllegalAccessException If this is thrown then the test
 * is broken.
 * @throws InterruptedException If this is thrown then the test is
 * broken.
 */
@Test
public void testLinkPagingReturnsData() throws NoSuchFieldException, IllegalArgumentException, IllegalAccessException, InterruptedException {

    final HttpStubProvider provider = new HttpStubProvider(url, new HeaderAndBody(SERIALIZED_POINTS.getBytes(), new HashMap<String, Object>()));

    PageConfig pageConfig = new PageConfig();
    GsonBuilder builder = new GsonBuilder().registerTypeAdapter(Point.class, new PointTypeAdapter());

    RestfulPipeConfiguration pipeConfig = PipeManager.config("listClassId", RestfulPipeConfiguration.class).withUrl(url);
    pipeConfig.requestBuilder(new GsonRequestBuilder(builder.create()));
    pipeConfig.pageConfig(pageConfig);

    Pipe<ListClassId> dataPipe = pipeConfig.forClass(ListClassId.class);
    Object restRunner = UnitTestUtils.getPrivateField(dataPipe, "restRunner");

    UnitTestUtils.setPrivateField(restRunner, "httpProviderFactory", new Provider<HttpProvider>() {
        @Override
        public HttpProvider get(Object... in) {
            return provider;
        }
    });

    ReadFilter onePageFilter = new ReadFilter();

    onePageFilter.setLimit(1);
    runRead(dataPipe, onePageFilter);
    List<ListClassId> result = runRead(dataPipe, onePageFilter);

    assertNotNull(result);
    assertFalse(result instanceof PagedList);

}
 
开发者ID:aerogear,项目名称:aerogear-android-pipe,代码行数:43,代码来源:RestAdapterTest.java

示例3: testDefaultPaging

import org.jboss.aerogear.android.core.ReadFilter; //导入方法依赖的package包/类
/**
 * This test tests the default paging configuration.
 *
 *
 * @throws InterruptedException this should not be thrown
 * @throws URISyntaxException this should not be thrown
 * @throws NoSuchFieldException this should not be thrown
 * @throws IllegalAccessException this should not be thrown
 */
@Test
public void testDefaultPaging() throws InterruptedException, NoSuchFieldException, NoSuchFieldException, IllegalArgumentException, IllegalAccessException,
        URISyntaxException {

    PageConfig pageConfig = new PageConfig();
    GsonBuilder builder = new GsonBuilder().registerTypeAdapter(Point.class, new PointTypeAdapter());

    RestfulPipeConfiguration pipeConfig = PipeManager.config("listClassId", RestfulPipeConfiguration.class).withUrl(url);
    pipeConfig.requestBuilder(new GsonRequestBuilder(builder.create()));
    pipeConfig.pageConfig(pageConfig);

    Pipe<ListClassId> dataPipe = pipeConfig.forClass(ListClassId.class);
    Object restRunner = UnitTestUtils.getPrivateField(dataPipe, "restRunner");

    UnitTestUtils.setPrivateField(restRunner, "httpProviderFactory", new Provider<HttpProvider>() {
        @Override
        public HttpProvider get(Object... in) {
            HashMap<String, Object> headers = new HashMap<String, Object>(1);
            headers
                    .put(
                            "Link",
                            "<http://example.com/TheBook/chapter2>; rel=\"previous\";title=\"previous chapter\",<http://example.com/TheBook/chapter3>; rel=\"next\";title=\"next chapter\"");
            HttpStubProvider provider = new HttpStubProvider(url, new HeaderAndBody(SERIALIZED_POINTS.getBytes(), headers));

            return provider;
        }
    });

    ReadFilter onePageFilter = new ReadFilter();
    onePageFilter.setLimit(1);
    List<ListClassId> resultList = runRead(dataPipe, onePageFilter);
    assertTrue(resultList instanceof PagedList);
    WrappingPagedList<ListClassId> pagedList = (WrappingPagedList<ListClassId>) resultList;

    assertEquals(new URI("http://example.com/TheBook/chapter3"), pagedList.getNextFilter().getLinkUri());
    assertEquals(new URI("http://example.com/TheBook/chapter2"), pagedList.getPreviousFilter().getLinkUri());
}
 
开发者ID:aerogear,项目名称:aerogear-android-pipe,代码行数:47,代码来源:RestAdapterTest.java

示例4: testRunReadWithFilter

import org.jboss.aerogear.android.core.ReadFilter; //导入方法依赖的package包/类
@Test
public void testRunReadWithFilter() throws Exception {

    final CountDownLatch latch = new CountDownLatch(1);

    HttpProviderFactory factory = mock(HttpProviderFactory.class);
    when(factory.get(anyObject())).thenReturn(mock(HttpProvider.class));

    RestfulPipeConfiguration config = PipeManager.config("data", RestfulPipeConfiguration.class);

    Pipe<Data> pipe = config.withUrl(url)
            .forClass(Data.class);

    Object restRunner = UnitTestUtils.getPrivateField(pipe, "restRunner");

    UnitTestUtils.setPrivateField(restRunner, "httpProviderFactory",
            factory);

    ReadFilter filter = new ReadFilter();
    filter.setLimit(10);
    filter.setWhere(new JSONObject("{\"model\":\"BMW\"}"));

    LoaderAdapter<Data> adapter = (LoaderAdapter<Data>) PipeManager.getPipe("data", getActivity());

    adapter.read(filter, new Callback<List<Data>>() {
        private static final long serialVersionUID = 1L;

        @Override
        public void onSuccess(List<Data> data) {
            latch.countDown();
        }

        @Override
        public void onFailure(Exception e) {
            latch.countDown();
            Logger.getLogger(getClass().getSimpleName()).log(Level.SEVERE,
                    TAG, e);
        }
    });
    latch.await(60, TimeUnit.SECONDS);

    verify(factory).get(Mockito.argThat(new ObjectVarArgsMatcher(new URL("http://server.com/context?limit=10&model=BMW"), 60000)));

}
 
开发者ID:aerogear,项目名称:aerogear-android-pipe,代码行数:45,代码来源:LoaderAdapterTest.java

示例5: runReadWithFilter

import org.jboss.aerogear.android.core.ReadFilter; //导入方法依赖的package包/类
public void runReadWithFilter() throws Exception {

        final CountDownLatch latch = new CountDownLatch(1);

        HttpProviderFactory factory = mock(HttpProviderFactory.class);
        when(factory.get(anyObject())).thenReturn(mock(HttpProvider.class));

        ModuleFields authFields = new ModuleFields();

        PipeModule urlModule = mock(PipeModule.class);

        when(urlModule.loadModule((URI) anyObject(), (String) anyObject(), (byte[]) anyObject())).thenReturn(authFields);

        RestfulPipeConfiguration config = PipeManager.config("listClassId", RestfulPipeConfiguration.class).withUrl(url);
        config.module(urlModule);

        RestAdapter<Data> adapter = new RestAdapter<Data>(Data.class, url, config);
        Object restRunner = UnitTestUtils.getPrivateField(adapter, "restRunner");

        UnitTestUtils.setPrivateField(restRunner, "httpProviderFactory", factory);

        ReadFilter filter = new ReadFilter();
        filter.setLimit(10);
        filter.setWhere(new JSONObject("{\"model\":\"BMW\"}"));

        adapter.read(filter, new Callback<List<Data>>() {
            @Override
            public void onSuccess(List<Data> data) {
                latch.countDown();
            }

            @Override
            public void onFailure(Exception e) {
                latch.countDown();
                Logger.getLogger(getClass().getSimpleName()).log(Level.SEVERE, TAG, e);
            }
        });
        latch.await(500, TimeUnit.MILLISECONDS);

        verify(factory).get(new URL(url.toString() + "?limit=10&model=BMW"));
    }
 
开发者ID:aerogear,项目名称:aerogear-android-pipe,代码行数:42,代码来源:RestAdapterTest.java


注:本文中的org.jboss.aerogear.android.core.ReadFilter.setLimit方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。