diff --git a/src/test/java/com/rymcu/forest/service/CurrencyRuleServiceTest.java b/src/test/java/com/rymcu/forest/service/CurrencyRuleServiceTest.java index 24c97da..1a6c2e9 100644 --- a/src/test/java/com/rymcu/forest/service/CurrencyRuleServiceTest.java +++ b/src/test/java/com/rymcu/forest/service/CurrencyRuleServiceTest.java @@ -1,7 +1,23 @@ package com.rymcu.forest.service; import com.rymcu.forest.base.BaseServiceTest; +import com.rymcu.forest.entity.CurrencyRule; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; + +import java.util.List; + +import static org.junit.jupiter.api.Assertions.assertEquals; class CurrencyRuleServiceTest extends BaseServiceTest { + @Autowired + private CurrencyRuleService currencyRuleService; + + @Test + void currencyService() { + List all = currencyRuleService.findAll(); + assertEquals(0, all.size()); + } + } \ No newline at end of file diff --git a/src/test/java/com/rymcu/forest/service/DashboardServiceTest.java b/src/test/java/com/rymcu/forest/service/DashboardServiceTest.java index 816b248..3e6f43b 100644 --- a/src/test/java/com/rymcu/forest/service/DashboardServiceTest.java +++ b/src/test/java/com/rymcu/forest/service/DashboardServiceTest.java @@ -1,7 +1,70 @@ package com.rymcu.forest.service; import com.rymcu.forest.base.BaseServiceTest; +import com.rymcu.forest.dto.ArticleDTO; +import com.rymcu.forest.dto.BankAccountDTO; +import com.rymcu.forest.dto.UserInfoDTO; +import com.rymcu.forest.dto.admin.Dashboard; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; + +import java.util.List; +import java.util.Map; + +import static org.junit.jupiter.api.Assertions.assertEquals; class DashboardServiceTest extends BaseServiceTest { + @Autowired + private DashboardService dashboardService; + + @BeforeEach + void setUp() { + } + + @Test + @DisplayName("统计系统数据") + void dashboard() { + Dashboard result = dashboardService.dashboard(); + assertEquals(1, result.getCountArticleNum()); + } + + @Test + @DisplayName("统计最近三十天数据") + void lastThirtyDaysData() { + Map result = dashboardService.lastThirtyDaysData(); + assertEquals(5, result.size()); + assertEquals(30, ((List) result.get("visits")).size()); + } + + @Test + @DisplayName("获取历史数据") + void history() { + Map result = dashboardService.history(); + assertEquals(5, result.size()); + assertEquals(12, ((List) result.get("visits")).size()); + } + + @Test + @DisplayName("获取新增用户列表") + void newUsers() { + List result = dashboardService.newUsers(); + assertEquals(0L, result.size()); + } + + @Test + @DisplayName("获取新增银行账号列表") + void newBankAccounts() { + List result = dashboardService.newBankAccounts(); + assertEquals(0L, result.size()); + } + + @Test + @DisplayName("获取新增文章列表") + void newArticles() { + List result = dashboardService.newArticles(); + assertEquals(0L, result.size()); + } } \ No newline at end of file diff --git a/src/test/java/com/rymcu/forest/service/FollowServiceTest.java b/src/test/java/com/rymcu/forest/service/FollowServiceTest.java index 72ff368..a5be386 100644 --- a/src/test/java/com/rymcu/forest/service/FollowServiceTest.java +++ b/src/test/java/com/rymcu/forest/service/FollowServiceTest.java @@ -1,31 +1,80 @@ package com.rymcu.forest.service; import com.rymcu.forest.base.BaseServiceTest; +import com.rymcu.forest.dto.UserDTO; +import com.rymcu.forest.entity.Follow; +import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; + +import java.util.List; + +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; class FollowServiceTest extends BaseServiceTest { + private final Long followingId = 1L; + private final Long idUser = 2L; + private final String followingType = "0"; + + private final Follow follow; + @Autowired + private FollowService followService; + + { + follow = new Follow(); + follow.setFollowerId(idUser); + + follow.setFollowingType(followingType); + follow.setFollowingId(followingId); + + } @Test void isFollow() { + Boolean b = followService.isFollow(followingId.intValue(), followingType, idUser); + assertFalse(b); + } @Test + @DisplayName("关注操作") void follow() { + + Boolean b = followService.follow(follow, "nickname"); + assertTrue(b); + } @Test + @DisplayName("取消关注操作") void cancelFollow() { + Boolean b = followService.cancelFollow(follow); + assertTrue(b); } @Test + @DisplayName("获取关注用户者数据") void findByFollowingId() { + List list = followService.findByFollowingId(followingType, followingId); + assertTrue(list.isEmpty()); } @Test + @DisplayName("查询用户粉丝") void findUserFollowersByUser() { + UserDTO userDTO = new UserDTO(); + userDTO.setIdUser(idUser); + List list = followService.findUserFollowersByUser(userDTO); + assertTrue(list.isEmpty()); } @Test + @DisplayName("查询用户关注用户") void findUserFollowingsByUser() { + UserDTO userDTO = new UserDTO(); + userDTO.setIdUser(idUser); + List list = followService.findUserFollowingsByUser(userDTO); + assertTrue(list.isEmpty()); } } \ No newline at end of file diff --git a/src/test/java/com/rymcu/forest/service/ForestFileServiceTest.java b/src/test/java/com/rymcu/forest/service/ForestFileServiceTest.java index 1e6296d..db87f60 100644 --- a/src/test/java/com/rymcu/forest/service/ForestFileServiceTest.java +++ b/src/test/java/com/rymcu/forest/service/ForestFileServiceTest.java @@ -2,19 +2,40 @@ package com.rymcu.forest.service; import com.rymcu.forest.base.BaseServiceTest; import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; + +import static org.junit.jupiter.api.Assertions.assertEquals; class ForestFileServiceTest extends BaseServiceTest { + private final String fileUrl = "localhost/upload/file/123.jpg"; + private final String filePath = "upload/file/123.jpg"; + private final String md5Value = "md5Value"; + private final long createdBy = 1L; + private final long fileSize = 1024L; + private final String fileType = "jpg"; + + @Autowired + private ForestFileService forestFileService; + @BeforeEach void setUp() { + forestFileService.insertForestFile(fileUrl, filePath, md5Value, createdBy, fileSize, fileType); } @Test + @DisplayName("通过md5获取文件访问链接") void getFileUrlByMd5() { + String fileUrlByMd5 = forestFileService.getFileUrlByMd5(md5Value, createdBy, fileType); + assertEquals(fileUrl, fileUrlByMd5); } @Test + @DisplayName("插入文件对象") void insertForestFile() { + int i = forestFileService.insertForestFile(fileUrl, filePath, md5Value, createdBy, fileSize, fileType); + assertEquals(1, i); } } \ No newline at end of file