{
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);
}
}