forked from apache/solr
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SOLR-17477: adding changes and one more demo test
- Loading branch information
Showing
2 changed files
with
49 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
solr/core/src/test/org/apache/solr/search/function/CustomParseHandlerTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package org.apache.solr.search.function; | ||
|
||
import org.apache.solr.SolrTestCaseJ4; | ||
import org.apache.solr.handler.component.ResponseBuilder; | ||
import org.apache.solr.request.SolrQueryRequest; | ||
import org.apache.solr.response.SolrQueryResponse; | ||
import org.apache.solr.search.SyntaxError; | ||
import org.apache.solr.search.facet.FacetField; | ||
import org.apache.solr.search.facet.FacetParser; | ||
import org.apache.solr.search.facet.FacetRequest; | ||
import org.junit.BeforeClass; | ||
|
||
import java.util.Collections; | ||
import java.util.Map; | ||
|
||
|
||
public class CustomParseHandlerTest extends SolrTestCaseJ4 { | ||
|
||
public static final FacetField FACET_FIELD_STUB = new FacetField(); | ||
|
||
static class CustomParseHandler implements FacetParser.ParseHandler { | ||
@Override | ||
public Object doParse(FacetParser<?> parent, String key, Object args) { | ||
assertEquals("arg", args); | ||
return FACET_FIELD_STUB; | ||
} | ||
} | ||
|
||
@BeforeClass | ||
public static void beforeClass() throws Exception { | ||
initCore("solrconfig.xml", "schema.xml"); | ||
} | ||
|
||
@Override | ||
public void setUp() throws Exception { | ||
super.setUp(); | ||
FacetParser.registerParseHandler("custom", new CustomParseHandler()); | ||
} | ||
|
||
public void testCustomParseHandler() { | ||
SolrQueryRequest req = req(); | ||
ResponseBuilder rsp = new ResponseBuilder(req, new SolrQueryResponse(), Collections.emptyList()); | ||
|
||
FacetRequest facetRequest = FacetRequest.parse(rsp.req, Map.of("bogus",Map.of("custom","arg"))); | ||
assertEquals(FACET_FIELD_STUB, facetRequest.getSubFacets().get("bogus")); | ||
} | ||
} |