use of org.json.JSONObject in project solo by b3log.
the class ArchiveDateQueryServiceTestCase 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 ArticleMgmtServiceTestCase method cancelPublishArticle.
/**
* Cancel Publish Article.
*
* @throws Exception exception
*/
@Test(dependsOnMethods = "init")
public void cancelPublishArticle() throws Exception {
final ArticleMgmtService articleMgmtService = getArticleMgmtService();
final JSONObject requestJSONObject = new JSONObject();
final JSONObject article = new JSONObject();
requestJSONObject.put(Article.ARTICLE, article);
article.put(Article.ARTICLE_AUTHOR_EMAIL, "test@gmail.com");
article.put(Article.ARTICLE_TITLE, "article4 title");
article.put(Article.ARTICLE_ABSTRACT, "article4 abstract");
article.put(Article.ARTICLE_CONTENT, "article4 content");
article.put(Article.ARTICLE_TAGS_REF, "tag1, tag2, tag3");
article.put(Article.ARTICLE_PERMALINK, "article4 permalink");
article.put(Article.ARTICLE_IS_PUBLISHED, true);
article.put(Common.POST_TO_COMMUNITY, true);
article.put(Article.ARTICLE_SIGN_ID, "1");
article.put(Article.ARTICLE_COMMENTABLE, true);
article.put(Article.ARTICLE_VIEW_PWD, "");
final String articleId = articleMgmtService.addArticle(requestJSONObject);
Assert.assertNotNull(articleId);
final ArticleQueryService articleQueryService = getArticleQueryService();
final JSONObject paginationRequest = Requests.buildPaginationRequest("1/10/20");
JSONArray articles = articleQueryService.getArticles(paginationRequest).optJSONArray(Article.ARTICLES);
int articleCount = articles.length();
Assert.assertNotEquals(articleCount, 0);
articleMgmtService.cancelPublishArticle(articleId);
articles = articleQueryService.getArticles(paginationRequest).optJSONArray(Article.ARTICLES);
Assert.assertEquals(articles.length(), articleCount - 1);
}
use of org.json.JSONObject in project solo by b3log.
the class ArticleMgmtServiceTestCase 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 ArticleMgmtServiceTestCase method removeArticle.
/**
* Remove Article.
*
* @throws Exception exception
*/
@Test(dependsOnMethods = "init")
public void removeArticle() throws Exception {
final ArticleMgmtService articleMgmtService = getArticleMgmtService();
final JSONObject requestJSONObject = new JSONObject();
final JSONObject article = new JSONObject();
requestJSONObject.put(Article.ARTICLE, article);
article.put(Article.ARTICLE_AUTHOR_EMAIL, "test@gmail.com");
article.put(Article.ARTICLE_TITLE, "article3 title");
article.put(Article.ARTICLE_ABSTRACT, "article3 abstract");
article.put(Article.ARTICLE_CONTENT, "article3 content");
article.put(Article.ARTICLE_TAGS_REF, "tag1, tag2, tag3");
article.put(Article.ARTICLE_PERMALINK, "article3 permalink");
article.put(Article.ARTICLE_IS_PUBLISHED, true);
article.put(Common.POST_TO_COMMUNITY, true);
article.put(Article.ARTICLE_SIGN_ID, "1");
article.put(Article.ARTICLE_COMMENTABLE, true);
article.put(Article.ARTICLE_VIEW_PWD, "");
final String articleId = articleMgmtService.addArticle(requestJSONObject);
Assert.assertNotNull(articleId);
articleMgmtService.removeArticle(articleId);
final ArticleQueryService articleQueryService = getArticleQueryService();
final JSONObject updated = articleQueryService.getArticleById(articleId);
Assert.assertNull(updated);
}
use of org.json.JSONObject in project solo by b3log.
the class ArticleQueryServiceTestCase method getArticlesByArchiveDate.
/**
* Get Archives By Archive Date.
*
* @throws Exception exception
*/
@Test(dependsOnMethods = "init")
public void getArticlesByArchiveDate() throws Exception {
final ArchiveDateQueryService archiveDateQueryService = getArchiveDateQueryService();
final List<JSONObject> archiveDates = archiveDateQueryService.getArchiveDates();
Assert.assertNotNull(archiveDates);
Assert.assertEquals(archiveDates.size(), 1);
final JSONObject archiveDate = archiveDates.get(0);
final ArticleQueryService articleQueryService = getArticleQueryService();
List<JSONObject> articles = articleQueryService.getArticlesByArchiveDate(archiveDate.getString(Keys.OBJECT_ID), 1, Integer.MAX_VALUE);
Assert.assertNotNull(articles);
Assert.assertEquals(articles.size(), 1);
articles = articleQueryService.getArticlesByArchiveDate("not found", 1, Integer.MAX_VALUE);
Assert.assertNotNull(articles);
Assert.assertTrue(articles.isEmpty());
}
Aggregations