package com.qmth.paper.library;

import com.qmth.paper.library.common.config.DictionaryConfig;
import com.qmth.paper.library.common.util.CodeUtil;
import com.qmth.paper.library.common.util.SmsSendUtil;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import javax.annotation.Resource;
import java.io.UnsupportedEncodingException;
import java.util.HashMap;
import java.util.Map;

/**
 * 短信工具测试类
 */
@SpringBootTest
@RunWith(SpringRunner.class)
public class SmsTest {

    @Resource
    SmsSendUtil smsSendUtil;

    @Resource
    DictionaryConfig dictionaryConfig;

//    @Test
    public void smsSend() throws UnsupportedEncodingException {
        String phoneNumber = "19945020703";
        String templateCode = dictionaryConfig.smsDomain().getVerificationCode();
        Map<String, Object> map = new HashMap<>();
        String normalCode = dictionaryConfig.smsDomain().getSmsNormalCode();
        map.put("code", CodeUtil.getVerificationCode(normalCode));
        smsSendUtil.sendSms(phoneNumber, templateCode, map);
    }
}
