### Question:
ValidPatternVisitor extends BaseVisitor { public static void check(JexlNode node) { ValidPatternVisitor visitor = new ValidPatternVisitor(); node.jjtAccept(visitor, null); } ValidPatternVisitor(); static void check(JexlNode node); @Override Object visit(ASTERNode node, Object data); @Override Object visit(ASTNRNode node, Object data); @Override Object visit(ASTFunctionNode node, Object data); void parseAndPutPattern(JexlNode node);  }### Answer:
@Test public void testValidER() throws ParseException { String queryString = "BAR == '1' && FOO =~ '1234.*\\d'"; ASTJexlScript script = JexlASTHelper.parseJexlQuery(queryString); ValidPatternVisitor.check(script); }
@Test public void testValidERWithCacheHit() throws ParseException { String queryString = "BAR == '1' && FOO =~ '1234.*\\d' && FOO2 =~ '1234.*\\d'"; ASTJexlScript script = JexlASTHelper.parseJexlQuery(queryString); ValidPatternVisitor.check(script); }
@Test(expected = PatternSyntaxException.class) public void testInvalidER() throws ParseException { String queryString = "BAR == '1' && FOO =~ '1234.**'"; ASTJexlScript script = JexlASTHelper.parseJexlQuery(queryString); ValidPatternVisitor.check(script); }
@Test public void testValidNR() throws ParseException { String queryString = "BAR == '1' && FOO !~ '1234.*\\d'"; ASTJexlScript script = JexlASTHelper.parseJexlQuery(queryString); ValidPatternVisitor.check(script); }
@Test public void testValidNRWithCacheHit() throws ParseException { String queryString = "BAR == '1' && FOO !~ '1234.*\\d' && FOO2 !~ '1234.*\\d'"; ASTJexlScript script = JexlASTHelper.parseJexlQuery(queryString); ValidPatternVisitor.check(script); }
@Test(expected = PatternSyntaxException.class) public void testInvalidNR() throws ParseException { String queryString = "BAR == '1' && FOO !~ '1234.**'"; ASTJexlScript script = JexlASTHelper.parseJexlQuery(queryString); ValidPatternVisitor.check(script); }
@Test(expected = PatternSyntaxException.class) public void testFilterFunctionIncludeRegex() throws ParseException { String queryString = "A == '1' && filter:includeRegex(B,'*2*')"; ASTJexlScript script = JexlASTHelper.parseJexlQuery(queryString); ValidPatternVisitor.check(script); }
@Test(expected = PatternSyntaxException.class) public void testFilterFunctionExcludeRegex() throws ParseException { String queryString = "A == '1' && filter:excludeRegex(B,'*2*')"; ASTJexlScript script = JexlASTHelper.parseJexlQuery(queryString); ValidPatternVisitor.check(script); }