Search in sources :

Example 91 with Content

use of com.enonic.xp.content.Content in project xp by enonic.

the class ParentContentSynchronizerTest method updateThumbnailCreated.

@Test
public void updateThumbnailCreated() throws Exception {
    final Content sourceContent = sourceContext.callWith(() -> createContent(ContentPath.ROOT, "content"));
    final Content targetContent = syncCreated(sourceContent.getId());
    sourceContext.runWith(() -> {
        try {
            final UpdateContentParams updateContentParams = new UpdateContentParams();
            updateContentParams.contentId(targetContent.getId()).editor(edit -> {
                edit.displayName = "new display name";
            }).createAttachments(CreateAttachments.from(CreateAttachment.create().byteSource(loadImage("darth-small.jpg")).name(AttachmentNames.THUMBNAIL).mimeType("image/jpeg").build()));
            this.contentService.update(updateContentParams);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    });
    final Content targetContentUpdated = syncUpdated(sourceContent.getId());
    assertNotNull(targetContentUpdated.getThumbnail());
}
Also used : CreateContentParams(com.enonic.xp.content.CreateContentParams) ChildOrder(com.enonic.xp.index.ChildOrder) Assertions.assertThrows(org.junit.jupiter.api.Assertions.assertThrows) BeforeEach(org.junit.jupiter.api.BeforeEach) Assertions.assertNotNull(org.junit.jupiter.api.Assertions.assertNotNull) FindContentByParentResult(com.enonic.xp.content.FindContentByParentResult) BinaryReferences(com.enonic.xp.util.BinaryReferences) Assertions.assertNotEquals(org.junit.jupiter.api.Assertions.assertNotEquals) ContentTypeName(com.enonic.xp.schema.content.ContentTypeName) ContentName(com.enonic.xp.content.ContentName) DeleteContentParams(com.enonic.xp.content.DeleteContentParams) ContentSyncEventType(com.enonic.xp.core.impl.content.ContentSyncEventType) ParentContentSynchronizer(com.enonic.xp.core.impl.content.ParentContentSynchronizer) ContentId(com.enonic.xp.content.ContentId) ReorderChildParams(com.enonic.xp.content.ReorderChildParams) CreateAttachments(com.enonic.xp.attachment.CreateAttachments) ResetContentInheritParams(com.enonic.xp.content.ResetContentInheritParams) Assertions.assertFalse(org.junit.jupiter.api.Assertions.assertFalse) FindContentByParentParams(com.enonic.xp.content.FindContentByParentParams) CreateAttachment(com.enonic.xp.attachment.CreateAttachment) ProjectName(com.enonic.xp.project.ProjectName) ContentEventsSyncParams(com.enonic.xp.core.impl.content.ContentEventsSyncParams) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) ByteSource(com.google.common.io.ByteSource) PropertyTree(com.enonic.xp.data.PropertyTree) ContentPropertyNames(com.enonic.xp.content.ContentPropertyNames) UpdateMediaParams(com.enonic.xp.content.UpdateMediaParams) ContentPath(com.enonic.xp.content.ContentPath) ContentSyncParams(com.enonic.xp.core.impl.content.ContentSyncParams) ContentInheritType(com.enonic.xp.content.ContentInheritType) Content(com.enonic.xp.content.Content) IOException(java.io.IOException) ContentNotFoundException(com.enonic.xp.content.ContentNotFoundException) UpdateContentParams(com.enonic.xp.content.UpdateContentParams) Test(org.junit.jupiter.api.Test) SyncContentServiceImpl(com.enonic.xp.core.impl.content.SyncContentServiceImpl) Assertions.assertArrayEquals(org.junit.jupiter.api.Assertions.assertArrayEquals) AttachmentNames(com.enonic.xp.attachment.AttachmentNames) List(java.util.List) RenameContentParams(com.enonic.xp.content.RenameContentParams) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) MoveContentParams(com.enonic.xp.content.MoveContentParams) ReorderChildContentsParams(com.enonic.xp.content.ReorderChildContentsParams) SetContentChildOrderParams(com.enonic.xp.content.SetContentChildOrderParams) UpdateContentParams(com.enonic.xp.content.UpdateContentParams) Content(com.enonic.xp.content.Content) IOException(java.io.IOException) Test(org.junit.jupiter.api.Test)

Example 92 with Content

use of com.enonic.xp.content.Content in project xp by enonic.

the class ParentContentSynchronizerTest method syncCreatedWithChildren.

@Test
public void syncCreatedWithChildren() throws Exception {
    final CreateContentParams createContentParams = CreateContentParams.create().contentData(new PropertyTree()).displayName("This is my content").createAttachments(CreateAttachments.create().add(CreateAttachment.create().byteSource(ByteSource.wrap("bytes".getBytes())).label("attachment").name("attachmentName").mimeType("image/png").build()).build()).parent(ContentPath.ROOT).type(ContentTypeName.folder()).build();
    final Content sourceContent = sourceContext.callWith(() -> this.contentService.create(createContentParams));
    final Content targetContent = syncCreated(sourceContent.getId());
    compareSynched(sourceContent, targetContent);
}
Also used : CreateContentParams(com.enonic.xp.content.CreateContentParams) Content(com.enonic.xp.content.Content) PropertyTree(com.enonic.xp.data.PropertyTree) Test(org.junit.jupiter.api.Test)

Example 93 with Content

use of com.enonic.xp.content.Content in project xp by enonic.

the class ParentContentSynchronizerTest method updateThumbnailUpdated.

@Test
public void updateThumbnailUpdated() throws Exception {
    final Content sourceContent = sourceContext.callWith(() -> createContent(ContentPath.ROOT, "content"));
    final Content targetContent = syncCreated(sourceContent.getId());
    sourceContext.runWith(() -> {
        try {
            final UpdateContentParams updateContentParams = new UpdateContentParams();
            updateContentParams.contentId(targetContent.getId()).editor(edit -> {
                edit.displayName = "new display name";
            }).createAttachments(CreateAttachments.from(CreateAttachment.create().byteSource(loadImage("darth-small.jpg")).name(AttachmentNames.THUMBNAIL).mimeType("image/jpeg").build()));
            this.contentService.update(updateContentParams);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    });
    final Content thumbnailCreated = syncUpdated(sourceContent.getId());
    sourceContext.runWith(() -> {
        try {
            final UpdateContentParams updateContentParams = new UpdateContentParams();
            updateContentParams.contentId(targetContent.getId()).editor(edit -> {
                edit.displayName = "new display name";
            }).createAttachments(CreateAttachments.from(CreateAttachment.create().byteSource(loadImage("cat-small.jpg")).name(AttachmentNames.THUMBNAIL).mimeType("image/jpeg").build()));
            this.contentService.update(updateContentParams);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    });
    final Content thumbnailUpdated = syncUpdated(sourceContent.getId());
    assertNotEquals(thumbnailCreated.getThumbnail().getSize(), thumbnailUpdated.getThumbnail().getSize());
}
Also used : CreateContentParams(com.enonic.xp.content.CreateContentParams) ChildOrder(com.enonic.xp.index.ChildOrder) Assertions.assertThrows(org.junit.jupiter.api.Assertions.assertThrows) BeforeEach(org.junit.jupiter.api.BeforeEach) Assertions.assertNotNull(org.junit.jupiter.api.Assertions.assertNotNull) FindContentByParentResult(com.enonic.xp.content.FindContentByParentResult) BinaryReferences(com.enonic.xp.util.BinaryReferences) Assertions.assertNotEquals(org.junit.jupiter.api.Assertions.assertNotEquals) ContentTypeName(com.enonic.xp.schema.content.ContentTypeName) ContentName(com.enonic.xp.content.ContentName) DeleteContentParams(com.enonic.xp.content.DeleteContentParams) ContentSyncEventType(com.enonic.xp.core.impl.content.ContentSyncEventType) ParentContentSynchronizer(com.enonic.xp.core.impl.content.ParentContentSynchronizer) ContentId(com.enonic.xp.content.ContentId) ReorderChildParams(com.enonic.xp.content.ReorderChildParams) CreateAttachments(com.enonic.xp.attachment.CreateAttachments) ResetContentInheritParams(com.enonic.xp.content.ResetContentInheritParams) Assertions.assertFalse(org.junit.jupiter.api.Assertions.assertFalse) FindContentByParentParams(com.enonic.xp.content.FindContentByParentParams) CreateAttachment(com.enonic.xp.attachment.CreateAttachment) ProjectName(com.enonic.xp.project.ProjectName) ContentEventsSyncParams(com.enonic.xp.core.impl.content.ContentEventsSyncParams) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) ByteSource(com.google.common.io.ByteSource) PropertyTree(com.enonic.xp.data.PropertyTree) ContentPropertyNames(com.enonic.xp.content.ContentPropertyNames) UpdateMediaParams(com.enonic.xp.content.UpdateMediaParams) ContentPath(com.enonic.xp.content.ContentPath) ContentSyncParams(com.enonic.xp.core.impl.content.ContentSyncParams) ContentInheritType(com.enonic.xp.content.ContentInheritType) Content(com.enonic.xp.content.Content) IOException(java.io.IOException) ContentNotFoundException(com.enonic.xp.content.ContentNotFoundException) UpdateContentParams(com.enonic.xp.content.UpdateContentParams) Test(org.junit.jupiter.api.Test) SyncContentServiceImpl(com.enonic.xp.core.impl.content.SyncContentServiceImpl) Assertions.assertArrayEquals(org.junit.jupiter.api.Assertions.assertArrayEquals) AttachmentNames(com.enonic.xp.attachment.AttachmentNames) List(java.util.List) RenameContentParams(com.enonic.xp.content.RenameContentParams) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) MoveContentParams(com.enonic.xp.content.MoveContentParams) ReorderChildContentsParams(com.enonic.xp.content.ReorderChildContentsParams) SetContentChildOrderParams(com.enonic.xp.content.SetContentChildOrderParams) UpdateContentParams(com.enonic.xp.content.UpdateContentParams) Content(com.enonic.xp.content.Content) IOException(java.io.IOException) Test(org.junit.jupiter.api.Test)

Example 94 with Content

use of com.enonic.xp.content.Content in project xp by enonic.

the class ParentContentSynchronizerTest method syncDeletedInParent.

@Test
public void syncDeletedInParent() throws Exception {
    final Content sourceContent = sourceContext.callWith(() -> createContent(ContentPath.ROOT, "name"));
    syncCreated(sourceContent.getId());
    sourceContext.runWith(() -> contentService.deleteWithoutFetch(DeleteContentParams.create().contentPath(sourceContent.getPath()).build()));
    refresh();
    sync(sourceContent.getId(), false);
    assertFalse(targetContext.callWith(() -> contentService.contentExists(sourceContent.getId())));
}
Also used : Content(com.enonic.xp.content.Content) Test(org.junit.jupiter.api.Test)

Example 95 with Content

use of com.enonic.xp.content.Content in project xp by enonic.

the class ParentContentSynchronizerTest method renameNotSynched.

@Test
public void renameNotSynched() throws Exception {
    final Content targetContent = targetContext.callWith(() -> createContent(ContentPath.ROOT, "name"));
    assertThrows(IllegalArgumentException.class, () -> syncRenamed(targetContent.getId()), "sourceContent must be set.");
}
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