*
* @throws Exception exception
*/
@Test(dependsOnMethods = {"add", "getMaxOrder"})
public void getUnderAndUpper() throws Exception {
final PageRepository pageRepository = getPageRepository();
final JSONObject page = new JSONObject();
page.put(Page.PAGE_COMMENT_COUNT, 0);
page.put(Page.PAGE_CONTENT, "page3 content");
page.put(Page.PAGE_ORDER, 2);
page.put(Page.PAGE_PERMALINK, "page3 permalink");
page.put(Page.PAGE_TITLE, "page3 title");
page.put(Page.PAGE_COMMENTABLE, true);
page.put(Page.PAGE_TYPE, "page");
page.put(Page.PAGE_OPEN_TARGET, "_self");
page.put(Page.PAGE_EDITOR_TYPE, "");
final Transaction transaction = pageRepository.beginTransaction();
pageRepository.add(page);
transaction.commit();
final JSONObject page2 =
pageRepository.getByPermalink("page2 permalink");
Assert.assertNotNull(page2);
final JSONObject page1 =
pageRepository.getUpper(page2.getString(Keys.OBJECT_ID));
Assert.assertNotNull(page1);
final JSONObject page3 =
pageRepository.getUnder(page2.getString(Keys.OBJECT_ID));
Assert.assertNotNull(page3);
final JSONObject notFound =
pageRepository.getUpper(page1.getString(Keys.OBJECT_ID));
Assert.assertNull(notFound);
Assert.assertNull(pageRepository.getUpper("not found"));
Assert.assertNull(pageRepository.getUnder("not found"));
}