package com.simuwang.datadaq;

import cn.hutool.core.collection.ListUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.map.MapUtil;
import com.simuwang.base.common.conts.DateConst;
import com.simuwang.base.pojo.dto.MailboxInfoDTO;
import com.simuwang.daq.service.EmailParseApiService;
import com.simuwang.daq.service.EmailParseService;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

import java.util.Date;
import java.util.List;
import java.util.Map;

@SpringBootTest
class DataTrusteeApplicationTests {

    @Autowired
    private EmailParseService emailParseService;

    @Autowired
    private EmailParseApiService emailParseApiService;

    @Test
    public void test() {
        MailboxInfoDTO emailInfoDTO = new MailboxInfoDTO();
        emailInfoDTO.setUserId(2395446);
        emailInfoDTO.setAccount("mozuwen@simuwang.com");
        emailInfoDTO.setPassword("Mzw@0306");
        emailInfoDTO.setHost("imap.exmail.qq.com");
        emailInfoDTO.setPort("993");
        emailInfoDTO.setProtocol("imap");
//
//        emailInfoDTO.setAccount("jjpj_test");
//        emailInfoDTO.setPassword("shzq#919");
//        emailInfoDTO.setHost("mail.shzq.com");
//        emailInfoDTO.setPort("993");
//        emailInfoDTO.setProtocol("imap");

        Date startDate = DateUtil.parse("2024-09-20 09:02:00", DateConst.YYYY_MM_DD_HH_MM_SS);
        Date endDate = DateUtil.parse("2024-09-20 10:00:00", DateConst.YYYY_MM_DD_HH_MM_SS);
        try {
            emailParseService.parseEmail(emailInfoDTO, startDate, endDate);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

    @Test
    public void testReparseEmail() {
        emailParseApiService.reparseEmail(7);
    }


    @Test
    public void testReparseFile() {
        emailParseApiService.reparseFile(ListUtil.toList(40,43));
    }
}
