Search in sources :

Example 31 with Content

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

the class ParentContentSynchronizerTest method updateDataChanged.

@Test
public void updateDataChanged() throws Exception {
    final Content sourceContent = sourceContext.callWith(() -> createContent(ContentPath.ROOT, "content1"));
    final Content targetContent = syncCreated(sourceContent.getId());
    sourceContext.runWith(() -> {
        contentService.update(new UpdateContentParams().contentId(sourceContent.getId()).editor((edit -> edit.data = new PropertyTree())));
    });
    final Content targetContentUpdated = syncUpdated(sourceContent.getId());
    assertNotEquals(targetContent.getData(), targetContentUpdated.getData());
    assertNotEquals(targetContent.getModifiedTime(), targetContentUpdated.getModifiedTime());
}
Also used : UpdateContentParams(com.enonic.xp.content.UpdateContentParams) Content(com.enonic.xp.content.Content) PropertyTree(com.enonic.xp.data.PropertyTree) Test(org.junit.jupiter.api.Test)

Example 32 with Content

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

the class ParentContentSynchronizerTest method testCreatedChild.

@Test
public void testCreatedChild() throws Exception {
    final Content sourceParent = sourceContext.callWith(() -> createContent(ContentPath.ROOT));
    final Content sourceChild = sourceContext.callWith(() -> createContent(sourceParent.getPath()));
    syncCreated(sourceParent.getId());
    final Content targetChild = syncCreated(sourceChild.getId());
    targetContext.runWith(() -> {
        assertEquals(contentService.getById(sourceChild.getId()).getParentPath(), contentService.getById(sourceParent.getId()).getPath());
        compareSynched(sourceChild, targetChild);
    });
}
Also used : Content(com.enonic.xp.content.Content) Test(org.junit.jupiter.api.Test)

Example 33 with Content

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

the class ParentContentSynchronizerTest method syncByRoot.

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

Example 34 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 35 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)

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