use of com.enonic.xp.content.CreateContentParams in project xp by enonic.
the class ContentServiceImplTest_duplicate method data_removed_on_duplicate.
@Test
public void data_removed_on_duplicate() throws Exception {
final CreateContentParams createContentParams = CreateContentParams.create().contentData(new PropertyTree()).displayName("rootContent").parent(ContentPath.ROOT).type(ContentTypeName.folder()).permissions(AccessControlList.create().build()).build();
final Content content = this.contentService.create(createContentParams);
this.nodeService.update(UpdateNodeParams.create().id(NodeId.from(content.getId())).editor(toBeEdited -> {
toBeEdited.data.addSet(ContentPropertyNames.PUBLISH_INFO, new PropertySet());
toBeEdited.data.addString(ContentPropertyNames.ORIGIN_PROJECT, "some-project");
toBeEdited.data.addStrings(ContentPropertyNames.INHERIT, ContentInheritType.CONTENT.name(), ContentInheritType.NAME.name());
}).build());
final Content duplicateContent = doDuplicateContent(content);
assertNull(duplicateContent.getPublishInfo());
assertNull(duplicateContent.getOriginProject());
assertTrue(duplicateContent.getInherit().isEmpty());
}
use of com.enonic.xp.content.CreateContentParams in project xp by enonic.
the class ContentServiceImplTest_duplicate method some_metadata_reset_on_duplicate.
@Test
public void some_metadata_reset_on_duplicate() throws Exception {
final User otherUser = User.create().key(PrincipalKey.ofUser(IdProviderKey.system(), "fisk")).login("fisk").build();
final CreateContentParams createContentParams = CreateContentParams.create().contentData(new PropertyTree()).displayName("rootContent").parent(ContentPath.ROOT).type(ContentTypeName.folder()).permissions(AccessControlList.create().add(AccessControlEntry.create().principal(otherUser.getKey()).allowAll().build()).build()).build();
final Content rootContent = this.contentService.create(createContentParams);
final Context duplicateContext = ContextBuilder.from(ContextAccessor.current()).authInfo(AuthenticationInfo.create().user(otherUser).principals(RoleKeys.CONTENT_MANAGER_ADMIN).build()).build();
final Content duplicateContent = duplicateContext.callWith(() -> doDuplicateContent(rootContent));
assertTrue(rootContent.getModifiedTime().isBefore(duplicateContent.getModifiedTime()));
assertTrue(rootContent.getCreatedTime().isBefore(duplicateContent.getCreatedTime()));
assertEquals(otherUser.getKey(), duplicateContent.getModifier());
assertEquals(otherUser.getKey(), duplicateContent.getOwner());
assertEquals(otherUser.getKey(), duplicateContent.getCreator());
}
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_create method create_content_unnamed.
@Test
public void create_content_unnamed() throws Exception {
final CreateContentParams createContentParams = CreateContentParams.create().contentData(new PropertyTree()).parent(ContentPath.ROOT).type(ContentTypeName.folder()).build();
final Content content = this.contentService.create(createContentParams);
final Content storedContent = this.contentService.getById(content.getId());
assertNotNull(storedContent.getName());
assertTrue(storedContent.getName().isUnnamed());
assertTrue(storedContent.getName().hasUniqueness());
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_create method create_with_attachments.
@Test
public void create_with_attachments() throws Exception {
final String name = "cat-small.jpg";
final ByteSource image = loadImage(name);
final CreateContentParams createContentParams = CreateContentParams.create().contentData(new PropertyTree()).displayName("This is my content").parent(ContentPath.ROOT).type(ContentTypeName.imageMedia()).createAttachments(createAttachment("cat", "image/jpeg", image)).build();
final Content content = this.contentService.create(createContentParams);
final Content storedContent = this.contentService.getById(content.getId());
final Attachments attachments = storedContent.getAttachments();
assertEquals(1, attachments.getSize());
}
Aggregations