Commit 4bf4432f937fdf593c745709a0d729c2c7d34f06
1 parent
9ea7bde7
✨ CRM:单测暂时不写
Showing
8 changed files
with
0 additions
and
1182 deletions
yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/business/BusinessStatusTypeServiceImplTest.java deleted
| 1 | -package cn.iocoder.yudao.module.crm.service.business; | |
| 2 | - | |
| 3 | -import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 4 | -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; | |
| 5 | -import cn.iocoder.yudao.module.crm.controller.admin.business.vo.type.CrmBusinessStatusTypePageReqVO; | |
| 6 | -import cn.iocoder.yudao.module.crm.controller.admin.business.vo.type.CrmBusinessStatusTypeSaveReqVO; | |
| 7 | -import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessStatusTypeDO; | |
| 8 | -import cn.iocoder.yudao.module.crm.dal.mysql.business.CrmBusinessStatusTypeMapper; | |
| 9 | -import org.junit.jupiter.api.Disabled; | |
| 10 | -import org.junit.jupiter.api.Test; | |
| 11 | -import org.springframework.context.annotation.Import; | |
| 12 | - | |
| 13 | -import jakarta.annotation.Resource; | |
| 14 | - | |
| 15 | -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; | |
| 16 | -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; | |
| 17 | -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomLongId; | |
| 18 | -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; | |
| 19 | -import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.BUSINESS_STATUS_TYPE_NOT_EXISTS; | |
| 20 | -import static org.junit.jupiter.api.Assertions.*; | |
| 21 | - | |
| 22 | -// TODO 芋艿:后续再 review | |
| 23 | -/** | |
| 24 | - * {@link CrmBusinessStatusTypeServiceImpl} 的单元测试类 | |
| 25 | - * | |
| 26 | - * @author ljlleo | |
| 27 | - */ | |
| 28 | -@Disabled // TODO 芋艿:后续 fix 补充的单测 | |
| 29 | -@Import(CrmBusinessStatusTypeServiceImpl.class) | |
| 30 | -public class BusinessStatusTypeServiceImplTest extends BaseDbUnitTest { | |
| 31 | - | |
| 32 | - @Resource | |
| 33 | - private CrmBusinessStatusTypeServiceImpl businessStatusTypeService; | |
| 34 | - | |
| 35 | - @Resource | |
| 36 | - private CrmBusinessStatusTypeMapper businessStatusTypeMapper; | |
| 37 | - | |
| 38 | - @Test | |
| 39 | - public void testCreateBusinessStatusType_success() { | |
| 40 | - // 准备参数 | |
| 41 | - CrmBusinessStatusTypeSaveReqVO createReqVO = randomPojo(CrmBusinessStatusTypeSaveReqVO.class).setId(null); | |
| 42 | - | |
| 43 | - // 调用 | |
| 44 | - Long businessStatusTypeId = businessStatusTypeService.createBusinessStatusType(createReqVO); | |
| 45 | - // 断言 | |
| 46 | - assertNotNull(businessStatusTypeId); | |
| 47 | - // 校验记录的属性是否正确 | |
| 48 | - CrmBusinessStatusTypeDO businessStatusType = businessStatusTypeMapper.selectById(businessStatusTypeId); | |
| 49 | - assertPojoEquals(createReqVO, businessStatusType, "id"); | |
| 50 | - } | |
| 51 | - | |
| 52 | - @Test | |
| 53 | - public void testUpdateBusinessStatusType_success() { | |
| 54 | - // mock 数据 | |
| 55 | - CrmBusinessStatusTypeDO dbBusinessStatusType = randomPojo(CrmBusinessStatusTypeDO.class); | |
| 56 | - businessStatusTypeMapper.insert(dbBusinessStatusType);// @Sql: 先插入出一条存在的数据 | |
| 57 | - // 准备参数 | |
| 58 | - CrmBusinessStatusTypeSaveReqVO updateReqVO = randomPojo(CrmBusinessStatusTypeSaveReqVO.class, o -> { | |
| 59 | - o.setId(dbBusinessStatusType.getId()); // 设置更新的 ID | |
| 60 | - }); | |
| 61 | - | |
| 62 | - // 调用 | |
| 63 | - businessStatusTypeService.updateBusinessStatusType(updateReqVO); | |
| 64 | - // 校验是否更新正确 | |
| 65 | - CrmBusinessStatusTypeDO businessStatusType = businessStatusTypeMapper.selectById(updateReqVO.getId()); // 获取最新的 | |
| 66 | - assertPojoEquals(updateReqVO, businessStatusType); | |
| 67 | - } | |
| 68 | - | |
| 69 | - @Test | |
| 70 | - public void testUpdateBusinessStatusType_notExists() { | |
| 71 | - // 准备参数 | |
| 72 | - CrmBusinessStatusTypeSaveReqVO updateReqVO = randomPojo(CrmBusinessStatusTypeSaveReqVO.class); | |
| 73 | - | |
| 74 | - // 调用, 并断言异常 | |
| 75 | - assertServiceException(() -> businessStatusTypeService.updateBusinessStatusType(updateReqVO), BUSINESS_STATUS_TYPE_NOT_EXISTS); | |
| 76 | - } | |
| 77 | - | |
| 78 | - @Test | |
| 79 | - public void testDeleteBusinessStatusType_success() { | |
| 80 | - // mock 数据 | |
| 81 | - CrmBusinessStatusTypeDO dbBusinessStatusType = randomPojo(CrmBusinessStatusTypeDO.class); | |
| 82 | - businessStatusTypeMapper.insert(dbBusinessStatusType);// @Sql: 先插入出一条存在的数据 | |
| 83 | - // 准备参数 | |
| 84 | - Long id = dbBusinessStatusType.getId(); | |
| 85 | - | |
| 86 | - // 调用 | |
| 87 | - businessStatusTypeService.deleteBusinessStatusType(id); | |
| 88 | - // 校验数据不存在了 | |
| 89 | - assertNull(businessStatusTypeMapper.selectById(id)); | |
| 90 | - } | |
| 91 | - | |
| 92 | - @Test | |
| 93 | - public void testDeleteBusinessStatusType_notExists() { | |
| 94 | - // 准备参数 | |
| 95 | - Long id = randomLongId(); | |
| 96 | - | |
| 97 | - // 调用, 并断言异常 | |
| 98 | - assertServiceException(() -> businessStatusTypeService.deleteBusinessStatusType(id), BUSINESS_STATUS_TYPE_NOT_EXISTS); | |
| 99 | - } | |
| 100 | - | |
| 101 | - @Test | |
| 102 | - @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 | |
| 103 | - public void testGetBusinessStatusTypePage() { | |
| 104 | - // mock 数据 | |
| 105 | - CrmBusinessStatusTypeDO dbBusinessStatusType = randomPojo(CrmBusinessStatusTypeDO.class, o -> { // 等会查询到 | |
| 106 | - }); | |
| 107 | - businessStatusTypeMapper.insert(dbBusinessStatusType); | |
| 108 | - // 准备参数 | |
| 109 | - CrmBusinessStatusTypePageReqVO reqVO = new CrmBusinessStatusTypePageReqVO(); | |
| 110 | - | |
| 111 | - // 调用 | |
| 112 | - PageResult<CrmBusinessStatusTypeDO> pageResult = businessStatusTypeService.getBusinessStatusTypePage(reqVO); | |
| 113 | - // 断言 | |
| 114 | - assertEquals(1, pageResult.getTotal()); | |
| 115 | - assertEquals(1, pageResult.getList().size()); | |
| 116 | - assertPojoEquals(dbBusinessStatusType, pageResult.getList().get(0)); | |
| 117 | - } | |
| 118 | - | |
| 119 | -} |
yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessServiceImplTest.java deleted
| 1 | -package cn.iocoder.yudao.module.crm.service.business; | |
| 2 | - | |
| 3 | -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; | |
| 4 | -import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessSaveReqVO; | |
| 5 | -import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO; | |
| 6 | -import cn.iocoder.yudao.module.crm.dal.mysql.business.CrmBusinessMapper; | |
| 7 | -import jakarta.annotation.Resource; | |
| 8 | -import org.junit.jupiter.api.Disabled; | |
| 9 | -import org.junit.jupiter.api.Test; | |
| 10 | -import org.springframework.context.annotation.Import; | |
| 11 | - | |
| 12 | -import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; | |
| 13 | -import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; | |
| 14 | -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; | |
| 15 | -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; | |
| 16 | -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomLongId; | |
| 17 | -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; | |
| 18 | -import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.BUSINESS_NOT_EXISTS; | |
| 19 | -import static org.junit.jupiter.api.Assertions.assertNotNull; | |
| 20 | -import static org.junit.jupiter.api.Assertions.assertNull; | |
| 21 | - | |
| 22 | -/** | |
| 23 | - * {@link CrmBusinessServiceImpl} 的单元测试类 | |
| 24 | - * | |
| 25 | - * @author ljlleo | |
| 26 | - */ | |
| 27 | -@Disabled // TODO 芋艿:后续 fix 补充的单测 | |
| 28 | -@Import(CrmBusinessServiceImpl.class) | |
| 29 | -public class CrmBusinessServiceImplTest extends BaseDbUnitTest { | |
| 30 | - | |
| 31 | - @Resource | |
| 32 | - private CrmBusinessServiceImpl businessService; | |
| 33 | - | |
| 34 | - @Resource | |
| 35 | - private CrmBusinessMapper businessMapper; | |
| 36 | - | |
| 37 | - @Test | |
| 38 | - public void testCreateBusiness_success() { | |
| 39 | - // 准备参数 | |
| 40 | - CrmBusinessSaveReqVO reqVO = randomPojo(CrmBusinessSaveReqVO.class); | |
| 41 | - | |
| 42 | - // 调用 | |
| 43 | - Long businessId = businessService.createBusiness(reqVO, getLoginUserId()); | |
| 44 | - // 断言 | |
| 45 | - assertNotNull(businessId); | |
| 46 | - // 校验记录的属性是否正确 | |
| 47 | - CrmBusinessDO business = businessMapper.selectById(businessId); | |
| 48 | - assertPojoEquals(reqVO, business); | |
| 49 | - } | |
| 50 | - | |
| 51 | - @Test | |
| 52 | - public void testUpdateBusiness_success() { | |
| 53 | - // mock 数据 | |
| 54 | - CrmBusinessDO dbBusiness = randomPojo(CrmBusinessDO.class); | |
| 55 | - businessMapper.insert(dbBusiness);// @Sql: 先插入出一条存在的数据 | |
| 56 | - // 准备参数 | |
| 57 | - CrmBusinessSaveReqVO reqVO = randomPojo(CrmBusinessSaveReqVO.class, o -> { | |
| 58 | - o.setId(dbBusiness.getId()); // 设置更新的 ID | |
| 59 | - }); | |
| 60 | - | |
| 61 | - // 调用 | |
| 62 | - businessService.updateBusiness(reqVO); | |
| 63 | - // 校验是否更新正确 | |
| 64 | - CrmBusinessDO business = businessMapper.selectById(reqVO.getId()); // 获取最新的 | |
| 65 | - assertPojoEquals(reqVO, business); | |
| 66 | - } | |
| 67 | - | |
| 68 | - @Test | |
| 69 | - public void testUpdateBusiness_notExists() { | |
| 70 | - // 准备参数 | |
| 71 | - CrmBusinessSaveReqVO reqVO = randomPojo(CrmBusinessSaveReqVO.class); | |
| 72 | - | |
| 73 | - // 调用, 并断言异常 | |
| 74 | - assertServiceException(() -> businessService.updateBusiness(reqVO), BUSINESS_NOT_EXISTS); | |
| 75 | - } | |
| 76 | - | |
| 77 | - @Test | |
| 78 | - public void testDeleteBusiness_success() { | |
| 79 | - // mock 数据 | |
| 80 | - CrmBusinessDO dbBusiness = randomPojo(CrmBusinessDO.class); | |
| 81 | - businessMapper.insert(dbBusiness);// @Sql: 先插入出一条存在的数据 | |
| 82 | - // 准备参数 | |
| 83 | - Long id = dbBusiness.getId(); | |
| 84 | - | |
| 85 | - // 调用 | |
| 86 | - businessService.deleteBusiness(id); | |
| 87 | - // 校验数据不存在了 | |
| 88 | - assertNull(businessMapper.selectById(id)); | |
| 89 | - } | |
| 90 | - | |
| 91 | - @Test | |
| 92 | - public void testDeleteBusiness_notExists() { | |
| 93 | - // 准备参数 | |
| 94 | - Long id = randomLongId(); | |
| 95 | - | |
| 96 | - // 调用, 并断言异常 | |
| 97 | - assertServiceException(() -> businessService.deleteBusiness(id), BUSINESS_NOT_EXISTS); | |
| 98 | - } | |
| 99 | - | |
| 100 | - @Test | |
| 101 | - @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 | |
| 102 | - public void testGetBusinessPage() { | |
| 103 | - // mock 数据 | |
| 104 | - CrmBusinessDO dbBusiness = randomPojo(CrmBusinessDO.class, o -> { // 等会查询到 | |
| 105 | - o.setName(null); | |
| 106 | - o.setStatusTypeId(null); | |
| 107 | - o.setStatusId(null); | |
| 108 | - o.setContactNextTime(null); | |
| 109 | - o.setCustomerId(null); | |
| 110 | - o.setDealTime(null); | |
| 111 | - o.setPrice(null); | |
| 112 | - o.setDiscountPercent(null); | |
| 113 | - o.setProductPrice(null); | |
| 114 | - o.setRemark(null); | |
| 115 | - o.setCreateTime(null); | |
| 116 | - o.setEndStatus(null); | |
| 117 | - o.setEndRemark(null); | |
| 118 | - o.setContactLastTime(null); | |
| 119 | - o.setFollowUpStatus(null); | |
| 120 | - }); | |
| 121 | - businessMapper.insert(dbBusiness); | |
| 122 | - // 测试 name 不匹配 | |
| 123 | - businessMapper.insert(cloneIgnoreId(dbBusiness, o -> o.setName(null))); | |
| 124 | - // 测试 statusTypeId 不匹配 | |
| 125 | - businessMapper.insert(cloneIgnoreId(dbBusiness, o -> o.setStatusTypeId(null))); | |
| 126 | - // 测试 statusId 不匹配 | |
| 127 | - businessMapper.insert(cloneIgnoreId(dbBusiness, o -> o.setStatusId(null))); | |
| 128 | - // 测试 contactNextTime 不匹配 | |
| 129 | - businessMapper.insert(cloneIgnoreId(dbBusiness, o -> o.setContactNextTime(null))); | |
| 130 | - // 测试 customerId 不匹配 | |
| 131 | - businessMapper.insert(cloneIgnoreId(dbBusiness, o -> o.setCustomerId(null))); | |
| 132 | - // 测试 dealTime 不匹配 | |
| 133 | - businessMapper.insert(cloneIgnoreId(dbBusiness, o -> o.setDealTime(null))); | |
| 134 | - // 测试 price 不匹配 | |
| 135 | - businessMapper.insert(cloneIgnoreId(dbBusiness, o -> o.setPrice(null))); | |
| 136 | - // 测试 discountPercent 不匹配 | |
| 137 | - businessMapper.insert(cloneIgnoreId(dbBusiness, o -> o.setDiscountPercent(null))); | |
| 138 | - // 测试 productPrice 不匹配 | |
| 139 | - businessMapper.insert(cloneIgnoreId(dbBusiness, o -> o.setProductPrice(null))); | |
| 140 | - // 测试 remark 不匹配 | |
| 141 | - businessMapper.insert(cloneIgnoreId(dbBusiness, o -> o.setRemark(null))); | |
| 142 | - // 测试 createTime 不匹配 | |
| 143 | - businessMapper.insert(cloneIgnoreId(dbBusiness, o -> o.setCreateTime(null))); | |
| 144 | - // 测试 endStatus 不匹配 | |
| 145 | - businessMapper.insert(cloneIgnoreId(dbBusiness, o -> o.setEndStatus(null))); | |
| 146 | - // 测试 endRemark 不匹配 | |
| 147 | - businessMapper.insert(cloneIgnoreId(dbBusiness, o -> o.setEndRemark(null))); | |
| 148 | - // 测试 contactLastTime 不匹配 | |
| 149 | - businessMapper.insert(cloneIgnoreId(dbBusiness, o -> o.setContactLastTime(null))); | |
| 150 | - // 测试 followUpStatus 不匹配 | |
| 151 | - businessMapper.insert(cloneIgnoreId(dbBusiness, o -> o.setFollowUpStatus(null))); | |
| 152 | - //// 准备参数 | |
| 153 | - //CrmBusinessPageReqVO reqVO = new CrmBusinessPageReqVO(); | |
| 154 | - //reqVO.setName(null); | |
| 155 | - //reqVO.setStatusTypeId(null); | |
| 156 | - //reqVO.setStatusId(null); | |
| 157 | - //reqVO.setContactNextTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); | |
| 158 | - //reqVO.setCustomerId(null); | |
| 159 | - //reqVO.setDealTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); | |
| 160 | - //reqVO.setPrice(null); | |
| 161 | - //reqVO.setDiscountPercent(null); | |
| 162 | - //reqVO.setProductPrice(null); | |
| 163 | - //reqVO.setRemark(null); | |
| 164 | - //reqVO.setOwnerUserId(null); | |
| 165 | - //reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); | |
| 166 | - //reqVO.setRoUserIds(null); | |
| 167 | - //reqVO.setRwUserIds(null); | |
| 168 | - //reqVO.setEndStatus(null); | |
| 169 | - //reqVO.setEndRemark(null); | |
| 170 | - //reqVO.setContactLastTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); | |
| 171 | - //reqVO.setFollowUpStatus(null); | |
| 172 | - // | |
| 173 | - //// 调用 | |
| 174 | - //PageResult<CrmBusinessDO> pageResult = businessService.getBusinessPage(reqVO); | |
| 175 | - //// 断言 | |
| 176 | - //assertEquals(1, pageResult.getTotal()); | |
| 177 | - //assertEquals(1, pageResult.getList().size()); | |
| 178 | - //assertPojoEquals(dbBusiness, pageResult.getList().get(0)); | |
| 179 | - } | |
| 180 | - | |
| 181 | -} |
yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/clue/CrmClueServiceImplTest.java deleted
| 1 | -package cn.iocoder.yudao.module.crm.service.clue; | |
| 2 | - | |
| 3 | -import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 4 | -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; | |
| 5 | -import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.CrmCluePageReqVO; | |
| 6 | -import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.CrmClueSaveReqVO; | |
| 7 | -import cn.iocoder.yudao.module.crm.dal.dataobject.clue.CrmClueDO; | |
| 8 | -import cn.iocoder.yudao.module.crm.dal.mysql.clue.CrmClueMapper; | |
| 9 | -import jakarta.annotation.Resource; | |
| 10 | -import org.junit.jupiter.api.Disabled; | |
| 11 | -import org.junit.jupiter.api.Test; | |
| 12 | -import org.springframework.context.annotation.Import; | |
| 13 | - | |
| 14 | -import java.util.List; | |
| 15 | - | |
| 16 | -import static cn.iocoder.yudao.framework.common.pojo.PageParam.PAGE_SIZE_NONE; | |
| 17 | -import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; | |
| 18 | -import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; | |
| 19 | -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; | |
| 20 | -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; | |
| 21 | -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomLongId; | |
| 22 | -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; | |
| 23 | -import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.CLUE_NOT_EXISTS; | |
| 24 | -import static org.junit.jupiter.api.Assertions.*; | |
| 25 | - | |
| 26 | -// TODO 芋艿:单测后续补; | |
| 27 | - | |
| 28 | -/** | |
| 29 | - * {@link CrmClueServiceImpl} 的单元测试类 | |
| 30 | - * | |
| 31 | - * @author Wanwan | |
| 32 | - */ | |
| 33 | -@Disabled // TODO 芋艿:后续 fix 补充的单测 | |
| 34 | -@Import(CrmClueServiceImpl.class) | |
| 35 | -public class CrmClueServiceImplTest extends BaseDbUnitTest { | |
| 36 | - | |
| 37 | - @Resource | |
| 38 | - private CrmClueServiceImpl clueService; | |
| 39 | - | |
| 40 | - @Resource | |
| 41 | - private CrmClueMapper clueMapper; | |
| 42 | - | |
| 43 | - @Test | |
| 44 | - public void testCreateClue_success() { | |
| 45 | - // 准备参数 | |
| 46 | - CrmClueSaveReqVO reqVO = randomPojo(CrmClueSaveReqVO.class); | |
| 47 | - | |
| 48 | - // 调用 | |
| 49 | - Long clueId = clueService.createClue(reqVO, getLoginUserId()); | |
| 50 | - // 断言 | |
| 51 | - assertNotNull(clueId); | |
| 52 | - // 校验记录的属性是否正确 | |
| 53 | - CrmClueDO clue = clueMapper.selectById(clueId); | |
| 54 | - assertPojoEquals(reqVO, clue); | |
| 55 | - } | |
| 56 | - | |
| 57 | - @Test | |
| 58 | - public void testUpdateClue_success() { | |
| 59 | - // mock 数据 | |
| 60 | - CrmClueDO dbClue = randomPojo(CrmClueDO.class); | |
| 61 | - clueMapper.insert(dbClue);// @Sql: 先插入出一条存在的数据 | |
| 62 | - // 准备参数 | |
| 63 | - CrmClueSaveReqVO reqVO = randomPojo(CrmClueSaveReqVO.class, o -> { | |
| 64 | - o.setId(dbClue.getId()); // 设置更新的 ID | |
| 65 | - }); | |
| 66 | - | |
| 67 | - // 调用 | |
| 68 | - clueService.updateClue(reqVO); | |
| 69 | - // 校验是否更新正确 | |
| 70 | - CrmClueDO clue = clueMapper.selectById(reqVO.getId()); // 获取最新的 | |
| 71 | - assertPojoEquals(reqVO, clue); | |
| 72 | - } | |
| 73 | - | |
| 74 | - @Test | |
| 75 | - public void testUpdateClue_notExists() { | |
| 76 | - // 准备参数 | |
| 77 | - CrmClueSaveReqVO reqVO = randomPojo(CrmClueSaveReqVO.class); | |
| 78 | - | |
| 79 | - // 调用, 并断言异常 | |
| 80 | - assertServiceException(() -> clueService.updateClue(reqVO), CLUE_NOT_EXISTS); | |
| 81 | - } | |
| 82 | - | |
| 83 | - @Test | |
| 84 | - public void testDeleteClue_success() { | |
| 85 | - // mock 数据 | |
| 86 | - CrmClueDO dbClue = randomPojo(CrmClueDO.class); | |
| 87 | - clueMapper.insert(dbClue);// @Sql: 先插入出一条存在的数据 | |
| 88 | - // 准备参数 | |
| 89 | - Long id = dbClue.getId(); | |
| 90 | - | |
| 91 | - // 调用 | |
| 92 | - clueService.deleteClue(id); | |
| 93 | - // 校验数据不存在了 | |
| 94 | - assertNull(clueMapper.selectById(id)); | |
| 95 | - } | |
| 96 | - | |
| 97 | - @Test | |
| 98 | - public void testDeleteClue_notExists() { | |
| 99 | - // 准备参数 | |
| 100 | - Long id = randomLongId(); | |
| 101 | - | |
| 102 | - // 调用, 并断言异常 | |
| 103 | - assertServiceException(() -> clueService.deleteClue(id), CLUE_NOT_EXISTS); | |
| 104 | - } | |
| 105 | - | |
| 106 | - @Test | |
| 107 | - @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 | |
| 108 | - public void testGetCluePage() { | |
| 109 | - // mock 数据 | |
| 110 | - CrmClueDO dbClue = randomPojo(CrmClueDO.class, o -> { // 等会查询到 | |
| 111 | - o.setTransformStatus(null); | |
| 112 | - o.setFollowUpStatus(null); | |
| 113 | - o.setName(null); | |
| 114 | - o.setCustomerId(null); | |
| 115 | - o.setContactNextTime(null); | |
| 116 | - o.setTelephone(null); | |
| 117 | - o.setMobile(null); | |
| 118 | - o.setAddress(null); | |
| 119 | - o.setContactLastTime(null); | |
| 120 | - o.setCreateTime(null); | |
| 121 | - }); | |
| 122 | - clueMapper.insert(dbClue); | |
| 123 | - // 测试 transformStatus 不匹配 | |
| 124 | - clueMapper.insert(cloneIgnoreId(dbClue, o -> o.setTransformStatus(null))); | |
| 125 | - // 测试 followUpStatus 不匹配 | |
| 126 | - clueMapper.insert(cloneIgnoreId(dbClue, o -> o.setFollowUpStatus(null))); | |
| 127 | - // 测试 name 不匹配 | |
| 128 | - clueMapper.insert(cloneIgnoreId(dbClue, o -> o.setName(null))); | |
| 129 | - // 测试 customerId 不匹配 | |
| 130 | - clueMapper.insert(cloneIgnoreId(dbClue, o -> o.setCustomerId(null))); | |
| 131 | - // 测试 contactNextTime 不匹配 | |
| 132 | - clueMapper.insert(cloneIgnoreId(dbClue, o -> o.setContactNextTime(null))); | |
| 133 | - // 测试 telephone 不匹配 | |
| 134 | - clueMapper.insert(cloneIgnoreId(dbClue, o -> o.setTelephone(null))); | |
| 135 | - // 测试 mobile 不匹配 | |
| 136 | - clueMapper.insert(cloneIgnoreId(dbClue, o -> o.setMobile(null))); | |
| 137 | - // 测试 address 不匹配 | |
| 138 | - clueMapper.insert(cloneIgnoreId(dbClue, o -> o.setAddress(null))); | |
| 139 | - // 测试 contactLastTime 不匹配 | |
| 140 | - clueMapper.insert(cloneIgnoreId(dbClue, o -> o.setContactLastTime(null))); | |
| 141 | - // 测试 createTime 不匹配 | |
| 142 | - clueMapper.insert(cloneIgnoreId(dbClue, o -> o.setCreateTime(null))); | |
| 143 | - // 准备参数 | |
| 144 | - CrmCluePageReqVO reqVO = new CrmCluePageReqVO(); | |
| 145 | - reqVO.setName(null); | |
| 146 | - reqVO.setTelephone(null); | |
| 147 | - reqVO.setMobile(null); | |
| 148 | - | |
| 149 | - // 调用 | |
| 150 | - PageResult<CrmClueDO> pageResult = clueService.getCluePage(reqVO, 1L); | |
| 151 | - // 断言 | |
| 152 | - assertEquals(1, pageResult.getTotal()); | |
| 153 | - assertEquals(1, pageResult.getList().size()); | |
| 154 | - assertPojoEquals(dbClue, pageResult.getList().get(0)); | |
| 155 | - } | |
| 156 | - | |
| 157 | - @Test | |
| 158 | - @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 | |
| 159 | - public void testGetClueList() { | |
| 160 | - // mock 数据 | |
| 161 | - CrmClueDO dbClue = randomPojo(CrmClueDO.class, o -> { // 等会查询到 | |
| 162 | - o.setTransformStatus(null); | |
| 163 | - o.setFollowUpStatus(null); | |
| 164 | - o.setName(null); | |
| 165 | - o.setCustomerId(null); | |
| 166 | - o.setContactNextTime(null); | |
| 167 | - o.setTelephone(null); | |
| 168 | - o.setMobile(null); | |
| 169 | - o.setAddress(null); | |
| 170 | - o.setContactLastTime(null); | |
| 171 | - o.setCreateTime(null); | |
| 172 | - }); | |
| 173 | - clueMapper.insert(dbClue); | |
| 174 | - // 测试 transformStatus 不匹配 | |
| 175 | - clueMapper.insert(cloneIgnoreId(dbClue, o -> o.setTransformStatus(null))); | |
| 176 | - // 测试 followUpStatus 不匹配 | |
| 177 | - clueMapper.insert(cloneIgnoreId(dbClue, o -> o.setFollowUpStatus(null))); | |
| 178 | - // 测试 name 不匹配 | |
| 179 | - clueMapper.insert(cloneIgnoreId(dbClue, o -> o.setName(null))); | |
| 180 | - // 测试 customerId 不匹配 | |
| 181 | - clueMapper.insert(cloneIgnoreId(dbClue, o -> o.setCustomerId(null))); | |
| 182 | - // 测试 contactNextTime 不匹配 | |
| 183 | - clueMapper.insert(cloneIgnoreId(dbClue, o -> o.setContactNextTime(null))); | |
| 184 | - // 测试 telephone 不匹配 | |
| 185 | - clueMapper.insert(cloneIgnoreId(dbClue, o -> o.setTelephone(null))); | |
| 186 | - // 测试 mobile 不匹配 | |
| 187 | - clueMapper.insert(cloneIgnoreId(dbClue, o -> o.setMobile(null))); | |
| 188 | - // 测试 address 不匹配 | |
| 189 | - clueMapper.insert(cloneIgnoreId(dbClue, o -> o.setAddress(null))); | |
| 190 | - // 测试 contactLastTime 不匹配 | |
| 191 | - clueMapper.insert(cloneIgnoreId(dbClue, o -> o.setContactLastTime(null))); | |
| 192 | - // 测试 createTime 不匹配 | |
| 193 | - clueMapper.insert(cloneIgnoreId(dbClue, o -> o.setCreateTime(null))); | |
| 194 | - // 准备参数 | |
| 195 | - CrmCluePageReqVO reqVO = new CrmCluePageReqVO(); | |
| 196 | - reqVO.setName(null); | |
| 197 | - reqVO.setTelephone(null); | |
| 198 | - reqVO.setMobile(null); | |
| 199 | - reqVO.setPageSize(PAGE_SIZE_NONE); | |
| 200 | - // 调用 | |
| 201 | - List<CrmClueDO> list = clueService.getCluePage(reqVO, 1L).getList(); | |
| 202 | - // 断言 | |
| 203 | - assertEquals(1, list.size()); | |
| 204 | - assertPojoEquals(dbClue, list.get(0)); | |
| 205 | - } | |
| 206 | - | |
| 207 | -} |
yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/contract/ContractServiceImplTest.java deleted
| 1 | -package cn.iocoder.yudao.module.crm.service.contract; | |
| 2 | - | |
| 3 | -import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 4 | -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; | |
| 5 | -import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.CrmContractPageReqVO; | |
| 6 | -import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.CrmContractSaveReqVO; | |
| 7 | -import cn.iocoder.yudao.module.crm.dal.dataobject.contract.CrmContractDO; | |
| 8 | -import cn.iocoder.yudao.module.crm.dal.mysql.contract.CrmContractMapper; | |
| 9 | -import jakarta.annotation.Resource; | |
| 10 | -import org.junit.jupiter.api.Disabled; | |
| 11 | -import org.junit.jupiter.api.Test; | |
| 12 | -import org.springframework.context.annotation.Import; | |
| 13 | - | |
| 14 | -import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; | |
| 15 | -import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; | |
| 16 | -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; | |
| 17 | -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; | |
| 18 | -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomLongId; | |
| 19 | -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; | |
| 20 | -import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.CONTRACT_NOT_EXISTS; | |
| 21 | -import static org.junit.jupiter.api.Assertions.*; | |
| 22 | - | |
| 23 | -/** | |
| 24 | - * {@link CrmContractServiceImpl} 的单元测试类 | |
| 25 | - * | |
| 26 | - * @author dhb52 | |
| 27 | - */ | |
| 28 | -@Import(CrmContractServiceImpl.class) | |
| 29 | -public class ContractServiceImplTest extends BaseDbUnitTest { | |
| 30 | - | |
| 31 | - @Resource | |
| 32 | - private CrmContractServiceImpl contractService; | |
| 33 | - | |
| 34 | - @Resource | |
| 35 | - private CrmContractMapper contractMapper; | |
| 36 | - | |
| 37 | - @Test | |
| 38 | - public void testCreateContract_success() { | |
| 39 | - // 准备参数 | |
| 40 | - CrmContractSaveReqVO reqVO = randomPojo(CrmContractSaveReqVO.class); | |
| 41 | - | |
| 42 | - // 调用 | |
| 43 | - Long contractId = contractService.createContract(reqVO, getLoginUserId()); | |
| 44 | - // 断言 | |
| 45 | - assertNotNull(contractId); | |
| 46 | - // 校验记录的属性是否正确 | |
| 47 | - CrmContractDO contract = contractMapper.selectById(contractId); | |
| 48 | - assertPojoEquals(reqVO, contract); | |
| 49 | - } | |
| 50 | - | |
| 51 | - @Test | |
| 52 | - public void testUpdateContract_success() { | |
| 53 | - // mock 数据 | |
| 54 | - CrmContractDO dbContract = randomPojo(CrmContractDO.class); | |
| 55 | - contractMapper.insert(dbContract);// @Sql: 先插入出一条存在的数据 | |
| 56 | - // 准备参数 | |
| 57 | - CrmContractSaveReqVO reqVO = randomPojo(CrmContractSaveReqVO.class, o -> { | |
| 58 | - o.setId(dbContract.getId()); // 设置更新的 ID | |
| 59 | - }); | |
| 60 | - | |
| 61 | - // 调用 | |
| 62 | - contractService.updateContract(reqVO); | |
| 63 | - // 校验是否更新正确 | |
| 64 | - CrmContractDO contract = contractMapper.selectById(reqVO.getId()); // 获取最新的 | |
| 65 | - assertPojoEquals(reqVO, contract); | |
| 66 | - } | |
| 67 | - | |
| 68 | - @Test | |
| 69 | - public void testUpdateContract_notExists() { | |
| 70 | - // 准备参数 | |
| 71 | - CrmContractSaveReqVO reqVO = randomPojo(CrmContractSaveReqVO.class); | |
| 72 | - | |
| 73 | - // 调用, 并断言异常 | |
| 74 | - assertServiceException(() -> contractService.updateContract(reqVO), CONTRACT_NOT_EXISTS); | |
| 75 | - } | |
| 76 | - | |
| 77 | - @Test | |
| 78 | - public void testDeleteContract_success() { | |
| 79 | - // mock 数据 | |
| 80 | - CrmContractDO dbContract = randomPojo(CrmContractDO.class); | |
| 81 | - contractMapper.insert(dbContract);// @Sql: 先插入出一条存在的数据 | |
| 82 | - // 准备参数 | |
| 83 | - Long id = dbContract.getId(); | |
| 84 | - | |
| 85 | - // 调用 | |
| 86 | - contractService.deleteContract(id); | |
| 87 | - // 校验数据不存在了 | |
| 88 | - assertNull(contractMapper.selectById(id)); | |
| 89 | - } | |
| 90 | - | |
| 91 | - @Test | |
| 92 | - public void testDeleteContract_notExists() { | |
| 93 | - // 准备参数 | |
| 94 | - Long id = randomLongId(); | |
| 95 | - | |
| 96 | - // 调用, 并断言异常 | |
| 97 | - assertServiceException(() -> contractService.deleteContract(id), CONTRACT_NOT_EXISTS); | |
| 98 | - } | |
| 99 | - | |
| 100 | - @Test | |
| 101 | - @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 | |
| 102 | - public void testGetContractPage() { | |
| 103 | - // mock 数据 | |
| 104 | - CrmContractDO dbContract = randomPojo(CrmContractDO.class, o -> { // 等会查询到 | |
| 105 | - o.setName(null); | |
| 106 | - o.setCustomerId(null); | |
| 107 | - o.setBusinessId(null); | |
| 108 | - o.setOrderDate(null); | |
| 109 | - o.setNo(null); | |
| 110 | - o.setDiscountPercent(null); | |
| 111 | - o.setProductPrice(null); | |
| 112 | - }); | |
| 113 | - contractMapper.insert(dbContract); | |
| 114 | - // 测试 name 不匹配 | |
| 115 | - contractMapper.insert(cloneIgnoreId(dbContract, o -> o.setName(null))); | |
| 116 | - // 测试 customerId 不匹配 | |
| 117 | - contractMapper.insert(cloneIgnoreId(dbContract, o -> o.setCustomerId(null))); | |
| 118 | - // 测试 no 不匹配 | |
| 119 | - contractMapper.insert(cloneIgnoreId(dbContract, o -> o.setNo(null))); | |
| 120 | - // 准备参数 | |
| 121 | - CrmContractPageReqVO reqVO = new CrmContractPageReqVO(); | |
| 122 | - reqVO.setName(null); | |
| 123 | - reqVO.setCustomerId(null); | |
| 124 | - reqVO.setBusinessId(null); | |
| 125 | - reqVO.setNo(null); | |
| 126 | - | |
| 127 | - // 调用 | |
| 128 | - PageResult<CrmContractDO> pageResult = contractService.getContractPage(reqVO, getLoginUserId()); | |
| 129 | - // 断言 | |
| 130 | - assertEquals(1, pageResult.getTotal()); | |
| 131 | - assertEquals(1, pageResult.getList().size()); | |
| 132 | - assertPojoEquals(dbContract, pageResult.getList().get(0)); | |
| 133 | - } | |
| 134 | - | |
| 135 | -} |
yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerServiceImplTest.java deleted
| 1 | -package cn.iocoder.yudao.module.crm.service.customer; | |
| 2 | - | |
| 3 | -import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 4 | -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; | |
| 5 | -import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerPageReqVO; | |
| 6 | -import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerSaveReqVO; | |
| 7 | -import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; | |
| 8 | -import cn.iocoder.yudao.module.crm.dal.mysql.customer.CrmCustomerMapper; | |
| 9 | -import cn.iocoder.yudao.module.crm.service.permission.CrmPermissionService; | |
| 10 | -import jakarta.annotation.Resource; | |
| 11 | -import org.junit.jupiter.api.Disabled; | |
| 12 | -import org.junit.jupiter.api.Test; | |
| 13 | -import org.springframework.boot.test.mock.mockito.MockBean; | |
| 14 | -import org.springframework.context.annotation.Import; | |
| 15 | - | |
| 16 | -import static cn.iocoder.yudao.framework.common.pojo.PageParam.PAGE_SIZE_NONE; | |
| 17 | -import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; | |
| 18 | -import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; | |
| 19 | -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; | |
| 20 | -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; | |
| 21 | -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomLongId; | |
| 22 | -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; | |
| 23 | -import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.CUSTOMER_NOT_EXISTS; | |
| 24 | -import static org.junit.jupiter.api.Assertions.*; | |
| 25 | - | |
| 26 | -// TODO 芋艿:单测后续补 | |
| 27 | - | |
| 28 | -/** | |
| 29 | - * {@link CrmCustomerServiceImpl} 的单元测试类 | |
| 30 | - * | |
| 31 | - * @author Wanwan | |
| 32 | - */ | |
| 33 | -@Disabled // TODO 芋艿:后续 fix 补充的单测 | |
| 34 | -@Import(CrmCustomerServiceImpl.class) | |
| 35 | -public class CrmCustomerServiceImplTest extends BaseDbUnitTest { | |
| 36 | - | |
| 37 | - @Resource | |
| 38 | - private CrmCustomerServiceImpl customerService; | |
| 39 | - | |
| 40 | - @Resource | |
| 41 | - private CrmCustomerMapper customerMapper; | |
| 42 | - @MockBean | |
| 43 | - private CrmPermissionService permissionService; | |
| 44 | - | |
| 45 | - @Test | |
| 46 | - public void testCreateCustomer_success() { | |
| 47 | - // 准备参数 | |
| 48 | - CrmCustomerSaveReqVO reqVO = randomPojo(CrmCustomerSaveReqVO.class); | |
| 49 | - | |
| 50 | - // 调用 | |
| 51 | - Long customerId = customerService.createCustomer(reqVO, getLoginUserId()); | |
| 52 | - // 断言 | |
| 53 | - assertNotNull(customerId); | |
| 54 | - // 校验记录的属性是否正确 | |
| 55 | - CrmCustomerDO customer = customerMapper.selectById(customerId); | |
| 56 | - assertPojoEquals(reqVO, customer); | |
| 57 | - } | |
| 58 | - | |
| 59 | - @Test | |
| 60 | - public void testUpdateCustomer_success() { | |
| 61 | - // mock 数据 | |
| 62 | - CrmCustomerDO dbCustomer = randomPojo(CrmCustomerDO.class); | |
| 63 | - customerMapper.insert(dbCustomer);// @Sql: 先插入出一条存在的数据 | |
| 64 | - // 准备参数 | |
| 65 | - CrmCustomerSaveReqVO reqVO = randomPojo(CrmCustomerSaveReqVO.class, o -> { | |
| 66 | - o.setId(dbCustomer.getId()); // 设置更新的 ID | |
| 67 | - }); | |
| 68 | - | |
| 69 | - // 调用 | |
| 70 | - customerService.updateCustomer(reqVO); | |
| 71 | - // 校验是否更新正确 | |
| 72 | - CrmCustomerDO customer = customerMapper.selectById(reqVO.getId()); // 获取最新的 | |
| 73 | - assertPojoEquals(reqVO, customer); | |
| 74 | - } | |
| 75 | - | |
| 76 | - @Test | |
| 77 | - public void testUpdateCustomer_notExists() { | |
| 78 | - // 准备参数 | |
| 79 | - CrmCustomerSaveReqVO reqVO = randomPojo(CrmCustomerSaveReqVO.class); | |
| 80 | - | |
| 81 | - // 调用, 并断言异常 | |
| 82 | - assertServiceException(() -> customerService.updateCustomer(reqVO), CUSTOMER_NOT_EXISTS); | |
| 83 | - } | |
| 84 | - | |
| 85 | - @Test | |
| 86 | - public void testDeleteCustomer_success() { | |
| 87 | - // mock 数据 | |
| 88 | - CrmCustomerDO dbCustomer = randomPojo(CrmCustomerDO.class); | |
| 89 | - customerMapper.insert(dbCustomer);// @Sql: 先插入出一条存在的数据 | |
| 90 | - // 准备参数 | |
| 91 | - Long id = dbCustomer.getId(); | |
| 92 | - | |
| 93 | - // 调用 | |
| 94 | - customerService.deleteCustomer(id); | |
| 95 | - // 校验数据不存在了 | |
| 96 | - assertNull(customerMapper.selectById(id)); | |
| 97 | - } | |
| 98 | - | |
| 99 | - @Test | |
| 100 | - public void testDeleteCustomer_notExists() { | |
| 101 | - // 准备参数 | |
| 102 | - Long id = randomLongId(); | |
| 103 | - | |
| 104 | - // 调用, 并断言异常 | |
| 105 | - assertServiceException(() -> customerService.deleteCustomer(id), CUSTOMER_NOT_EXISTS); | |
| 106 | - } | |
| 107 | - | |
| 108 | - @Test | |
| 109 | - public void testGetCustomerPage() { | |
| 110 | - // mock 数据 | |
| 111 | - CrmCustomerDO dbCustomer = randomPojo(CrmCustomerDO.class, o -> { // 等会查询到 | |
| 112 | - o.setName("张三"); | |
| 113 | - o.setMobile("13888888888"); | |
| 114 | - o.setTelephone("13888888888"); | |
| 115 | - o.setWebsite("https://yudao.com"); | |
| 116 | - }); | |
| 117 | - //customerMapper.insert(dbCustomer); | |
| 118 | - // 测试 name 不匹配 | |
| 119 | - //customerMapper.insert(cloneIgnoreId(dbCustomer, o -> o.setName(""))); | |
| 120 | - // 测试 mobile 不匹配 | |
| 121 | - //customerMapper.insert(cloneIgnoreId(dbCustomer, o -> o.setMobile(null))); | |
| 122 | - // 测试 telephone 不匹配 | |
| 123 | - //customerMapper.insert(cloneIgnoreId(dbCustomer, o -> o.setTelephone(null))); | |
| 124 | - // 测试 website 不匹配 | |
| 125 | - //customerMapper.insert(cloneIgnoreId(dbCustomer, o -> o.setWebsite(null))); | |
| 126 | - // 准备参数 | |
| 127 | - CrmCustomerPageReqVO reqVO = new CrmCustomerPageReqVO(); | |
| 128 | - reqVO.setName("张三"); | |
| 129 | - reqVO.setMobile("13888888888"); | |
| 130 | - //reqVO.setTelephone(null); | |
| 131 | - //reqVO.setWebsite(null); | |
| 132 | - | |
| 133 | - // 调用 | |
| 134 | - PageResult<CrmCustomerDO> pageResult = customerService.getCustomerPage(reqVO, 1L); | |
| 135 | - // 断言 | |
| 136 | - //assertEquals(1, pageResult.getTotal()); | |
| 137 | - //assertEquals(1, pageResult.getList().size()); | |
| 138 | - //assertPojoEquals(dbCustomer, pageResult.getList().get(0)); | |
| 139 | - } | |
| 140 | - | |
| 141 | -} |
yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/customerlimitconfig/CrmCustomerLimitConfigServiceImplTest.java deleted
| 1 | -package cn.iocoder.yudao.module.crm.service.customerlimitconfig; | |
| 2 | - | |
| 3 | -import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 4 | -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; | |
| 5 | -import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.limitconfig.CrmCustomerLimitConfigPageReqVO; | |
| 6 | -import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.limitconfig.CrmCustomerLimitConfigSaveReqVO; | |
| 7 | -import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerLimitConfigDO; | |
| 8 | -import cn.iocoder.yudao.module.crm.dal.mysql.customer.CrmCustomerLimitConfigMapper; | |
| 9 | -import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerLimitConfigServiceImpl; | |
| 10 | -import jakarta.annotation.Resource; | |
| 11 | -import org.junit.jupiter.api.Disabled; | |
| 12 | -import org.junit.jupiter.api.Test; | |
| 13 | -import org.springframework.context.annotation.Import; | |
| 14 | - | |
| 15 | -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; | |
| 16 | -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; | |
| 17 | -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomLongId; | |
| 18 | -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; | |
| 19 | -import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.CUSTOMER_LIMIT_CONFIG_NOT_EXISTS; | |
| 20 | -import static org.junit.jupiter.api.Assertions.*; | |
| 21 | - | |
| 22 | -// TODO 芋艿:单测后面搞 | |
| 23 | -/** | |
| 24 | - * {@link CrmCustomerLimitConfigServiceImpl} 的单元测试类 | |
| 25 | - * | |
| 26 | - * @author Wanwan | |
| 27 | - */ | |
| 28 | -@Disabled // TODO 芋艿:后续 fix 补充的单测 | |
| 29 | -@Import(CrmCustomerLimitConfigServiceImpl.class) | |
| 30 | -public class CrmCustomerLimitConfigServiceImplTest extends BaseDbUnitTest { | |
| 31 | - | |
| 32 | - @Resource | |
| 33 | - private CrmCustomerLimitConfigServiceImpl customerLimitConfigService; | |
| 34 | - | |
| 35 | - @Resource | |
| 36 | - private CrmCustomerLimitConfigMapper customerLimitConfigMapper; | |
| 37 | - | |
| 38 | - @Test | |
| 39 | - public void testCreateCustomerLimitConfig_success() { | |
| 40 | - // 准备参数 | |
| 41 | - CrmCustomerLimitConfigSaveReqVO reqVO = randomPojo(CrmCustomerLimitConfigSaveReqVO.class); | |
| 42 | - | |
| 43 | - // 调用 | |
| 44 | - Long customerLimitConfigId = customerLimitConfigService.createCustomerLimitConfig(reqVO); | |
| 45 | - // 断言 | |
| 46 | - assertNotNull(customerLimitConfigId); | |
| 47 | - // 校验记录的属性是否正确 | |
| 48 | - CrmCustomerLimitConfigDO customerLimitConfig = customerLimitConfigMapper.selectById(customerLimitConfigId); | |
| 49 | - assertPojoEquals(reqVO, customerLimitConfig); | |
| 50 | - } | |
| 51 | - | |
| 52 | - @Test | |
| 53 | - public void testUpdateCustomerLimitConfig_success() { | |
| 54 | - // mock 数据 | |
| 55 | - CrmCustomerLimitConfigDO dbCustomerLimitConfig = randomPojo(CrmCustomerLimitConfigDO.class); | |
| 56 | - customerLimitConfigMapper.insert(dbCustomerLimitConfig);// @Sql: 先插入出一条存在的数据 | |
| 57 | - // 准备参数 | |
| 58 | - CrmCustomerLimitConfigSaveReqVO reqVO = randomPojo(CrmCustomerLimitConfigSaveReqVO.class, o -> { | |
| 59 | - o.setId(dbCustomerLimitConfig.getId()); // 设置更新的 ID | |
| 60 | - }); | |
| 61 | - | |
| 62 | - // 调用 | |
| 63 | - customerLimitConfigService.updateCustomerLimitConfig(reqVO); | |
| 64 | - // 校验是否更新正确 | |
| 65 | - CrmCustomerLimitConfigDO customerLimitConfig = customerLimitConfigMapper.selectById(reqVO.getId()); // 获取最新的 | |
| 66 | - assertPojoEquals(reqVO, customerLimitConfig); | |
| 67 | - } | |
| 68 | - | |
| 69 | - @Test | |
| 70 | - public void testUpdateCustomerLimitConfig_notExists() { | |
| 71 | - // 准备参数 | |
| 72 | - CrmCustomerLimitConfigSaveReqVO reqVO = randomPojo(CrmCustomerLimitConfigSaveReqVO.class); | |
| 73 | - | |
| 74 | - // 调用, 并断言异常 | |
| 75 | - assertServiceException(() -> customerLimitConfigService.updateCustomerLimitConfig(reqVO), CUSTOMER_LIMIT_CONFIG_NOT_EXISTS); | |
| 76 | - } | |
| 77 | - | |
| 78 | - @Test | |
| 79 | - public void testDeleteCustomerLimitConfig_success() { | |
| 80 | - // mock 数据 | |
| 81 | - CrmCustomerLimitConfigDO dbCustomerLimitConfig = randomPojo(CrmCustomerLimitConfigDO.class); | |
| 82 | - customerLimitConfigMapper.insert(dbCustomerLimitConfig);// @Sql: 先插入出一条存在的数据 | |
| 83 | - // 准备参数 | |
| 84 | - Long id = dbCustomerLimitConfig.getId(); | |
| 85 | - | |
| 86 | - // 调用 | |
| 87 | - customerLimitConfigService.deleteCustomerLimitConfig(id); | |
| 88 | - // 校验数据不存在了 | |
| 89 | - assertNull(customerLimitConfigMapper.selectById(id)); | |
| 90 | - } | |
| 91 | - | |
| 92 | - @Test | |
| 93 | - public void testDeleteCustomerLimitConfig_notExists() { | |
| 94 | - // 准备参数 | |
| 95 | - Long id = randomLongId(); | |
| 96 | - | |
| 97 | - // 调用, 并断言异常 | |
| 98 | - assertServiceException(() -> customerLimitConfigService.deleteCustomerLimitConfig(id), CUSTOMER_LIMIT_CONFIG_NOT_EXISTS); | |
| 99 | - } | |
| 100 | - | |
| 101 | - @Test | |
| 102 | - @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 | |
| 103 | - public void testGetCustomerLimitConfigPage() { | |
| 104 | - // mock 数据 | |
| 105 | - CrmCustomerLimitConfigDO dbCustomerLimitConfig = randomPojo(CrmCustomerLimitConfigDO.class, o -> { // 等会查询到 | |
| 106 | - }); | |
| 107 | - customerLimitConfigMapper.insert(dbCustomerLimitConfig); | |
| 108 | - // 准备参数 | |
| 109 | - CrmCustomerLimitConfigPageReqVO reqVO = new CrmCustomerLimitConfigPageReqVO(); | |
| 110 | - | |
| 111 | - // 调用 | |
| 112 | - PageResult<CrmCustomerLimitConfigDO> pageResult = customerLimitConfigService.getCustomerLimitConfigPage(reqVO); | |
| 113 | - // 断言 | |
| 114 | - assertEquals(1, pageResult.getTotal()); | |
| 115 | - assertEquals(1, pageResult.getList().size()); | |
| 116 | - assertPojoEquals(dbCustomerLimitConfig, pageResult.getList().get(0)); | |
| 117 | - } | |
| 118 | - | |
| 119 | -} |
yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/receivable/CrmCrmReceivablePlanServiceImplTest.java deleted
| 1 | -package cn.iocoder.yudao.module.crm.service.receivable; | |
| 2 | - | |
| 3 | -import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 4 | -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; | |
| 5 | -import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.plan.CrmReceivablePlanCreateReqVO; | |
| 6 | -import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.plan.CrmReceivablePlanPageReqVO; | |
| 7 | -import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.plan.CrmReceivablePlanUpdateReqVO; | |
| 8 | -import cn.iocoder.yudao.module.crm.dal.dataobject.receivable.CrmReceivablePlanDO; | |
| 9 | -import cn.iocoder.yudao.module.crm.dal.mysql.receivable.CrmReceivablePlanMapper; | |
| 10 | -import jakarta.annotation.Resource; | |
| 11 | -import org.junit.jupiter.api.Disabled; | |
| 12 | -import org.junit.jupiter.api.Test; | |
| 13 | -import org.springframework.context.annotation.Import; | |
| 14 | - | |
| 15 | -import static cn.iocoder.yudao.framework.common.pojo.PageParam.PAGE_SIZE_NONE; | |
| 16 | -import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; | |
| 17 | -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; | |
| 18 | -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; | |
| 19 | -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomLongId; | |
| 20 | -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; | |
| 21 | -import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.RECEIVABLE_PLAN_NOT_EXISTS; | |
| 22 | -import static org.junit.jupiter.api.Assertions.*; | |
| 23 | - | |
| 24 | -// TODO 芋艿:后续,需要补充测试用例 | |
| 25 | - | |
| 26 | -/** | |
| 27 | - * {@link CrmReceivablePlanServiceImpl} 的单元测试类 | |
| 28 | - * | |
| 29 | - * @author 芋道源码 | |
| 30 | - */ | |
| 31 | -@Disabled // TODO 芋艿:后续 fix 补充的单测 | |
| 32 | -@Import(CrmReceivablePlanServiceImpl.class) | |
| 33 | -public class CrmCrmReceivablePlanServiceImplTest extends BaseDbUnitTest { | |
| 34 | - | |
| 35 | - @Resource | |
| 36 | - private CrmReceivablePlanServiceImpl receivablePlanService; | |
| 37 | - | |
| 38 | - @Resource | |
| 39 | - private CrmReceivablePlanMapper crmReceivablePlanMapper; | |
| 40 | - | |
| 41 | - @Test | |
| 42 | - public void testCreateReceivablePlan_success() { | |
| 43 | - // 准备参数 | |
| 44 | - CrmReceivablePlanCreateReqVO reqVO = randomPojo(CrmReceivablePlanCreateReqVO.class); | |
| 45 | - | |
| 46 | - // 调用 | |
| 47 | - Long receivablePlanId = receivablePlanService.createReceivablePlan(reqVO, 1L); | |
| 48 | - // 断言 | |
| 49 | - assertNotNull(receivablePlanId); | |
| 50 | - // 校验记录的属性是否正确 | |
| 51 | - CrmReceivablePlanDO receivablePlan = crmReceivablePlanMapper.selectById(receivablePlanId); | |
| 52 | - assertPojoEquals(reqVO, receivablePlan); | |
| 53 | - } | |
| 54 | - | |
| 55 | - @Test | |
| 56 | - public void testUpdateReceivablePlan_success() { | |
| 57 | - // mock 数据 | |
| 58 | - CrmReceivablePlanDO dbReceivablePlan = randomPojo(CrmReceivablePlanDO.class); | |
| 59 | - crmReceivablePlanMapper.insert(dbReceivablePlan);// @Sql: 先插入出一条存在的数据 | |
| 60 | - // 准备参数 | |
| 61 | - CrmReceivablePlanUpdateReqVO reqVO = randomPojo(CrmReceivablePlanUpdateReqVO.class, o -> { | |
| 62 | - o.setId(dbReceivablePlan.getId()); // 设置更新的 ID | |
| 63 | - }); | |
| 64 | - | |
| 65 | - // 调用 | |
| 66 | - receivablePlanService.updateReceivablePlan(reqVO); | |
| 67 | - // 校验是否更新正确 | |
| 68 | - CrmReceivablePlanDO receivablePlan = crmReceivablePlanMapper.selectById(reqVO.getId()); // 获取最新的 | |
| 69 | - assertPojoEquals(reqVO, receivablePlan); | |
| 70 | - } | |
| 71 | - | |
| 72 | - @Test | |
| 73 | - public void testUpdateReceivablePlan_notExists() { | |
| 74 | - // 准备参数 | |
| 75 | - CrmReceivablePlanUpdateReqVO reqVO = randomPojo(CrmReceivablePlanUpdateReqVO.class); | |
| 76 | - | |
| 77 | - // 调用, 并断言异常 | |
| 78 | - assertServiceException(() -> receivablePlanService.updateReceivablePlan(reqVO), RECEIVABLE_PLAN_NOT_EXISTS); | |
| 79 | - } | |
| 80 | - | |
| 81 | - @Test | |
| 82 | - public void testDeleteReceivablePlan_success() { | |
| 83 | - // mock 数据 | |
| 84 | - CrmReceivablePlanDO dbReceivablePlan = randomPojo(CrmReceivablePlanDO.class); | |
| 85 | - crmReceivablePlanMapper.insert(dbReceivablePlan);// @Sql: 先插入出一条存在的数据 | |
| 86 | - // 准备参数 | |
| 87 | - Long id = dbReceivablePlan.getId(); | |
| 88 | - | |
| 89 | - // 调用 | |
| 90 | - receivablePlanService.deleteReceivablePlan(id); | |
| 91 | - // 校验数据不存在了 | |
| 92 | - assertNull(crmReceivablePlanMapper.selectById(id)); | |
| 93 | - } | |
| 94 | - | |
| 95 | - @Test | |
| 96 | - public void testDeleteReceivablePlan_notExists() { | |
| 97 | - // 准备参数 | |
| 98 | - Long id = randomLongId(); | |
| 99 | - | |
| 100 | - // 调用, 并断言异常 | |
| 101 | - assertServiceException(() -> receivablePlanService.deleteReceivablePlan(id), RECEIVABLE_PLAN_NOT_EXISTS); | |
| 102 | - } | |
| 103 | - | |
| 104 | - @Test | |
| 105 | - @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 | |
| 106 | - public void testGetReceivablePlanPage() { | |
| 107 | - // mock 数据 | |
| 108 | - CrmReceivablePlanDO dbReceivablePlan = randomPojo(CrmReceivablePlanDO.class, o -> { // 等会查询到 | |
| 109 | - o.setPeriod(null); | |
| 110 | - o.setReturnTime(null); | |
| 111 | - o.setRemindDays(null); | |
| 112 | - o.setRemindTime(null); | |
| 113 | - o.setCustomerId(null); | |
| 114 | - o.setContractId(null); | |
| 115 | - o.setOwnerUserId(null); | |
| 116 | - o.setRemark(null); | |
| 117 | - o.setCreateTime(null); | |
| 118 | - }); | |
| 119 | - crmReceivablePlanMapper.insert(dbReceivablePlan); | |
| 120 | - // 测试 customerId 不匹配 | |
| 121 | - crmReceivablePlanMapper.insert(cloneIgnoreId(dbReceivablePlan, o -> o.setCustomerId(null))); | |
| 122 | - // 测试 contractId 不匹配 | |
| 123 | - crmReceivablePlanMapper.insert(cloneIgnoreId(dbReceivablePlan, o -> o.setContractId(null))); | |
| 124 | - // 准备参数 | |
| 125 | - CrmReceivablePlanPageReqVO reqVO = new CrmReceivablePlanPageReqVO(); | |
| 126 | - reqVO.setCustomerId(null); | |
| 127 | - reqVO.setContractId(null); | |
| 128 | - reqVO.setPageSize(PAGE_SIZE_NONE); | |
| 129 | - // 调用 | |
| 130 | - PageResult<CrmReceivablePlanDO> pageResult = receivablePlanService.getReceivablePlanPage(reqVO, 1L); | |
| 131 | - // 断言 | |
| 132 | - assertEquals(1, pageResult.getTotal()); | |
| 133 | - assertEquals(1, pageResult.getList().size()); | |
| 134 | - assertPojoEquals(dbReceivablePlan, pageResult.getList().get(0)); | |
| 135 | - } | |
| 136 | - | |
| 137 | -} |
yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/receivable/CrmCrmReceivableServiceImplTest.java deleted
| 1 | -package cn.iocoder.yudao.module.crm.service.receivable; | |
| 2 | - | |
| 3 | -import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 4 | -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; | |
| 5 | -import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.receivable.CrmReceivableCreateReqVO; | |
| 6 | -import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.receivable.CrmReceivablePageReqVO; | |
| 7 | -import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.receivable.CrmReceivableUpdateReqVO; | |
| 8 | -import cn.iocoder.yudao.module.crm.dal.dataobject.receivable.CrmReceivableDO; | |
| 9 | -import cn.iocoder.yudao.module.crm.dal.mysql.receivable.CrmReceivableMapper; | |
| 10 | -import jakarta.annotation.Resource; | |
| 11 | -import org.junit.jupiter.api.Disabled; | |
| 12 | -import org.junit.jupiter.api.Test; | |
| 13 | -import org.springframework.context.annotation.Import; | |
| 14 | - | |
| 15 | -import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; | |
| 16 | -import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; | |
| 17 | -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; | |
| 18 | -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; | |
| 19 | -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomLongId; | |
| 20 | -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; | |
| 21 | -import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.RECEIVABLE_NOT_EXISTS; | |
| 22 | -import static org.junit.jupiter.api.Assertions.*; | |
| 23 | - | |
| 24 | -// TODO 芋艿:等实现完,在校验下; | |
| 25 | -/** | |
| 26 | - * {@link CrmReceivableServiceImpl} 的单元测试类 | |
| 27 | - * | |
| 28 | - * @author 赤焰 | |
| 29 | - */ | |
| 30 | -@Disabled // TODO 芋艿:后续 fix 补充的单测 | |
| 31 | -@Import(CrmReceivableServiceImpl.class) | |
| 32 | -public class CrmCrmReceivableServiceImplTest extends BaseDbUnitTest { | |
| 33 | - | |
| 34 | - @Resource | |
| 35 | - private CrmReceivableServiceImpl receivableService; | |
| 36 | - | |
| 37 | - @Resource | |
| 38 | - private CrmReceivableMapper crmReceivableMapper; | |
| 39 | - | |
| 40 | - @Test | |
| 41 | - public void testCreateReceivable_success() { | |
| 42 | - // 准备参数 | |
| 43 | - CrmReceivableCreateReqVO reqVO = randomPojo(CrmReceivableCreateReqVO.class); | |
| 44 | - | |
| 45 | - // 调用 | |
| 46 | - Long receivableId = receivableService.createReceivable(reqVO, getLoginUserId()); | |
| 47 | - // 断言 | |
| 48 | - assertNotNull(receivableId); | |
| 49 | - // 校验记录的属性是否正确 | |
| 50 | - CrmReceivableDO receivable = crmReceivableMapper.selectById(receivableId); | |
| 51 | - assertPojoEquals(reqVO, receivable); | |
| 52 | - } | |
| 53 | - | |
| 54 | - @Test | |
| 55 | - public void testUpdateReceivable_success() { | |
| 56 | - // mock 数据 | |
| 57 | - CrmReceivableDO dbReceivable = randomPojo(CrmReceivableDO.class); | |
| 58 | - crmReceivableMapper.insert(dbReceivable);// @Sql: 先插入出一条存在的数据 | |
| 59 | - // 准备参数 | |
| 60 | - CrmReceivableUpdateReqVO reqVO = randomPojo(CrmReceivableUpdateReqVO.class, o -> { | |
| 61 | - o.setId(dbReceivable.getId()); // 设置更新的 ID | |
| 62 | - }); | |
| 63 | - | |
| 64 | - // 调用 | |
| 65 | - receivableService.updateReceivable(reqVO); | |
| 66 | - // 校验是否更新正确 | |
| 67 | - CrmReceivableDO receivable = crmReceivableMapper.selectById(reqVO.getId()); // 获取最新的 | |
| 68 | - assertPojoEquals(reqVO, receivable); | |
| 69 | - } | |
| 70 | - | |
| 71 | - @Test | |
| 72 | - public void testUpdateReceivable_notExists() { | |
| 73 | - // 准备参数 | |
| 74 | - CrmReceivableUpdateReqVO reqVO = randomPojo(CrmReceivableUpdateReqVO.class); | |
| 75 | - | |
| 76 | - // 调用, 并断言异常 | |
| 77 | - assertServiceException(() -> receivableService.updateReceivable(reqVO), RECEIVABLE_NOT_EXISTS); | |
| 78 | - } | |
| 79 | - | |
| 80 | - @Test | |
| 81 | - public void testDeleteReceivable_success() { | |
| 82 | - // mock 数据 | |
| 83 | - CrmReceivableDO dbReceivable = randomPojo(CrmReceivableDO.class); | |
| 84 | - crmReceivableMapper.insert(dbReceivable);// @Sql: 先插入出一条存在的数据 | |
| 85 | - // 准备参数 | |
| 86 | - Long id = dbReceivable.getId(); | |
| 87 | - | |
| 88 | - // 调用 | |
| 89 | - receivableService.deleteReceivable(id); | |
| 90 | - // 校验数据不存在了 | |
| 91 | - assertNull(crmReceivableMapper.selectById(id)); | |
| 92 | - } | |
| 93 | - | |
| 94 | - @Test | |
| 95 | - public void testDeleteReceivable_notExists() { | |
| 96 | - // 准备参数 | |
| 97 | - Long id = randomLongId(); | |
| 98 | - | |
| 99 | - // 调用, 并断言异常 | |
| 100 | - assertServiceException(() -> receivableService.deleteReceivable(id), RECEIVABLE_NOT_EXISTS); | |
| 101 | - } | |
| 102 | - | |
| 103 | - @Test | |
| 104 | - @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 | |
| 105 | - public void testGetReceivablePage() { | |
| 106 | - // mock 数据 | |
| 107 | - CrmReceivableDO dbReceivable = randomPojo(CrmReceivableDO.class, o -> { // 等会查询到 | |
| 108 | - o.setNo(null); | |
| 109 | - o.setPlanId(null); | |
| 110 | - o.setCustomerId(null); | |
| 111 | - o.setContractId(null); | |
| 112 | - o.setProcessInstanceId(null); | |
| 113 | - o.setReturnTime(null); | |
| 114 | - o.setReturnType(null); | |
| 115 | - o.setPrice(null); | |
| 116 | - o.setOwnerUserId(null); | |
| 117 | - o.setSort(null); | |
| 118 | - o.setAuditStatus(null); | |
| 119 | - o.setRemark(null); | |
| 120 | - o.setCreateTime(null); | |
| 121 | - }); | |
| 122 | - crmReceivableMapper.insert(dbReceivable); | |
| 123 | - // 测试 no 不匹配 | |
| 124 | - crmReceivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setNo(null))); | |
| 125 | - // 测试 planId 不匹配 | |
| 126 | - crmReceivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setPlanId(null))); | |
| 127 | - // 测试 customerId 不匹配 | |
| 128 | - crmReceivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setCustomerId(null))); | |
| 129 | - // 准备参数 | |
| 130 | - CrmReceivablePageReqVO reqVO = new CrmReceivablePageReqVO(); | |
| 131 | - reqVO.setNo(null); | |
| 132 | - reqVO.setPlanId(null); | |
| 133 | - reqVO.setCustomerId(null); | |
| 134 | - | |
| 135 | - // 调用 | |
| 136 | - PageResult<CrmReceivableDO> pageResult = receivableService.getReceivablePage(reqVO, 1L); | |
| 137 | - // 断言 | |
| 138 | - assertEquals(1, pageResult.getTotal()); | |
| 139 | - assertEquals(1, pageResult.getList().size()); | |
| 140 | - assertPojoEquals(dbReceivable, pageResult.getList().get(0)); | |
| 141 | - } | |
| 142 | - | |
| 143 | -} |