@Override public SqlNode transform(SqlNode sqlNode) { AnonymousNode result = new AnonymousNode(); for (SqlNode child : sqlNode.getChildren()) { result.appendNode(child.accept(this, null)); } return result; }
public void testIfSuppressed() throws Exception { Class<?> target = BatchSqlValidationDao.class; addCompilationUnit(target); compile(); ExecutableElement methodElement = createMethodElement(target, "testIfSuppressed"); Map<String, TypeMirror> parameterTypeMap = createParameterTypeMap(methodElement); BatchSqlValidator validator = new BatchSqlValidator( getProcessingEnvironment(), methodElement, parameterTypeMap, "aaa/bbbDao/ccc.sql"); SqlParser parser = new SqlParser("select * from emp where /*%if true*/ id = 1 /*%end */"); SqlNode sqlNode = parser.parse(); sqlNode.accept(validator, null); assertNoMessage(); }
public void testEmbeddedVariable() throws Exception { Class<?> target = BatchSqlValidationDao.class; addCompilationUnit(target); compile(); ExecutableElement methodElement = createMethodElement(target, "testEmbeddedVariable", String.class); Map<String, TypeMirror> parameterTypeMap = createParameterTypeMap(methodElement); BatchSqlValidator validator = new BatchSqlValidator( getProcessingEnvironment(), methodElement, parameterTypeMap, "aaa/bbbDao/ccc.sql"); SqlParser parser = new SqlParser("select * from emp /*# orderBy */"); SqlNode sqlNode = parser.parse(); sqlNode.accept(validator, null); assertMessage(Message.DOMA4181); }
public void testIfAndEmbeddedVariable() throws Exception { Class<?> target = BatchSqlValidationDao.class; addCompilationUnit(target); compile(); ExecutableElement methodElement = createMethodElement(target, "testIfAndEmbeddedVariable", String.class); Map<String, TypeMirror> parameterTypeMap = createParameterTypeMap(methodElement); BatchSqlValidator validator = new BatchSqlValidator( getProcessingEnvironment(), methodElement, parameterTypeMap, "aaa/bbbDao/ccc.sql"); SqlParser parser = new SqlParser("select * from emp where /*%if true*/ id = 1 /*%end */ /*# orderBy */"); SqlNode sqlNode = parser.parse(); sqlNode.accept(validator, null); assertEquals(2, getDiagnostics().size()); }