### Question:
ShardingSQL { public void rewriteSQL4ReBalance(String reshardAt) { } ShardingSQL(SQLObject sqlStmt, ShardingRouter shardingRouter); void setComment(String comment); String getComment(); boolean isQueryGlobalAutoCommit(); String getQueryAutoCommitHeader(); long getClientIdForKill(); void collectShardingColumnValue(int shardingRuleIndex, String value4ShardingKey); void generateOriginalShardedSQLs(); static String addPrefixComment(String queryComment, String sql); static void handleSQLConstruct(ShardingSQL shardingSQL, String sql, String queryComment,
        List<SQLStatement> stmtList); static ShardingSQL handleMySQLBasicly(String sql, String queryComment,
        ShardingRouter shardingRouter, Send2BatchCond batchCond,
        Predicate<String> whiteFieldsFilter); static ShardingSQL handlePGBasicly(String sql, String queryComment,
        ShardingRouter shardingRouter, Send2BatchCond batchCond,
        Predicate<String> whiteFieldsFilter); static void handleSQLSharding(ShardingSQL shardingSQL); boolean needRewriteSQLWhenNoSharding(); void setMostSafeSQL(String mostSafeSQL); String getMostSafeSQL(); String getOriginMostSafeSQL(); void setOriginMostSafeSQL(String originMostSafeSQL); IterableShardingResult getMappingResults(); void resetShardingResult(); String getWhiteFields(); void setWhiteFields(String whiteFields); String getOriginWhiteFields(); void setOriginWhiteFields(String originWhiteFields); void rewriteSQL4ReBalance(String reshardAt); boolean rewriteSQLHints(List<SQLHint> hints); static final Predicate<String> BLACK_FIELDS_FILTER; public boolean needCacheResult; public boolean needSharding; public Send2BatchCond send2Batch; public String tableName; public String tableNameLowerCase; public String tableNameAlias; public String specifyDB; public IterableShardingResult results; public String originSQL; public int autocommitValue; public boolean isContainsBindMasterExpr; public boolean isEZoneShardInfoRewrited; final Map<String, String> params; public String selected_value; public String next_begin; public String next_end; public QUERY_TYPE queryType; final SQLFeature sqlFeature; }### Answer:
@Test public void testHackInReshardCondtion4UpdateWithoutWhere() { String sql = "update test set a=1"; ShardingSQL shardingSQL = handleSQL(sql, mixShardingRouter); shardingSQL.rewriteSQL4ReBalance("2017-02-27T07:07:47.111"); String expectedOriginSQL = "UPDATE test SET a = 1 WHERE created_at > '2017-02-27T07:07:47.111'"; assertEquals(shardingSQL.originSQL, expectedOriginSQL); }
@Test public void testHackInReshardCondtion4UpdateWithWhere() { String sql = "update test set a=1 where b = 'test' and c > 3"; ShardingSQL shardingSQL = handleSQL(sql, mixShardingRouter); shardingSQL.rewriteSQL4ReBalance("2017-02-27T07:07:47.111"); String expectedOriginSQL = "UPDATE test SET a = 1 WHERE created_at > '2017-02-27T07:07:47.111' AND (b = 'test' AND c > 3)"; assertEquals(shardingSQL.originSQL, expectedOriginSQL); }