Search in sources :

Example 16 with Content

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");
}
Also used : Content(com.enonic.xp.content.Content) Attachment(com.enonic.xp.attachment.Attachment) Test(org.junit.jupiter.api.Test)

Example 17 with Content

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));
}
Also used : Content(com.enonic.xp.content.Content) Attachment(com.enonic.xp.attachment.Attachment)

Example 18 with Content

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");
}
Also used : UpdateContentParams(com.enonic.xp.content.UpdateContentParams) Content(com.enonic.xp.content.Content) EditableContent(com.enonic.xp.content.EditableContent) Test(org.junit.jupiter.api.Test)

Example 19 with Content

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");
}
Also used : Content(com.enonic.xp.content.Content) ContentIds(com.enonic.xp.content.ContentIds) PushContentParams(com.enonic.xp.content.PushContentParams) Test(org.junit.jupiter.api.Test)

Example 20 with Content

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");
}
Also used : Content(com.enonic.xp.content.Content) Test(org.junit.jupiter.api.Test)

Aggregations

Content (com.enonic.xp.content.Content)560 Test (org.junit.jupiter.api.Test)432 PropertyTree (com.enonic.xp.data.PropertyTree)130 CreateContentParams (com.enonic.xp.content.CreateContentParams)57 ContentId (com.enonic.xp.content.ContentId)50 UpdateContentParams (com.enonic.xp.content.UpdateContentParams)48 ContentPath (com.enonic.xp.content.ContentPath)47 ValidationErrors (com.enonic.xp.content.ValidationErrors)47 Site (com.enonic.xp.site.Site)43 PropertySet (com.enonic.xp.data.PropertySet)30 GetContentTypeParams (com.enonic.xp.schema.content.GetContentTypeParams)27 Page (com.enonic.xp.page.Page)26 Contents (com.enonic.xp.content.Contents)25 Node (com.enonic.xp.node.Node)25 ContentIds (com.enonic.xp.content.ContentIds)24 FindContentByParentParams (com.enonic.xp.content.FindContentByParentParams)24 ContentQuery (com.enonic.xp.content.ContentQuery)23 FindContentByParentResult (com.enonic.xp.content.FindContentByParentResult)23 DataValidationError (com.enonic.xp.content.DataValidationError)21 ContentType (com.enonic.xp.schema.content.ContentType)20