/**
* Tests the {@link FieldAnalysisRequestHandler#resolveAnalysisRequest(org.apache.solr.request.SolrQueryRequest)}
*/
public void testResolveAnalysisRequest() throws Exception {
ModifiableSolrParams params = new ModifiableSolrParams();
params.add(AnalysisParams.FIELD_NAME, "text,nametext");
params.add(AnalysisParams.FIELD_TYPE, "whitetok,keywordtok");
params.add(AnalysisParams.FIELD_VALUE, "the quick red fox jumped over the lazy brown dogs");
params.add(CommonParams.Q, "fox brown");
FieldAnalysisRequest request = handler.resolveAnalysisRequest(new LocalSolrQueryRequest(h.getCore(), params));
List<String> fieldNames = request.getFieldNames();
assertEquals("Expecting 2 field names", 2, fieldNames.size());
assertEquals("text", fieldNames.get(0));
assertEquals("nametext", fieldNames.get(1));
List<String> fieldTypes = request.getFieldTypes();
assertEquals("Expecting 2 field types", 2, fieldTypes.size());
assertEquals("whitetok", fieldTypes.get(0));
assertEquals("keywordtok", fieldTypes.get(1));
assertEquals("the quick red fox jumped over the lazy brown dogs", request.getFieldValue());
assertEquals("fox brown", request.getQuery());
assertFalse(request.isShowMatch());
// testing overide of query value using analysis.query param
params.add(AnalysisParams.QUERY, "quick lazy");
request = handler.resolveAnalysisRequest(new LocalSolrQueryRequest(h.getCore(), params));
assertEquals("quick lazy", request.getQuery());
// testing analysis.showmatch param
params.add(AnalysisParams.SHOW_MATCH, "false");
request = handler.resolveAnalysisRequest(new LocalSolrQueryRequest(h.getCore(), params));
assertFalse(request.isShowMatch());
params.set(AnalysisParams.SHOW_MATCH, "true");
request = handler.resolveAnalysisRequest(new LocalSolrQueryRequest(h.getCore(), params));
assertTrue(request.isShowMatch());
// testing absence of query value
params.remove(CommonParams.Q);
params.remove(AnalysisParams.QUERY);
request = handler.resolveAnalysisRequest(new LocalSolrQueryRequest(h.getCore(), params));
assertNull(request.getQuery());
}