From d0290b88adfa19518aa2e55c906c30275ccf6d83 Mon Sep 17 00:00:00 2001 From: chen quan <18975233382@163.com> Date: Tue, 21 Dec 2021 17:23:26 +0800 Subject: [PATCH] =?UTF-8?q?=E7=B4=A7=E6=80=A5=E4=BF=AE=E5=A4=8D=20?= =?UTF-8?q?=E6=94=AF=E4=BB=98=E9=80=80=E6=AC=BE=E8=AE=A2=E5=8D=95=20servic?= =?UTF-8?q?e=20=E5=8D=95=E5=85=83=E6=B5=8B=E8=AF=95bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/refund/PayRefundServiceTest.java | 39 ++++++++++--------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/yudao-admin-server/src/test/java/cn/iocoder/yudao/adminserver/modules/pay/service/refund/PayRefundServiceTest.java b/yudao-admin-server/src/test/java/cn/iocoder/yudao/adminserver/modules/pay/service/refund/PayRefundServiceTest.java index 29035a3bc..d60c6fc59 100755 --- a/yudao-admin-server/src/test/java/cn/iocoder/yudao/adminserver/modules/pay/service/refund/PayRefundServiceTest.java +++ b/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; import cn.iocoder.yudao.coreservice.modules.pay.enums.order.PayRefundTypeEnum; import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.util.date.DateUtils; -import cn.iocoder.yudao.framework.common.util.object.ObjectUtils; import cn.iocoder.yudao.framework.pay.core.enums.PayChannelEnum; import org.junit.jupiter.api.Test; import org.springframework.context.annotation.Import; @@ -19,10 +18,12 @@ import org.springframework.context.annotation.Import; import javax.annotation.Resource; import java.util.List; +import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; import static org.junit.jupiter.api.Assertions.assertEquals; + /** * {@link PayRefundServiceImpl} 的单元测试类 * @@ -72,24 +73,24 @@ public class PayRefundServiceTest extends BaseDbUnitTest { }); refundMapper.insert(dbRefund); // 测试 reqNo 不匹配 - refundMapper.insert(ObjectUtils.clone(dbRefund, o -> o.setReqNo("RF1111112"))); + refundMapper.insert(cloneIgnoreId(dbRefund, o -> o.setReqNo("RF1111112"))); // 测试 merchantId 不匹配 - refundMapper.insert(ObjectUtils.clone(dbRefund, o -> o.setMerchantId(2L))); + refundMapper.insert(cloneIgnoreId(dbRefund, o -> o.setMerchantId(2L))); // 测试 appId 不匹配 - refundMapper.insert(ObjectUtils.clone(dbRefund, o -> o.setAppId(2L))); + refundMapper.insert(cloneIgnoreId(dbRefund, o -> o.setAppId(2L))); // 测试 channelCode 不匹配 - refundMapper.insert(ObjectUtils.clone(dbRefund, o -> o.setChannelCode(PayChannelEnum.ALIPAY_APP.getCode()))); + refundMapper.insert(cloneIgnoreId(dbRefund, o -> o.setChannelCode(PayChannelEnum.ALIPAY_APP.getCode()))); // 测试 merchantRefundNo 不匹配 - refundMapper.insert(ObjectUtils.clone(dbRefund, o -> o.setMerchantRefundNo("MRF1111112"))); + refundMapper.insert(cloneIgnoreId(dbRefund, o -> o.setMerchantRefundNo("MRF1111112"))); // 测试 notifyStatus 不匹配 refundMapper.insert( - ObjectUtils.clone(dbRefund, o -> o.setNotifyStatus(PayOrderNotifyStatusEnum.FAILURE.getStatus()))); + cloneIgnoreId(dbRefund, o -> o.setNotifyStatus(PayOrderNotifyStatusEnum.FAILURE.getStatus()))); // 测试 status 不匹配 - refundMapper.insert(ObjectUtils.clone(dbRefund, o -> o.setStatus(PayRefundStatusEnum.CLOSE.getStatus()))); + refundMapper.insert(cloneIgnoreId(dbRefund, o -> o.setStatus(PayRefundStatusEnum.CLOSE.getStatus()))); // 测试 type 不匹配 - refundMapper.insert(ObjectUtils.clone(dbRefund, o -> o.setType(PayRefundTypeEnum.ALL.getStatus()))); + refundMapper.insert(cloneIgnoreId(dbRefund, o -> o.setType(PayRefundTypeEnum.ALL.getStatus()))); // 测试 createTime 不匹配 - refundMapper.insert(ObjectUtils.clone(dbRefund, o -> + refundMapper.insert(cloneIgnoreId(dbRefund, o -> o.setCreateTime(DateUtils.buildTime(2022, 1, 1, 10, 10, 10)))); // 准备参数 PayRefundPageReqVO reqVO = new PayRefundPageReqVO(); @@ -147,24 +148,24 @@ public class PayRefundServiceTest extends BaseDbUnitTest { }); refundMapper.insert(dbRefund); // 测试 reqNo 不匹配 - refundMapper.insert(ObjectUtils.clone(dbRefund, o -> o.setReqNo("RF1111112"))); + refundMapper.insert(cloneIgnoreId(dbRefund, o -> o.setReqNo("RF1111112"))); // 测试 merchantId 不匹配 - refundMapper.insert(ObjectUtils.clone(dbRefund, o -> o.setMerchantId(2L))); + refundMapper.insert(cloneIgnoreId(dbRefund, o -> o.setMerchantId(2L))); // 测试 appId 不匹配 - refundMapper.insert(ObjectUtils.clone(dbRefund, o -> o.setAppId(2L))); + refundMapper.insert(cloneIgnoreId(dbRefund, o -> o.setAppId(2L))); // 测试 channelCode 不匹配 - refundMapper.insert(ObjectUtils.clone(dbRefund, o -> o.setChannelCode(PayChannelEnum.ALIPAY_APP.getCode()))); + refundMapper.insert(cloneIgnoreId(dbRefund, o -> o.setChannelCode(PayChannelEnum.ALIPAY_APP.getCode()))); // 测试 merchantRefundNo 不匹配 - refundMapper.insert(ObjectUtils.clone(dbRefund, o -> o.setMerchantRefundNo("MRF1111112"))); + refundMapper.insert(cloneIgnoreId(dbRefund, o -> o.setMerchantRefundNo("MRF1111112"))); // 测试 notifyStatus 不匹配 refundMapper.insert( - ObjectUtils.clone(dbRefund, o -> o.setNotifyStatus(PayOrderNotifyStatusEnum.FAILURE.getStatus()))); + cloneIgnoreId(dbRefund, o -> o.setNotifyStatus(PayOrderNotifyStatusEnum.FAILURE.getStatus()))); // 测试 status 不匹配 - refundMapper.insert(ObjectUtils.clone(dbRefund, o -> o.setStatus(PayRefundStatusEnum.CLOSE.getStatus()))); + refundMapper.insert(cloneIgnoreId(dbRefund, o -> o.setStatus(PayRefundStatusEnum.CLOSE.getStatus()))); // 测试 type 不匹配 - refundMapper.insert(ObjectUtils.clone(dbRefund, o -> o.setType(PayRefundTypeEnum.ALL.getStatus()))); + refundMapper.insert(cloneIgnoreId(dbRefund, o -> o.setType(PayRefundTypeEnum.ALL.getStatus()))); // 测试 createTime 不匹配 - refundMapper.insert(ObjectUtils.clone(dbRefund, o -> + refundMapper.insert(cloneIgnoreId(dbRefund, o -> o.setCreateTime(DateUtils.buildTime(2022, 1, 1, 10, 10, 10)))); // 准备参数