Wikipedia implements WikiConstants { protected long __getPageHibernateId(int pageID) { long hibernateID = -1; if (idMapPages.containsKey(pageID)) { return idMapPages.get(pageID); } Session session = this.__getHibernateSession(); session.beginTransaction(); Object retObjectPage = session.createQuery( "select page.id from Page as page where page.pageId = :pageId") .setParameter("pageId", pageID, IntegerType.INSTANCE) .uniqueResult(); session.getTransaction().commit(); if (retObjectPage != null) { hibernateID = (Long) retObjectPage; idMapPages.put(pageID, hibernateID); return hibernateID; } return hibernateID; } 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 testGetPageHibernateId() { long objectID = wiki.__getPageHibernateId(A_FAMOUS_PAGE_ID); assertTrue(objectID > 0); assertEquals(objectID, wiki.__getPageHibernateId(A_FAMOUS_PAGE_ID)); }
@Test public void testGetPageHibernateIdInvalid1() { long objectID = wiki.__getPageHibernateId(-42); assertEquals(-1, objectID); }
@Test public void testGetPageHibernateIdInvalid2() { long objectID = wiki.__getPageHibernateId(Integer.MAX_VALUE); assertEquals(-1, objectID); }