Search in sources :

Example 61 with JSONObject

use of org.json.JSONObject in project solo by b3log.

the class ArticleQueryServiceTestCase method getArticle.

/**
     * Get Article.
     * 
     * @throws Exception exception
     */
@Test(dependsOnMethods = "getRecentArticles")
public void getArticle() throws Exception {
    final ArticleQueryService articleQueryService = getArticleQueryService();
    final List<JSONObject> articles = articleQueryService.getRecentArticles(10);
    Assert.assertEquals(articles.size(), 1);
    final String articleId = articles.get(0).getString(Keys.OBJECT_ID);
    final JSONObject article = articleQueryService.getArticle(articleId);
    Assert.assertNotNull(article);
    Assert.assertEquals(article.optString(Article.ARTICLE_VIEW_COUNT), "");
}
Also used : JSONObject(org.json.JSONObject) Test(org.testng.annotations.Test)

Example 62 with JSONObject

use of org.json.JSONObject in project solo by b3log.

the class CommentMgmtServiceTestCase method addPage.

/**
     * Adds a page.
     * 
     * @throws Exception exception
     */
private void addPage() throws Exception {
    final PageMgmtService pageMgmtService = getPageMgmtService();
    final JSONObject requestJSONObject = new JSONObject();
    final JSONObject page = new JSONObject();
    requestJSONObject.put(Page.PAGE, page);
    page.put(Page.PAGE_CONTENT, "page1 content");
    page.put(Page.PAGE_PERMALINK, "page1 permalink");
    page.put(Page.PAGE_TITLE, "page1 title");
    page.put(Page.PAGE_COMMENTABLE, true);
    page.put(Page.PAGE_TYPE, "page");
    page.put(Page.PAGE_OPEN_TARGET, "_self");
    final String pageId = pageMgmtService.addPage(requestJSONObject);
    Assert.assertNotNull(pageId);
}
Also used : JSONObject(org.json.JSONObject)

Example 63 with JSONObject

use of org.json.JSONObject in project solo by b3log.

the class PreferenceQueryServiceTestCase method init.

/**
     * Init.
     *
     * @throws Exception exception
     */
@Test
public void init() throws Exception {
    final InitService initService = getInitService();
    final JSONObject requestJSONObject = new JSONObject();
    requestJSONObject.put(User.USER_EMAIL, "test@gmail.com");
    requestJSONObject.put(User.USER_NAME, "Admin");
    requestJSONObject.put(User.USER_PASSWORD, "pass");
    initService.init(requestJSONObject);
    final UserQueryService userQueryService = getUserQueryService();
    Assert.assertNotNull(userQueryService.getUserByEmail("test@gmail.com"));
}
Also used : JSONObject(org.json.JSONObject) Test(org.testng.annotations.Test)

Example 64 with JSONObject

use of org.json.JSONObject in project solo by b3log.

the class PreferenceQueryServiceTestCase method getPreference.

/**
     * Get Preference.
     *
     * @throws Exception exception
     */
@Test(dependsOnMethods = "init")
public void getPreference() throws Exception {
    final PreferenceQueryService preferenceQueryService = getPreferenceQueryService();
    final JSONObject preference = preferenceQueryService.getPreference();
    Assert.assertEquals(preference.getString(Option.ID_C_BLOG_TITLE), Option.DefaultPreference.DEFAULT_BLOG_TITLE);
}
Also used : JSONObject(org.json.JSONObject) Test(org.testng.annotations.Test)

Example 65 with JSONObject

use of org.json.JSONObject in project solo by b3log.

the class TagQueryServiceTestCase method getTagByTitle.

/**
     * Get Tag By Title.
     * 
     * @throws Exception exception
     */
@Test(dependsOnMethods = "init")
public void getTagByTitle() throws Exception {
    final TagQueryService tagQueryService = getTagQueryService();
    final JSONObject result = tagQueryService.getTagByTitle("Solo");
    Assert.assertNotNull(result);
    final JSONObject tag = result.getJSONObject(Tag.TAG);
    Assert.assertNotNull(tag);
    Assert.assertEquals(tag.getString(Tag.TAG_TITLE), "Solo");
}
Also used : JSONObject(org.json.JSONObject) Test(org.testng.annotations.Test)

Aggregations

JSONObject (org.json.JSONObject)4075 JSONException (org.json.JSONException)1601 JSONArray (org.json.JSONArray)1156 Test (org.junit.Test)526 IOException (java.io.IOException)456 ArrayList (java.util.ArrayList)402 HashMap (java.util.HashMap)290 Test (org.testng.annotations.Test)175 File (java.io.File)145 Date (java.util.Date)144 ServiceException (org.b3log.latke.service.ServiceException)125 Bundle (android.os.Bundle)109 VolleyError (com.android.volley.VolleyError)104 Map (java.util.Map)96 BufferedReader (java.io.BufferedReader)93 RequestProcessing (org.b3log.latke.servlet.annotation.RequestProcessing)92 InputStreamReader (java.io.InputStreamReader)90 List (java.util.List)85 Response (com.android.volley.Response)84 InputStream (java.io.InputStream)73