Search in sources :

Example 31 with CreateContentParams

use of com.enonic.xp.content.CreateContentParams 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());
}
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 32 with CreateContentParams

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

the class ContentServiceImplTest_delete method create_delete_content.

@Test
public void create_delete_content() throws Exception {
    // Creates a content
    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);
    // Deletes the content
    final DeleteContentParams deleteContentParams = DeleteContentParams.create().contentPath(content.getPath()).build();
    final DeleteContentsResult deletedContents = this.contentService.deleteWithoutFetch(deleteContentParams);
    assertNotNull(deletedContents);
    assertEquals(1, deletedContents.getDeletedContents().getSize());
    assertEquals(content.getId(), deletedContents.getDeletedContents().first());
    // Checks that the content is deleted
    final ContentIds contentIds = ContentIds.from(content.getId());
    final GetContentByIdsParams getContentByIdsParams = new GetContentByIdsParams(contentIds);
    final Contents foundContents = this.contentService.getByIds(getContentByIdsParams);
    assertEquals(0, foundContents.getSize());
}
Also used : DeleteContentParams(com.enonic.xp.content.DeleteContentParams) 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) ContentIds(com.enonic.xp.content.ContentIds) DeleteContentsResult(com.enonic.xp.content.DeleteContentsResult) Test(org.junit.jupiter.api.Test)

Example 33 with CreateContentParams

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

the class AbstractContentSynchronizerTest method createContent.

protected Content createContent(final ContentPath parent, final String name) {
    final PropertyTree data = new PropertyTree();
    data.addStrings("stringField", "stringValue");
    final CreateContentParams createParent = CreateContentParams.create().contentData(data).name(name).displayName(name).parent(parent).type(ContentTypeName.folder()).build();
    return this.contentService.create(createParent);
}
Also used : CreateContentParams(com.enonic.xp.content.CreateContentParams) PropertyTree(com.enonic.xp.data.PropertyTree)

Example 34 with CreateContentParams

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

the class ContentServiceImplTest_applyPermissions method audit_data.

@Test
public void audit_data() throws Exception {
    final ArgumentCaptor<LogAuditLogParams> captor = ArgumentCaptor.forClass(LogAuditLogParams.class);
    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 ApplyContentPermissionsParams applyParams = ApplyContentPermissionsParams.create().contentId(content.getId()).applyContentPermissionsListener(Mockito.mock(ApplyPermissionsListener.class)).build();
    final ApplyContentPermissionsResult result = this.contentService.applyPermissions(applyParams);
    Mockito.verify(auditLogService, Mockito.timeout(5000).atLeast(16)).log(captor.capture());
    final PropertySet logResultSet = captor.getAllValues().stream().filter(log -> log.getType().equals("system.content.applyPermissions")).findFirst().get().getData().getSet("result");
    assertEquals(content.getPath().toString(), logResultSet.getStrings("succeedContents").iterator().next());
}
Also used : LogAuditLogParams(com.enonic.xp.audit.LogAuditLogParams) CreateContentParams(com.enonic.xp.content.CreateContentParams) Content(com.enonic.xp.content.Content) PropertyTree(com.enonic.xp.data.PropertyTree) ApplyContentPermissionsParams(com.enonic.xp.content.ApplyContentPermissionsParams) PropertySet(com.enonic.xp.data.PropertySet) ApplyContentPermissionsResult(com.enonic.xp.content.ApplyContentPermissionsResult) Test(org.junit.jupiter.api.Test)

Example 35 with CreateContentParams

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

the class ContentServiceImplTest_create method create_with_workflow_info.

@Test
public void create_with_workflow_info() throws Exception {
    final CreateContentParams createContentParams = CreateContentParams.create().contentData(new PropertyTree()).displayName("This is my content").parent(ContentPath.ROOT).type(ContentTypeName.folder()).workflowInfo(WorkflowInfo.create().state(WorkflowState.PENDING_APPROVAL).checks(Map.of("My check", WorkflowCheckState.REJECTED)).build()).build();
    final Content content = this.contentService.create(createContentParams);
    assertNotNull(content.getWorkflowInfo());
    assertEquals(WorkflowState.PENDING_APPROVAL, content.getWorkflowInfo().getState());
    assertEquals(Map.of("My check", WorkflowCheckState.REJECTED), content.getWorkflowInfo().getChecks());
    final Content storedContent = this.contentService.getById(content.getId());
    assertNotNull(storedContent.getWorkflowInfo());
    assertEquals(WorkflowState.PENDING_APPROVAL, storedContent.getWorkflowInfo().getState());
    assertEquals(Map.of("My check", WorkflowCheckState.REJECTED), storedContent.getWorkflowInfo().getChecks());
}
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)

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