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 | 17 | import org.mockito.ArgumentMatcher; |
| 18 | 18 | import org.mockito.InjectMocks; |
| 19 | 19 | |
| 20 | +import java.util.Collections; | |
| 20 | 21 | import java.util.HashMap; |
| 21 | 22 | import java.util.Map; |
| 22 | 23 | |
| ... | ... | @@ -56,7 +57,7 @@ public class AlipayLitePayClientTest extends AbstractAlipayClientTest { |
| 56 | 57 | when(defaultAlipayClient.execute(argThat(assertRequest(config.getAppId(), null, buyerOpenId)))) |
| 57 | 58 | .thenReturn(response); |
| 58 | 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 | 62 | PayOrderRespDTO resp = client.unifiedOrder(reqDTO); |
| 62 | 63 | |
| ... | ... | @@ -80,7 +81,7 @@ public class AlipayLitePayClientTest extends AbstractAlipayClientTest { |
| 80 | 81 | when(defaultAlipayClient.execute(argThat(assertRequest(config.getAppId(), buyerId, null)))) |
| 81 | 82 | .thenReturn(response); |
| 82 | 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 | 86 | PayOrderRespDTO resp = client.unifiedOrder(reqDTO); |
| 86 | 87 | |
| ... | ... | @@ -98,7 +99,7 @@ public class AlipayLitePayClientTest extends AbstractAlipayClientTest { |
| 98 | 99 | when(defaultAlipayClient.execute(argThat(assertRequest(config.getAppId(), null, buyerOpenId)))) |
| 99 | 100 | .thenReturn(response); |
| 100 | 101 | PayOrderUnifiedReqDTO reqDTO = buildOrderUnifiedReqDTO(randomURL(), randomString(), randomInteger()); |
| 101 | - reqDTO.setChannelExtras(Map.of("openid", buyerOpenId)); | |
| 102 | + reqDTO.setChannelExtras(Collections.singletonMap("openid", buyerOpenId)); | |
| 102 | 103 | |
| 103 | 104 | PayOrderRespDTO resp = client.unifiedOrder(reqDTO); |
| 104 | 105 | |
| ... | ... | @@ -117,7 +118,7 @@ public class AlipayLitePayClientTest extends AbstractAlipayClientTest { |
| 117 | 118 | when(defaultAlipayClient.certificateExecute(argThat(assertRequest(config.getAppId(), null, buyerOpenId)))) |
| 118 | 119 | .thenReturn(response); |
| 119 | 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 | 123 | PayOrderRespDTO resp = client.unifiedOrder(reqDTO); |
| 123 | 124 | |
| ... | ... | @@ -139,7 +140,7 @@ public class AlipayLitePayClientTest extends AbstractAlipayClientTest { |
| 139 | 140 | when(defaultAlipayClient.execute(argThat((ArgumentMatcher<AlipayTradeCreateRequest>) request -> true))) |
| 140 | 141 | .thenReturn(response); |
| 141 | 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 | 145 | PayOrderRespDTO resp = client.unifiedOrder(reqDTO); |
| 145 | 146 | |
| ... | ... | @@ -170,7 +171,7 @@ public class AlipayLitePayClientTest extends AbstractAlipayClientTest { |
| 170 | 171 | when(defaultAlipayClient.execute(argThat((ArgumentMatcher<AlipayTradeCreateRequest>) request -> true))) |
| 171 | 172 | .thenThrow(ServiceExceptionUtil.exception(GlobalErrorCodeConstants.INTERNAL_SERVER_ERROR)); |
| 172 | 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 | 176 | assertThrows(ServiceException.class, () -> client.unifiedOrder(reqDTO)); |
| 176 | 177 | } |
| ... | ... | @@ -181,7 +182,7 @@ public class AlipayLitePayClientTest extends AbstractAlipayClientTest { |
| 181 | 182 | when(defaultAlipayClient.execute(argThat((ArgumentMatcher<AlipayTradeCreateRequest>) request -> true))) |
| 182 | 183 | .thenThrow(new RuntimeException("系统异常")); |
| 183 | 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 | 187 | assertThrows(PayClientException.class, () -> client.unifiedOrder(reqDTO)); |
| 187 | 188 | } | ... | ... |