use of org.xwiki.rest.model.jaxb.PageSummary in project xwiki-platform by xwiki.
the class WikisResourceTest method testPages.
@Test
public void testPages() throws Exception {
// Create a clean test page.
this.testUtils.rest().delete(this.reference);
this.testUtils.rest().savePage(this.reference);
// Get all pages
GetMethod getMethod = executeGet(String.format("%s", buildURI(WikiPagesResource.class, 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=" + this.pageName, buildURI(WikiPagesResource.class, 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() == 1);
PageSummary pageSummary = pageSummaries.get(0);
assertEquals(this.fullName, pageSummary.getFullName());
checkLinks(pageSummary);
// 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=" + this.pageName + "&space=" + this.fullName.charAt(2), buildURI(WikiPagesResource.class, getWiki())));
Assert.assertEquals(getHttpMethodInfo(getMethod), HttpStatus.SC_OK, getMethod.getStatusCode());
pages = (Pages) unmarshaller.unmarshal(getMethod.getResponseBodyAsStream());
pageSummaries = pages.getPageSummaries();
Assert.assertTrue(pageSummaries.size() == 1);
pageSummary = pageSummaries.get(0);
assertEquals(this.fullName, pageSummary.getFullName());
checkLinks(pageSummary);
}
use of org.xwiki.rest.model.jaxb.PageSummary in project xwiki-platform by xwiki.
the class ModelFactory method toRestPageSummary.
public PageSummary toRestPageSummary(URI baseUri, Document doc, Boolean withPrettyNames) throws XWikiException {
PageSummary pageSummary = this.objectFactory.createPageSummary();
toRestPageSummary(pageSummary, baseUri, doc, false, withPrettyNames);
String pageUri = Utils.createURI(baseUri, PageResource.class, doc.getWiki(), Utils.getSpacesFromSpaceId(doc.getSpace()), doc.getName()).toString();
Link pageLink = this.objectFactory.createLink();
pageLink.setHref(pageUri);
pageLink.setRel(Relations.PAGE);
pageSummary.getLinks().add(pageLink);
return pageSummary;
}
Aggregations