Wikipedia implements WikiConstants { public Set<Page> getPages(String title) throws WikiApiException { Set<Integer> ids = new HashSet<Integer>(getPageIdsCaseInsensitive(title)); Set<Page> pages = new HashSet<Page>(); for (Integer id : ids) { pages.add(new Page(this, id)); } return pages; } Wikipedia(DatabaseConfiguration dbConfig); Page getPage(String title); Page getPageByExactTitle(String exactTitle); Set<Page> getPages(String title); Page getPage(int pageId); Title getTitle(int pageId); List<Integer> getPageIds(String title); List<Integer> getPageIdsCaseInsensitive(String title); Page getArticleForDiscussionPage(Page discussionPage); Page getDiscussionPage(int articlePageId); Page getDiscussionPage(String title); Page getDiscussionPage(Page articlePage); Iterable<Page> getDiscussionArchives(int articlePageId); Iterable<Page> getDiscussionArchives(String title); Iterable<Page> getDiscussionArchives(Page articlePage); Category getCategory(String title); Category getCategory(int pageId); Iterable<Category> getCategories(); Set<Category> getCategories(String pageTitle); Iterable<Page> getPages(); Iterable<Integer> getPageIds(); Iterable<Page> getPages(PageQuery query); Iterable<Page> getArticles(); Iterable<Title> getTitles(); Language getLanguage(); boolean existsPage(String title); boolean existsPage(int pageID); MetaData getMetaData(); DatabaseConfiguration getDatabaseConfiguration(); String getWikipediaId();  }
@Test public void testGetPagesByPageQuery() { try { PageQuery query = new PageQuery(); query.setTitlePattern(A_FAMOUS_PAGE+"%"); Iterable<Page> iterable = wiki.getPages(query); assertNotNull(iterable); Page page = iterable.iterator().next(); assertEquals(A_FAMOUS_PAGE_ID, page.getPageId()); query.setOnlyArticlePages(true); iterable = wiki.getPages(query); assertNotNull(iterable); page = iterable.iterator().next(); assertEquals(A_FAMOUS_PAGE_ID, page.getPageId()); query.setOnlyArticlePages(false); query.setOnlyDisambiguationPages(true); iterable = wiki.getPages(query); assertNotNull(iterable); assertFalse(iterable.iterator().hasNext()); query.setTitlePattern(A_FAMOUS_PAGE+"_"); iterable = wiki.getPages(query); assertNotNull(iterable); assertFalse(iterable.iterator().hasNext()); } catch (WikiApiException e) { fail("Encountered WikiApiException: " + e.getLocalizedMessage()); } }
@Test public void testGetPagesByTitle() { try { Set<Page> pages = wiki.getPages(A_FAMOUS_PAGE); assertNotNull(pages); assertEquals(1, pages.size()); assertEquals(A_FAMOUS_PAGE_ID, pages.iterator().next().getPageId()); } catch (WikiApiException e) { logger.error(e.getLocalizedMessage(), e); fail("Encountered WikiApiException: " + e.getLocalizedMessage()); } }