Package org.fao.geonet.kernel.search.keyword

Examples of org.fao.geonet.kernel.search.keyword.KeywordSearchParamsBuilder


    }

    @Test
    public void testSearchMaxResults() throws Exception {
        KeywordsSearcher searcher = new KeywordsSearcher(isoLangMapper, thesaurusFinder);
        KeywordSearchParamsBuilder params = new KeywordSearchParamsBuilder(isoLangMapper)
            .addLang("eng")
            .maxResults(5);
        searcher.search(params.build());
        assertEquals(5, searcher.getNbResults());
    }
View Full Code Here


        assertEquals(5, searcher.getNbResults());
    }
    @Test
    public void testSearchOffest() throws Exception {
        KeywordsSearcher searcher = new KeywordsSearcher(isoLangMapper, thesaurusFinder);
        KeywordSearchParamsBuilder params = new KeywordSearchParamsBuilder(isoLangMapper)
            .addLang("eng")
            .offset(5);
        try {
            params.build();
            fail("Expected an IllegalStateException because offset is not allowed if no thesaurus is defined");
        } catch (IllegalStateException e) {
            // good
        }
        params.addThesaurus(thesaurus.getKey());
        searcher.search(params.build());
        assertEquals(keywords-5, searcher.getNbResults());
       
        params.addThesaurus(thesaurusBlah.getKey());
        try {
            params.build();
            fail("Expected an IllegalStateException because offset is not allowed if more than one thesaurus");
        } catch (IllegalStateException e) {
            // good
        }
       
View Full Code Here

       
    }
    @Test
    public void testSearchOffestMaxResults() throws Exception {
        KeywordsSearcher searcher = new KeywordsSearcher(isoLangMapper, thesaurusFinder);
        KeywordSearchParamsBuilder params = new KeywordSearchParamsBuilder(isoLangMapper)
            .addLang("eng")
            .offset(5)
            .addThesaurus(thesaurus.getKey())
            .maxResults(5);
        searcher.search(params.build());
        assertEquals(5, searcher.getNbResults());
        assertEquals("5", searcher.getResults().get(0).getRelativeCode());
    }
View Full Code Here

        assertEquals("5", searcher.getResults().get(0).getRelativeCode());
    }
    @Test
    public void testSearchContextNoLangKeywordNoSearchTwoSpecificThesauri() throws Exception {
        KeywordsSearcher searcher = new KeywordsSearcher(isoLangMapper, thesaurusFinder);
        KeywordSearchParamsBuilder params = new KeywordSearchParamsBuilder(isoLangMapper)
            .addThesaurus(thesaurusFoo.getKey())
            .addThesaurus(thesaurusBlah.getKey());
       
        searcher.search("ger" , params.toXmlParams());

        for (KeywordBean word : searcher.getResults()) {
            assertEquals("ger", word.getDefaultLang());
            assertTrue(word.getValues().keySet().containsAll(Arrays.asList("ger")));
            assertEquals(1, word.getValues().size());
View Full Code Here

    }

    @Test
    public void testSortResults() throws Exception {
        KeywordsSearcher searcher = new KeywordsSearcher(isoLangMapper, thesaurusFinder);
        KeywordSearchParamsBuilder params = new KeywordSearchParamsBuilder(isoLangMapper)
            .addLang("eng")
            .maxResults(10);
        searcher.search(params.build());
        searcher.sortResults(KeywordSort.defaultLabelSorter(SortDirection.ASC));
       
        for(int i=0; i < searcher.getNbResults() - 2; i++ ){
            String val1 = searcher.getResults().get(i).getDefaultValue();
            String val2 = searcher.getResults().get(i+1).getDefaultValue();
View Full Code Here

    }

    @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) {
View Full Code Here

    }

    @Test
    public void testExistsResult() throws Exception {
        KeywordsSearcher searcher = new KeywordsSearcher(isoLangMapper, thesaurusFinder);
        KeywordSearchParamsBuilder params = new KeywordSearchParamsBuilder(isoLangMapper)
            .addLang("eng")
            .maxResults(10);
        searcher.search(params.build());
       
        assertEquals(2, searcher.getKeywordFromResultsById(2).getId());
        assertNotNull(searcher.getKeywordFromResultsByUriCode(searcher.getResults().get(4).getUriCode()).getId());
        assertNull(searcher.getKeywordFromResultsById(100));
    }
View Full Code Here

TOP

Related Classes of org.fao.geonet.kernel.search.keyword.KeywordSearchParamsBuilder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.