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