class Page implements WikiConstants {

	public int getNumberOfCategories()
	{
		BigInteger nrOfCategories = new BigInteger("0");

		long id = __getId();
		Session session = wiki.__getHibernateSession();
		session.beginTransaction();
		Object returnValue = session
				.createNativeQuery("select count(pages) from page_categories where id = :pageid")
				.setParameter("pageid", id, LongType.INSTANCE).uniqueResult();
		session.getTransaction().commit();

		if (returnValue != null) {
			nrOfCategories = (BigInteger) returnValue;
		}
		return nrOfCategories.intValue();
	}

}

class PageTest  {

	private static final Logger logger;
	private static final String A_FAMOUS_PAGE;
	private static final int A_FAMOUS_PAGE_ID;
	private static final long A_FAMOUS_PAGE_OBJECT_ID;
	private Page page;

	@Test
	public void testGetNumberOfCategories() {

		int categories = page.getNumberOfCategories();
		assertTrue(categories > 0);
		assertEquals(2, categories);
	}

}