mirror of
https://gitee.com/hhyykk/ipms-sjy.git
synced 2025-08-06 22:31:53 +08:00
【代码优化】SYSTEM:七牛云短信的接入
This commit is contained in:
@@ -29,6 +29,7 @@ import static org.mockito.Mockito.mockStatic;
|
||||
* @author scholar
|
||||
*/
|
||||
public class QiniuSmsClientTest extends BaseMockitoUnitTest {
|
||||
|
||||
private final SmsChannelProperties properties = new SmsChannelProperties()
|
||||
.setApiKey(randomString())// 随机一个 apiKey,避免构建报错
|
||||
.setApiSecret(randomString()) // 随机一个 apiSecret,避免构建报错
|
||||
@@ -37,12 +38,6 @@ public class QiniuSmsClientTest extends BaseMockitoUnitTest {
|
||||
@InjectMocks
|
||||
private QiniuSmsClient smsClient = new QiniuSmsClient(properties);
|
||||
|
||||
@Test
|
||||
public void testDoInit() {
|
||||
// 调用
|
||||
smsClient.doInit();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDoSendSms_success() throws Throwable {
|
||||
try (MockedStatic<HttpUtils> httpUtilsMockedStatic = mockStatic(HttpUtils.class)) {
|
||||
@@ -113,12 +108,13 @@ public class QiniuSmsClientTest extends BaseMockitoUnitTest {
|
||||
List<SmsReceiveRespDTO> statuses = smsClient.parseSmsReceiveStatus(text);
|
||||
// 断言
|
||||
assertEquals(1, statuses.size());
|
||||
assertTrue(statuses.getFirst().getSuccess());
|
||||
assertEquals("DELIVRD", statuses.getFirst().getErrorMsg());
|
||||
assertEquals(LocalDateTime.of(2024, 8, 25, 21, 14, 26), statuses.getFirst().getReceiveTime());
|
||||
assertEquals("18881234567", statuses.getFirst().getMobile());
|
||||
assertEquals("10135515063508004167", statuses.getFirst().getSerialNo());
|
||||
assertEquals(123, statuses.getFirst().getLogId());
|
||||
SmsReceiveRespDTO status = statuses.get(0);
|
||||
assertTrue(status.getSuccess());
|
||||
assertEquals("DELIVRD", status.getErrorMsg());
|
||||
assertEquals(LocalDateTime.of(2024, 8, 25, 21, 14, 26), status.getReceiveTime());
|
||||
assertEquals("18881234567", status.getMobile());
|
||||
assertEquals("10135515063508004167", status.getSerialNo());
|
||||
assertEquals(123, status.getLogId());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@@ -1,5 +1,6 @@
|
||||
package cn.iocoder.yudao.module.system.framework.sms.core.client.impl;
|
||||
|
||||
import cn.hutool.core.collection.ListUtil;
|
||||
import cn.iocoder.yudao.framework.common.core.KeyValue;
|
||||
import cn.iocoder.yudao.module.system.framework.sms.core.client.SmsClient;
|
||||
import cn.iocoder.yudao.module.system.framework.sms.core.client.dto.SmsSendRespDTO;
|
||||
@@ -47,7 +48,7 @@ public class SmsClientTests {
|
||||
String mobile = "15601691323";
|
||||
String apiTemplateId = "SMS_207945135";
|
||||
// 调用
|
||||
SmsSendRespDTO sendRespDTO = client.sendSms(sendLogId, mobile, apiTemplateId, List.of(new KeyValue<>("code", "1024")));
|
||||
SmsSendRespDTO sendRespDTO = client.sendSms(sendLogId, mobile, apiTemplateId, ListUtil.of(new KeyValue<>("code", "1024")));
|
||||
// 打印结果
|
||||
System.out.println(sendRespDTO);
|
||||
}
|
||||
@@ -68,7 +69,7 @@ public class SmsClientTests {
|
||||
String mobile = "15601691323";
|
||||
String apiTemplateId = "358212";
|
||||
// 调用
|
||||
SmsSendRespDTO sendRespDTO = client.sendSms(sendLogId, mobile, apiTemplateId, List.of(new KeyValue<>("code", "1024")));
|
||||
SmsSendRespDTO sendRespDTO = client.sendSms(sendLogId, mobile, apiTemplateId, ListUtil.of(new KeyValue<>("code", "1024")));
|
||||
// 打印结果
|
||||
System.out.println(sendRespDTO);
|
||||
}
|
||||
@@ -105,7 +106,7 @@ public class SmsClientTests {
|
||||
Long sendLogId = System.currentTimeMillis();
|
||||
String mobile = "17321315478";
|
||||
String apiTemplateId = "3644cdab863546a3b718d488659a99ef";
|
||||
List<KeyValue<String, Object>> templateParams = List.of(new KeyValue<>("code", "1024"));
|
||||
List<KeyValue<String, Object>> templateParams = ListUtil.of(new KeyValue<>("code", "1024"));
|
||||
// 调用
|
||||
SmsSendRespDTO smsSendRespDTO = client.sendSms(sendLogId, mobile, apiTemplateId, templateParams);
|
||||
// 打印结果
|
||||
@@ -125,7 +126,7 @@ public class SmsClientTests {
|
||||
Long sendLogId = System.currentTimeMillis();
|
||||
String mobile = "17321315478";
|
||||
String apiTemplateId = "3644cdab863546a3b718d488659a99ef";
|
||||
List<KeyValue<String, Object>> templateParams = List.of(new KeyValue<>("code", "1122"));
|
||||
List<KeyValue<String, Object>> templateParams = ListUtil.of(new KeyValue<>("code", "1122"));
|
||||
// 调用
|
||||
SmsSendRespDTO smsSendRespDTO = client.sendSms(sendLogId, mobile, apiTemplateId, templateParams);
|
||||
// 打印结果
|
||||
|
Reference in New Issue
Block a user