package com.njcn.msgpush.module.push.sms;

import com.njcn.msgpush.module.push.client.channel.sms.Impl.AliYunSmsClient;
import com.njcn.msgpush.module.push.client.channel.sms.SmsClient;
import com.njcn.msgpush.module.push.client.channel.sms.factory.SmsFactory;
import com.njcn.msgpush.module.push.client.constant.ClientConstant;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author caozehui
 * @data 2026-02-06
 */
@SpringBootTest
public class AliYumSmsClientTest {

    @Autowired
    private SmsFactory smsFactory;

    @Test
    public void testSendSms() throws Exception {
        Map<String, Object> params = new HashMap<>();
        params.put(AliYunSmsClient.SIGN_NAME, "灿能云");
        params.put(AliYunSmsClient.TEMPLATE_CODE, "SMS_481710295");
        params.put(AliYunSmsClient.TEMPLATE_PARAM, "{\"code\":\"123456\"}");
        boolean b = smsFactory.getClient("阿里云").sendSms(params, "18839431215");
        System.out.println(System.currentTimeMillis() + " " + b);
    }

    @Test
    public void testSendBatchSms() {
        Map<String, Object> params = new HashMap<>();
        params.put(AliYunSmsClient.SIGN_NAME, List.of("灿能云"));
        params.put(AliYunSmsClient.TEMPLATE_CODE, "SMS_481710295");
        params.put(AliYunSmsClient.TEMPLATE_PARAM, List.of("{\"code\":\"123456\"}"));
        smsFactory.getClient("阿里云").sendBatchSms(params, List.of("18839431215"));
    }

    @Test
    public void testQuerySmsTemplateListRequest() {
        SmsClient client = smsFactory.getClient(ClientConstant.ALI_YUN);
        client.querySmsTemplateList();
    }
}
