SolrFacetFieldsService implements FacetFieldsService { @Override public List<FacetField> getFacetFields(QueryFacetsSelection selection, List<String> facets, int valueLimit) { return removeSelectedValsFromResponse(selection, searchResultsDao.getFacets(queryFatory.createFacetQuery(selection, facets, valueLimit))); } 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 testGetFacetFields() { final QueryFacetsSelection selection = new QueryFacetsSelection("query"); 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).createFacetQuery(selection, facets, 20); will(returnValue(query)); oneOf(dao).getFacets(query); will(returnValue(fields)); } }); final List<FacetField> result = instance.getFacetFields(selection, facets, 20); assertEquals(fields, result); }