- 各短信平台兼容问题,放弃 sign 和 template 模板审核过程
- 增加短信类型 - 云片ok - 阿里云 未完成
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
package cn.iocoder.mall.admin.client;
|
||||
|
||||
import cn.iocoder.mall.admin.SystemApplicationTest;
|
||||
import com.aliyuncs.CommonRequest;
|
||||
import com.aliyuncs.CommonResponse;
|
||||
import com.aliyuncs.DefaultAcsClient;
|
||||
import com.aliyuncs.IAcsClient;
|
||||
import com.aliyuncs.exceptions.ClientException;
|
||||
import com.aliyuncs.exceptions.ServerException;
|
||||
import com.aliyuncs.http.MethodType;
|
||||
import com.aliyuncs.profile.DefaultProfile;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import org.assertj.core.util.Lists;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 短信 sms client test
|
||||
*
|
||||
* @author Sin
|
||||
* @time 2019/5/25 12:46 PM
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(classes = SystemApplicationTest.class)
|
||||
public class SmsYunPianClientTest {
|
||||
|
||||
@Autowired
|
||||
private SmsYunPianClient smsYunPianClient;
|
||||
|
||||
private String sign = null;
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
sign = "悦跑运动";
|
||||
}
|
||||
|
||||
@Test
|
||||
public void sendMobileTest() {
|
||||
String mobile = "13302926050";
|
||||
String template = "您的验证码是#code#,打死也不告诉别人哦。";
|
||||
smsYunPianClient.singleSend(mobile, sign, template, ImmutableMap.of("code", "1111"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void batchSendTest() {
|
||||
String mobile = "13302926050";
|
||||
String template = "您的验证码是#code#,打死也不告诉别人哦。";
|
||||
smsYunPianClient.batchSend(Lists.newArrayList(mobile), sign, template, ImmutableMap.of("code", "2222"));
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,16 @@
|
||||
package cn.iocoder.mall.admin.service;
|
||||
|
||||
import cn.iocoder.common.framework.exception.ServiceException;
|
||||
import cn.iocoder.mall.admin.SystemApplicationTest;
|
||||
import cn.iocoder.mall.admin.api.SmsService;
|
||||
import cn.iocoder.mall.admin.api.bo.sms.SmsSignBO;
|
||||
import cn.iocoder.mall.admin.api.bo.sms.SmsTemplateBO;
|
||||
import cn.iocoder.mall.admin.api.constant.SmsPlatformEnum;
|
||||
import cn.iocoder.mall.admin.api.constant.SmsTypeEnum;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import org.assertj.core.util.Lists;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
@@ -21,55 +27,57 @@ import org.springframework.test.context.junit4.SpringRunner;
|
||||
public class SmsServiceImplTest {
|
||||
|
||||
@Autowired
|
||||
private SmsServiceImpl smsService;
|
||||
private SmsService smsService;
|
||||
|
||||
@Test
|
||||
public void createSignTest() {
|
||||
smsService.createSign("测试签名1");
|
||||
// smsService.createSign("悦跑会");
|
||||
smsService.createSign("悦跑运动", SmsPlatformEnum.YunPian.getValue());
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getSignTest() {
|
||||
SmsSignBO smsSignBO = smsService.getSign("悦跑会");
|
||||
Assert.assertNotNull(smsSignBO);
|
||||
SmsSignBO smsSignBO = smsService.getSign(3);
|
||||
Assert.assertNotNull("不能为空!", smsSignBO);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void updateSignTest() {
|
||||
smsService.updateSign("测试签名2", "测试签名3");
|
||||
SmsSignBO newSmsSignBO = smsService.getSign("测试签名3");
|
||||
Assert.assertNotNull(newSmsSignBO);
|
||||
String oldSign = "悦跑运动2";
|
||||
String newSign = "悦跑运动";
|
||||
smsService.updateSign(3, newSign, SmsPlatformEnum.YunPian.getValue());
|
||||
SmsSignBO smsSignBO = smsService.getSign(3);
|
||||
Assert.assertTrue("更新不成功!", smsSignBO.getSign().equals(newSign));
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// template
|
||||
@Test
|
||||
public void deletedSignTest() {
|
||||
smsService.deleteSign(3);
|
||||
Assertions.assertThrows(ServiceException.class, () -> {
|
||||
smsService.getSign(3);
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void createTemplateTest() {
|
||||
smsService.createTemplate(1, "打死也不要告诉别人哦002 #code# ", 1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getTemplateTest() {
|
||||
SmsTemplateBO smsTemplateBO = smsService.getTemplate(3);
|
||||
Assert.assertNotNull(smsTemplateBO);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void updateTemplateTest() {
|
||||
smsService.updateTemplate(3, "打死也不要告诉别人哦444 #code# ", 1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void deleteTemplateTest() {
|
||||
smsService.deleteTemplate(3);
|
||||
String template = "您的验证码是#code#,打死也不告诉别人哦。";
|
||||
smsService.createTemplate(3, template,
|
||||
SmsPlatformEnum.YunPian.getValue(),
|
||||
SmsTypeEnum.VERIFICATION_CODE.getValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void singleSendTest() {
|
||||
String mobile = "13302926050";
|
||||
smsService.singleSend(mobile, 1);
|
||||
Integer templateId = 5;
|
||||
smsService.singleSend(mobile, templateId, ImmutableMap.of("code", "8888"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void batchSendTest() {
|
||||
String mobile = "13302926050";
|
||||
Integer templateId = 5;
|
||||
smsService.batchSend(Lists.newArrayList(mobile), templateId, ImmutableMap.of("code", "8888"));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user