use of org.b3log.solo.MockRequest in project solo by 88250.
the class ArticleConsoleTestCase method updateArticle.
/**
* updateArticle.
*
* @throws Exception exception
*/
public void updateArticle() throws Exception {
final JSONObject article = getArticleRepository().getFirst(new Query());
final MockRequest request = mockRequest();
request.setRequestURI("/console/article/");
request.setMethod("PUT");
final JSONObject requestJSON = new JSONObject();
requestJSON.put(Article.ARTICLE, article);
request.setJSON(requestJSON);
mockAdminLogin(request);
final MockResponse response = mockResponse();
mockDispatcher(request, response);
final String content = response.getString();
Assert.assertTrue(StringUtils.contains(content, "\"code\":0"));
}
use of org.b3log.solo.MockRequest in project solo by 88250.
the class ArticleConsoleTestCase method removeArticle.
/**
* removeArticle.
*
* @throws Exception exception
*/
@Test(dependsOnMethods = "updateArticle")
public void removeArticle() throws Exception {
final JSONObject article = getArticleRepository().getFirst(new Query());
final String articleId = article.optString(Keys.OBJECT_ID);
final MockRequest request = mockRequest();
request.setRequestURI("/console/article/" + articleId);
request.setMethod("DELETE");
mockAdminLogin(request);
final MockResponse response = mockResponse();
mockDispatcher(request, response);
final String content = response.getString();
Assert.assertTrue(StringUtils.contains(content, "\"code\":0"));
}
use of org.b3log.solo.MockRequest in project solo by 88250.
the class ArticleConsoleTestCase method cancelTopArticle.
/**
* cancelTopArticle.
*
* @throws Exception exception
*/
public void cancelTopArticle() throws Exception {
final JSONObject article = getArticleRepository().getFirst(new Query());
final String articleId = article.optString(Keys.OBJECT_ID);
final MockRequest request = mockRequest();
request.setRequestURI("/console/article/canceltop/" + articleId);
request.setMethod("PUT");
mockAdminLogin(request);
final MockResponse response = mockResponse();
mockDispatcher(request, response);
final String content = response.getString();
Assert.assertTrue(StringUtils.contains(content, "\"code\":0"));
}
use of org.b3log.solo.MockRequest in project solo by 88250.
the class CategoryConsoleTestCase method getCategory.
/**
* getCategory.
*
* @throws Exception exception
*/
@Test(dependsOnMethods = "addCategory")
public void getCategory() throws Exception {
final JSONObject category = getCategoryQueryService().getByTitle("分类1");
final MockRequest request = mockRequest();
request.setRequestURI("/console/category/" + category.optString(Keys.OBJECT_ID));
request.setMethod("GET");
mockAdminLogin(request);
final MockResponse response = mockResponse();
mockDispatcher(request, response);
final String content = response.getString();
Assert.assertTrue(StringUtils.contains(content, "code\":0"));
}
use of org.b3log.solo.MockRequest in project solo by 88250.
the class CategoryConsoleTestCase method changeOrder.
/**
* changeOrder.
*
* @throws Exception exception
*/
@Test(dependsOnMethods = "getCategories")
public void changeOrder() throws Exception {
final JSONObject category = getCategoryQueryService().getByTitle("新的分类1");
final MockRequest request = mockRequest();
request.setRequestURI("/console/category/order/");
request.setMethod("PUT");
final JSONObject requestJSON = new JSONObject();
requestJSON.put(Keys.OBJECT_ID, category.optString(Keys.OBJECT_ID));
requestJSON.put(Common.DIRECTION, "up");
request.setJSON(requestJSON);
mockAdminLogin(request);
final MockResponse response = mockResponse();
mockDispatcher(request, response);
final String content = response.getString();
Assert.assertTrue(StringUtils.contains(content, "code\":0"));
}
Aggregations