use of com.enonic.xp.content.DeleteContentsResult in project xp by enonic.
the class ContentServiceImplTest_delete method create_delete_published_content.
@Test
public void create_delete_published_content() throws Exception {
final Content content = this.contentService.create(CreateContentParams.create().contentData(new PropertyTree()).displayName("This is my content").name("myContent").parent(ContentPath.ROOT).type(ContentTypeName.folder()).build());
refresh();
final PublishContentResult result = this.contentService.publish(PushContentParams.create().contentIds(ContentIds.from(content.getId())).target(WS_OTHER).build());
assertEquals(1, result.getPushedContents().getSize());
// Deletes the content
final DeleteContentParams deleteContentParams = DeleteContentParams.create().contentPath(content.getPath()).build();
final DeleteContentsResult deletedContents = this.contentService.deleteWithoutFetch(deleteContentParams);
assertNotNull(deletedContents);
assertEquals(1, deletedContents.getPendingContents().getSize());
for (ContentId deletedContent : deletedContents.getPendingContents()) {
assertTrue(NodeState.PENDING_DELETE == this.nodeService.getById(NodeId.from(deletedContent)).getNodeState());
}
// Checks that the content is marked for deletion
final Content foundContent = this.contentService.getById(content.getId());
assertTrue(ContentState.PENDING_DELETE == foundContent.getContentState());
}
use of com.enonic.xp.content.DeleteContentsResult in project xp by enonic.
the class ContentServiceImplTest_delete method create_content_with_same_paths_in_two_repos_then_delete.
@Test
public void create_content_with_same_paths_in_two_repos_then_delete() throws Exception {
final CreateContentParams params = CreateContentParams.create().contentData(new PropertyTree()).displayName("This is my content").parent(ContentPath.ROOT).type(ContentTypeName.folder()).build();
final Content content = this.contentService.create(params);
final Content contentOther = ctxOther().callWith(() -> this.contentService.create(params));
// Deletes the content
final DeleteContentsResult deletedContents = this.contentService.deleteWithoutFetch(DeleteContentParams.create().contentPath(content.getPath()).build());
assertNotNull(deletedContents);
assertEquals(1, deletedContents.getDeletedContents().getSize());
final DeleteContentsResult deletedOther = ctxOther().callWith(() -> this.contentService.deleteWithoutFetch(DeleteContentParams.create().contentPath(contentOther.getPath()).build()));
assertNotNull(deletedOther);
assertEquals(1, deletedOther.getDeletedContents().getSize());
}
use of com.enonic.xp.content.DeleteContentsResult in project xp by enonic.
the class ContentServiceImplTest_delete method publish_pending_content_with_child_moved_inside_the_tree.
@Test
public void publish_pending_content_with_child_moved_inside_the_tree() throws Exception {
// Creates a content with children
final CreateContentParams createContentParams = CreateContentParams.create().contentData(new PropertyTree()).displayName("Root Content").parent(ContentPath.ROOT).type(ContentTypeName.folder()).build();
final Content content = this.contentService.create(createContentParams);
final CreateContentParams createChild1ContentParams = CreateContentParams.create().contentData(new PropertyTree()).displayName("Child1 Content").parent(content.getPath()).type(ContentTypeName.folder()).build();
final Content child1Content = this.contentService.create(createChild1ContentParams);
final CreateContentParams createMovedContentParams = CreateContentParams.create().contentData(new PropertyTree()).displayName("Content to move").parent(child1Content.getPath()).type(ContentTypeName.folder()).build();
final Content contentToMove = this.contentService.create(createMovedContentParams);
refresh();
this.contentService.publish(PushContentParams.create().contentIds(ContentIds.from(contentToMove.getId())).target(WS_OTHER).build());
refresh();
this.contentService.move(MoveContentParams.create().contentId(contentToMove.getId()).parentContentPath(content.getPath()).build());
refresh();
DeleteContentsResult result = this.contentService.deleteWithoutFetch(DeleteContentParams.create().contentPath(content.getPath()).build());
assertEquals(3, result.getPendingContents().getSize());
final PublishContentResult publishResult = this.contentService.publish(PushContentParams.create().contentIds(ContentIds.from(content.getId())).target(WS_OTHER).includeDependencies(false).build());
assertEquals(3, publishResult.getUnpublishedContents().getSize());
assertEquals(3, publishResult.getDeletedContents().getSize());
}
use of com.enonic.xp.content.DeleteContentsResult in project xp by enonic.
the class ContentServiceImplTest_delete method publish_pending_content_with_excluded_child_moved_out_of_tree.
@Test
public void publish_pending_content_with_excluded_child_moved_out_of_tree() throws Exception {
// Creates a content with children
final CreateContentParams createContentParams = CreateContentParams.create().contentData(new PropertyTree()).displayName("Root Content").parent(ContentPath.ROOT).type(ContentTypeName.folder()).build();
final Content content = this.contentService.create(createContentParams);
final CreateContentParams createChild1ContentParams = CreateContentParams.create().contentData(new PropertyTree()).displayName("Child1 Content").parent(content.getPath()).type(ContentTypeName.folder()).build();
final Content child1Content = this.contentService.create(createChild1ContentParams);
final CreateContentParams createMovedContentParams = CreateContentParams.create().contentData(new PropertyTree()).displayName("Content to move").parent(child1Content.getPath()).type(ContentTypeName.folder()).build();
final Content contentToMove = this.contentService.create(createMovedContentParams);
refresh();
this.contentService.publish(PushContentParams.create().contentIds(ContentIds.from(contentToMove.getId())).target(WS_OTHER).build());
refresh();
this.contentService.move(MoveContentParams.create().contentId(contentToMove.getId()).parentContentPath(ContentPath.ROOT).build());
refresh();
DeleteContentsResult result = this.contentService.deleteWithoutFetch(DeleteContentParams.create().contentPath(content.getPath()).build());
assertEquals(2, result.getPendingContents().getSize());
final PublishContentResult publishResult = this.contentService.publish(PushContentParams.create().contentIds(ContentIds.from(content.getId())).target(WS_OTHER).includeDependencies(false).excludedContentIds(ContentIds.from(contentToMove.getId())).build());
assertEquals(0, publishResult.getPushedContents().getSize());
assertEquals(2, publishResult.getDeletedContents().getSize());
assertEquals(3, publishResult.getUnpublishedContents().getSize());
}
use of com.enonic.xp.content.DeleteContentsResult in project xp by enonic.
the class ContentServiceImplTest_delete method create_delete_published_content_with_children.
@Test
public void create_delete_published_content_with_children() throws Exception {
// Creates a content with children
final CreateContentParams createContentParams = CreateContentParams.create().contentData(new PropertyTree()).displayName("Root Content").parent(ContentPath.ROOT).type(ContentTypeName.folder()).build();
final Content content = this.contentService.create(createContentParams);
final CreateContentParams createChild1ContentParams = CreateContentParams.create().contentData(new PropertyTree()).displayName("Child1 Content").parent(content.getPath()).type(ContentTypeName.folder()).build();
final Content child1Content = this.contentService.create(createChild1ContentParams);
final CreateContentParams createChild2ContentParams = CreateContentParams.create().contentData(new PropertyTree()).displayName("Child2 Content").parent(content.getPath()).type(ContentTypeName.folder()).build();
final Content child2Content = this.contentService.create(createChild2ContentParams);
final CreateContentParams createSubChildContentParams = CreateContentParams.create().contentData(new PropertyTree()).displayName("SubChild Content").parent(child1Content.getPath()).type(ContentTypeName.folder()).build();
final Content subChildContent = this.contentService.create(createSubChildContentParams);
// Publishes the content
final PushContentParams pushParams = PushContentParams.create().contentIds(ContentIds.from(content.getId())).target(WS_OTHER).build();
refresh();
this.contentService.publish(pushParams);
// Deletes the content
final DeleteContentParams deleteContentParams = DeleteContentParams.create().contentPath(content.getPath()).build();
final DeleteContentsResult deletedContents = this.contentService.deleteWithoutFetch(deleteContentParams);
assertNotNull(deletedContents);
assertEquals(4, deletedContents.getPendingContents().getSize());
// Checks that the content and children are marked for deletion
final ContentIds contentIds = ContentIds.from(content.getId(), child1Content.getId(), child2Content.getId(), subChildContent.getId());
final GetContentByIdsParams getContentByIdsParams = new GetContentByIdsParams(contentIds);
final Contents foundContents = this.contentService.getByIds(getContentByIdsParams);
assertEquals(4, foundContents.getSize());
for (Content foundContent : foundContents) {
assertTrue(ContentState.PENDING_DELETE == foundContent.getContentState());
}
}
Aggregations