{
// Get all pages
GetMethod getMethod = executeGet(String.format("%s", getUriBuilder(WikiPagesResource.class).build(getWiki())));
Assert.assertEquals(getHttpMethodInfo(getMethod), HttpStatus.SC_OK, getMethod.getStatusCode());
Pages pages = (Pages) unmarshaller.unmarshal(getMethod.getResponseBodyAsStream());
Assert.assertTrue(pages.getPageSummaries().size() > 0);
for (PageSummary pageSummary : pages.getPageSummaries()) {
checkLinks(pageSummary);
}
// Get all pages having a document name that contains "WebHome" (for all spaces)
getMethod =
executeGet(String.format("%s?name=WebHome", getUriBuilder(WikiPagesResource.class).build(getWiki())));
Assert.assertEquals(getHttpMethodInfo(getMethod), HttpStatus.SC_OK, getMethod.getStatusCode());
pages = (Pages) unmarshaller.unmarshal(getMethod.getResponseBodyAsStream());
List<PageSummary> pageSummaries = pages.getPageSummaries();
Assert.assertTrue(pageSummaries.size() > 0);
// Verify that some WebHomes we expect are found.
int foundCounter = 0;
List<String> expectedWebHomes = Arrays.asList("Main.WebHome", "Sandbox.WebHome", "XWiki.WebHome");
for (PageSummary pageSummary : pages.getPageSummaries()) {
if (expectedWebHomes.contains(pageSummary.getFullName())) {
foundCounter++;
}
Assert.assertTrue(pageSummary.getFullName().endsWith(".WebHome"));
checkLinks(pageSummary);
}
// 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());
// Get all pages having a document name that contains "WebHome" and a space with an "s" in its name.
getMethod =
executeGet(String
.format("%s?name=WebHome&space=s", getUriBuilder(WikiPagesResource.class).build(getWiki())));
Assert.assertEquals(getHttpMethodInfo(getMethod), HttpStatus.SC_OK, getMethod.getStatusCode());
pages = (Pages) unmarshaller.unmarshal(getMethod.getResponseBodyAsStream());
pageSummaries = pages.getPageSummaries();
Assert.assertTrue(pageSummaries.size() > 0);
// Verify that some WebHomes we expect are found.
foundCounter = 0;
expectedWebHomes =
Arrays.asList("ColorThemes.WebHome", "Stats.WebHome", "Sandbox.WebHome", "Panels.WebHome",
"Scheduler.WebHome", "Sandbox.WebHome");
for (PageSummary pageSummary : pages.getPageSummaries()) {
if (expectedWebHomes.contains(pageSummary.getFullName())) {
foundCounter++;
}
Assert.assertTrue(pageSummary.getFullName().endsWith(".WebHome"));
checkLinks(pageSummary);