🐛 测试过的单元测试
This commit is contained in:
parent
6fffea0f09
commit
31969cfb1f
@ -1,7 +1,6 @@
|
|||||||
package com.rymcu.forest.service;
|
package com.rymcu.forest.service;
|
||||||
|
|
||||||
import com.rymcu.forest.core.exception.BusinessException;
|
import com.rymcu.forest.core.exception.BusinessException;
|
||||||
import com.rymcu.forest.core.exception.ServiceException;
|
|
||||||
import com.rymcu.forest.dto.ArticleDTO;
|
import com.rymcu.forest.dto.ArticleDTO;
|
||||||
import com.rymcu.forest.dto.ArticleSearchDTO;
|
import com.rymcu.forest.dto.ArticleSearchDTO;
|
||||||
import com.rymcu.forest.entity.ArticleThumbsUp;
|
import com.rymcu.forest.entity.ArticleThumbsUp;
|
||||||
@ -42,13 +41,10 @@ class ArticleThumbsUpServiceTest {
|
|||||||
private ArticleService articleService;
|
private ArticleService articleService;
|
||||||
|
|
||||||
{
|
{
|
||||||
{
|
|
||||||
articleThumbsUp = new ArticleThumbsUp();
|
articleThumbsUp = new ArticleThumbsUp();
|
||||||
articleThumbsUp.setIdArticle(-1L);
|
articleThumbsUp.setIdArticle(-1L);
|
||||||
articleThumbsUp.setThumbsUpTime(new Date());
|
articleThumbsUp.setThumbsUpTime(new Date());
|
||||||
articleThumbsUp.setIdUser(-1L);
|
articleThumbsUp.setIdUser(-1L);
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -56,7 +52,7 @@ class ArticleThumbsUpServiceTest {
|
|||||||
* 测试点赞不存在的文章
|
* 测试点赞不存在的文章
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
void thumbsNotExistsArticle() {
|
public void thumbsNotExistsArticle() {
|
||||||
assertThrows(BusinessException.class, () -> {
|
assertThrows(BusinessException.class, () -> {
|
||||||
articleThumbsUpService.thumbsUp(articleThumbsUp);
|
articleThumbsUpService.thumbsUp(articleThumbsUp);
|
||||||
});
|
});
|
||||||
@ -66,20 +62,7 @@ class ArticleThumbsUpServiceTest {
|
|||||||
* 测试点赞存在的文章
|
* 测试点赞存在的文章
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
void thumbsExistsArticle() {
|
public void thumbsExistsArticle2() {
|
||||||
assertThrows(NullPointerException.class, () -> {
|
|
||||||
assertDoesNotThrow(() -> {
|
|
||||||
List<ArticleDTO> articles = articleService.findArticles(null);
|
|
||||||
});
|
|
||||||
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 测试点赞存在的文章
|
|
||||||
*/
|
|
||||||
@Test
|
|
||||||
void thumbsExistsArticle2() {
|
|
||||||
assertDoesNotThrow(() -> {
|
assertDoesNotThrow(() -> {
|
||||||
List<ArticleDTO> articles = articleService.findArticles(new ArticleSearchDTO());
|
List<ArticleDTO> articles = articleService.findArticles(new ArticleSearchDTO());
|
||||||
articleThumbsUp.setIdArticle(articles.get(0).getIdArticle());
|
articleThumbsUp.setIdArticle(articles.get(0).getIdArticle());
|
||||||
@ -89,17 +72,4 @@ class ArticleThumbsUpServiceTest {
|
|||||||
assertEquals(1, i);
|
assertEquals(1, i);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 测试点赞存在的文章
|
|
||||||
*/
|
|
||||||
@Test
|
|
||||||
void thumbsNotExistsUser() {
|
|
||||||
articleThumbsUp.setIdUser(null);
|
|
||||||
assertThrows(ServiceException.class, () -> {
|
|
||||||
articleThumbsUpService.thumbsUp(articleThumbsUp);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user