### Question:
GeoWavePruningVisitor extends RebuildingVisitor { public static <T extends JexlNode> T pruneTree(JexlNode node) { return pruneTree(node, null, null); } private  GeoWavePruningVisitor(Multimap<String,String> prunedTerms, MetadataHelper metadataHelper); static T pruneTree(JexlNode node); static T pruneTree(JexlNode node, Multimap<String,String> prunedTerms, MetadataHelper metadataHelper); @Override Object visit(ASTAndNode node, Object data); @Override Object visit(ASTOrNode node, Object data); @Override Object visit(ASTReference node, Object data); @Override Object visit(ASTReferenceExpression node, Object data); @Override Object visit(ASTEQNode node, Object data);  }### Answer:
@Test public void pruningVisitorTest() throws Exception { String query = "geowave:intersects(GEO_FIELD, 'POLYGON((10 10, 20 10, 20 20, 10 20, 10 10))')"; ShardQueryConfiguration config = new ShardQueryConfiguration(); String expandedQuery = query + " && (GEO_FIELD == '0100' || " + convertFunctionToIndexQuery(query, config) + ")"; Multimap<String,String> prunedTerms = HashMultimap.create(); JexlNode prunedTree = GeoWavePruningVisitor.pruneTree(JexlASTHelper.parseJexlQuery(expandedQuery), prunedTerms, null); Assert.assertEquals(1, prunedTerms.entries().size()); Map.Entry<String,String> term = prunedTerms.entries().iterator().next(); Assert.assertEquals("GEO_FIELD", term.getKey()); Assert.assertEquals("0100", term.getValue()); Assert.assertEquals(query + " && (" + convertFunctionToIndexQuery(query, config) + ")", JexlStringBuildingVisitor.buildQuery(prunedTree)); }
@Test public void emptyRefExpTest() throws Exception { String query = "geowave:intersects(GEO_FIELD, 'POLYGON((10 10, 20 10, 20 20, 10 20, 10 10))')"; ShardQueryConfiguration config = new ShardQueryConfiguration(); String expandedQuery = query + " && ((GEO_FIELD == '0100') || " + convertFunctionToIndexQuery(query, config) + ")"; Multimap<String,String> prunedTerms = HashMultimap.create(); JexlNode prunedTree = GeoWavePruningVisitor.pruneTree(JexlASTHelper.parseJexlQuery(expandedQuery), prunedTerms, null); RefExpVisitor refExpVisitor = new RefExpVisitor(); prunedTree.jjtAccept(refExpVisitor, null); Assert.assertFalse(refExpVisitor.hasChildlessNode); }