.toString();
PutMethod putMethod = executePut(attachmentUri, content, MediaType.TEXT_PLAIN, "Admin", "admin");
Assert.assertEquals(getHttpMethodInfo(putMethod), HttpStatus.SC_CREATED, putMethod.getStatusCode());
Attachment attachment = (Attachment) this.unmarshaller.unmarshal(putMethod.getResponseBodyAsStream());
pageVersions[i] = attachment.getPageVersion();
}
/*
* For each page version generated, check that the attachments that are supposed to be there are actually there.
* We do the following: at pageVersion[i] we check that all attachmentNames[0..i] are there.
*/
for (int i = 0; i < NUMBER_OF_ATTACHMENTS; i++) {
String attachmentsUri =
getUriBuilder(AttachmentsAtPageVersionResource.class).build(getWiki(), SPACE_NAME, PAGE_NAME,
pageVersions[i]).toString();
GetMethod getMethod = executeGet(attachmentsUri);
Assert.assertEquals(getHttpMethodInfo(getMethod), HttpStatus.SC_OK, getMethod.getStatusCode());
Attachments attachments = (Attachments) this.unmarshaller.unmarshal(getMethod.getResponseBodyAsStream());
/*
* Check that all attachmentNames[0..i] are present in the list of attachments of page at version
* pageVersions[i]
*/
for (int j = 0; j <= i; j++) {
boolean found = false;
for (Attachment attachment : attachments.getAttachments()) {
if (attachment.getName().equals(attachmentNames[j])) {
if (attachment.getPageVersion().equals(pageVersions[i])) {
found = true;
break;
}
}
}