.setSystemTags(ImmutableSet.<String>of());
dbSession.commit();
// should not have any facet!
RuleQuery query = new RuleQuery();
Result result = index.search(query, new QueryContext());
assertThat(result.getFacets()).isEmpty();
// should not have any facet on non matching query!
result = index.search(new RuleQuery().setQueryText("aeiou"), new QueryContext().addFacets(Arrays.asList("repositories")));
assertThat(result.getFacets()).isEmpty();
// Repositories Facet is preset
result = index.search(query, new QueryContext().addFacets(Arrays.asList("repositories", "tags")));
assertThat(result.getFacets()).isNotNull();
assertThat(result.getFacets()).hasSize(3);
// Verify the value of a given facet
Collection<FacetValue> repoFacets = result.getFacetValues("repositories");
assertThat(repoFacets).hasSize(2);
assertThat(Iterables.get(repoFacets, 0).getKey()).isEqualTo("php");
assertThat(Iterables.get(repoFacets, 0).getValue()).isEqualTo(2);
assertThat(Iterables.get(repoFacets, 1).getKey()).isEqualTo("javascript");
assertThat(Iterables.get(repoFacets, 1).getValue()).isEqualTo(1);
// Check that tag facet has both Tags and SystemTags values
Collection<FacetValue> tagFacet = result.getFacetValues("tags");
assertThat(tagFacet).hasSize(3);
assertThat(Iterables.get(tagFacet, 0).getKey()).isEqualTo("tag1");
assertThat(Iterables.get(tagFacet, 0).getValue()).isEqualTo(2);
}