use of com.enonic.xp.content.Content 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.content.Content 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.content.Content in project xp by enonic.
the class ModifyContentHandlerTest method modifyNotMappedXDataFieldNameNotStricted.
@Test
public void modifyNotMappedXDataFieldNameNotStricted() throws Exception {
final Content content = TestDataFixtures.newSmallContent();
when(this.contentService.getByPath(content.getPath())).thenReturn(content);
when(this.contentService.update(Mockito.isA(UpdateContentParams.class))).thenAnswer(invocationOnMock -> invokeUpdate((UpdateContentParams) invocationOnMock.getArguments()[0], TestDataFixtures.newSmallContent()));
mockXData();
runFunction("/test/ModifyContentHandlerTest.js", "modifyNotMappedXDataFieldName_notStricted");
}
use of com.enonic.xp.content.Content in project xp by enonic.
the class PublishContentHandlerTest method testExample.
@Test
public void testExample() {
final Content content = exampleContent(PUB_ID_1, "mycontent", "My Content", "/mysite/somepage", "myfield", "Hello World");
Mockito.when(this.contentService.getByPath(ContentPath.from("/mysite/somepage"))).thenReturn(content);
ContentIds ids = ContentIds.from(PUB_ID_1, FAIL_ID);
PushContentParams pushParams = PushContentParams.create().contentIds(ids).target(Branch.from("master")).includeDependencies(false).message("My first publish").build();
Mockito.when(this.contentService.publish(pushParams)).thenReturn(exampleResult());
runScript("/lib/xp/examples/content/publish.js");
}
use of com.enonic.xp.content.Content in project xp by enonic.
the class RemoveAttachmentHandlerTest method removeAttachmentSingle.
@Test
public void removeAttachmentSingle() throws Exception {
final Content content = TestDataFixtures.newExampleContent();
Mockito.when(this.contentService.getByPath(Mockito.any())).thenReturn(content);
runFunction("/test/RemoveAttachmentHandlerTest.js", "removeAttachmentSingle");
}
Aggregations