@Test
public void testSelectUnselectKeywords() throws Exception {

    KeywordsSearcher searcher = new KeywordsSearcher(isoLangMapper, thesaurusFinder);
    KeywordSearchParamsBuilder params = new KeywordSearchParamsBuilder(isoLangMapper)
        .addLang("eng")
        .maxResults(10);
    searcher.search(params.build());
    Element selectParams = new Element("params");
    Set<String> ids = new HashSet<String>();
    for (int i = 0; i < 5; i++) {
        KeywordBean bean = searcher.getResults().get(i);
        if (i % 2 == 0) {
            ids.add(bean.getUriCode());
        } else {
            ids.add("" + bean.getId());
        }
    }
    for (String string : ids) {
        selectParams.addContent(new Element("pIdKeyword").setText(string));
    }
    searcher.selectUnselectKeywords(selectParams);
    assertEquals(5, searcher.getSelectedKeywordsInList().size());
    assertEquals(5, searcher.getSelectedKeywordsAsXml().getChildren("keyword").size());
    searcher.selectUnselectKeywords(selectParams);
    assertEquals(0, searcher.getSelectedKeywordsInList().size());
    assertEquals(0, searcher.getSelectedKeywordsAsXml().getChildren("keyword").size());
    searcher.selectUnselectKeywords(ids);
    assertEquals(5, searcher.getSelectedKeywordsInList().size());
    searcher.selectUnselectKeywords(ids);
    assertEquals(0, searcher.getSelectedKeywordsInList().size());
    searcher.selectUnselectKeywords(ids);
    searcher.clearSelection();
    assertEquals(0, searcher.getSelectedKeywordsInList().size());
}