|  | @@ -1,146 +0,0 @@
 | 
	
		
			
				|  |  | -package cn.newfeifan.mall.module.distri.service.applicationforwithdrawalchannel;
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -import org.junit.jupiter.api.Disabled;
 | 
	
		
			
				|  |  | -import org.junit.jupiter.api.Test;
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -import javax.annotation.Resource;
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -import cn.newfeifan.mall.framework.test.core.ut.BaseDbUnitTest;
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -import cn.newfeifan.mall.module.distri.controller.admin.applicationforwithdrawalchannel.vo.*;
 | 
	
		
			
				|  |  | -import cn.newfeifan.mall.module.distri.dal.dataobject.applicationforwithdrawalchannel.ApplicationForWithdrawalChannelDO;
 | 
	
		
			
				|  |  | -import cn.newfeifan.mall.module.distri.dal.mysql.applicationforwithdrawalchannel.ApplicationForWithdrawalChannelMapper;
 | 
	
		
			
				|  |  | -import cn.newfeifan.mall.framework.common.pojo.PageResult;
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -import org.springframework.context.annotation.Import;
 | 
	
		
			
				|  |  | -import static cn.newfeifan.mall.module.distri.enums.ErrorCodeConstants.*;
 | 
	
		
			
				|  |  | -import static cn.newfeifan.mall.framework.test.core.util.AssertUtils.*;
 | 
	
		
			
				|  |  | -import static cn.newfeifan.mall.framework.test.core.util.RandomUtils.*;
 | 
	
		
			
				|  |  | -import static cn.newfeifan.mall.framework.common.util.date.LocalDateTimeUtils.*;
 | 
	
		
			
				|  |  | -import static cn.newfeifan.mall.framework.common.util.object.ObjectUtils.*;
 | 
	
		
			
				|  |  | -import static org.junit.jupiter.api.Assertions.*;
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -/**
 | 
	
		
			
				|  |  | - * {@link ApplicationForWithdrawalChannelServiceImpl} 的单元测试类
 | 
	
		
			
				|  |  | - *
 | 
	
		
			
				|  |  | - * @author 非繁人
 | 
	
		
			
				|  |  | - */
 | 
	
		
			
				|  |  | -@Import(ApplicationForWithdrawalChannelServiceImpl.class)
 | 
	
		
			
				|  |  | -public class ApplicationForWithdrawalChannelServiceImplTest extends BaseDbUnitTest {
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -    @Resource
 | 
	
		
			
				|  |  | -    private ApplicationForWithdrawalChannelServiceImpl applicationForWithdrawalChannelService;
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -    @Resource
 | 
	
		
			
				|  |  | -    private ApplicationForWithdrawalChannelMapper applicationForWithdrawalChannelMapper;
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -    @Test
 | 
	
		
			
				|  |  | -    public void testCreateApplicationForWithdrawalChannel_success() {
 | 
	
		
			
				|  |  | -        // 准备参数
 | 
	
		
			
				|  |  | -        ApplicationForWithdrawalChannelSaveReqVO createReqVO = randomPojo(ApplicationForWithdrawalChannelSaveReqVO.class).setId(null);
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -        // 调用
 | 
	
		
			
				|  |  | -        Long applicationForWithdrawalChannelId = applicationForWithdrawalChannelService.createApplicationForWithdrawalChannel(createReqVO);
 | 
	
		
			
				|  |  | -        // 断言
 | 
	
		
			
				|  |  | -        assertNotNull(applicationForWithdrawalChannelId);
 | 
	
		
			
				|  |  | -        // 校验记录的属性是否正确
 | 
	
		
			
				|  |  | -        ApplicationForWithdrawalChannelDO applicationForWithdrawalChannel = applicationForWithdrawalChannelMapper.selectById(applicationForWithdrawalChannelId);
 | 
	
		
			
				|  |  | -        assertPojoEquals(createReqVO, applicationForWithdrawalChannel, "id");
 | 
	
		
			
				|  |  | -    }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -    @Test
 | 
	
		
			
				|  |  | -    public void testUpdateApplicationForWithdrawalChannel_success() {
 | 
	
		
			
				|  |  | -        // mock 数据
 | 
	
		
			
				|  |  | -        ApplicationForWithdrawalChannelDO dbApplicationForWithdrawalChannel = randomPojo(ApplicationForWithdrawalChannelDO.class);
 | 
	
		
			
				|  |  | -        applicationForWithdrawalChannelMapper.insert(dbApplicationForWithdrawalChannel);// @Sql: 先插入出一条存在的数据
 | 
	
		
			
				|  |  | -        // 准备参数
 | 
	
		
			
				|  |  | -        ApplicationForWithdrawalChannelSaveReqVO updateReqVO = randomPojo(ApplicationForWithdrawalChannelSaveReqVO.class, o -> {
 | 
	
		
			
				|  |  | -            o.setId(dbApplicationForWithdrawalChannel.getId()); // 设置更新的 ID
 | 
	
		
			
				|  |  | -        });
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -        // 调用
 | 
	
		
			
				|  |  | -        applicationForWithdrawalChannelService.updateApplicationForWithdrawalChannel(updateReqVO);
 | 
	
		
			
				|  |  | -        // 校验是否更新正确
 | 
	
		
			
				|  |  | -        ApplicationForWithdrawalChannelDO applicationForWithdrawalChannel = applicationForWithdrawalChannelMapper.selectById(updateReqVO.getId()); // 获取最新的
 | 
	
		
			
				|  |  | -        assertPojoEquals(updateReqVO, applicationForWithdrawalChannel);
 | 
	
		
			
				|  |  | -    }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -    @Test
 | 
	
		
			
				|  |  | -    public void testUpdateApplicationForWithdrawalChannel_notExists() {
 | 
	
		
			
				|  |  | -        // 准备参数
 | 
	
		
			
				|  |  | -        ApplicationForWithdrawalChannelSaveReqVO updateReqVO = randomPojo(ApplicationForWithdrawalChannelSaveReqVO.class);
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -        // 调用, 并断言异常
 | 
	
		
			
				|  |  | -        assertServiceException(() -> applicationForWithdrawalChannelService.updateApplicationForWithdrawalChannel(updateReqVO), APPLICATION_FOR_WITHDRAWAL_CHANNEL_NOT_EXISTS);
 | 
	
		
			
				|  |  | -    }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -    @Test
 | 
	
		
			
				|  |  | -    public void testDeleteApplicationForWithdrawalChannel_success() {
 | 
	
		
			
				|  |  | -        // mock 数据
 | 
	
		
			
				|  |  | -        ApplicationForWithdrawalChannelDO dbApplicationForWithdrawalChannel = randomPojo(ApplicationForWithdrawalChannelDO.class);
 | 
	
		
			
				|  |  | -        applicationForWithdrawalChannelMapper.insert(dbApplicationForWithdrawalChannel);// @Sql: 先插入出一条存在的数据
 | 
	
		
			
				|  |  | -        // 准备参数
 | 
	
		
			
				|  |  | -        Long id = dbApplicationForWithdrawalChannel.getId();
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -        // 调用
 | 
	
		
			
				|  |  | -        applicationForWithdrawalChannelService.deleteApplicationForWithdrawalChannel(id);
 | 
	
		
			
				|  |  | -       // 校验数据不存在了
 | 
	
		
			
				|  |  | -       assertNull(applicationForWithdrawalChannelMapper.selectById(id));
 | 
	
		
			
				|  |  | -    }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -    @Test
 | 
	
		
			
				|  |  | -    public void testDeleteApplicationForWithdrawalChannel_notExists() {
 | 
	
		
			
				|  |  | -        // 准备参数
 | 
	
		
			
				|  |  | -        Long id = randomLongId();
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -        // 调用, 并断言异常
 | 
	
		
			
				|  |  | -        assertServiceException(() -> applicationForWithdrawalChannelService.deleteApplicationForWithdrawalChannel(id), APPLICATION_FOR_WITHDRAWAL_CHANNEL_NOT_EXISTS);
 | 
	
		
			
				|  |  | -    }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -    @Test
 | 
	
		
			
				|  |  | -    @Disabled  // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解
 | 
	
		
			
				|  |  | -    public void testGetApplicationForWithdrawalChannelPage() {
 | 
	
		
			
				|  |  | -       // mock 数据
 | 
	
		
			
				|  |  | -       ApplicationForWithdrawalChannelDO dbApplicationForWithdrawalChannel = randomPojo(ApplicationForWithdrawalChannelDO.class, o -> { // 等会查询到
 | 
	
		
			
				|  |  | -           o.setWithdrawalType(null);
 | 
	
		
			
				|  |  | -           o.setWithdrawalName(null);
 | 
	
		
			
				|  |  | -           o.setAmount(null);
 | 
	
		
			
				|  |  | -           o.setCount(null);
 | 
	
		
			
				|  |  | -           o.setStatus(null);
 | 
	
		
			
				|  |  | -           o.setPtDailyWithdrawalId(null);
 | 
	
		
			
				|  |  | -           o.setCreateTime(null);
 | 
	
		
			
				|  |  | -       });
 | 
	
		
			
				|  |  | -       applicationForWithdrawalChannelMapper.insert(dbApplicationForWithdrawalChannel);
 | 
	
		
			
				|  |  | -       // 测试 withdrawalType 不匹配
 | 
	
		
			
				|  |  | -       applicationForWithdrawalChannelMapper.insert(cloneIgnoreId(dbApplicationForWithdrawalChannel, o -> o.setWithdrawalType(null)));
 | 
	
		
			
				|  |  | -       // 测试 withdrawalName 不匹配
 | 
	
		
			
				|  |  | -       applicationForWithdrawalChannelMapper.insert(cloneIgnoreId(dbApplicationForWithdrawalChannel, o -> o.setWithdrawalName(null)));
 | 
	
		
			
				|  |  | -       // 测试 amount 不匹配
 | 
	
		
			
				|  |  | -       applicationForWithdrawalChannelMapper.insert(cloneIgnoreId(dbApplicationForWithdrawalChannel, o -> o.setAmount(null)));
 | 
	
		
			
				|  |  | -       // 测试 count 不匹配
 | 
	
		
			
				|  |  | -       applicationForWithdrawalChannelMapper.insert(cloneIgnoreId(dbApplicationForWithdrawalChannel, o -> o.setCount(null)));
 | 
	
		
			
				|  |  | -       // 测试 status 不匹配
 | 
	
		
			
				|  |  | -       applicationForWithdrawalChannelMapper.insert(cloneIgnoreId(dbApplicationForWithdrawalChannel, o -> o.setStatus(null)));
 | 
	
		
			
				|  |  | -       // 测试 ptDailyWithdrawalId 不匹配
 | 
	
		
			
				|  |  | -       applicationForWithdrawalChannelMapper.insert(cloneIgnoreId(dbApplicationForWithdrawalChannel, o -> o.setPtDailyWithdrawalId(null)));
 | 
	
		
			
				|  |  | -       // 测试 createTime 不匹配
 | 
	
		
			
				|  |  | -       applicationForWithdrawalChannelMapper.insert(cloneIgnoreId(dbApplicationForWithdrawalChannel, o -> o.setCreateTime(null)));
 | 
	
		
			
				|  |  | -       // 准备参数
 | 
	
		
			
				|  |  | -       ApplicationForWithdrawalChannelPageReqVO reqVO = new ApplicationForWithdrawalChannelPageReqVO();
 | 
	
		
			
				|  |  | -       reqVO.setWithdrawalType(null);
 | 
	
		
			
				|  |  | -       reqVO.setWithdrawalName(null);
 | 
	
		
			
				|  |  | -       reqVO.setAmount(null);
 | 
	
		
			
				|  |  | -       reqVO.setCount(null);
 | 
	
		
			
				|  |  | -       reqVO.setStatus(null);
 | 
	
		
			
				|  |  | -       reqVO.setPtDailyWithdrawalId(null);
 | 
	
		
			
				|  |  | -       reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28));
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -       // 调用
 | 
	
		
			
				|  |  | -       PageResult<ApplicationForWithdrawalChannelDO> pageResult = applicationForWithdrawalChannelService.getApplicationForWithdrawalChannelPage(reqVO);
 | 
	
		
			
				|  |  | -       // 断言
 | 
	
		
			
				|  |  | -       assertEquals(1, pageResult.getTotal());
 | 
	
		
			
				|  |  | -       assertEquals(1, pageResult.getList().size());
 | 
	
		
			
				|  |  | -       assertPojoEquals(dbApplicationForWithdrawalChannel, pageResult.getList().get(0));
 | 
	
		
			
				|  |  | -    }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -}
 |