package com.cf.imes.module.system.service.sms;

import com.cf.imes.module.system.framework.sms.config.ChenfengSmsAutoConfiguration;
import com.cf.imes.framework.test.core.ut.BaseDbUnitTest;
import com.cf.imes.module.system.framework.sms.core.client.SmsClient;
import com.cf.imes.module.system.framework.sms.core.client.SmsClientFactory;
import com.cf.imes.module.system.framework.sms.core.client.impl.aliyun.AliyunSmsClient;
import com.cf.imes.module.system.framework.sms.core.client.impl.debug.DebugDingTalkSmsClient;
import com.cf.imes.module.system.framework.sms.core.enums.SmsChannelEnum;
import com.cf.imes.module.system.framework.sms.core.property.SmsProperties;
import org.junit.jupiter.api.Test;
import org.springframework.context.annotation.Import;

import jakarta.annotation.Resource;

import static org.assertj.core.api.AssertionsForClassTypes.assertThat;


@Import({SmsChannelServiceImpl.class, ChenfengSmsAutoConfiguration.class})
public class SmsChannelServiceTest extends BaseDbUnitTest {

    @Resource
    private SmsChannelServiceImpl smsChannelService;

    @Resource
    private SmsProperties smsProperties; // 真实 Bean

    @Resource
    private SmsClientFactory smsClientFactory; // 真实 Bean

    @Test
    void testGetSmsClient_aliyun() {
        smsProperties.setChannel(SmsChannelEnum.ALIYUN.getCode());
        SmsClient aliyunClient = smsChannelService.getSmsClient();
        assertThat(aliyunClient).isInstanceOf(AliyunSmsClient.class);

        smsProperties.setChannel(SmsChannelEnum.DEBUG_DING_TALK.getCode());
        SmsClient dingDingClient = smsChannelService.getSmsClient();
        assertThat(dingDingClient).isInstanceOf(DebugDingTalkSmsClient.class);
    }
}
