// Path: ddal-ddr/src/main/java/org/hellojavaer/ddal/ddr/shard/simple/SimpleShardParser.java
// public class SimpleShardParser implements ShardParser {
// 
//     private ShardRouter shardRouter;
//     private SQLParser   sqlParser;
// 
//     private SimpleShardParser() {
//     }
// 
//     public SimpleShardParser(SQLParser sqlParser, ShardRouter shardRouter) {
//         setSqlParser(sqlParser);
//         setShardRouter(shardRouter);
//     }
// 
//     public ShardRouter getShardRouter() {
//         return shardRouter;
//     }
// 
//     public void setShardRouter(ShardRouter shardRouter) {
//         this.shardRouter = shardRouter;
//     }
// 
//     public SQLParser getSqlParser() {
//         return sqlParser;
//     }
// 
//     public void setSqlParser(SQLParser sqlParser) {
//         this.sqlParser = sqlParser;
//     }
// 
//     @Override
//     public SQLParsedResult parse(String sql, Map<Object, Object> jdbcParams) {
//         SQLParsedState sqlParsedState = sqlParser.parse(sql, shardRouter);
//         return sqlParsedState.parse(jdbcParams);
//     }
// }
// 
// Path: ddal-ddr/src/main/java/org/hellojavaer/ddal/ddr/sqlparse/SQLParsedState.java
// public interface SQLParsedState {
// 
//     SQLParsedResult parse(Map<Object, Object> jdbcParams);
// 
// }
// 
// Path: ddal-ddr/src/main/java/org/hellojavaer/ddal/ddr/sqlparse/exception/AmbiguousRouteResultException.java
// public class AmbiguousRouteResultException extends DDRSQLParseException {
// 
//     public AmbiguousRouteResultException() {
//     }
// 
//     public AmbiguousRouteResultException(String message) {
//         super(message);
//     }
// 
//     public AmbiguousRouteResultException(String message, Throwable cause) {
//         super(message, cause);
//     }
// 
//     public AmbiguousRouteResultException(Throwable cause) {
//         super(cause);
//     }
// 
//     public AmbiguousRouteResultException(String message, Throwable cause, boolean enableSuppression,
//                                          boolean writableStackTrace) {
//         super(message, cause, enableSuppression, writableStackTrace);
//     }
// }


import java.util.HashMap;
import java.util.Map;
import net.sf.jsqlparser.JSQLParserException;
import org.hellojavaer.ddal.core.utils.Assert;
import org.hellojavaer.ddal.ddr.datasource.exception.CrossPreparedStatementException;
import org.hellojavaer.ddal.ddr.shard.ShardRouter;
import org.hellojavaer.ddal.ddr.shard.simple.SimpleShardParser;
import org.hellojavaer.ddal.ddr.sqlparse.SQLParsedResult;
import org.hellojavaer.ddal.ddr.sqlparse.SQLParsedState;
import org.hellojavaer.ddal.ddr.sqlparse.exception.AmbiguousRouteResultException;
import org.junit.Test;
        jdbcParams.put(1, 506);
        SQLParsedResult sqlParsedResult = sqlParsedState.parse(jdbcParams);
        Assert.equals(sqlParsedResult.getSql(), "SELECT * FROM db_02.user_0122 AS user WHERE id = ?");
        jsqlParserAdapter = new JSQLParserAdapter(sql, shardRouter, true);
        try {
            sqlParsedState = jsqlParserAdapter.parse();
            throw new Error();
        } catch (Exception e) {
        }
    }

    @Test
    public void testSelectLimitCheck01() {
        String sql = "select * from user where id = ? limit 10";
        ShardRouter shardRouter = buildParserForId().getShardRouter();
        JSQLParserAdapter jsqlParserAdapter = new JSQLParserAdapter(sql, shardRouter, false);
        SQLParsedState sqlParsedState = jsqlParserAdapter.parse();
        Map<Object, Object> jdbcParams = new HashMap<>();
        jdbcParams.put(1, 506);
        SQLParsedResult sqlParsedResult = sqlParsedState.parse(jdbcParams);
        Assert.equals(sqlParsedResult.getSql(), "SELECT * FROM db_02.user_0122 AS user WHERE id = ? LIMIT 10");

        jsqlParserAdapter = new JSQLParserAdapter(sql, shardRouter, true);
        sqlParsedState = jsqlParserAdapter.parse();
        jdbcParams = new HashMap<>();
        jdbcParams.put(1, 506);
        sqlParsedResult = sqlParsedState.parse(jdbcParams);
        Assert.equals(sqlParsedResult.getSql(), "SELECT * FROM db_02.user_0122 AS user WHERE id = ? LIMIT 10");
    }

// Path: ddal-ddr/src/main/java/org/hellojavaer/ddal/ddr/shard/simple/SimpleShardParser.java
// public class SimpleShardParser implements ShardParser {
// 
//     private ShardRouter shardRouter;
//     private SQLParser   sqlParser;
// 
//     private SimpleShardParser() {
//     }
// 
//     public SimpleShardParser(SQLParser sqlParser, ShardRouter shardRouter) {
//         setSqlParser(sqlParser);
//         setShardRouter(shardRouter);
//     }
// 
//     public ShardRouter getShardRouter() {
//         return shardRouter;
//     }
// 
//     public void setShardRouter(ShardRouter shardRouter) {
//         this.shardRouter = shardRouter;
//     }
// 
//     public SQLParser getSqlParser() {
//         return sqlParser;
//     }
// 
//     public void setSqlParser(SQLParser sqlParser) {
//         this.sqlParser = sqlParser;
//     }
// 
//     @Override
//     public SQLParsedResult parse(String sql, Map<Object, Object> jdbcParams) {
//         SQLParsedState sqlParsedState = sqlParser.parse(sql, shardRouter);
//         return sqlParsedState.parse(jdbcParams);
//     }
// }
// 
// Path: ddal-ddr/src/main/java/org/hellojavaer/ddal/ddr/sqlparse/SQLParsedState.java
// public interface SQLParsedState {
// 
//     SQLParsedResult parse(Map<Object, Object> jdbcParams);
// 
// }
// 
// Path: ddal-ddr/src/main/java/org/hellojavaer/ddal/ddr/sqlparse/exception/AmbiguousRouteResultException.java
// public class AmbiguousRouteResultException extends DDRSQLParseException {
// 
//     public AmbiguousRouteResultException() {
//     }
// 
//     public AmbiguousRouteResultException(String message) {
//         super(message);
//     }
// 
//     public AmbiguousRouteResultException(String message, Throwable cause) {
//         super(message, cause);
//     }
// 
//     public AmbiguousRouteResultException(Throwable cause) {
//         super(cause);
//     }
// 
//     public AmbiguousRouteResultException(String message, Throwable cause, boolean enableSuppression,
//                                          boolean writableStackTrace) {
//         super(message, cause, enableSuppression, writableStackTrace);
//     }
// }


// Path: ddal-jsqlparser/src/test/java/org.hellojavaer.ddal.jsqlparser/JSQLParserAdapterTest.java
import java.util.HashMap;
import java.util.Map;
import net.sf.jsqlparser.JSQLParserException;
import org.hellojavaer.ddal.core.utils.Assert;
import org.hellojavaer.ddal.ddr.datasource.exception.CrossPreparedStatementException;
import org.hellojavaer.ddal.ddr.shard.ShardRouter;
import org.hellojavaer.ddal.ddr.shard.simple.SimpleShardParser;
import org.hellojavaer.ddal.ddr.sqlparse.SQLParsedResult;
import org.hellojavaer.ddal.ddr.sqlparse.SQLParsedState;
import org.hellojavaer.ddal.ddr.sqlparse.exception.AmbiguousRouteResultException;
import org.junit.Test;

        jdbcParams.put(1, 506);
        SQLParsedResult sqlParsedResult = sqlParsedState.parse(jdbcParams);
        Assert.equals(sqlParsedResult.getSql(), "SELECT * FROM db_02.user_0122 AS user WHERE id = ?");
        jsqlParserAdapter = new JSQLParserAdapter(sql, shardRouter, true);
        try {
            sqlParsedState = jsqlParserAdapter.parse();
            throw new Error();
        } catch (Exception e) {
        }
    }

    @Test
    public void testSelectLimitCheck01() {
        String sql = "select * from user where id = ? limit 10";
        ShardRouter shardRouter = buildParserForId().getShardRouter();
        JSQLParserAdapter jsqlParserAdapter = new JSQLParserAdapter(sql, shardRouter, false);
        SQLParsedState sqlParsedState = jsqlParserAdapter.parse();
        Map<Object, Object> jdbcParams = new HashMap<>();
        jdbcParams.put(1, 506);
        SQLParsedResult sqlParsedResult = sqlParsedState.parse(jdbcParams);
        Assert.equals(sqlParsedResult.getSql(), "SELECT * FROM db_02.user_0122 AS user WHERE id = ? LIMIT 10");

        jsqlParserAdapter = new JSQLParserAdapter(sql, shardRouter, true);
        sqlParsedState = jsqlParserAdapter.parse();
        jdbcParams = new HashMap<>();
        jdbcParams.put(1, 506);
        sqlParsedResult = sqlParsedState.parse(jdbcParams);
        Assert.equals(sqlParsedResult.getSql(), "SELECT * FROM db_02.user_0122 AS user WHERE id = ? LIMIT 10");
    }

    @Test