@Test public void testLoadPage_Quaggan_Remote() throws IOException { System.out.println("loadPage(Quaggan remote)"); // NOI18N. final int pageIndex = 1; final int pageSize = 10; final String[] urls = {"https://api.guildwars2.com/v2/quaggans"}; final Class[] classes = {Quaggan.class}; final JsonpContext instance = JsonpContext.SAX; assertEquals(urls.length, classes.length); IntStream.range(0, urls.length) .forEach( index -> { try { final String url = urls[index]; final Class aClass = classes[index]; final String path = String.format("%s?page=%d&page_size=%d", url, pageIndex, pageSize); System.out.println(path); final PageResult page = instance.loadPage(aClass, new URL(path)); assertNotNull(page); } catch (IOException ex) { fail(ex.getMessage()); } }); }
@Test public void testLoadPage_Integer_Local() throws IOException { System.out.println("loadPage(integer local)"); // NOI18N. final int expPageTotal = 1; final int expPageSize = 10; final int expResultCount = expPageSize; final int expResultTotal = expPageSize; final URL url = getClass().getResource("test_page1.json"); // NOI18N. final JsonpContext instance = JsonpContext.SAX; final PageResult<Integer> value = instance.loadPage(Integer.class, url); assertNotNull(value); assertEquals(expPageTotal, value.getPageTotal()); assertEquals(expPageSize, value.getPageSize()); assertEquals(expResultCount, value.getResultCount()); assertEquals(expResultTotal, value.getResultTotal()); final Iterator<Integer> iterator = value.iterator(); IntStream.range(0, expPageSize) .forEach( index -> { final int expResult = index; final int result = iterator.next(); assertEquals(expResult, result); }); }