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());
}
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));
}
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());
}
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());
}
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());
}
Aggregations