Search in sources :

Example 36 with Content

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

the class ParentContentSynchronizerTest method testCreateExisted.

@Test
public void testCreateExisted() throws Exception {
    final Content sourceContent = sourceContext.callWith(() -> createContent(ContentPath.ROOT));
    final Content targetContent1 = syncCreated(sourceContent.getId());
    assertThrows(IllegalArgumentException.class, () -> syncCreated(sourceContent.getId()), "targetContent must be set.");
    final Content targetContent2 = targetContext.callWith(() -> contentService.getById(sourceContent.getId()));
    assertEquals(targetContent1, targetContent2);
    compareSynched(sourceContent, targetContent1);
}
Also used : Content(com.enonic.xp.content.Content) Test(org.junit.jupiter.api.Test)

Example 37 with Content

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

the class ParentContentSynchronizerTest method sortNotSynched.

@Test
public void sortNotSynched() throws Exception {
    final Content sourceContent = sourceContext.callWith(() -> createContent(ContentPath.ROOT, "name"));
    assertThrows(IllegalArgumentException.class, () -> syncSorted(sourceContent.getId()));
}
Also used : Content(com.enonic.xp.content.Content) Test(org.junit.jupiter.api.Test)

Example 38 with Content

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

the class ParentContentSynchronizerTest method renameChanged.

@Test
public void renameChanged() throws Exception {
    final Content sourceContent = sourceContext.callWith(() -> createContent(ContentPath.ROOT));
    final Content targetContent = syncCreated(sourceContent.getId());
    sourceContext.runWith(() -> contentService.rename(RenameContentParams.create().contentId(sourceContent.getId()).newName(ContentName.from("newName")).build()));
    final Content targetContentRenamed = syncRenamed(sourceContent.getId());
    assertNotEquals(targetContent.getName(), targetContentRenamed.getName());
    assertEquals("newName", targetContentRenamed.getName().toString());
}
Also used : Content(com.enonic.xp.content.Content) Test(org.junit.jupiter.api.Test)

Example 39 with Content

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

the class ParentContentSynchronizerTest method syncWithoutChildren.

@Test
public void syncWithoutChildren() throws Exception {
    final Content sourceContent = sourceContext.callWith(() -> createContent(ContentPath.ROOT, "name"));
    final Content sourceChild1 = sourceContext.callWith(() -> createContent(sourceContent.getPath(), "child1"));
    sync(sourceContent.getId(), false);
    assertTrue(targetContext.callWith(() -> contentService.contentExists(sourceContent.getId())));
    assertFalse(targetContext.callWith(() -> contentService.contentExists(sourceChild1.getId())));
}
Also used : Content(com.enonic.xp.content.Content) Test(org.junit.jupiter.api.Test)

Example 40 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)

Aggregations

Content (com.enonic.xp.content.Content)563 Test (org.junit.jupiter.api.Test)435 PropertyTree (com.enonic.xp.data.PropertyTree)131 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)31 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 ContentQuery (com.enonic.xp.content.ContentQuery)24 FindContentByParentParams (com.enonic.xp.content.FindContentByParentParams)24 FindContentByParentResult (com.enonic.xp.content.FindContentByParentResult)23 DataValidationError (com.enonic.xp.content.DataValidationError)21 ContentType (com.enonic.xp.schema.content.ContentType)20