Package org.xwiki.rest.model.jaxb

Examples of org.xwiki.rest.model.jaxb.SearchResults


        GetMethod getMethod =
            executeGet(String.format("%s?q=somethingthatcannotpossiblyexist", getUriBuilder(SpaceSearchResource.class)
                .build(getWiki(), "Main")));
        Assert.assertEquals(getHttpMethodInfo(getMethod), HttpStatus.SC_OK, getMethod.getStatusCode());

        SearchResults searchResults = (SearchResults) unmarshaller.unmarshal(getMethod.getResponseBodyAsStream());

        Assert.assertEquals(0, searchResults.getSearchResults().size());

        getMethod =
            executeGet(String.format("%s?q=sandbox", getUriBuilder(WikiSearchResource.class)
                .build(getWiki(), "Sandbox")));
        Assert.assertEquals(getHttpMethodInfo(getMethod), HttpStatus.SC_OK, getMethod.getStatusCode());

        searchResults = (SearchResults) unmarshaller.unmarshal(getMethod.getResponseBodyAsStream());

        int resultSize = searchResults.getSearchResults().size();
        Assert.assertTrue("Found " + resultSize + " result", resultSize >= 2);

        for (SearchResult searchResult : searchResults.getSearchResults()) {
            checkLinks(searchResult);
        }
    }
View Full Code Here


    {
        GetMethod getMethod =
            executeGet(String.format("%s?q=easy-to-edit", getUriBuilder(WikiSearchResource.class).build(getWiki())));
        Assert.assertEquals(getHttpMethodInfo(getMethod), HttpStatus.SC_OK, getMethod.getStatusCode());

        SearchResults searchResults = (SearchResults) unmarshaller.unmarshal(getMethod.getResponseBodyAsStream());

        int resultSize = searchResults.getSearchResults().size();
        Assert.assertTrue(String.format("Found %s results", resultSize), resultSize >= 1);

        for (SearchResult searchResult : searchResults.getSearchResults()) {
            checkLinks(searchResult);
        }

        getMethod =
            executeGet(String.format("%s?q=WebHome&scope=name", getUriBuilder(WikiSearchResource.class)
                .build(getWiki())));
        Assert.assertEquals(getHttpMethodInfo(getMethod), HttpStatus.SC_OK, getMethod.getStatusCode());

        searchResults = (SearchResults) unmarshaller.unmarshal(getMethod.getResponseBodyAsStream());

        resultSize = searchResults.getSearchResults().size();
        Assert.assertTrue(String.format("Found %s results", resultSize), resultSize >= 3);

        for (SearchResult searchResult : searchResults.getSearchResults()) {
            checkLinks(searchResult);
        }

        // Note: we use $msg.get(...) a bit everywhere in our title for the moment... The search is a search in the DB
        // and not on the rendered content. Thus for our tests we search on msg...
        getMethod =
            executeGet(String.format("%s?q=msg&scope=title", getUriBuilder(WikiSearchResource.class).build(getWiki())));
        Assert.assertEquals(getHttpMethodInfo(getMethod), HttpStatus.SC_OK, getMethod.getStatusCode());

        searchResults = (SearchResults) unmarshaller.unmarshal(getMethod.getResponseBodyAsStream());

        resultSize = searchResults.getSearchResults().size();
        Assert.assertTrue(String.format("Found %s results", resultSize), searchResults.getSearchResults().size() >= 1);

        for (SearchResult searchResult : searchResults.getSearchResults()) {
            checkLinks(searchResult);
        }

        /* Check search for space names. Here we should get at least Sandbox as a result */
        getMethod =
            executeGet(String.format("%s?q=db&scope=spaces", getUriBuilder(WikiSearchResource.class).build(getWiki())));
        Assert.assertEquals(getHttpMethodInfo(getMethod), HttpStatus.SC_OK, getMethod.getStatusCode());

        searchResults = (SearchResults) unmarshaller.unmarshal(getMethod.getResponseBodyAsStream());

        resultSize = searchResults.getSearchResults().size();
        Assert.assertTrue(String.format("Found %s results", resultSize), resultSize >= 1);

        for (SearchResult searchResult : searchResults.getSearchResults()) {
            checkLinks(searchResult);
        }
    }
View Full Code Here

    {
        GetMethod getMethod =
            executeGet(String.format("%s?q=easy-to-edit", getUriBuilder(WikiSearchResource.class).build(getWiki())));
        Assert.assertEquals(getHttpMethodInfo(getMethod), HttpStatus.SC_OK, getMethod.getStatusCode());

        SearchResults searchResults = (SearchResults) unmarshaller.unmarshal(getMethod.getResponseBodyAsStream());

        int resultSize = searchResults.getSearchResults().size();
        Assert.assertTrue(String.format("Found %s results", resultSize), resultSize >= 1);

        for (SearchResult searchResult : searchResults.getSearchResults()) {
            checkLinks(searchResult);
        }

        getMethod =
            executeGet(String.format("%s?q=WebHome&scope=name", getUriBuilder(WikiSearchResource.class)
                .build(getWiki())));
        Assert.assertEquals(getHttpMethodInfo(getMethod), HttpStatus.SC_OK, getMethod.getStatusCode());

        searchResults = (SearchResults) unmarshaller.unmarshal(getMethod.getResponseBodyAsStream());

        resultSize = searchResults.getSearchResults().size();
        Assert.assertTrue(String.format("Found %s results", resultSize), resultSize >= 3);

        for (SearchResult searchResult : searchResults.getSearchResults()) {
            checkLinks(searchResult);
        }

        // Note: we use $services.<service> a bit everywhere in our title for the moment... The search is a search in the DB
        // and not on the rendered content. Thus for our tests we search on services...
        getMethod =
            executeGet(String.format("%s?q=services&scope=title", getUriBuilder(WikiSearchResource.class).build(getWiki())));
        Assert.assertEquals(getHttpMethodInfo(getMethod), HttpStatus.SC_OK, getMethod.getStatusCode());

        searchResults = (SearchResults) unmarshaller.unmarshal(getMethod.getResponseBodyAsStream());

        resultSize = searchResults.getSearchResults().size();
        Assert.assertTrue(String.format("Found %s results", resultSize), searchResults.getSearchResults().size() >= 1);

        for (SearchResult searchResult : searchResults.getSearchResults()) {
            checkLinks(searchResult);
        }

        /* Check search for space names. Here we should get at least Sandbox as a result */
        getMethod =
            executeGet(String.format("%s?q=db&scope=spaces", getUriBuilder(WikiSearchResource.class).build(getWiki())));
        Assert.assertEquals(getHttpMethodInfo(getMethod), HttpStatus.SC_OK, getMethod.getStatusCode());

        searchResults = (SearchResults) unmarshaller.unmarshal(getMethod.getResponseBodyAsStream());

        resultSize = searchResults.getSearchResults().size();
        Assert.assertTrue(String.format("Found %s results", resultSize), resultSize >= 1);

        for (SearchResult searchResult : searchResults.getSearchResults()) {
            checkLinks(searchResult);
        }
    }
View Full Code Here

        GetMethod getMethod =
            executeGet(String.format("%s?q=XWiki.Admin&scope=objects",
                getUriBuilder(WikiSearchResource.class).build(getWiki())));
        Assert.assertEquals(getHttpMethodInfo(getMethod), HttpStatus.SC_OK, getMethod.getStatusCode());

        SearchResults searchResults = (SearchResults) unmarshaller.unmarshal(getMethod.getResponseBodyAsStream());

        int resultSize = searchResults.getSearchResults().size();
        Assert.assertTrue(String.format("Found %s results", resultSize), resultSize == 0);
    }
View Full Code Here

            executeGet(String.format("%s?q=XWiki.Admin&scope=objects",
                getUriBuilder(WikiSearchResource.class).build(getWiki())), TestUtils.ADMIN_CREDENTIALS.getUserName(),
                TestUtils.ADMIN_CREDENTIALS.getPassword());
        Assert.assertEquals(getHttpMethodInfo(getMethod), HttpStatus.SC_OK, getMethod.getStatusCode());

        SearchResults searchResults = (SearchResults) unmarshaller.unmarshal(getMethod.getResponseBodyAsStream());

        /*
         * We get more results because previous tests have also created comments on behalf of XWiki.Admin. They will
         * appear in the results.
         */
        int resultSize = searchResults.getSearchResults().size();
        Assert.assertTrue(String.format("Found %s results", resultSize), resultSize >= 1);
    }
View Full Code Here

            executeGet(URIUtil.encodeQuery(String.format(
                "%s?q=where doc.name='WebHome' order by doc.space desc&type=hql",
                getUriBuilder(WikiSearchQueryResource.class).build(getWiki()))));
        Assert.assertEquals(getHttpMethodInfo(getMethod), HttpStatus.SC_OK, getMethod.getStatusCode());

        SearchResults searchResults = (SearchResults) unmarshaller.unmarshal(getMethod.getResponseBodyAsStream());

        int resultSize = searchResults.getSearchResults().size();
        Assert.assertTrue(String.format("Found %s results", resultSize), resultSize >= 1);

        // Verify that some WebHomes we expect are found.
        int foundCounter = 0;
        List<String> expectedWebHomes =
            Arrays.asList("ColorThemes.WebHome", "Stats.WebHome", "Sandbox.WebHome", "Panels.WebHome",
                "Scheduler.WebHome", "Sandbox.WebHome", "XWiki.WebHome");
        for (SearchResult searchResult : searchResults.getSearchResults()) {
            checkLinks(searchResult);

            if (expectedWebHomes.contains(searchResult.getPageFullName())) {
                foundCounter++;
            }

            Assert.assertTrue(searchResult.getPageFullName().endsWith(".WebHome"));
        }

        // Note: since we can have translations, the number of found pages can be greater than the expected size.
        Assert.assertTrue("Some WebHome pages were not found!", foundCounter >= expectedWebHomes.size());

        Assert.assertEquals("XWiki.WebHome", searchResults.getSearchResults().get(0).getPageFullName());
    }
View Full Code Here

                "%s?q=where doc.space='XWiki' and doc.name='Admin'&type=hql&className=XWiki.XWikiUsers",
                getUriBuilder(WikiSearchQueryResource.class).build(getWiki()))),
                TestUtils.ADMIN_CREDENTIALS.getUserName(), TestUtils.ADMIN_CREDENTIALS.getPassword());
        Assert.assertEquals(getHttpMethodInfo(getMethod), HttpStatus.SC_OK, getMethod.getStatusCode());

        SearchResults searchResults = (SearchResults) unmarshaller.unmarshal(getMethod.getResponseBodyAsStream());

        int resultSize = searchResults.getSearchResults().size();
        Assert.assertTrue(String.format("Found %s results", resultSize), resultSize == 1);

        Assert.assertNotNull(searchResults.getSearchResults().get(0).getObject());
    }
View Full Code Here

            executeGet(URIUtil.encodeQuery(String.format(
                "%s?q=where doc.space='XWiki' and doc.name='Admin'&type=hql&classname=XWiki.XWikiUsers",
                getUriBuilder(WikiSearchQueryResource.class).build(getWiki()))));
        Assert.assertEquals(getHttpMethodInfo(getMethod), HttpStatus.SC_OK, getMethod.getStatusCode());

        SearchResults searchResults = (SearchResults) unmarshaller.unmarshal(getMethod.getResponseBodyAsStream());

        int resultSize = searchResults.getSearchResults().size();
        Assert.assertTrue(String.format("Found %s results", resultSize), resultSize == 1);

        Assert.assertNull(searchResults.getSearchResults().get(0).getObject());
    }
View Full Code Here

        GetMethod getMethod =
            executeGet(URIUtil.encodeQuery(String.format("%s?q=\"easy-to-edit\"&type=lucene",
                getUriBuilder(WikiSearchQueryResource.class).build(getWiki()))));
        Assert.assertEquals(getHttpMethodInfo(getMethod), HttpStatus.SC_OK, getMethod.getStatusCode());

        SearchResults searchResults = (SearchResults) unmarshaller.unmarshal(getMethod.getResponseBodyAsStream());

        int resultSize = searchResults.getSearchResults().size();
        Assert.assertTrue(String.format("Found %s results", resultSize), resultSize == 1);

        Assert.assertEquals("Main.Welcome", searchResults.getSearchResults().get(0).getPageFullName());
    }
View Full Code Here

        GetMethod getMethod =
            executeGet(URIUtil.encodeQuery(String.format("%s?q=\"easy-to-edit\"&type=lucene&wikis=xwiki",
                getUriBuilder(WikisSearchQueryResource.class).build(getWiki()))));
        Assert.assertEquals(getHttpMethodInfo(getMethod), HttpStatus.SC_OK, getMethod.getStatusCode());

        SearchResults searchResults = (SearchResults) unmarshaller.unmarshal(getMethod.getResponseBodyAsStream());

        int resultSize = searchResults.getSearchResults().size();
        Assert.assertTrue(String.format("Found %s results", resultSize), resultSize == 1);

        Assert.assertEquals("Main.Welcome", searchResults.getSearchResults().get(0).getPageFullName());
    }
View Full Code Here

TOP

Related Classes of org.xwiki.rest.model.jaxb.SearchResults

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.