@Test
public void testSearchResultsSorter() throws Exception {

    Comparator<KeywordBean> comparator = KeywordSort.searchResultsSorter("wate", SortDirection.DESC);
    KeywordBean waterBean = new KeywordBean(new IsoLanguagesMapper()).setValue("Water", "eng").setDefaultLang("eng");
    KeywordBean waterSurfaceBean = new KeywordBean(new IsoLanguagesMapper()).setValue("Water (Surface)", "eng").setDefaultLang("eng");
    KeywordBean waterAgricultureBean = new KeywordBean(new IsoLanguagesMapper()).setValue("Water Agriculture", "eng").setDefaultLang("eng");
    KeywordBean waterGeogBean = new KeywordBean(new IsoLanguagesMapper()).setValue("Water (Geographic)", "eng").setDefaultLang("eng");
    KeywordBean wasteWaterBean = new KeywordBean(new IsoLanguagesMapper()).setValue("Waste Water", "eng").setDefaultLang("eng");
    KeywordBean wasteWaterTreatmentBean = new KeywordBean(new IsoLanguagesMapper()).setValue("Waste Water treatment", "eng").setDefaultLang("eng");
    KeywordBean atmosphereWaterBean = new KeywordBean(new IsoLanguagesMapper()).setValue("Atmosphere Water", "eng").setDefaultLang("eng");
    ArrayList<KeywordBean> expected = Lists.newArrayList(waterBean, waterAgricultureBean, waterGeogBean, waterSurfaceBean,
        atmosphereWaterBean, wasteWaterBean, wasteWaterTreatmentBean);
    Collection<List<KeywordBean>> permutations = Collections2.permutations(expected);
    for (List<KeywordBean> permutation : permutations) {
        ArrayList<KeywordBean> copy = Lists.newArrayList(permutation);
        Collections.sort(copy, comparator);
        assertArrayEquals(expected.toArray(), copy.toArray());
    }
}