### Question:
QueryParser { public ParseBaseNode parse(String query) { CommonTree queryTree = parseAST(query); try { ParseBaseNode rootNode = parseQuery(queryTree, query); rootNode.validate(parseContext); postValidate(rootNode); return rootNode; } catch (QueryParseException e) { logger.error(e.getMessage()); throw e; } catch (Throwable t) { throw new QueryParseException(QueryErrCodeEnum.SYNTAX_ERROR, MessageFormat.format("{0}!Syntax Error: {1}", query, t.getMessage()), t); } } QueryParser(QueryContext queryContext); ParseBaseNode parse(String query);  }### Answer:
@Test public void testParser() throws Exception { for (String q : queries) { logger.debug("parsing {}\n", q); ParseBaseNode node = raptorParser.parse(q); printNode(node); } for (String q : stratusQuries) { ParseBaseNode node = stratusParser.parse(q); printNode(node); } }
@Test public void testParser01() throws Exception { String query = "Compute[@fqdns=\"aaaa.ebay.com\"]{*}." + "( <VPool>parentCluster[@_oid=\"CLguf6sdle-invalid\"] " + "&& activeManifestRef[@_oid=\"B-N-D-1.20111108154904.0\"]" + "|| activeManifestCur[@_oid=\"Black-Pearl-1.20111103221326.0\"])"; ParseBaseNode baseNode = stratusParser.parse(query); Assert.assertTrue(baseNode.getType() == ParseNodeTypeEnum.QUERY); Assert.assertTrue(baseNode.getNextNodes().size() == 1); ParseBaseNode joinNode = baseNode.getNextNodes().get(0); Assert.assertTrue(joinNode.getType() == ParseNodeTypeEnum.INNERJOIN); Assert.assertTrue(joinNode.getNextNodes().size() == 1); ParseBaseNode unionNode = joinNode.getNextNodes().get(0); Assert.assertTrue(unionNode.getType() == ParseNodeTypeEnum.UNION); Assert.assertTrue(unionNode.getNextNodes().size() == 2); ParseBaseNode intersectNode = unionNode.getNextNodes().get(0); Assert.assertTrue(intersectNode.getType() == ParseNodeTypeEnum.INTERSECTION); Assert.assertTrue(intersectNode.getNextNodes().size() == 2); ParseBaseNode manifestCurNode = unionNode.getNextNodes().get(1); Assert.assertTrue(manifestCurNode.getType() == ParseNodeTypeEnum.QUERY); }
@Test public void testFailure() throws Exception { int errCount = 0; for (String q : badQueries) { try { raptorParser.parse(q); } catch(QueryParseException e) { logger.error("++++parsing {} - {}\n", q, e.getMessage()); errCount++; } } Assert.assertEquals(errCount, badQueries.length); }
@Test public void testSetQueries() throws Exception { for (String q : setQueries) { logger.debug("parsing {}\n", q); ParseBaseNode node = raptorParser.parse(q); printNode(node); } }