SolrFacetFieldsService implements FacetFieldsService { @Override public long getFacetFieldCount(List<String> facets) { return (long) searchResultsDao.getFacets(queryFatory.createCountFacetsQuery(facets)).size(); } SolrFacetFieldsService(SearchResultsDao searchResultsDao, SolrFacetQueryFactory queryFatory); @Override List<FacetField> getFacetFields(QueryFacetsSelection selection, List<String> facets, int valueLimit); @Override long getFacetFieldCount(List<String> facets);  }
@Test public void testGetFacetFieldCount() { final SolrQuery query = new SolrQuery("query"); final List<FacetField> fields = ImmutableList.of(new FacetField("field1"), new FacetField("field2")); final List<String> facets = ImmutableList.of("facet1", "facet2"); context.checking(new Expectations() { { oneOf(queryFactory).createCountFacetsQuery(facets); will(returnValue(query)); oneOf(dao).getFacets(query); will(returnValue(fields)); } }); final long result = instance.getFacetFieldCount(facets); assertEquals(2, result); }