package cn.com.poc.utils;

import cn.com.poc.common.utils.DatabaseUtil;
import cn.com.poc.common.utils.JsonUtils;
import cn.com.poc.thirdparty.resource.demand.ai.entity.largemodel.LargeModelDemandResult;
import cn.com.yict.framemax.core.spring.SingleContextInitializer;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.web.WebAppConfiguration;

/**
 * @author alex.yao
 * @date 2025/4/27
 */
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(initializers = SingleContextInitializer.class)
@WebAppConfiguration
public class DatabaseUtilTest {


    @Test
    public void test_connection() {
        String host = "111.230.74.77";
        int port = 3306;
        String username = "root";
        String password = "Cdhit2fF@3210fd";
        String database = "bi";
        System.out.println(DatabaseUtil.testConnect(host, port, username, password, database));
    }

    @Test
    public void test_getTableData() {
        String host = "192.168.21.31";
        int port = 3306;
        String username = "poc_root";
        String password = "8db58a2836dc";
        String database = "gsst_poc_sit";
        System.out.println(JsonUtils.serialize(DatabaseUtil.getTableData(host, port, username, password, database, "biz_member_info", 3, 10)));
    }

    @Test
    public void test_getTableInfo() {
        String host = "192.168.21.31";
        int port = 3306;
        String username = "poc_root";
        String password = "8db58a2836dc";
        String database = "gsst_poc_sit";
        System.out.println(DatabaseUtil.getTableStructure(host, port, username, password, database, "biz_member_info"));
    }

    @Test
    public void test() {
        LargeModelDemandResult result = new LargeModelDemandResult();
        result.setCode("0");
        result.setFunction(null);
        result.setDbChainResult(null);
//        result.setKnowledgeContentResult(null);
        System.out.println(JsonUtils.serialize(result));
    }


}
