Search in sources :

Example 96 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 97 with Content

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

the class ContentServiceImplTest_undoPendingDelete method child_resurrected.

@Test
public void child_resurrected() throws Exception {
    final Content parent = this.createTestContent("myContent");
    this.createTestContent("myOtherContent", parent.getPath());
    final Content child2 = this.createTestContent("myOtherContent2", parent.getPath());
    this.nodeService.setNodeState(SetNodeStateParams.create().nodeId(NodeId.from(child2.getId())).recursive(true).nodeState(NodeState.DEFAULT).build());
    int result = resurrect(ContentIds.from(parent.getId()));
    assertEquals(2, result);
}
Also used : Content(com.enonic.xp.content.Content) Test(org.junit.jupiter.api.Test)

Example 98 with Content

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

the class ContentServiceImplTest_undoPendingDelete method deleted_parents_resurrected.

@Test
public void deleted_parents_resurrected() throws Exception {
    final Content node1 = this.createTestContent("node1", ContentPath.ROOT);
    this.createTestContent("node2", ContentPath.ROOT);
    final Content node1_1 = this.createTestContent("node1_1", node1.getPath());
    this.createTestContent("node1_2", node1.getPath());
    final Content node1_1_1 = this.createTestContent("node1_1_1", node1_1.getPath());
    final int result = resurrect(ContentIds.from(node1_1_1.getId()));
    assertEquals(3, result);
}
Also used : Content(com.enonic.xp.content.Content) Test(org.junit.jupiter.api.Test)

Example 99 with Content

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

the class ContentServiceImplTest_undoPendingDelete method not_deleted_not_resurrected.

@Test
public void not_deleted_not_resurrected() throws Exception {
    final CreateContentParams createContentParams = CreateContentParams.create().contentData(new PropertyTree()).displayName("This is my content").name("myContent").parent(ContentPath.ROOT).type(ContentTypeName.folder()).build();
    final Content content = this.contentService.create(createContentParams);
    int result = resurrect(ContentIds.from(ContentIds.from(content.getId())));
    assertEquals(0, result);
}
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 100 with Content

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

the class ContentServiceImplTest_update method update_content_modified_time_updated.

@Test
public void update_content_modified_time_updated() throws Exception {
    final CreateContentParams createContentParams = CreateContentParams.create().contentData(new PropertyTree()).displayName("This is my content").parent(ContentPath.ROOT).type(ContentTypeName.folder()).build();
    final Content content = this.contentService.create(createContentParams);
    final UpdateContentParams updateContentParams = new UpdateContentParams();
    updateContentParams.contentId(content.getId()).editor(edit -> {
        edit.displayName = "new display name";
    });
    this.contentService.update(updateContentParams);
    final Content updatedContent = this.contentService.getById(content.getId());
    assertEquals("new display name", updatedContent.getDisplayName());
    assertNotNull(updatedContent.getCreator());
    assertNotNull(updatedContent.getCreatedTime());
    assertNotNull(updatedContent.getModifier());
    assertNotNull(updatedContent.getModifiedTime());
    assertTrue(updatedContent.getModifiedTime().isAfter(content.getModifiedTime()));
}
Also used : UpdateContentParams(com.enonic.xp.content.UpdateContentParams) CreateContentParams(com.enonic.xp.content.CreateContentParams) Content(com.enonic.xp.content.Content) PropertyTree(com.enonic.xp.data.PropertyTree) 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