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);
}
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);
}
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);
}
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"));
}
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);
}
Aggregations