// Verify there are attachments in the whole wiki
GetMethod getMethod =
executeGet(String.format("%s", getUriBuilder(WikiAttachmentsResource.class).build(getWiki())));
Assert.assertEquals(getHttpMethodInfo(getMethod), HttpStatus.SC_OK, getMethod.getStatusCode());
Attachments attachments = (Attachments) unmarshaller.unmarshal(getMethod.getResponseBodyAsStream());
Assert.assertTrue(attachments.getAttachments().size() > 0);
for (Attachment attachment : attachments.getAttachments()) {
checkLinks(attachment);
}
// Verify we can search for a specific attachment name in the whole wiki
// Matches Sandbox.WebHome@XWikLogo.png
getMethod =
executeGet(String.format("%s?name=Logo", getUriBuilder(WikiAttachmentsResource.class).build(getWiki())));
Assert.assertEquals(getHttpMethodInfo(getMethod), HttpStatus.SC_OK, getMethod.getStatusCode());
attachments = (Attachments) unmarshaller.unmarshal(getMethod.getResponseBodyAsStream());
Assert.assertEquals(getAttachmentsInfo(attachments), 1, attachments.getAttachments().size());
for (Attachment attachment : attachments.getAttachments()) {
checkLinks(attachment);
}
// Verify we can search for all attachments in a given space (sandbox)
// Also verify that a space can be looked up independtly of its case ("sandbox" will match the "Sandbox" space)
getMethod =
executeGet(String.format("%s?space=sandbox", getUriBuilder(WikiAttachmentsResource.class).build(getWiki())));
Assert.assertEquals(getHttpMethodInfo(getMethod), HttpStatus.SC_OK, getMethod.getStatusCode());
attachments = (Attachments) unmarshaller.unmarshal(getMethod.getResponseBodyAsStream());
Assert.assertEquals(getAttachmentsInfo(attachments), 1, attachments.getAttachments().size());
for (Attachment attachment : attachments.getAttachments()) {
checkLinks(attachment);
}
// Verify we can search for an attachment in a given space (sandbox)
getMethod =
executeGet(String.format("%s?name=Logo&space=Sandbox",
getUriBuilder(WikiAttachmentsResource.class).build(getWiki())));
Assert.assertEquals(getHttpMethodInfo(getMethod), HttpStatus.SC_OK, getMethod.getStatusCode());
attachments = (Attachments) unmarshaller.unmarshal(getMethod.getResponseBodyAsStream());
Assert.assertEquals(getAttachmentsInfo(attachments), 1, attachments.getAttachments().size());
for (Attachment attachment : attachments.getAttachments()) {
checkLinks(attachment);
}
}