Service层修改 单元测试
This commit is contained in:
@@ -162,6 +162,13 @@ public class ArticleMapperTest extends BaseTest {
|
||||
assertNotEquals(0, allByCategoryId.size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void findAllByCategoryIdAndOpen() {
|
||||
List<Article> allByCategoryId = articleMapper.findAllByCategoryId(1);
|
||||
assertNotEquals(0, allByCategoryId.size());
|
||||
allByCategoryId.forEach(article -> assertTrue(article.getOpen()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void findAll() {
|
||||
List<Article> allByCategoryId = articleMapper.findAll();
|
||||
@@ -173,6 +180,21 @@ public class ArticleMapperTest extends BaseTest {
|
||||
assertNotEquals(0, articleMapper.count());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getPreArticle() {
|
||||
ArticleTag articleTag = generateArticle();
|
||||
Article preArticle = articleMapper.getPreArticle(articleTag.getArticle().getId());
|
||||
assertNotNull(preArticle);
|
||||
assertTrue(preArticle.getId() < articleTag.getArticle().getId());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getNextArticle() {
|
||||
Article getNextArticle = articleMapper.getNextArticle(3L);
|
||||
assertNotNull(getNextArticle);
|
||||
assertTrue(getNextArticle.getId() > 3L);
|
||||
}
|
||||
|
||||
private ArticleTag generateArticle() {
|
||||
String randomText = UUID.randomUUID().toString();
|
||||
|
||||
@@ -199,5 +221,4 @@ public class ArticleMapperTest extends BaseTest {
|
||||
|
||||
return articleTag;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user