Commit d0290b88adfa19518aa2e55c906c30275ccf6d83
1 parent
aad85337
紧急修复 支付退款订单 service 单元测试bug
Showing
1 changed file
with
20 additions
and
19 deletions
yudao-admin-server/src/test/java/cn/iocoder/yudao/adminserver/modules/pay/service/refund/PayRefundServiceTest.java
| @@ -11,7 +11,6 @@ import cn.iocoder.yudao.coreservice.modules.pay.enums.order.PayRefundStatusEnum; | @@ -11,7 +11,6 @@ import cn.iocoder.yudao.coreservice.modules.pay.enums.order.PayRefundStatusEnum; | ||
| 11 | import cn.iocoder.yudao.coreservice.modules.pay.enums.order.PayRefundTypeEnum; | 11 | import cn.iocoder.yudao.coreservice.modules.pay.enums.order.PayRefundTypeEnum; |
| 12 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 12 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 13 | import cn.iocoder.yudao.framework.common.util.date.DateUtils; | 13 | import cn.iocoder.yudao.framework.common.util.date.DateUtils; |
| 14 | -import cn.iocoder.yudao.framework.common.util.object.ObjectUtils; | ||
| 15 | import cn.iocoder.yudao.framework.pay.core.enums.PayChannelEnum; | 14 | import cn.iocoder.yudao.framework.pay.core.enums.PayChannelEnum; |
| 16 | import org.junit.jupiter.api.Test; | 15 | import org.junit.jupiter.api.Test; |
| 17 | import org.springframework.context.annotation.Import; | 16 | import org.springframework.context.annotation.Import; |
| @@ -19,10 +18,12 @@ import org.springframework.context.annotation.Import; | @@ -19,10 +18,12 @@ import org.springframework.context.annotation.Import; | ||
| 19 | import javax.annotation.Resource; | 18 | import javax.annotation.Resource; |
| 20 | import java.util.List; | 19 | import java.util.List; |
| 21 | 20 | ||
| 21 | +import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; | ||
| 22 | import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; | 22 | import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; |
| 23 | import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; | 23 | import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; |
| 24 | import static org.junit.jupiter.api.Assertions.assertEquals; | 24 | import static org.junit.jupiter.api.Assertions.assertEquals; |
| 25 | 25 | ||
| 26 | + | ||
| 26 | /** | 27 | /** |
| 27 | * {@link PayRefundServiceImpl} 的单元测试类 | 28 | * {@link PayRefundServiceImpl} 的单元测试类 |
| 28 | * | 29 | * |
| @@ -72,24 +73,24 @@ public class PayRefundServiceTest extends BaseDbUnitTest { | @@ -72,24 +73,24 @@ public class PayRefundServiceTest extends BaseDbUnitTest { | ||
| 72 | }); | 73 | }); |
| 73 | refundMapper.insert(dbRefund); | 74 | refundMapper.insert(dbRefund); |
| 74 | // 测试 reqNo 不匹配 | 75 | // 测试 reqNo 不匹配 |
| 75 | - refundMapper.insert(ObjectUtils.clone(dbRefund, o -> o.setReqNo("RF1111112"))); | 76 | + refundMapper.insert(cloneIgnoreId(dbRefund, o -> o.setReqNo("RF1111112"))); |
| 76 | // 测试 merchantId 不匹配 | 77 | // 测试 merchantId 不匹配 |
| 77 | - refundMapper.insert(ObjectUtils.clone(dbRefund, o -> o.setMerchantId(2L))); | 78 | + refundMapper.insert(cloneIgnoreId(dbRefund, o -> o.setMerchantId(2L))); |
| 78 | // 测试 appId 不匹配 | 79 | // 测试 appId 不匹配 |
| 79 | - refundMapper.insert(ObjectUtils.clone(dbRefund, o -> o.setAppId(2L))); | 80 | + refundMapper.insert(cloneIgnoreId(dbRefund, o -> o.setAppId(2L))); |
| 80 | // 测试 channelCode 不匹配 | 81 | // 测试 channelCode 不匹配 |
| 81 | - refundMapper.insert(ObjectUtils.clone(dbRefund, o -> o.setChannelCode(PayChannelEnum.ALIPAY_APP.getCode()))); | 82 | + refundMapper.insert(cloneIgnoreId(dbRefund, o -> o.setChannelCode(PayChannelEnum.ALIPAY_APP.getCode()))); |
| 82 | // 测试 merchantRefundNo 不匹配 | 83 | // 测试 merchantRefundNo 不匹配 |
| 83 | - refundMapper.insert(ObjectUtils.clone(dbRefund, o -> o.setMerchantRefundNo("MRF1111112"))); | 84 | + refundMapper.insert(cloneIgnoreId(dbRefund, o -> o.setMerchantRefundNo("MRF1111112"))); |
| 84 | // 测试 notifyStatus 不匹配 | 85 | // 测试 notifyStatus 不匹配 |
| 85 | refundMapper.insert( | 86 | refundMapper.insert( |
| 86 | - ObjectUtils.clone(dbRefund, o -> o.setNotifyStatus(PayOrderNotifyStatusEnum.FAILURE.getStatus()))); | 87 | + cloneIgnoreId(dbRefund, o -> o.setNotifyStatus(PayOrderNotifyStatusEnum.FAILURE.getStatus()))); |
| 87 | // 测试 status 不匹配 | 88 | // 测试 status 不匹配 |
| 88 | - refundMapper.insert(ObjectUtils.clone(dbRefund, o -> o.setStatus(PayRefundStatusEnum.CLOSE.getStatus()))); | 89 | + refundMapper.insert(cloneIgnoreId(dbRefund, o -> o.setStatus(PayRefundStatusEnum.CLOSE.getStatus()))); |
| 89 | // 测试 type 不匹配 | 90 | // 测试 type 不匹配 |
| 90 | - refundMapper.insert(ObjectUtils.clone(dbRefund, o -> o.setType(PayRefundTypeEnum.ALL.getStatus()))); | 91 | + refundMapper.insert(cloneIgnoreId(dbRefund, o -> o.setType(PayRefundTypeEnum.ALL.getStatus()))); |
| 91 | // 测试 createTime 不匹配 | 92 | // 测试 createTime 不匹配 |
| 92 | - refundMapper.insert(ObjectUtils.clone(dbRefund, o -> | 93 | + refundMapper.insert(cloneIgnoreId(dbRefund, o -> |
| 93 | o.setCreateTime(DateUtils.buildTime(2022, 1, 1, 10, 10, 10)))); | 94 | o.setCreateTime(DateUtils.buildTime(2022, 1, 1, 10, 10, 10)))); |
| 94 | // 准备参数 | 95 | // 准备参数 |
| 95 | PayRefundPageReqVO reqVO = new PayRefundPageReqVO(); | 96 | PayRefundPageReqVO reqVO = new PayRefundPageReqVO(); |
| @@ -147,24 +148,24 @@ public class PayRefundServiceTest extends BaseDbUnitTest { | @@ -147,24 +148,24 @@ public class PayRefundServiceTest extends BaseDbUnitTest { | ||
| 147 | }); | 148 | }); |
| 148 | refundMapper.insert(dbRefund); | 149 | refundMapper.insert(dbRefund); |
| 149 | // 测试 reqNo 不匹配 | 150 | // 测试 reqNo 不匹配 |
| 150 | - refundMapper.insert(ObjectUtils.clone(dbRefund, o -> o.setReqNo("RF1111112"))); | 151 | + refundMapper.insert(cloneIgnoreId(dbRefund, o -> o.setReqNo("RF1111112"))); |
| 151 | // 测试 merchantId 不匹配 | 152 | // 测试 merchantId 不匹配 |
| 152 | - refundMapper.insert(ObjectUtils.clone(dbRefund, o -> o.setMerchantId(2L))); | 153 | + refundMapper.insert(cloneIgnoreId(dbRefund, o -> o.setMerchantId(2L))); |
| 153 | // 测试 appId 不匹配 | 154 | // 测试 appId 不匹配 |
| 154 | - refundMapper.insert(ObjectUtils.clone(dbRefund, o -> o.setAppId(2L))); | 155 | + refundMapper.insert(cloneIgnoreId(dbRefund, o -> o.setAppId(2L))); |
| 155 | // 测试 channelCode 不匹配 | 156 | // 测试 channelCode 不匹配 |
| 156 | - refundMapper.insert(ObjectUtils.clone(dbRefund, o -> o.setChannelCode(PayChannelEnum.ALIPAY_APP.getCode()))); | 157 | + refundMapper.insert(cloneIgnoreId(dbRefund, o -> o.setChannelCode(PayChannelEnum.ALIPAY_APP.getCode()))); |
| 157 | // 测试 merchantRefundNo 不匹配 | 158 | // 测试 merchantRefundNo 不匹配 |
| 158 | - refundMapper.insert(ObjectUtils.clone(dbRefund, o -> o.setMerchantRefundNo("MRF1111112"))); | 159 | + refundMapper.insert(cloneIgnoreId(dbRefund, o -> o.setMerchantRefundNo("MRF1111112"))); |
| 159 | // 测试 notifyStatus 不匹配 | 160 | // 测试 notifyStatus 不匹配 |
| 160 | refundMapper.insert( | 161 | refundMapper.insert( |
| 161 | - ObjectUtils.clone(dbRefund, o -> o.setNotifyStatus(PayOrderNotifyStatusEnum.FAILURE.getStatus()))); | 162 | + cloneIgnoreId(dbRefund, o -> o.setNotifyStatus(PayOrderNotifyStatusEnum.FAILURE.getStatus()))); |
| 162 | // 测试 status 不匹配 | 163 | // 测试 status 不匹配 |
| 163 | - refundMapper.insert(ObjectUtils.clone(dbRefund, o -> o.setStatus(PayRefundStatusEnum.CLOSE.getStatus()))); | 164 | + refundMapper.insert(cloneIgnoreId(dbRefund, o -> o.setStatus(PayRefundStatusEnum.CLOSE.getStatus()))); |
| 164 | // 测试 type 不匹配 | 165 | // 测试 type 不匹配 |
| 165 | - refundMapper.insert(ObjectUtils.clone(dbRefund, o -> o.setType(PayRefundTypeEnum.ALL.getStatus()))); | 166 | + refundMapper.insert(cloneIgnoreId(dbRefund, o -> o.setType(PayRefundTypeEnum.ALL.getStatus()))); |
| 166 | // 测试 createTime 不匹配 | 167 | // 测试 createTime 不匹配 |
| 167 | - refundMapper.insert(ObjectUtils.clone(dbRefund, o -> | 168 | + refundMapper.insert(cloneIgnoreId(dbRefund, o -> |
| 168 | o.setCreateTime(DateUtils.buildTime(2022, 1, 1, 10, 10, 10)))); | 169 | o.setCreateTime(DateUtils.buildTime(2022, 1, 1, 10, 10, 10)))); |
| 169 | 170 | ||
| 170 | // 准备参数 | 171 | // 准备参数 |