### Question:
KbSqlParser { public static String bindArgs(String sql, @Nullable Object[] bindArgs) { if (bindArgs == null || bindArgs.length == 0 || sql.startsWith("PRAGMA")) { return sql; } try { KbSqlParserManager pm = new KbSqlParserManager(); Statement statement = pm.parse(sql); Set<Expression> expressionSet = findBindArgsExpressions(statement); Iterator<Object> iterator = Arrays.asList(bindArgs).iterator(); bindExpressionArgs(expressionSet, iterator); return statement.toString(); } catch (Exception e) { e.printStackTrace(); } return sql; }  static String bindArgs(String sql, @Nullable Object[] bindArgs);  }### Answer:
@Test public void bindDeleteArgs() { Object[] args = new Object[]{1}; String sql = "DELETE FROM person WHERE id = ?"; String boundSql = KbSqlParser.bindArgs(sql, args); Assert.assertEquals("DELETE FROM person WHERE id = 1", boundSql); }
@Test public void bindUpdateArgs() { Object[] args = new Object[]{"kk", 1}; String sql = "UPDATE person SET name = ? WHERE id = ?"; String boundSql = KbSqlParser.bindArgs(sql, args); Assert.assertEquals("UPDATE person SET name = 'kk' WHERE id = 1", boundSql); }
@Test public void bindSelectArgs() throws Exception { Object[] args = new Object[]{1, 10, 20, "test"}; String sql = "select * from person where id=? and (uid BETWEEN ? and ?) and test LIKE ? order by id"; String boundSql = KbSqlParser.bindArgs(sql, args); System.out.println(boundSql); Assert.assertEquals("SELECT * FROM person WHERE id = 1 AND (uid BETWEEN 10 AND 20) AND test LIKE 'test' ORDER BY id", boundSql); }
@Test public void bindInsertArgs() { Object[] args = new Object[]{1, "kk"}; String sql = "INSERT INTO person (id, name) VALUES (?, ?)"; String boundSql = KbSqlParser.bindArgs(sql, args); Assert.assertEquals("INSERT INTO person (id, name) VALUES (1, 'kk')", boundSql); }