Search in sources :

Example 1 with TagArticleRepository

use of org.b3log.solo.repository.TagArticleRepository in project solo by b3log.

the class TagArticleRepositoryImplTestCase method add.

/**
     * Add.
     *
     * @throws Exception exception
     */
@Test
public void add() throws Exception {
    final TagArticleRepository tagArticleRepository = getTagArticleRepository();
    final JSONObject tagArticle = new JSONObject();
    tagArticle.put(Article.ARTICLE + "_" + Keys.OBJECT_ID, "article1 id");
    tagArticle.put(Tag.TAG + "_" + Keys.OBJECT_ID, "tag1 id");
    final Transaction transaction = tagArticleRepository.beginTransaction();
    tagArticleRepository.add(tagArticle);
    transaction.commit();
}
Also used : TagArticleRepository(org.b3log.solo.repository.TagArticleRepository) JSONObject(org.json.JSONObject) Transaction(org.b3log.latke.repository.Transaction) Test(org.testng.annotations.Test)

Example 2 with TagArticleRepository

use of org.b3log.solo.repository.TagArticleRepository in project solo by b3log.

the class TagRepositoryImplTestCase method addTagArticle.

private void addTagArticle() throws Exception {
    final TagArticleRepository tagArticleRepository = getTagArticleRepository();
    final JSONObject tagArticle = new JSONObject();
    tagArticle.put(Article.ARTICLE + "_" + Keys.OBJECT_ID, "article1 id");
    tagArticle.put(Tag.TAG + "_" + Keys.OBJECT_ID, "tag1 id");
    final Transaction transaction = tagArticleRepository.beginTransaction();
    tagArticleRepository.add(tagArticle);
    transaction.commit();
}
Also used : TagArticleRepository(org.b3log.solo.repository.TagArticleRepository) JSONObject(org.json.JSONObject) Transaction(org.b3log.latke.repository.Transaction)

Example 3 with TagArticleRepository

use of org.b3log.solo.repository.TagArticleRepository in project solo by b3log.

the class TagArticleRepositoryImplTestCase method getByTagId.

/**
     * Get By TagId.
     *
     * @throws Exception exception
     */
@Test(dependsOnMethods = "add")
public void getByTagId() throws Exception {
    final TagArticleRepository tagArticleRepository = getTagArticleRepository();
    final JSONArray results = tagArticleRepository.getByTagId("tag1 id", 1, Integer.MAX_VALUE).getJSONArray(Keys.RESULTS);
    Assert.assertEquals(1, results.length());
}
Also used : TagArticleRepository(org.b3log.solo.repository.TagArticleRepository) JSONArray(org.json.JSONArray) Test(org.testng.annotations.Test)

Example 4 with TagArticleRepository

use of org.b3log.solo.repository.TagArticleRepository in project solo by b3log.

the class TagArticleRepositoryImplTestCase method getByArticleId.

/**
     * Get By ArticleId.
     *
     * @throws Exception exception
     */
@Test(dependsOnMethods = "add")
public void getByArticleId() throws Exception {
    final TagArticleRepository tagArticleRepository = getTagArticleRepository();
    final List<JSONObject> tagArticle = tagArticleRepository.getByArticleId("article1 id");
    Assert.assertNotNull(tagArticle);
    Assert.assertEquals(0, tagArticleRepository.getByArticleId("").size());
}
Also used : TagArticleRepository(org.b3log.solo.repository.TagArticleRepository) JSONObject(org.json.JSONObject) Test(org.testng.annotations.Test)

Aggregations

TagArticleRepository (org.b3log.solo.repository.TagArticleRepository)4 JSONObject (org.json.JSONObject)3 Test (org.testng.annotations.Test)3 Transaction (org.b3log.latke.repository.Transaction)2 JSONArray (org.json.JSONArray)1