Commit 6188a22c0d83ff4638377afcdb1502288b51dd42
1 parent
bebbad3c
feat:增强对 JDK8 的兼容性
Showing
1 changed file
with
8 additions
and
7 deletions
yudao-module-pay/src/test/java/cn/iocoder/yudao/module/pay/framework/pay/core/client/impl/alipay/AlipayLitePayClientTest.java
| @@ -17,6 +17,7 @@ import org.junit.jupiter.api.Test; | @@ -17,6 +17,7 @@ import org.junit.jupiter.api.Test; | ||
| 17 | import org.mockito.ArgumentMatcher; | 17 | import org.mockito.ArgumentMatcher; |
| 18 | import org.mockito.InjectMocks; | 18 | import org.mockito.InjectMocks; |
| 19 | 19 | ||
| 20 | +import java.util.Collections; | ||
| 20 | import java.util.HashMap; | 21 | import java.util.HashMap; |
| 21 | import java.util.Map; | 22 | import java.util.Map; |
| 22 | 23 | ||
| @@ -56,7 +57,7 @@ public class AlipayLitePayClientTest extends AbstractAlipayClientTest { | @@ -56,7 +57,7 @@ public class AlipayLitePayClientTest extends AbstractAlipayClientTest { | ||
| 56 | when(defaultAlipayClient.execute(argThat(assertRequest(config.getAppId(), null, buyerOpenId)))) | 57 | when(defaultAlipayClient.execute(argThat(assertRequest(config.getAppId(), null, buyerOpenId)))) |
| 57 | .thenReturn(response); | 58 | .thenReturn(response); |
| 58 | PayOrderUnifiedReqDTO reqDTO = buildOrderUnifiedReqDTO(randomURL(), randomString(), randomInteger()); | 59 | PayOrderUnifiedReqDTO reqDTO = buildOrderUnifiedReqDTO(randomURL(), randomString(), randomInteger()); |
| 59 | - reqDTO.setChannelExtras(Map.of(AlipayLitePayClient.BUYER_OPEN_ID_KEY, buyerOpenId)); | 60 | + reqDTO.setChannelExtras(Collections.singletonMap(AlipayLitePayClient.BUYER_OPEN_ID_KEY, buyerOpenId)); |
| 60 | 61 | ||
| 61 | PayOrderRespDTO resp = client.unifiedOrder(reqDTO); | 62 | PayOrderRespDTO resp = client.unifiedOrder(reqDTO); |
| 62 | 63 | ||
| @@ -80,7 +81,7 @@ public class AlipayLitePayClientTest extends AbstractAlipayClientTest { | @@ -80,7 +81,7 @@ public class AlipayLitePayClientTest extends AbstractAlipayClientTest { | ||
| 80 | when(defaultAlipayClient.execute(argThat(assertRequest(config.getAppId(), buyerId, null)))) | 81 | when(defaultAlipayClient.execute(argThat(assertRequest(config.getAppId(), buyerId, null)))) |
| 81 | .thenReturn(response); | 82 | .thenReturn(response); |
| 82 | PayOrderUnifiedReqDTO reqDTO = buildOrderUnifiedReqDTO(randomURL(), randomString(), randomInteger()); | 83 | PayOrderUnifiedReqDTO reqDTO = buildOrderUnifiedReqDTO(randomURL(), randomString(), randomInteger()); |
| 83 | - reqDTO.setChannelExtras(Map.of(AlipayLitePayClient.BUYER_ID_KEY, buyerId)); | 84 | + reqDTO.setChannelExtras(Collections.singletonMap(AlipayLitePayClient.BUYER_ID_KEY, buyerId)); |
| 84 | 85 | ||
| 85 | PayOrderRespDTO resp = client.unifiedOrder(reqDTO); | 86 | PayOrderRespDTO resp = client.unifiedOrder(reqDTO); |
| 86 | 87 | ||
| @@ -98,7 +99,7 @@ public class AlipayLitePayClientTest extends AbstractAlipayClientTest { | @@ -98,7 +99,7 @@ public class AlipayLitePayClientTest extends AbstractAlipayClientTest { | ||
| 98 | when(defaultAlipayClient.execute(argThat(assertRequest(config.getAppId(), null, buyerOpenId)))) | 99 | when(defaultAlipayClient.execute(argThat(assertRequest(config.getAppId(), null, buyerOpenId)))) |
| 99 | .thenReturn(response); | 100 | .thenReturn(response); |
| 100 | PayOrderUnifiedReqDTO reqDTO = buildOrderUnifiedReqDTO(randomURL(), randomString(), randomInteger()); | 101 | PayOrderUnifiedReqDTO reqDTO = buildOrderUnifiedReqDTO(randomURL(), randomString(), randomInteger()); |
| 101 | - reqDTO.setChannelExtras(Map.of("openid", buyerOpenId)); | 102 | + reqDTO.setChannelExtras(Collections.singletonMap("openid", buyerOpenId)); |
| 102 | 103 | ||
| 103 | PayOrderRespDTO resp = client.unifiedOrder(reqDTO); | 104 | PayOrderRespDTO resp = client.unifiedOrder(reqDTO); |
| 104 | 105 | ||
| @@ -117,7 +118,7 @@ public class AlipayLitePayClientTest extends AbstractAlipayClientTest { | @@ -117,7 +118,7 @@ public class AlipayLitePayClientTest extends AbstractAlipayClientTest { | ||
| 117 | when(defaultAlipayClient.certificateExecute(argThat(assertRequest(config.getAppId(), null, buyerOpenId)))) | 118 | when(defaultAlipayClient.certificateExecute(argThat(assertRequest(config.getAppId(), null, buyerOpenId)))) |
| 118 | .thenReturn(response); | 119 | .thenReturn(response); |
| 119 | PayOrderUnifiedReqDTO reqDTO = buildOrderUnifiedReqDTO(randomURL(), randomString(), randomInteger()); | 120 | PayOrderUnifiedReqDTO reqDTO = buildOrderUnifiedReqDTO(randomURL(), randomString(), randomInteger()); |
| 120 | - reqDTO.setChannelExtras(Map.of(AlipayLitePayClient.BUYER_OPEN_ID_KEY, buyerOpenId)); | 121 | + reqDTO.setChannelExtras(Collections.singletonMap(AlipayLitePayClient.BUYER_OPEN_ID_KEY, buyerOpenId)); |
| 121 | 122 | ||
| 122 | PayOrderRespDTO resp = client.unifiedOrder(reqDTO); | 123 | PayOrderRespDTO resp = client.unifiedOrder(reqDTO); |
| 123 | 124 | ||
| @@ -139,7 +140,7 @@ public class AlipayLitePayClientTest extends AbstractAlipayClientTest { | @@ -139,7 +140,7 @@ public class AlipayLitePayClientTest extends AbstractAlipayClientTest { | ||
| 139 | when(defaultAlipayClient.execute(argThat((ArgumentMatcher<AlipayTradeCreateRequest>) request -> true))) | 140 | when(defaultAlipayClient.execute(argThat((ArgumentMatcher<AlipayTradeCreateRequest>) request -> true))) |
| 140 | .thenReturn(response); | 141 | .thenReturn(response); |
| 141 | PayOrderUnifiedReqDTO reqDTO = buildOrderUnifiedReqDTO(randomURL(), randomString(), randomInteger()); | 142 | PayOrderUnifiedReqDTO reqDTO = buildOrderUnifiedReqDTO(randomURL(), randomString(), randomInteger()); |
| 142 | - reqDTO.setChannelExtras(Map.of(AlipayLitePayClient.BUYER_OPEN_ID_KEY, randomString())); | 143 | + reqDTO.setChannelExtras(Collections.singletonMap(AlipayLitePayClient.BUYER_OPEN_ID_KEY, randomString())); |
| 143 | 144 | ||
| 144 | PayOrderRespDTO resp = client.unifiedOrder(reqDTO); | 145 | PayOrderRespDTO resp = client.unifiedOrder(reqDTO); |
| 145 | 146 | ||
| @@ -170,7 +171,7 @@ public class AlipayLitePayClientTest extends AbstractAlipayClientTest { | @@ -170,7 +171,7 @@ public class AlipayLitePayClientTest extends AbstractAlipayClientTest { | ||
| 170 | when(defaultAlipayClient.execute(argThat((ArgumentMatcher<AlipayTradeCreateRequest>) request -> true))) | 171 | when(defaultAlipayClient.execute(argThat((ArgumentMatcher<AlipayTradeCreateRequest>) request -> true))) |
| 171 | .thenThrow(ServiceExceptionUtil.exception(GlobalErrorCodeConstants.INTERNAL_SERVER_ERROR)); | 172 | .thenThrow(ServiceExceptionUtil.exception(GlobalErrorCodeConstants.INTERNAL_SERVER_ERROR)); |
| 172 | PayOrderUnifiedReqDTO reqDTO = buildOrderUnifiedReqDTO(randomURL(), randomString(), randomInteger()); | 173 | PayOrderUnifiedReqDTO reqDTO = buildOrderUnifiedReqDTO(randomURL(), randomString(), randomInteger()); |
| 173 | - reqDTO.setChannelExtras(Map.of(AlipayLitePayClient.BUYER_OPEN_ID_KEY, randomString())); | 174 | + reqDTO.setChannelExtras(Collections.singletonMap(AlipayLitePayClient.BUYER_OPEN_ID_KEY, randomString())); |
| 174 | 175 | ||
| 175 | assertThrows(ServiceException.class, () -> client.unifiedOrder(reqDTO)); | 176 | assertThrows(ServiceException.class, () -> client.unifiedOrder(reqDTO)); |
| 176 | } | 177 | } |
| @@ -181,7 +182,7 @@ public class AlipayLitePayClientTest extends AbstractAlipayClientTest { | @@ -181,7 +182,7 @@ public class AlipayLitePayClientTest extends AbstractAlipayClientTest { | ||
| 181 | when(defaultAlipayClient.execute(argThat((ArgumentMatcher<AlipayTradeCreateRequest>) request -> true))) | 182 | when(defaultAlipayClient.execute(argThat((ArgumentMatcher<AlipayTradeCreateRequest>) request -> true))) |
| 182 | .thenThrow(new RuntimeException("系统异常")); | 183 | .thenThrow(new RuntimeException("系统异常")); |
| 183 | PayOrderUnifiedReqDTO reqDTO = buildOrderUnifiedReqDTO(randomURL(), randomString(), randomInteger()); | 184 | PayOrderUnifiedReqDTO reqDTO = buildOrderUnifiedReqDTO(randomURL(), randomString(), randomInteger()); |
| 184 | - reqDTO.setChannelExtras(Map.of(AlipayLitePayClient.BUYER_OPEN_ID_KEY, randomString())); | 185 | + reqDTO.setChannelExtras(Collections.singletonMap(AlipayLitePayClient.BUYER_OPEN_ID_KEY, randomString())); |
| 185 | 186 | ||
| 186 | assertThrows(PayClientException.class, () -> client.unifiedOrder(reqDTO)); | 187 | assertThrows(PayClientException.class, () -> client.unifiedOrder(reqDTO)); |
| 187 | } | 188 | } |