🎨 统一异常处理

This commit is contained in:
ronger 2022-10-29 23:23:39 +08:00
parent bb3b298da3
commit 2e888c1e88

View File

@ -5,7 +5,6 @@ import com.rymcu.forest.dto.ArticleSearchDTO;
import com.rymcu.forest.dto.ArticleTagDTO; import com.rymcu.forest.dto.ArticleTagDTO;
import com.rymcu.forest.dto.Author; import com.rymcu.forest.dto.Author;
import com.rymcu.forest.entity.User; import com.rymcu.forest.entity.User;
import com.rymcu.forest.web.api.exception.BaseApiException;
import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.MethodOrderer; import org.junit.jupiter.api.MethodOrderer;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
@ -94,11 +93,10 @@ class ArticleServiceTest {
* *
* 测试数据是否会返回Article的Id并且Id会填充到测试数据中 * 测试数据是否会返回Article的Id并且Id会填充到测试数据中
* @throws UnsupportedEncodingException * @throws UnsupportedEncodingException
* @throws BaseApiException
*/ */
@Test @Test
@BeforeEach @BeforeEach
public void postArticle() throws UnsupportedEncodingException, BaseApiException { public void postArticle() throws UnsupportedEncodingException {
Long articleId = articleService.postArticle(testArticle, testUser); Long articleId = articleService.postArticle(testArticle, testUser);
testArticle.setIdArticle(articleId); testArticle.setIdArticle(articleId);
assertNotNull(articleId); assertNotNull(articleId);
@ -218,10 +216,9 @@ class ArticleServiceTest {
* cn.hutool.core.io.IORuntimeException: Path [xxxxxxx] is not directory! * cn.hutool.core.io.IORuntimeException: Path [xxxxxxx] is not directory!
* 这是由于Lucene的路径通配符默认为linux的解决方式 * 这是由于Lucene的路径通配符默认为linux的解决方式
* 将ArticleIndexUtil.deleteIndex()方法中的PATH改为WINDOW_PATH即可 :) * 将ArticleIndexUtil.deleteIndex()方法中的PATH改为WINDOW_PATH即可 :)
* @throws BaseApiException 基础Api错误
*/ */
@Test @Test
void delete() throws BaseApiException { void delete() {
articleService.delete(testArticle.getIdArticle()); articleService.delete(testArticle.getIdArticle());
ArticleDTO articleDTOByIdAfter = articleService.findArticleDTOById(testArticle.getIdArticle(), 0); ArticleDTO articleDTOByIdAfter = articleService.findArticleDTOById(testArticle.getIdArticle(), 0);
assertNull(articleDTOByIdAfter); assertNull(articleDTOByIdAfter);