use of org.b3log.latke.repository.Transaction in project solo by b3log.
the class PageRepositoryImplTestCase method getUnderAndUpper.
/**
* Get Under and Upper.
*
* @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"));
}
use of org.b3log.latke.repository.Transaction in project solo by b3log.
the class TagRepositoryImplTestCase method add.
/**
* Add.
*
* @throws Exception exception
*/
@Test
public void add() throws Exception {
final TagRepository tagRepository = getTagRepository();
final JSONObject tag = new JSONObject();
tag.put(Tag.TAG_TITLE, "tag title1");
tag.put(Tag.TAG_REFERENCE_COUNT, 1);
tag.put(Tag.TAG_PUBLISHED_REFERENCE_COUNT, 0);
final Transaction transaction = tagRepository.beginTransaction();
tagRepository.add(tag);
transaction.commit();
}
Aggregations