Search in sources :

Example 36 with JSONObject

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

the class PageMgmtServiceTestCase method addPage.

/**
     * Add Page.
     * 
     * @throws Exception exception
     */
@Test(dependsOnMethods = "init")
public 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) Test(org.testng.annotations.Test)

Example 37 with JSONObject

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

the class PageQueryServiceTestCase method addPage.

/**
     * Add Page.
     * 
     * @throws Exception exception
     */
@Test(dependsOnMethods = "init")
public 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) Test(org.testng.annotations.Test)

Example 38 with JSONObject

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

the class PageQueryServiceTestCase method getPages.

/**
     * Get Pages.
     * 
     * @throws Exception exception
     */
@Test(dependsOnMethods = "addPage")
public void getPages() throws Exception {
    final PageQueryService pageQueryService = getPageQueryService();
    final JSONObject paginationRequest = Requests.buildPaginationRequest("1/10/20");
    final JSONObject result = pageQueryService.getPages(paginationRequest);
    Assert.assertNotNull(result);
    Assert.assertEquals(result.getJSONArray(Page.PAGES).length(), 1);
}
Also used : JSONObject(org.json.JSONObject) Test(org.testng.annotations.Test)

Example 39 with JSONObject

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

the class PreferenceMgmtServiceTestCase method updateReplyNotificationTemplate.

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

Example 40 with JSONObject

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

the class PreferenceMgmtServiceTestCase 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)

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