Search in sources :

Example 56 with Content

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

the class ContentServiceImplTest_restore method restore_to_custom_path.

@Test
public void restore_to_custom_path() throws Exception {
    final Content parent = createContent(ContentPath.ROOT, "archive");
    final Content target = createContent(ContentPath.ROOT, "target");
    final Content child1 = createContent(parent.getPath(), "child1");
    createContent(child1.getPath(), "child1_1");
    createContent(child1.getPath(), "child2_1");
    this.contentService.archive(ArchiveContentParams.create().contentId(parent.getId()).build());
    RestoreContentsResult result = this.contentService.restore(RestoreContentParams.create().contentId(parent.getId()).restoreContentListener(listener).path(target.getPath()).build());
    assertEquals(4, listener.getRestored());
    assertEquals("/target", result.getParentPath().toString());
}
Also used : RestoreContentsResult(com.enonic.xp.archive.RestoreContentsResult) Content(com.enonic.xp.content.Content) Test(org.junit.jupiter.api.Test)

Example 57 with Content

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

the class ContentServiceImplTest_restore method restore_inherited.

@Test
public void restore_inherited() {
    final Content content = createContent(ContentPath.ROOT, "content");
    this.contentService.deleteWithoutFetch(DeleteContentParams.create().contentPath(content.getPath()).build());
    refresh();
    final ContentId importedId = archiveContext().callWith(() -> this.contentService.importContent(ImportContentParams.create().importContent(content).targetPath(content.getPath()).inherit(EnumSet.allOf(ContentInheritType.class)).build()).getContent().getId());
    this.contentService.restore(RestoreContentParams.create().contentId(importedId).build());
    final Set<ContentInheritType> inherit = this.contentService.getById(importedId).getInherit();
    assertEquals(2, inherit.size());
    assertTrue(inherit.contains(ContentInheritType.SORT));
    assertTrue(inherit.contains(ContentInheritType.NAME));
}
Also used : Content(com.enonic.xp.content.Content) ContentId(com.enonic.xp.content.ContentId) ContentInheritType(com.enonic.xp.content.ContentInheritType) Test(org.junit.jupiter.api.Test)

Example 58 with Content

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

the class ContentServiceImplTest_restore method restore_to_custom_root_path.

@Test
public void restore_to_custom_root_path() throws Exception {
    final Content parent = createContent(ContentPath.ROOT, "archive");
    final Content child1 = createContent(parent.getPath(), "child1");
    createContent(child1.getPath(), "child1_1");
    createContent(child1.getPath(), "child2_1");
    this.contentService.archive(ArchiveContentParams.create().contentId(child1.getId()).build());
    RestoreContentsResult result = this.contentService.restore(RestoreContentParams.create().contentId(child1.getId()).restoreContentListener(listener).path(ContentPath.ROOT).build());
    assertEquals(3, listener.getRestored());
    assertEquals("/", result.getParentPath().toString());
}
Also used : RestoreContentsResult(com.enonic.xp.archive.RestoreContentsResult) Content(com.enonic.xp.content.Content) Test(org.junit.jupiter.api.Test)

Example 59 with Content

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

the class ContentServiceImplTest_restore method restore_with_existed_name.

@Test
public void restore_with_existed_name() throws Exception {
    final Content content = createContent(ContentPath.ROOT, "archive");
    this.contentService.archive(ArchiveContentParams.create().contentId(content.getId()).build());
    createContent(ContentPath.ROOT, "archive");
    this.contentService.restore(RestoreContentParams.create().contentId(content.getId()).restoreContentListener(listener).build());
    assertEquals("archive-1", this.contentService.getById(content.getId()).getName().toString());
}
Also used : Content(com.enonic.xp.content.Content) Test(org.junit.jupiter.api.Test)

Example 60 with Content

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

the class ContentServiceImplTest_restore method restore_dont_stop_inherited.

@Test
public void restore_dont_stop_inherited() {
    final Content content = createContent(ContentPath.ROOT, "content");
    this.contentService.deleteWithoutFetch(DeleteContentParams.create().contentPath(content.getPath()).build());
    refresh();
    final ContentId importedId = archiveContext().callWith(() -> this.contentService.importContent(ImportContentParams.create().importContent(content).targetPath(content.getPath()).inherit(EnumSet.allOf(ContentInheritType.class)).build()).getContent().getId());
    this.contentService.restore(RestoreContentParams.create().contentId(importedId).stopInherit(false).build());
    final Set<ContentInheritType> inherit = this.contentService.getById(importedId).getInherit();
    assertEquals(4, inherit.size());
}
Also used : Content(com.enonic.xp.content.Content) ContentId(com.enonic.xp.content.ContentId) ContentInheritType(com.enonic.xp.content.ContentInheritType) 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