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