diff --git a/docker/dev/forest.sql b/docker/dev/forest.sql index 59ac599..13ba877 100644 --- a/docker/dev/forest.sql +++ b/docker/dev/forest.sql @@ -587,22 +587,27 @@ insert into forest.forest_user (id, account, password, nickname, real_name, sex, values (2, 'testUser', '8ce2dd866238958ac4f07870766813cdaa39a9b83a8c75e26aa50f23', 'testUser', 'testUser', '0', '0', null, 'testUser@rymcu.com', null, '0', '2021-01-25 18:21:51', '2021-01-25 18:21:54', '2021-01-25 18:21:54', null); +INSERT INTO `forest`.`forest_user` (`id`, `account`, `password`, `nickname`, `real_name`, `sex`, `avatar_type`, + `avatar_url`, `email`, `phone`, `status`, `created_time`, `updated_time`, + `last_login_time`, `signature`, `last_online_time`, `bg_img_url`) +VALUES (65001, 'testUser1', '8ce2dd866238958ac4f07870766813cdaa39a9b83a8c75e26aa50f23', 'testUser', 'testUser1', '0', + '0', NULL, 'testUser@rymcu.com', NULL, '0', '2021-01-25 18:21:51', '2021-01-25 18:21:54', '2021-01-25 18:21:54', + NULL, NULL, NULL); insert into forest.forest_user_role (id_user, id_role, created_time) values (1, 1, '2021-01-25 18:22:12'); create table forest_file ( - id int unsigned auto_increment comment 'id' - primary key, + id int unsigned auto_increment comment 'id' primary key, md5_value varchar(40) not null comment '文件md5值', file_path varchar(255) not null comment '文件上传路径', file_url varchar(255) not null comment '网络访问路径', - created_time datetime null comment '创建时间', - updated_time datetime null comment '更新时间', - created_by int null comment '创建人', - file_size int null comment '文件大小', - file_type varchar(10) null comment '文件类型' + created_time datetime null comment '创建时间', + updated_time datetime null comment '更新时间', + created_by int null comment '创建人', + file_size int null comment '文件大小', + file_type varchar(10) null comment '文件类型' ) comment '文件上传记录表' collate = utf8mb4_unicode_ci; create index index_md5_value_created_by diff --git a/src/main/java/com/rymcu/forest/service/BankAccountService.java b/src/main/java/com/rymcu/forest/service/BankAccountService.java index 171f1c7..46475cb 100644 --- a/src/main/java/com/rymcu/forest/service/BankAccountService.java +++ b/src/main/java/com/rymcu/forest/service/BankAccountService.java @@ -9,6 +9,8 @@ import com.rymcu.forest.entity.BankAccount; import java.util.List; /** + * 银行账户服务 + * * @author ronger */ public interface BankAccountService extends Service { diff --git a/src/main/java/com/rymcu/forest/service/BankService.java b/src/main/java/com/rymcu/forest/service/BankService.java index 59fd8bb..51df799 100644 --- a/src/main/java/com/rymcu/forest/service/BankService.java +++ b/src/main/java/com/rymcu/forest/service/BankService.java @@ -7,6 +7,8 @@ import com.rymcu.forest.entity.Bank; import java.util.List; /** + * 银行 + * * @author ronger */ public interface BankService extends Service { diff --git a/src/main/java/com/rymcu/forest/service/impl/BankServiceImpl.java b/src/main/java/com/rymcu/forest/service/impl/BankServiceImpl.java index 431a506..4040f34 100644 --- a/src/main/java/com/rymcu/forest/service/impl/BankServiceImpl.java +++ b/src/main/java/com/rymcu/forest/service/impl/BankServiceImpl.java @@ -11,6 +11,8 @@ import javax.annotation.Resource; import java.util.List; /** + * 银行 + * * @author ronger */ @Service diff --git a/src/test/java/com/rymcu/forest/base/BaseServiceTest.java b/src/test/java/com/rymcu/forest/base/BaseServiceTest.java new file mode 100644 index 0000000..c0163c9 --- /dev/null +++ b/src/test/java/com/rymcu/forest/base/BaseServiceTest.java @@ -0,0 +1,16 @@ +package com.rymcu.forest.base; + +import org.junit.jupiter.api.MethodOrderer; +import org.junit.jupiter.api.TestMethodOrder; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit.jupiter.SpringExtension; +import org.springframework.transaction.annotation.Transactional; + +@SpringBootTest +@ExtendWith(SpringExtension.class) +@Transactional +// 顺序执行单元测试 +@TestMethodOrder(MethodOrderer.Random.class) +public class BaseServiceTest { +} diff --git a/src/test/java/com/rymcu/forest/service/ArticleThumbsUpServiceTest.java b/src/test/java/com/rymcu/forest/service/ArticleThumbsUpServiceTest.java index c3a79a9..c57c95c 100644 --- a/src/test/java/com/rymcu/forest/service/ArticleThumbsUpServiceTest.java +++ b/src/test/java/com/rymcu/forest/service/ArticleThumbsUpServiceTest.java @@ -1,17 +1,12 @@ package com.rymcu.forest.service; +import com.rymcu.forest.base.BaseServiceTest; import com.rymcu.forest.core.exception.BusinessException; import com.rymcu.forest.dto.ArticleDTO; import com.rymcu.forest.dto.ArticleSearchDTO; import com.rymcu.forest.entity.ArticleThumbsUp; -import org.junit.jupiter.api.MethodOrderer; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.TestMethodOrder; -import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.test.context.junit.jupiter.SpringExtension; -import org.springframework.transaction.annotation.Transactional; import java.util.Date; import java.util.List; @@ -19,16 +14,11 @@ import java.util.List; import static org.junit.jupiter.api.Assertions.*; /** - * 点赞文章 + * 点赞文章测试 * * @author 毛毛虫 */ -@SpringBootTest -@ExtendWith(SpringExtension.class) -@Transactional -// 顺序执行单元测试 -@TestMethodOrder(MethodOrderer.Random.class) -class ArticleThumbsUpServiceTest { +class ArticleThumbsUpServiceTest extends BaseServiceTest { /** * 测试用点赞实体 @@ -64,7 +54,9 @@ class ArticleThumbsUpServiceTest { @Test public void thumbsExistsArticle2() { assertDoesNotThrow(() -> { - List articles = articleService.findArticles(new ArticleSearchDTO()); + ArticleSearchDTO articleSearchDTO = new ArticleSearchDTO(); + articleSearchDTO.setTopicUri("news"); + List articles = articleService.findArticles(articleSearchDTO); articleThumbsUp.setIdArticle(articles.get(0).getIdArticle()); }); diff --git a/src/test/java/com/rymcu/forest/service/BankAccountServiceTest.java b/src/test/java/com/rymcu/forest/service/BankAccountServiceTest.java new file mode 100644 index 0000000..81300e2 --- /dev/null +++ b/src/test/java/com/rymcu/forest/service/BankAccountServiceTest.java @@ -0,0 +1,67 @@ +package com.rymcu.forest.service; + +import com.rymcu.forest.base.BaseServiceTest; +import com.rymcu.forest.dto.BankAccountDTO; +import com.rymcu.forest.dto.BankAccountSearchDTO; +import com.rymcu.forest.dto.TransactionRecordDTO; +import com.rymcu.forest.entity.BankAccount; +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 static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + +public class BankAccountServiceTest extends BaseServiceTest { + + /** + * 待查询银行账户列表 + */ + private final BankAccountSearchDTO bankAccountSearchDTO; + private final Long idUser = 65001L; + + @Autowired + private ArticleThumbsUpService articleThumbsUpService; + @Autowired + private BankAccountService bankAccountService; + + { + bankAccountSearchDTO = new BankAccountSearchDTO(); + + } + + @Test + @BeforeEach + @DisplayName("创建钱包账号") + public void createBankAccount() { + + BankAccount bankAccount = bankAccountService.createBankAccount(idUser); + assertEquals(idUser, bankAccount.getAccountOwner()); + } + + @Test + @DisplayName("测试查询银行账户列表") + public void findBankAccounts() { + List bankAccounts = bankAccountService.findBankAccounts(bankAccountSearchDTO); + assertEquals(1L, bankAccounts.size()); + } + + @Test + @DisplayName("测试查询银行账户") + public void findBankAccountByIdUser() { + BankAccountDTO bankAccountByIdUser = bankAccountService.findBankAccountByIdUser(idUser); + assertEquals(idUser.intValue(), bankAccountByIdUser.getAccountOwner()); + + + } + + @Test + @DisplayName("根据时间查询账号交易记录") + public void findUserTransactionRecords() { + List userTransactionRecords = bankAccountService.findUserTransactionRecords(idUser.toString(), "", ""); + assertTrue(userTransactionRecords.isEmpty()); + } +} \ No newline at end of file diff --git a/src/test/java/com/rymcu/forest/service/BankServiceTest.java b/src/test/java/com/rymcu/forest/service/BankServiceTest.java new file mode 100644 index 0000000..88fa46e --- /dev/null +++ b/src/test/java/com/rymcu/forest/service/BankServiceTest.java @@ -0,0 +1,27 @@ +package com.rymcu.forest.service; + +import com.rymcu.forest.base.BaseServiceTest; +import com.rymcu.forest.dto.BankDTO; +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.assertEquals; + +public class BankServiceTest extends BaseServiceTest { + + + @Autowired + private BankService bankService; + + @Test + @DisplayName("测试查询银行列表") + public void findBanks() { + List banks = bankService.findBanks(); + assertEquals(2L, banks.size()); + } + + +} \ No newline at end of file