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());
}
use of com.enonic.xp.content.CreateContentParams in project xp by enonic.
the class ContentServiceImplTest_create method audit_data.
@Test
public void audit_data() {
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);
Mockito.verify(auditLogService, Mockito.timeout(5000).times(1)).log(captor.capture());
final PropertySet logResultSet = captor.getValue().getData().getSet("result");
assertEquals(content.getId().toString(), logResultSet.getString("id"));
assertEquals(content.getPath().toString(), logResultSet.getString("path"));
}
use of com.enonic.xp.content.CreateContentParams in project xp by enonic.
the class ContentServiceImplTest_create method create_content_generated_properties.
@Test
public void create_content_generated_properties() throws Exception {
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);
assertNotNull(content.getName());
assertEquals("this-is-my-content", content.getName().toString());
assertNotNull(content.getCreatedTime());
assertNotNull(content.getCreator());
assertNotNull(content.getModifiedTime());
assertNotNull(content.getModifier());
assertNotNull(content.getChildOrder());
assertEquals(ContentConstants.DEFAULT_CHILD_ORDER, content.getChildOrder());
final Content storedContent = this.contentService.getById(content.getId());
assertNotNull(storedContent.getName());
assertEquals("this-is-my-content", storedContent.getName().toString());
assertNotNull(storedContent.getCreatedTime());
assertNotNull(storedContent.getCreator());
assertNotNull(storedContent.getModifiedTime());
assertNotNull(storedContent.getModifier());
assertNotNull(storedContent.getChildOrder());
assertEquals(ContentConstants.DEFAULT_CHILD_ORDER, storedContent.getChildOrder());
}
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 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());
}
Aggregations