ranges.add("004000000");
FacetHandler<?> facetHandler = new DynamicTimeRangeFacetHandler("timerange", "timeinmillis", now, ranges );
browser.setFacetHandler(facetHandler );
//
BrowseRequest req = new BrowseRequest();
BrowseFacet facet = null;
FacetSpec facetSpec = new FacetSpec();
req.setFacetSpec("timerange", facetSpec);
BrowseResult result = browser.browse(req);
FacetAccessible facetholder = result.getFacetAccessor("timerange");
List<BrowseFacet> facets = facetholder.getFacets();
facet = facets.get(0);
assertEquals("order by value", "000000001", facet.getValue());
assertEquals("order by value", 1 , facet.getFacetValueHitCount());
facet = facets.get(1);
assertEquals("order by value", "000010000", facet.getValue());
assertEquals("order by value", 1 , facet.getFacetValueHitCount());
facet = facets.get(5);
assertEquals("order by value", "001000000", facet.getValue());
assertEquals("order by value", 20 , facet.getFacetValueHitCount());
facet = facets.get(7);
assertEquals("order by value", "003000000", facet.getValue());
assertEquals("order by value", 3 , facet.getFacetValueHitCount());
//
req = new BrowseRequest();
facetSpec = new FacetSpec();
facetSpec.setMinHitCount(0);
facetSpec.setOrderBy(FacetSortSpec.OrderHitsDesc);
req.setFacetSpec("timerange", facetSpec);
result = browser.browse(req);
facetholder = result.getFacetAccessor("timerange");
facets = facetholder.getFacets();
facet = facets.get(0);
assertEquals("", "002000000", facet.getValue());
assertEquals("", 25 , facet.getFacetValueHitCount());
facet = facets.get(1);
assertEquals("", "001000000", facet.getValue());
assertEquals("", 20 , facet.getFacetValueHitCount());
facet = facets.get(2);
assertEquals("", "003000000", facet.getValue());
assertEquals("", 3 , facet.getFacetValueHitCount());
facet = facets.get(8);
assertEquals("minCount=0", "004000000", facet.getValue());
assertEquals("minCount=0", 0 , facet.getFacetValueHitCount());
//
req = new BrowseRequest();
facetSpec = new FacetSpec();
BrowseSelection sel = new BrowseSelection("timerange");
sel.addValue("001000000");
req.addSelection(sel);
facetSpec.setExpandSelection(true);
req.setFacetSpec("timerange", facetSpec);
result = browser.browse(req);
facetholder = result.getFacetAccessor("timerange");
facets = facetholder.getFacets();
facet = facets.get(0);
assertEquals("", "000000001", facet.getValue());
assertEquals("", 1 , facet.getFacetValueHitCount());
facet = facets.get(6);
assertEquals("", "002000000", facet.getValue());
assertEquals("", 25 , facet.getFacetValueHitCount());
facet = facets.get(7);
assertEquals("", "003000000", facet.getValue());
assertEquals("", 3 , facet.getFacetValueHitCount());
//
req = new BrowseRequest();
facetSpec = new FacetSpec();
sel = new BrowseSelection("timerange");
sel.addValue("001000000");
sel.addValue("003000000");
sel.addValue("004000000");
req.addSelection(sel );
facetSpec.setExpandSelection(false);
req.setFacetSpec("timerange", facetSpec);
result = browser.browse(req);
facetholder = result.getFacetAccessor("timerange");
facet = facetholder.getFacet("001000000");
assertEquals("001000000", 20, facet.getFacetValueHitCount());
facet = facetholder.getFacet("003000000");
assertEquals("003000000", 3, facet.getFacetValueHitCount());
facet = facetholder.getFacet("004000000");
assertEquals("004000000", 0, facet.getFacetValueHitCount());
assertEquals("",23,result.getNumHits());
}