ParsedQueryFactory { public static ParsedQuery getParsedQuery(String db, Query toParse, Session session) throws FieldNotIndexedException { if (db == null || db.trim().equals("")) { throw new IllegalArgumentException("Query must be populated."); } if (toParse == null) { throw new IllegalArgumentException("Query cannot be null."); } final String key = db + ":" + toParse.getTable() + ":" + toParse.getWhere(); Cache c = CacheFactory.getCache("parsedQuery"); Element e = c.get(key); if (e == null) { logger.debug("Creating new ParsedQuery for: " + key); e = new Element(key, parseQuery(db, toParse, session)); c.put(e); } else { logger.trace("Pulling ParsedQuery from Cache: " + e.getObjectValue().toString()); } return (ParsedQuery) e.getObjectValue(); }  static ParsedQuery getParsedQuery(String db, Query toParse, Session session); static ParsedQuery parseQuery(String db, Query toParse, Session session);  }
@Test public void testGetParsedQuery() throws FieldNotIndexedException { System.out.println("testGetParsedQuery"); String db = Fixtures.DB; CacheFactory.clearAllCaches(); Query toParse = Fixtures.createTestQuery(); ParsedQuery expResult = new ParsedQuery(toParse, new WhereClause(toParse.getWhere()), Fixtures.createTestIndexOneField()); ParsedQuery result = ParsedQueryFactory.getParsedQuery(db, toParse, f.getSession()); assertEquals(expResult, result); result = ParsedQueryFactory.getParsedQuery(db, toParse, f.getSession()); assertEquals(expResult, result); }