Search in sources :

Example 46 with JSONObject

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

the class LinkMgmtServiceTestCase method addLink.

/**
     * Add Link.
     * 
     * @throws Exception exception
     */
@Test(dependsOnMethods = "init")
public void addLink() 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, "link1 title");
    link.put(Link.LINK_ADDRESS, "link1 address");
    link.put(Link.LINK_DESCRIPTION, "link1 description");
    final String linkId = linkMgmtService.addLink(requestJSONObject);
    Assert.assertNotNull(linkId);
}
Also used : JSONObject(org.json.JSONObject) Test(org.testng.annotations.Test)

Example 47 with JSONObject

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

the class LinkQueryServiceTestCase method getLinks.

/**
     * Get Links.
     * 
     * @throws Exception exception
     */
@Test(dependsOnMethods = "addLink")
public void getLinks() throws Exception {
    final LinkQueryService linkQueryService = getLinkQueryService();
    final JSONObject paginationRequest = Requests.buildPaginationRequest("1/10/20");
    final JSONObject result = linkQueryService.getLinks(paginationRequest);
    Assert.assertNotNull(result);
    Assert.assertEquals(result.getJSONArray(Link.LINKS).length(), 2);
}
Also used : JSONObject(org.json.JSONObject) Test(org.testng.annotations.Test)

Example 48 with JSONObject

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

the class LinkQueryServiceTestCase 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 49 with JSONObject

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

the class OptionMgmtServiceTestCase method add.

/**
     * Add.
     * 
     * @throws Exception exception
     */
@Test
public void add() throws Exception {
    final OptionMgmtService optionMgmtService = getOptionMgmtService();
    final JSONObject option = new JSONObject();
    option.put(Keys.OBJECT_ID, Option.ID_C_BROADCAST_CHANCE_EXPIRATION_TIME);
    option.put(Option.OPTION_CATEGORY, Option.CATEGORY_C_BROADCAST);
    option.put(Option.OPTION_VALUE, 0L);
    final String id = optionMgmtService.addOrUpdateOption(option);
    System.out.println(id);
    Assert.assertNotNull(id);
}
Also used : JSONObject(org.json.JSONObject) Test(org.testng.annotations.Test)

Example 50 with JSONObject

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

the class TagProcessorTestCase 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) UserQueryService(org.b3log.solo.service.UserQueryService) InitService(org.b3log.solo.service.InitService) 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