use of com.enonic.xp.attachment.Attachment in project xp by enonic.
the class TestDataFixtures method newAttachments.
public static Attachments newAttachments() {
final Attachment a1 = Attachment.create().name("logo.png").mimeType("image/png").label("small").size(6789).build();
final Attachment a2 = Attachment.create().name("document.pdf").mimeType("application/pdf").size(12345).build();
return Attachments.from(a1, a2);
}
use of com.enonic.xp.attachment.Attachment in project xp by enonic.
the class AttachmentsMapper method serialize.
@Override
public void serialize(final MapGenerator gen) {
for (Attachment attachment : attachments) {
gen.map(attachment.getName());
serializeAttachment(gen, attachment);
gen.end();
}
}
use of com.enonic.xp.attachment.Attachment in project xp by enonic.
the class GetAttachmentStreamHandlerTest method getById_AttachmentNotFound.
@Test
public void getById_AttachmentNotFound() throws Exception {
final Content content = TestDataFixtures.newContent();
final Attachment attachment = content.getAttachments().byName("document.pdf");
Mockito.when(this.contentService.getById(content.getId())).thenReturn(content);
Mockito.when(this.contentService.getBinary(content.getId(), attachment.getBinaryReference())).thenReturn(ByteSource.wrap(ATTACHMENT_DATA));
runFunction("/test/GetAttachmentStreamHandlerTest.js", "getAttachmentStreamById_AttachmentNotFound");
}
use of com.enonic.xp.attachment.Attachment in project xp by enonic.
the class GetAttachmentStreamHandlerTest method mockAttachmentBinary.
private void mockAttachmentBinary() {
final Content content = TestDataFixtures.newContent();
final Attachment attachment = content.getAttachments().byName("document.pdf");
Mockito.when(this.contentService.getById(content.getId())).thenReturn(content);
Mockito.when(this.contentService.getByPath(content.getPath())).thenReturn(content);
Mockito.when(this.contentService.getBinary(content.getId(), attachment.getBinaryReference())).thenReturn(ByteSource.wrap(ATTACHMENT_DATA));
}
use of com.enonic.xp.attachment.Attachment in project xp by enonic.
the class ImageHandlerTest method setupContentSvgz.
private void setupContentSvgz() throws Exception {
final Attachment attachment = Attachment.create().name("enonic-logo.svgz").mimeType("image/svg+xml").label("source").build();
final Content content = createContent("123456", "path/to/image-name.svgz", attachment);
when(this.contentService.getById(eq(content.getId()))).thenReturn(content);
when(this.contentService.getByPath(eq(content.getPath()))).thenReturn(content);
final ByteSource imageBytes = ByteSource.wrap(new byte[0]);
when(this.contentService.getBinary(isA(ContentId.class), isA(BinaryReference.class))).thenReturn(imageBytes);
when(this.imageService.readImage(isA(ReadImageParams.class))).thenReturn(imageBytes);
}
Aggregations