### Question:
StandardCountGettingTransformer extends SimpleSqlNodeVisitor<SqlNode, Void> { public SqlNode transform(SqlNode sqlNode) { AnonymousNode result = new AnonymousNode(); for (SqlNode child : sqlNode.getChildren()) { result.appendNode(child.accept(this, null)); } return result; }  SqlNode transform(SqlNode sqlNode); @Override SqlNode visitSelectStatementNode(SelectStatementNode node, Void p); @Override SqlNode defaultAction(SqlNode node, Void p);  }### Answer:
@Test public void test() { String expected = "select count(*) from ( select * from emp) t_"; StandardCountGettingTransformer transformer = new StandardCountGettingTransformer(); SqlParser parser = new SqlParser("select * from emp"); SqlNode sqlNode = transformer.transform(parser.parse()); NodePreparedSqlBuilder sqlBuilder = new NodePreparedSqlBuilder(new MockConfig(), SqlKind.SELECT, "dummyPath"); PreparedSql sql = sqlBuilder.build(sqlNode, Function.identity()); assertEquals(expected, sql.getRawSql()); }
@Test public void testOrderBy() { String expected = "select count(*) from ( select * from emp ) t_"; StandardCountGettingTransformer transformer = new StandardCountGettingTransformer(); SqlParser parser = new SqlParser("select * from emp order by emp.id"); SqlNode sqlNode = transformer.transform(parser.parse()); NodePreparedSqlBuilder sqlBuilder = new NodePreparedSqlBuilder(new MockConfig(), SqlKind.SELECT, "dummyPath"); PreparedSql sql = sqlBuilder.build(sqlNode, Function.identity()); assertEquals(expected, sql.getRawSql()); }