Search in sources :

Example 41 with JSONObject

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

the class PreferenceQueryServiceTestCase method getReplyNotificationTemplate.

/**
     * Get Reply Notification Template.
     *
     * @throws Exception exception
     */
@Test(dependsOnMethods = "init")
public void getReplyNotificationTemplate() throws Exception {
    final PreferenceQueryService preferenceQueryService = getPreferenceQueryService();
    final JSONObject replyNotificationTemplate = preferenceQueryService.getReplyNotificationTemplate();
    Assert.assertEquals(replyNotificationTemplate.toString(), Option.DefaultPreference.DEFAULT_REPLY_NOTIFICATION_TEMPLATE);
}
Also used : JSONObject(org.json.JSONObject) Test(org.testng.annotations.Test)

Example 42 with JSONObject

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

the class CommentQueryServiceTestCase method getCommentsOnId.

/**
     * Get Comment on id.
     * 
     * @throws Exception exception
     */
@Test(dependsOnMethods = "init")
public void getCommentsOnId() throws Exception {
    final ArticleQueryService articleQueryService = getArticleQueryService();
    final JSONObject result = articleQueryService.getArticles(Requests.buildPaginationRequest("1/10/20"));
    Assert.assertNotNull(result);
    Assert.assertEquals(result.getJSONArray(Article.ARTICLES).length(), 1);
    final JSONObject article = result.getJSONArray(Article.ARTICLES).getJSONObject(0);
    final String articleId = article.getString(Keys.OBJECT_ID);
    final CommentQueryService commentQueryService = getCommentQueryService();
    final List<JSONObject> comments = commentQueryService.getComments(articleId);
    Assert.assertNotNull(comments);
    Assert.assertEquals(comments.size(), 1);
}
Also used : JSONObject(org.json.JSONObject) Test(org.testng.annotations.Test)

Example 43 with JSONObject

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

the class CommentQueryServiceTestCase method getComments.

/**
     * Get Comments.
     * 
     * @throws Exception exception
     */
@Test(dependsOnMethods = "init")
public void getComments() throws Exception {
    final CommentQueryService commentQueryService = getCommentQueryService();
    final JSONObject paginationRequest = Requests.buildPaginationRequest("1/10/20");
    final JSONObject result = commentQueryService.getComments(paginationRequest);
    Assert.assertNotNull(result);
    Assert.assertEquals(result.getJSONArray(Comment.COMMENTS).length(), 1);
}
Also used : JSONObject(org.json.JSONObject) Test(org.testng.annotations.Test)

Example 44 with JSONObject

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

the class InitServiceTestCase 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@b3log.org");
    requestJSONObject.put(User.USER_NAME, "Admin");
    requestJSONObject.put(User.USER_PASSWORD, "pass");
    initService.init(requestJSONObject);
    final UserQueryService userQueryService = getUserQueryService();
    Assert.assertNotNull(userQueryService.getUserByEmail("test@b3log.org"));
}
Also used : JSONObject(org.json.JSONObject)

Example 45 with JSONObject

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

the class LinkMgmtServiceTestCase method removeLink.

/**
     * Remove Link.
     * 
     * @throws Exception exception
     */
@Test(dependsOnMethods = "init")
public void removeLink() throws Exception {
    final LinkMgmtService linkMgmtService = getLinkMgmtService();
    final JSONObject requestJSONObject = new JSONObject();
    final JSONObject link = new JSONObject();
    requestJSONObject.put(Link.LINK, link);
    link.put(Link.LINK_TITLE, "link2 title");
    link.put(Link.LINK_ADDRESS, "link2 address");
    link.put(Link.LINK_DESCRIPTION, "link2 description");
    final String linkId = linkMgmtService.addLink(requestJSONObject);
    Assert.assertNotNull(linkId);
    final LinkQueryService linkQueryService = getLinkQueryService();
    JSONObject result = linkQueryService.getLink(linkId);
    Assert.assertNotNull(result);
    Assert.assertEquals(result.getJSONObject(Link.LINK).getString(Link.LINK_TITLE), "link2 title");
    linkMgmtService.removeLink(linkId);
    result = linkQueryService.getLink(linkId);
    Assert.assertNull(result);
}
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