Commit c7f0b5c73dd2bbd7daf74fa0e0ea69a972dc9868
1 parent
4c634245
支付宝 H5 Client 单元测试
Showing
3 changed files
with
141 additions
and
34 deletions
yudao-framework/yudao-spring-boot-starter-biz-pay/src/test/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AbstractAlipayClientTest.java
| 1 | package cn.iocoder.yudao.framework.pay.core.client.impl.alipay; | 1 | package cn.iocoder.yudao.framework.pay.core.client.impl.alipay; |
| 2 | 2 | ||
| 3 | import cn.hutool.core.date.LocalDateTimeUtil; | 3 | import cn.hutool.core.date.LocalDateTimeUtil; |
| 4 | +import cn.hutool.core.util.RandomUtil; | ||
| 4 | import cn.hutool.core.util.ReflectUtil; | 5 | import cn.hutool.core.util.ReflectUtil; |
| 5 | import cn.iocoder.yudao.framework.common.exception.ServiceException; | 6 | import cn.iocoder.yudao.framework.common.exception.ServiceException; |
| 6 | import cn.iocoder.yudao.framework.common.exception.enums.GlobalErrorCodeConstants; | 7 | import cn.iocoder.yudao.framework.common.exception.enums.GlobalErrorCodeConstants; |
| 7 | import cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil; | 8 | import cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil; |
| 9 | +import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderUnifiedReqDTO; | ||
| 8 | import cn.iocoder.yudao.framework.pay.core.client.dto.refund.PayRefundRespDTO; | 10 | import cn.iocoder.yudao.framework.pay.core.client.dto.refund.PayRefundRespDTO; |
| 9 | import cn.iocoder.yudao.framework.pay.core.client.dto.refund.PayRefundUnifiedReqDTO; | 11 | import cn.iocoder.yudao.framework.pay.core.client.dto.refund.PayRefundUnifiedReqDTO; |
| 10 | import cn.iocoder.yudao.framework.pay.core.client.exception.PayException; | 12 | import cn.iocoder.yudao.framework.pay.core.client.exception.PayException; |
| @@ -16,6 +18,7 @@ import com.alipay.api.DefaultSigner; | @@ -16,6 +18,7 @@ import com.alipay.api.DefaultSigner; | ||
| 16 | import com.alipay.api.domain.AlipayTradeRefundModel; | 18 | import com.alipay.api.domain.AlipayTradeRefundModel; |
| 17 | import com.alipay.api.request.AlipayTradeRefundRequest; | 19 | import com.alipay.api.request.AlipayTradeRefundRequest; |
| 18 | import com.alipay.api.response.AlipayTradeRefundResponse; | 20 | import com.alipay.api.response.AlipayTradeRefundResponse; |
| 21 | +import org.junit.jupiter.api.BeforeEach; | ||
| 19 | import org.junit.jupiter.api.DisplayName; | 22 | import org.junit.jupiter.api.DisplayName; |
| 20 | import org.junit.jupiter.api.Test; | 23 | import org.junit.jupiter.api.Test; |
| 21 | import org.mockito.ArgumentMatcher; | 24 | import org.mockito.ArgumentMatcher; |
| @@ -52,6 +55,12 @@ public abstract class AbstractAlipayClientTest extends BaseMockitoUnitTest { | @@ -52,6 +55,12 @@ public abstract class AbstractAlipayClientTest extends BaseMockitoUnitTest { | ||
| 52 | 55 | ||
| 53 | private AbstractAlipayPayClient client; | 56 | private AbstractAlipayPayClient client; |
| 54 | 57 | ||
| 58 | + /** | ||
| 59 | + * 子类需要实现该方法. 设置 client 的具体实现 | ||
| 60 | + */ | ||
| 61 | + @BeforeEach | ||
| 62 | + public abstract void setUp(); | ||
| 63 | + | ||
| 55 | public void setClient(AbstractAlipayPayClient client) { | 64 | public void setClient(AbstractAlipayPayClient client) { |
| 56 | this.client = client; | 65 | this.client = client; |
| 57 | } | 66 | } |
| @@ -177,4 +186,28 @@ public abstract class AbstractAlipayClientTest extends BaseMockitoUnitTest { | @@ -177,4 +186,28 @@ public abstract class AbstractAlipayClientTest extends BaseMockitoUnitTest { | ||
| 177 | // 断言 | 186 | // 断言 |
| 178 | assertThrows(PayException.class, () -> client.unifiedRefund(refundReqDTO)); | 187 | assertThrows(PayException.class, () -> client.unifiedRefund(refundReqDTO)); |
| 179 | } | 188 | } |
| 189 | + | ||
| 190 | + @Test | ||
| 191 | + @DisplayName("支付宝 Client 统一下单, 参数校验不通过") | ||
| 192 | + public void test_unified_order_param_validate() { | ||
| 193 | + // 准备请求参数 | ||
| 194 | + String outTradeNo = randomString(); | ||
| 195 | + String notifyUrl = randomURL(); | ||
| 196 | + PayOrderUnifiedReqDTO reqDTO = randomPojo(PayOrderUnifiedReqDTO.class, o -> { | ||
| 197 | + o.setOutTradeNo(outTradeNo); | ||
| 198 | + o.setNotifyUrl(notifyUrl); | ||
| 199 | + }); | ||
| 200 | + // 断言 | ||
| 201 | + assertThrows(ConstraintViolationException.class, () -> client.unifiedOrder(reqDTO)); | ||
| 202 | + } | ||
| 203 | + | ||
| 204 | + protected PayOrderUnifiedReqDTO buildOrderUnifiedReqDTO(String notifyUrl, String outTradeNo, Integer price) { | ||
| 205 | + return randomPojo(PayOrderUnifiedReqDTO.class, o -> { | ||
| 206 | + o.setOutTradeNo(outTradeNo); | ||
| 207 | + o.setNotifyUrl(notifyUrl); | ||
| 208 | + o.setPrice(price); | ||
| 209 | + o.setSubject(RandomUtil.randomString(32)); | ||
| 210 | + o.setBody(RandomUtil.randomString(32)); | ||
| 211 | + }); | ||
| 212 | + } | ||
| 180 | } | 213 | } |
yudao-framework/yudao-spring-boot-starter-biz-pay/src/test/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AlipayQrPayClientTest.java
| 1 | package cn.iocoder.yudao.framework.pay.core.client.impl.alipay; | 1 | package cn.iocoder.yudao.framework.pay.core.client.impl.alipay; |
| 2 | 2 | ||
| 3 | -import cn.hutool.core.util.RandomUtil; | ||
| 4 | import cn.iocoder.yudao.framework.common.exception.ServiceException; | 3 | import cn.iocoder.yudao.framework.common.exception.ServiceException; |
| 5 | import cn.iocoder.yudao.framework.common.exception.enums.GlobalErrorCodeConstants; | 4 | import cn.iocoder.yudao.framework.common.exception.enums.GlobalErrorCodeConstants; |
| 6 | import cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil; | 5 | import cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil; |
| @@ -17,8 +16,6 @@ import org.junit.jupiter.api.Test; | @@ -17,8 +16,6 @@ import org.junit.jupiter.api.Test; | ||
| 17 | import org.mockito.ArgumentMatcher; | 16 | import org.mockito.ArgumentMatcher; |
| 18 | import org.mockito.InjectMocks; | 17 | import org.mockito.InjectMocks; |
| 19 | 18 | ||
| 20 | -import javax.validation.ConstraintViolationException; | ||
| 21 | - | ||
| 22 | import static cn.iocoder.yudao.framework.pay.core.enums.order.PayOrderStatusRespEnum.CLOSED; | 19 | import static cn.iocoder.yudao.framework.pay.core.enums.order.PayOrderStatusRespEnum.CLOSED; |
| 23 | import static cn.iocoder.yudao.framework.pay.core.enums.order.PayOrderStatusRespEnum.WAITING; | 20 | import static cn.iocoder.yudao.framework.pay.core.enums.order.PayOrderStatusRespEnum.WAITING; |
| 24 | import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; | 21 | import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; |
| @@ -42,11 +39,12 @@ public class AlipayQrPayClientTest extends AbstractAlipayClientTest { | @@ -42,11 +39,12 @@ public class AlipayQrPayClientTest extends AbstractAlipayClientTest { | ||
| 42 | } | 39 | } |
| 43 | 40 | ||
| 44 | @Test | 41 | @Test |
| 45 | - @DisplayName("支付包扫描支付下单成功") | 42 | + @DisplayName("支付宝扫描支付下单成功") |
| 46 | public void test_unified_order_success() throws AlipayApiException { | 43 | public void test_unified_order_success() throws AlipayApiException { |
| 47 | // 准备返回对象 | 44 | // 准备返回对象 |
| 48 | String notifyUrl = randomURL(); | 45 | String notifyUrl = randomURL(); |
| 49 | String qrCode = randomString(); | 46 | String qrCode = randomString(); |
| 47 | + Integer price = randomInteger(); | ||
| 50 | AlipayTradePrecreateResponse response = randomPojo(AlipayTradePrecreateResponse.class, o -> { | 48 | AlipayTradePrecreateResponse response = randomPojo(AlipayTradePrecreateResponse.class, o -> { |
| 51 | o.setQrCode(qrCode); | 49 | o.setQrCode(qrCode); |
| 52 | o.setSubCode(""); | 50 | o.setSubCode(""); |
| @@ -58,7 +56,7 @@ public class AlipayQrPayClientTest extends AbstractAlipayClientTest { | @@ -58,7 +56,7 @@ public class AlipayQrPayClientTest extends AbstractAlipayClientTest { | ||
| 58 | }))).thenReturn(response); | 56 | }))).thenReturn(response); |
| 59 | // 准备请求参数 | 57 | // 准备请求参数 |
| 60 | String outTradeNo = randomString(); | 58 | String outTradeNo = randomString(); |
| 61 | - PayOrderUnifiedReqDTO reqDTO = buildOrderUnifiedReqDTO(notifyUrl, outTradeNo); | 59 | + PayOrderUnifiedReqDTO reqDTO = buildOrderUnifiedReqDTO(notifyUrl, outTradeNo, price); |
| 62 | 60 | ||
| 63 | PayOrderRespDTO resp = client.unifiedOrder(reqDTO); | 61 | PayOrderRespDTO resp = client.unifiedOrder(reqDTO); |
| 64 | // 断言 | 62 | // 断言 |
| @@ -70,11 +68,12 @@ public class AlipayQrPayClientTest extends AbstractAlipayClientTest { | @@ -70,11 +68,12 @@ public class AlipayQrPayClientTest extends AbstractAlipayClientTest { | ||
| 70 | } | 68 | } |
| 71 | 69 | ||
| 72 | @Test | 70 | @Test |
| 73 | - @DisplayName("支付包扫描支付,渠道返回失败") | 71 | + @DisplayName("支付宝扫描支付,渠道返回失败") |
| 74 | public void test_unified_order_channel_failed() throws AlipayApiException { | 72 | public void test_unified_order_channel_failed() throws AlipayApiException { |
| 75 | String notifyUrl = randomURL(); | 73 | String notifyUrl = randomURL(); |
| 76 | String subCode = randomString(); | 74 | String subCode = randomString(); |
| 77 | String subMsg = randomString(); | 75 | String subMsg = randomString(); |
| 76 | + Integer price = randomInteger(); | ||
| 78 | AlipayTradePrecreateResponse response = randomPojo(AlipayTradePrecreateResponse.class, o -> { | 77 | AlipayTradePrecreateResponse response = randomPojo(AlipayTradePrecreateResponse.class, o -> { |
| 79 | o.setSubCode(subCode); | 78 | o.setSubCode(subCode); |
| 80 | o.setSubMsg(subMsg); | 79 | o.setSubMsg(subMsg); |
| @@ -86,7 +85,7 @@ public class AlipayQrPayClientTest extends AbstractAlipayClientTest { | @@ -86,7 +85,7 @@ public class AlipayQrPayClientTest extends AbstractAlipayClientTest { | ||
| 86 | }))).thenReturn(response); | 85 | }))).thenReturn(response); |
| 87 | // 准备请求参数 | 86 | // 准备请求参数 |
| 88 | String outTradeNo = randomString(); | 87 | String outTradeNo = randomString(); |
| 89 | - PayOrderUnifiedReqDTO reqDTO = buildOrderUnifiedReqDTO(notifyUrl, outTradeNo); | 88 | + PayOrderUnifiedReqDTO reqDTO = buildOrderUnifiedReqDTO(notifyUrl, outTradeNo, price); |
| 90 | 89 | ||
| 91 | PayOrderRespDTO resp = client.unifiedOrder(reqDTO); | 90 | PayOrderRespDTO resp = client.unifiedOrder(reqDTO); |
| 92 | // 断言 | 91 | // 断言 |
| @@ -97,59 +96,38 @@ public class AlipayQrPayClientTest extends AbstractAlipayClientTest { | @@ -97,59 +96,38 @@ public class AlipayQrPayClientTest extends AbstractAlipayClientTest { | ||
| 97 | } | 96 | } |
| 98 | 97 | ||
| 99 | @Test | 98 | @Test |
| 100 | - @DisplayName("支付包扫描支付,抛出系统异常") | 99 | + @DisplayName("支付宝扫描支付, 抛出系统异常") |
| 101 | public void test_unified_order_throw_pay_exception() throws AlipayApiException { | 100 | public void test_unified_order_throw_pay_exception() throws AlipayApiException { |
| 102 | // 准备请求参数 | 101 | // 准备请求参数 |
| 103 | String outTradeNo = randomString(); | 102 | String outTradeNo = randomString(); |
| 104 | String notifyUrl = randomURL(); | 103 | String notifyUrl = randomURL(); |
| 104 | + Integer price = randomInteger(); | ||
| 105 | // mock | 105 | // mock |
| 106 | when(defaultAlipayClient.execute(argThat((ArgumentMatcher<AlipayTradePrecreateRequest>) request -> { | 106 | when(defaultAlipayClient.execute(argThat((ArgumentMatcher<AlipayTradePrecreateRequest>) request -> { |
| 107 | assertEquals(notifyUrl, request.getNotifyUrl()); | 107 | assertEquals(notifyUrl, request.getNotifyUrl()); |
| 108 | return true; | 108 | return true; |
| 109 | }))).thenThrow(new RuntimeException("系统异常")); | 109 | }))).thenThrow(new RuntimeException("系统异常")); |
| 110 | // 准备请求参数 | 110 | // 准备请求参数 |
| 111 | - PayOrderUnifiedReqDTO reqDTO = buildOrderUnifiedReqDTO(notifyUrl, outTradeNo); | 111 | + PayOrderUnifiedReqDTO reqDTO = buildOrderUnifiedReqDTO(notifyUrl, outTradeNo,price); |
| 112 | // 断言 | 112 | // 断言 |
| 113 | assertThrows(PayException.class, () -> client.unifiedOrder(reqDTO)); | 113 | assertThrows(PayException.class, () -> client.unifiedOrder(reqDTO)); |
| 114 | } | 114 | } |
| 115 | 115 | ||
| 116 | @Test | 116 | @Test |
| 117 | - @DisplayName("支付包扫描支付,抛出业务异常") | 117 | + @DisplayName("支付宝 Client 统一下单,抛出业务异常") |
| 118 | public void test_unified_order_throw_service_exception() throws AlipayApiException { | 118 | public void test_unified_order_throw_service_exception() throws AlipayApiException { |
| 119 | // 准备请求参数 | 119 | // 准备请求参数 |
| 120 | String outTradeNo = randomString(); | 120 | String outTradeNo = randomString(); |
| 121 | String notifyUrl = randomURL(); | 121 | String notifyUrl = randomURL(); |
| 122 | + Integer price = randomInteger(); | ||
| 122 | // mock | 123 | // mock |
| 123 | when(defaultAlipayClient.execute(argThat((ArgumentMatcher<AlipayTradePrecreateRequest>) request -> { | 124 | when(defaultAlipayClient.execute(argThat((ArgumentMatcher<AlipayTradePrecreateRequest>) request -> { |
| 124 | assertEquals(notifyUrl, request.getNotifyUrl()); | 125 | assertEquals(notifyUrl, request.getNotifyUrl()); |
| 125 | return true; | 126 | return true; |
| 126 | }))).thenThrow(ServiceExceptionUtil.exception(GlobalErrorCodeConstants.INTERNAL_SERVER_ERROR)); | 127 | }))).thenThrow(ServiceExceptionUtil.exception(GlobalErrorCodeConstants.INTERNAL_SERVER_ERROR)); |
| 127 | // 准备请求参数 | 128 | // 准备请求参数 |
| 128 | - PayOrderUnifiedReqDTO reqDTO = buildOrderUnifiedReqDTO(notifyUrl, outTradeNo); | 129 | + PayOrderUnifiedReqDTO reqDTO = buildOrderUnifiedReqDTO(notifyUrl, outTradeNo, price); |
| 129 | // 断言 | 130 | // 断言 |
| 130 | assertThrows(ServiceException.class, () -> client.unifiedOrder(reqDTO)); | 131 | assertThrows(ServiceException.class, () -> client.unifiedOrder(reqDTO)); |
| 131 | } | 132 | } |
| 132 | - | ||
| 133 | - @Test | ||
| 134 | - @DisplayName("支付包扫描支付,参数校验不通过") | ||
| 135 | - public void test_unified_order_param_validate() { | ||
| 136 | - // 准备请求参数 | ||
| 137 | - String outTradeNo = randomString(); | ||
| 138 | - String notifyUrl = randomURL(); | ||
| 139 | - PayOrderUnifiedReqDTO reqDTO = randomPojo(PayOrderUnifiedReqDTO.class, o -> { | ||
| 140 | - o.setOutTradeNo(outTradeNo); | ||
| 141 | - o.setNotifyUrl(notifyUrl); | ||
| 142 | - }); | ||
| 143 | - // 断言 | ||
| 144 | - assertThrows(ConstraintViolationException.class, () -> client.unifiedOrder(reqDTO)); | ||
| 145 | - } | ||
| 146 | - | ||
| 147 | - private PayOrderUnifiedReqDTO buildOrderUnifiedReqDTO(String notifyUrl, String outTradeNo) { | ||
| 148 | - return randomPojo(PayOrderUnifiedReqDTO.class, o -> { | ||
| 149 | - o.setOutTradeNo(outTradeNo); | ||
| 150 | - o.setNotifyUrl(notifyUrl); | ||
| 151 | - o.setSubject(RandomUtil.randomString(32)); | ||
| 152 | - o.setBody(RandomUtil.randomString(32)); | ||
| 153 | - }); | ||
| 154 | - } | ||
| 155 | } | 133 | } |
yudao-framework/yudao-spring-boot-starter-biz-pay/src/test/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AlipayWapPayClientTest.java
0 → 100644
| 1 | +package cn.iocoder.yudao.framework.pay.core.client.impl.alipay; | ||
| 2 | + | ||
| 3 | +import cn.hutool.http.Method; | ||
| 4 | +import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderRespDTO; | ||
| 5 | +import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderUnifiedReqDTO; | ||
| 6 | +import cn.iocoder.yudao.framework.pay.core.enums.order.PayOrderDisplayModeEnum; | ||
| 7 | +import com.alipay.api.AlipayApiException; | ||
| 8 | +import com.alipay.api.domain.AlipayTradeWapPayModel; | ||
| 9 | +import com.alipay.api.request.AlipayTradeWapPayRequest; | ||
| 10 | +import com.alipay.api.response.AlipayTradeWapPayResponse; | ||
| 11 | +import org.junit.jupiter.api.BeforeEach; | ||
| 12 | +import org.junit.jupiter.api.DisplayName; | ||
| 13 | +import org.junit.jupiter.api.Test; | ||
| 14 | +import org.mockito.ArgumentMatcher; | ||
| 15 | +import org.mockito.InjectMocks; | ||
| 16 | + | ||
| 17 | +import static cn.iocoder.yudao.framework.pay.core.enums.order.PayOrderStatusRespEnum.CLOSED; | ||
| 18 | +import static cn.iocoder.yudao.framework.pay.core.enums.order.PayOrderStatusRespEnum.WAITING; | ||
| 19 | +import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; | ||
| 20 | +import static org.junit.jupiter.api.Assertions.*; | ||
| 21 | +import static org.junit.jupiter.api.Assertions.assertEquals; | ||
| 22 | +import static org.mockito.ArgumentMatchers.argThat; | ||
| 23 | +import static org.mockito.ArgumentMatchers.eq; | ||
| 24 | +import static org.mockito.Mockito.when; | ||
| 25 | + | ||
| 26 | +/** | ||
| 27 | + * {@link AlipayWapPayClient} 单元测试 | ||
| 28 | + * | ||
| 29 | + * @author jason | ||
| 30 | + */ | ||
| 31 | +public class AlipayWapPayClientTest extends AbstractAlipayClientTest { | ||
| 32 | + | ||
| 33 | + /** | ||
| 34 | + * 支付宝 H5 支付 Client | ||
| 35 | + */ | ||
| 36 | + @InjectMocks | ||
| 37 | + private AlipayWapPayClient client = new AlipayWapPayClient(randomLongId(), config); | ||
| 38 | + | ||
| 39 | + @BeforeEach | ||
| 40 | + public void setUp() { | ||
| 41 | + setClient(client); | ||
| 42 | + } | ||
| 43 | + | ||
| 44 | + @Test | ||
| 45 | + @DisplayName("支付宝 H5 支付下单成功") | ||
| 46 | + public void test_unified_order_success() throws AlipayApiException { | ||
| 47 | + // 准备响应对象 | ||
| 48 | + String h5Body = randomString(); | ||
| 49 | + Integer price = randomInteger(); | ||
| 50 | + AlipayTradeWapPayResponse response = randomPojo(AlipayTradeWapPayResponse.class, o -> { | ||
| 51 | + o.setSubCode(""); | ||
| 52 | + o.setBody(h5Body); | ||
| 53 | + }); | ||
| 54 | + String notifyUrl = randomURL(); | ||
| 55 | + // mock | ||
| 56 | + when(defaultAlipayClient.pageExecute(argThat((ArgumentMatcher<AlipayTradeWapPayRequest>) request -> { | ||
| 57 | + assertInstanceOf(AlipayTradeWapPayModel.class, request.getBizModel()); | ||
| 58 | + AlipayTradeWapPayModel bizModel = (AlipayTradeWapPayModel) request.getBizModel(); | ||
| 59 | + assertEquals(String.valueOf(price / 100.0), bizModel.getTotalAmount()); | ||
| 60 | + assertEquals(notifyUrl, request.getNotifyUrl()); | ||
| 61 | + return true; | ||
| 62 | + }), eq(Method.GET.name()))).thenReturn(response); | ||
| 63 | + | ||
| 64 | + String outTradeNo = randomString(); | ||
| 65 | + PayOrderUnifiedReqDTO reqDTO = buildOrderUnifiedReqDTO(notifyUrl, outTradeNo, price); | ||
| 66 | + PayOrderRespDTO resp = client.unifiedOrder(reqDTO); | ||
| 67 | + assertEquals(WAITING.getStatus(), resp.getStatus()); | ||
| 68 | + assertEquals(PayOrderDisplayModeEnum.URL.getMode(), resp.getDisplayMode()); | ||
| 69 | + assertEquals(outTradeNo, resp.getOutTradeNo()); | ||
| 70 | + assertEquals(h5Body, resp.getDisplayContent()); | ||
| 71 | + assertSame(response, resp.getRawData()); | ||
| 72 | + } | ||
| 73 | + | ||
| 74 | + @Test | ||
| 75 | + @DisplayName("支付宝 H5 支付,渠道返回失败") | ||
| 76 | + public void test_unified_order_channel_failed() throws AlipayApiException { | ||
| 77 | + // 准备响应对象 | ||
| 78 | + String subCode = randomString(); | ||
| 79 | + String subMsg = randomString(); | ||
| 80 | + AlipayTradeWapPayResponse response = randomPojo(AlipayTradeWapPayResponse.class, o -> { | ||
| 81 | + o.setSubCode(subCode); | ||
| 82 | + o.setSubMsg(subMsg); | ||
| 83 | + }); | ||
| 84 | + // mock | ||
| 85 | + when(defaultAlipayClient.pageExecute(argThat((ArgumentMatcher<AlipayTradeWapPayRequest>) request -> true), | ||
| 86 | + eq(Method.GET.name()))).thenReturn(response); | ||
| 87 | + PayOrderUnifiedReqDTO reqDTO = buildOrderUnifiedReqDTO(randomURL(), randomString(), randomInteger()); | ||
| 88 | + | ||
| 89 | + PayOrderRespDTO resp = client.unifiedOrder(reqDTO); | ||
| 90 | + // 断言 | ||
| 91 | + assertEquals(CLOSED.getStatus(), resp.getStatus()); | ||
| 92 | + assertEquals(subCode, resp.getChannelErrorCode()); | ||
| 93 | + assertEquals(subMsg, resp.getChannelErrorMsg()); | ||
| 94 | + assertSame(response, resp.getRawData()); | ||
| 95 | + } | ||
| 96 | +} |