### Question:
QuerqyDismaxQParser extends QParser { @Override public Query getQuery() throws SyntaxError { if (query==null) { query=parse(); applyLocalParams(); } return query; } QuerqyDismaxQParser(final String qstr, final SolrParams localParams, final SolrParams params,
                               final SolrQueryRequest req, final QuerqyParser querqyParser,
                               final RewriteChain rewriteChain, final InfoLogging infoLogging,
                               final TermQueryCache termQueryCache); @Override Query parse(); @Override Query getQuery(); @Override Query getHighlightQuery(); @Override void addDebugInfo(final NamedList<Object> debugInfo); SearchEngineRequestAdapter getSearchEngineRequestAdapter(); List<Query> getFilterQueries(); Optional<RankQuery> getRankQuery();  }### Answer:
@Test public void testSuppressCaching() throws Exception { when(request.getSchema()).thenReturn(schema); when(schema.getQueryAnalyzer()).thenReturn(new StandardAnalyzer()); when(rewriteChain.rewrite(any(), any())).thenReturn(new ExpandedQuery(new MatchAllQuery())); final ModifiableSolrParams solrParams = new ModifiableSolrParams(); solrParams.add("qf", "f1"); final ModifiableSolrParams localParams = new ModifiableSolrParams(); localParams.add(CommonParams.CACHE, CommonParams.FALSE); final QuerqyDismaxQParser parser = new QuerqyDismaxQParser("*:*", localParams, solrParams, request, querqyParser, rewriteChain, infoLogging, null); final Query query = parser.getQuery(); Assert.assertTrue(query instanceof ExtendedQuery); final ExtendedQuery extendedQuery = (ExtendedQuery) query; Assert.assertFalse(extendedQuery.getCache()); }
@Test public void testForceCaching() throws Exception { when(request.getSchema()).thenReturn(schema); when(schema.getQueryAnalyzer()).thenReturn(new StandardAnalyzer()); when(rewriteChain.rewrite(any(), any())).thenReturn(new ExpandedQuery(new MatchAllQuery())); final ModifiableSolrParams solrParams = new ModifiableSolrParams(); solrParams.add("qf", "f1"); final ModifiableSolrParams localParams = new ModifiableSolrParams(); localParams.add(CommonParams.CACHE, CommonParams.TRUE); final QuerqyDismaxQParser parser = new QuerqyDismaxQParser("*:*", localParams, solrParams, request, querqyParser, rewriteChain, infoLogging, null); final Query query = parser.getQuery(); Assert.assertTrue(query instanceof ExtendedQuery); final ExtendedQuery extendedQuery = (ExtendedQuery) query; Assert.assertTrue(extendedQuery.getCache()); }