### Question:
SafeMySQLOutputVisitor extends DalMySqlOutputVisitor implements SafeOutputVisitor { @Override public WhiteFieldsOutputProxy getWhiteFieldsOutputProxy() { return outputProxy; } SafeMySQLOutputVisitor(Appendable appender, Appendable whiteFieldsAppender,
        Predicate<String> whiteFieldsFilter); @Override WhiteFieldsOutputProxy getWhiteFieldsOutputProxy(); @Override boolean visit(SQLCharExpr x); @Override boolean visit(SQLIntegerExpr x); @Override boolean visit(SQLNumberExpr x); @Override boolean visit(SQLInListExpr x); @Override boolean visit(SQLHexExpr x); @Override boolean visit(SQLLimit x);  }### Answer:
@Test public void testInsertSql() throws Exception { StringBuilder mostSafeSb = new StringBuilder(); StringBuilder whiteFieldsSb = new StringBuilder(); SafeMySQLOutputVisitor v; v = new SafeMySQLOutputVisitor(mostSafeSb, whiteFieldsSb, whiteFieldsFilter); v.getWhiteFieldsOutputProxy().setIfInsertStatement(insertStmt); v.setPrettyFormat(false); insertStmt.accept(v); String desensitizedStr = whiteFieldsSb.toString(); String expectedMostSafeSql = "INSERT INTO eleme_order (id, user_id, restaurant_id, task_hash, date , index) VALUES (?)"; String expectedWhiteFields = "id->1#user_id->2#restaurant_id->3#task_hash->'21329173'#"; Assert.assertEquals(mostSafeSb.toString(), expectedMostSafeSql); Assert.assertEquals(whiteFieldsSb.toString(), expectedWhiteFields); Assert.assertTrue(mostSafeSb.toString().contains("INSERT")); Assert.assertTrue(desensitizedStr.contains("id")); Assert.assertTrue(desensitizedStr.contains("user_id")); Assert.assertTrue(desensitizedStr.contains("restaurant_id")); Assert.assertTrue(desensitizedStr.contains("task_hash")); Assert.assertFalse(desensitizedStr.contains("date")); Assert.assertFalse(desensitizedStr.contains("index")); }
@Test public void testSetNonInsertStmt() { StringBuilder mostSafeSb = new StringBuilder(); StringBuilder whiteFieldsSb = new StringBuilder(); SafeMySQLOutputVisitor v = new SafeMySQLOutputVisitor(mostSafeSb, whiteFieldsSb, whiteFieldsFilter); v.getWhiteFieldsOutputProxy().setIfInsertStatement(selectStmt); v.setPrettyFormat(false); insertStmt.accept(v); Assert.assertTrue(whiteFieldsSb.toString().isEmpty()); }