package com.purui.prims;

import com.purui.prims.auth.api.authentication.pojo.User;
import com.purui.prims.common.util.ContextUtils;
import com.purui.prims.headless.api.pojo.request.SqlExecuteReq;
import com.purui.prims.headless.api.pojo.response.SemanticQueryResp;
import com.purui.prims.headless.server.service.DatabaseService;
import org.junit.Assert;
import org.junit.jupiter.api.Test;

/**
 * 类说明
 *
 * @author charlie
 * @date 2024/8/5
 */
public class DatabaseTest extends BaseTest{

    @Test
    void execSqlTest() {
        String sql = "select * from ods_prinsu_settlement";
        DatabaseService databaseService = ContextUtils.getBean(DatabaseService.class);
        if (databaseService != null) {
            SqlExecuteReq sqlExecuteReq = new SqlExecuteReq();
            sqlExecuteReq.setSql(sql);
            sqlExecuteReq.setId(3L);
            SemanticQueryResp semanticQueryResp = databaseService.executeSql(sqlExecuteReq, sqlExecuteReq.getId(), User.getFakeUser());
            Assert.assertTrue(semanticQueryResp.getColumns().size()>0);
        }

    }
}
