package jesse.keeblarcraft.ConfigMgr;

import jesse.keeblarcraft.ConfigMgr.SQLTypeSupport.VALID_SQL_TYPE;
import jesse.keeblarcraft.Utils.CommonStructures.Pair;

// Random commands to run to test the SQL class
public class SQLUnitTest {
    public void RunTests() {
        CreateTableTest();
        ForeignKeyTest();
    }

    public void CreateTableTest() {
        String tableName = "test_table";
        Pair<String, VALID_SQL_TYPE> pairOne = new Pair<>("name", VALID_SQL_TYPE.VARCHAR);
        Pair<String, VALID_SQL_TYPE> pairTwo = new Pair<>("address", VALID_SQL_TYPE.BIGINT);
        Pair<String, VALID_SQL_TYPE> pairThree = new Pair<>("email", VALID_SQL_TYPE.TEXT);

        SQLConfig.GetInstance().CreateTable(tableName, pairOne, pairTwo, pairThree);
    }

    public void DoesTableExistTest() {
        String tableName = "test_table";
        Boolean temp = SQLConfig.GetInstance().DoesTableExist(tableName.toUpperCase());

        System.out.println("[SQL-UnitTest]: Does the table " + tableName + " exist? " + (temp ? "YES":"NO"));
    }

    public void ForeignKeyTest() {
        String primTableName = "test_table";
        String primColName = "name";
        String foreTableName = "accounts";
        String foreColName = "global_account_id";

        Integer ret = SQLConfig.GetInstance().AddForeignKey(primTableName, primColName, foreTableName, foreColName);
        System.out.println("[SQL-UnitTest]: Update foreign key test. Got return result number: " + ret);
    }
}
