🐛 测试

This commit is contained in:
你一个人在这儿干嘛你是来拉屎的吧 2023-04-02 11:32:42 +08:00 committed by Zeeland
parent 6ac0060289
commit a21842ac0b
8 changed files with 134 additions and 21 deletions

View File

@ -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

View File

@ -9,6 +9,8 @@ import com.rymcu.forest.entity.BankAccount;
import java.util.List;
/**
* 银行账户服务
*
* @author ronger
*/
public interface BankAccountService extends Service<BankAccount> {

View File

@ -7,6 +7,8 @@ import com.rymcu.forest.entity.Bank;
import java.util.List;
/**
* 银行
*
* @author ronger
*/
public interface BankService extends Service<Bank> {

View File

@ -11,6 +11,8 @@ import javax.annotation.Resource;
import java.util.List;
/**
* 银行
*
* @author ronger
*/
@Service

View File

@ -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 {
}

View File

@ -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<ArticleDTO> articles = articleService.findArticles(new ArticleSearchDTO());
ArticleSearchDTO articleSearchDTO = new ArticleSearchDTO();
articleSearchDTO.setTopicUri("news");
List<ArticleDTO> articles = articleService.findArticles(articleSearchDTO);
articleThumbsUp.setIdArticle(articles.get(0).getIdArticle());
});

View File

@ -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<BankAccountDTO> 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<TransactionRecordDTO> userTransactionRecords = bankAccountService.findUserTransactionRecords(idUser.toString(), "", "");
assertTrue(userTransactionRecords.isEmpty());
}
}

View File

@ -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<BankDTO> banks = bankService.findBanks();
assertEquals(2L, banks.size());
}
}