Search in sources :

Example 41 with CreateContentParams

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

the class ContentServiceImplTest_delete method publish_pending_content_with_child_moved_out_of_tree.

@Test
public void publish_pending_content_with_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).build());
    assertEquals(1, publishResult.getPushedContents().getSize());
    assertEquals(2, publishResult.getDeletedContents().getSize());
    assertEquals(2, publishResult.getUnpublishedContents().getSize());
}
Also used : PublishContentResult(com.enonic.xp.content.PublishContentResult) CreateContentParams(com.enonic.xp.content.CreateContentParams) Content(com.enonic.xp.content.Content) PropertyTree(com.enonic.xp.data.PropertyTree) DeleteContentsResult(com.enonic.xp.content.DeleteContentsResult) Test(org.junit.jupiter.api.Test)

Example 42 with CreateContentParams

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

the class ContentServiceImplTest_delete method create_delete_content_with_children.

@Test
public void create_delete_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);
    refresh();
    // Deletes the content
    final DeleteContentsResult deletedContents = this.contentService.deleteWithoutFetch(DeleteContentParams.create().contentPath(content.getPath()).build());
    assertNotNull(deletedContents);
    assertEquals(4, deletedContents.getDeletedContents().getSize());
    // Checks that the content and the children are deleted
    final GetContentByIdsParams getContentByIdsParams = new GetContentByIdsParams(ContentIds.from(content.getId(), child1Content.getId(), child2Content.getId(), subChildContent.getId()));
    final Contents foundContents = this.contentService.getByIds(getContentByIdsParams);
    assertEquals(0, foundContents.getSize());
}
Also used : GetContentByIdsParams(com.enonic.xp.content.GetContentByIdsParams) Contents(com.enonic.xp.content.Contents) CreateContentParams(com.enonic.xp.content.CreateContentParams) Content(com.enonic.xp.content.Content) PropertyTree(com.enonic.xp.data.PropertyTree) DeleteContentsResult(com.enonic.xp.content.DeleteContentsResult) Test(org.junit.jupiter.api.Test)

Example 43 with CreateContentParams

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

the class ContentServiceImplTest_delete method audit_data.

@Test
public void audit_data() {
    final ArgumentCaptor<LogAuditLogParams> captor = ArgumentCaptor.forClass(LogAuditLogParams.class);
    // 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();
    this.contentService.create(createChild1ContentParams);
    final DeleteContentParams deleteContentParams = DeleteContentParams.create().contentPath(content.getPath()).build();
    this.contentService.deleteWithoutFetch(deleteContentParams);
    Mockito.verify(auditLogService, Mockito.timeout(5000).atLeast(17)).log(captor.capture());
    final PropertySet logResultSet = captor.getAllValues().stream().filter(log -> log.getType().equals("system.content.delete")).findFirst().get().getData().getSet("result");
    final Iterable<String> deletedContents = logResultSet.getStrings("deletedContents");
    assertEquals(2, StreamSupport.stream(deletedContents.spliterator(), false).count());
}
Also used : DeleteContentParams(com.enonic.xp.content.DeleteContentParams) LogAuditLogParams(com.enonic.xp.audit.LogAuditLogParams) CreateContentParams(com.enonic.xp.content.CreateContentParams) Content(com.enonic.xp.content.Content) PropertyTree(com.enonic.xp.data.PropertyTree) PropertySet(com.enonic.xp.data.PropertySet) Test(org.junit.jupiter.api.Test)

Example 44 with CreateContentParams

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

the class ContentServiceImplTest_delete method delete_published_content_with_child_moved_out.

@Test
public void delete_published_content_with_child_moved_out() 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());
    result = this.contentService.deleteWithoutFetch(DeleteContentParams.create().contentPath(content.getPath()).deleteOnline(true).build());
    assertEquals(2, result.getDeletedContents().getSize());
}
Also used : CreateContentParams(com.enonic.xp.content.CreateContentParams) Content(com.enonic.xp.content.Content) PropertyTree(com.enonic.xp.data.PropertyTree) DeleteContentsResult(com.enonic.xp.content.DeleteContentsResult) Test(org.junit.jupiter.api.Test)

Example 45 with CreateContentParams

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

the class ContentServiceImplTest_delete method delete_published_content_with_child_moved_in.

@Test
public void delete_published_content_with_child_moved_in() 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 createMovedContentParams = CreateContentParams.create().contentData(new PropertyTree()).displayName("Content to move").parent(ContentPath.ROOT).type(ContentTypeName.folder()).build();
    final Content contentToMove = this.contentService.create(createMovedContentParams);
    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);
    refresh();
    this.contentService.publish(PushContentParams.create().contentIds(ContentIds.from(content.getId(), contentToMove.getId())).target(WS_OTHER).build());
    refresh();
    this.contentService.move(MoveContentParams.create().contentId(contentToMove.getId()).parentContentPath(child1Content.getPath()).build());
    refresh();
    assertThrows(RuntimeException.class, () -> this.contentService.deleteWithoutFetch(DeleteContentParams.create().contentPath(content.getPath()).build()));
    final DeleteContentsResult result = this.contentService.deleteWithoutFetch(DeleteContentParams.create().contentPath(content.getPath()).deleteOnline(true).build());
    assertEquals(3, result.getDeletedContents().getSize());
}
Also used : CreateContentParams(com.enonic.xp.content.CreateContentParams) Content(com.enonic.xp.content.Content) PropertyTree(com.enonic.xp.data.PropertyTree) DeleteContentsResult(com.enonic.xp.content.DeleteContentsResult) Test(org.junit.jupiter.api.Test)

Aggregations

CreateContentParams (com.enonic.xp.content.CreateContentParams)81 Test (org.junit.jupiter.api.Test)66 PropertyTree (com.enonic.xp.data.PropertyTree)63 Content (com.enonic.xp.content.Content)52 GetContentTypeParams (com.enonic.xp.schema.content.GetContentTypeParams)25 PropertySet (com.enonic.xp.data.PropertySet)14 UpdateContentParams (com.enonic.xp.content.UpdateContentParams)11 ContentType (com.enonic.xp.schema.content.ContentType)10 LogAuditLogParams (com.enonic.xp.audit.LogAuditLogParams)9 DeleteContentsResult (com.enonic.xp.content.DeleteContentsResult)9 PublishContentResult (com.enonic.xp.content.PublishContentResult)7 ProcessCreateResult (com.enonic.xp.content.processor.ProcessCreateResult)7 CreateAttachments (com.enonic.xp.attachment.CreateAttachments)6 ExtraData (com.enonic.xp.content.ExtraData)6 ProcessCreateParams (com.enonic.xp.content.processor.ProcessCreateParams)6 Attachments (com.enonic.xp.attachment.Attachments)5 Node (com.enonic.xp.node.Node)5 ByteSource (com.google.common.io.ByteSource)5 CreateAttachment (com.enonic.xp.attachment.CreateAttachment)4 ExtraDatas (com.enonic.xp.content.ExtraDatas)4