use of com.enonic.xp.content.CreateContentParams in project xp by enonic.
the class CreateContentCommandTest method createPageTemplateInRoot_fails.
@Test
public void createPageTemplateInRoot_fails() {
Mockito.when(contentTypeService.getByName(Mockito.isA(GetContentTypeParams.class))).thenAnswer(a -> BuiltinContentTypesAccessor.getContentType(((GetContentTypeParams) a.getArgument(0)).getContentTypeName()));
mockContentRootNode();
final CreateContentParams params = CreateContentParams.create().type(ContentTypeName.templateFolder()).name("folder").parent(ContentPath.ROOT).contentData(new PropertyTree()).displayName("displayName").build();
CreateContentCommand command = createContentCommand(params);
assertThrows(IllegalArgumentException.class, command::execute);
}
use of com.enonic.xp.content.CreateContentParams in project xp by enonic.
the class CreateContentCommandTest method badParentContentPath.
@Test
public void badParentContentPath() {
PropertyTree existingContentData = new PropertyTree();
existingContentData.addString("myData", "aaa");
CreateContentParams params = CreateContentParams.create().name("name").type(ContentTypeName.site()).parent(ContentPath.from("/myPath/myContent")).contentData(existingContentData).displayName("displayName").build();
CreateContentCommand command = createContentCommand(params);
Mockito.when(contentTypeService.getByName(Mockito.isA(GetContentTypeParams.class))).thenReturn(ContentType.create().superType(ContentTypeName.documentMedia()).name(ContentTypeName.dataMedia()).build());
assertThrows(IllegalStateException.class, command::execute);
}
use of com.enonic.xp.content.CreateContentParams in project xp by enonic.
the class CreateFragmentCommand method execute.
public Content execute() {
final String displayName = generateDisplayName(params.getComponent());
final String name = generateUniqueContentName(params.getParent(), "fragment-" + displayName);
final CreateContentParams createContent = CreateContentParams.create().parent(params.getParent()).displayName(displayName).name(name).type(ContentTypeName.fragment()).contentData(new PropertyTree()).workflowInfo(params.getWorkflowInfo()).build();
final Content content = contentService.create(createContent);
final Page page = Page.create().config(this.params.getConfig()).fragment(this.params.getComponent()).build();
final UpdateContentParams params = new UpdateContentParams().contentId(content.getId()).modifier(getCurrentUser().getKey()).editor(edit -> edit.page = page);
return this.contentService.update(params);
}
use of com.enonic.xp.content.CreateContentParams in project xp by enonic.
the class ParentContentSynchronizerTest method testCreatedWithSetOriginProject.
@Test
public void testCreatedWithSetOriginProject() throws Exception {
final PropertyTree data = new PropertyTree();
data.setString(ContentPropertyNames.ORIGIN_PROJECT, "first");
final CreateContentParams createContentParams = CreateContentParams.create().contentData(data).displayName("This is my content").createAttachments(CreateAttachments.create().add(CreateAttachment.create().byteSource(ByteSource.wrap("bytes".getBytes())).label("attachment").name("attachmentName").mimeType("image/png").build()).build()).parent(ContentPath.ROOT).type(ContentTypeName.folder()).build();
final Content sourceContent = sourceContext.callWith(() -> this.contentService.create(createContentParams));
final Content targetContent = syncCreated(sourceContent.getId());
compareSynched(sourceContent, targetContent);
assertEquals("source_project", targetContent.getOriginProject().toString());
}
use of com.enonic.xp.content.CreateContentParams in project xp by enonic.
the class ContentServiceImplTest_undoPendingDelete method createTestContent.
private Content createTestContent(final String name, final ContentPath parentPath) {
final CreateContentParams createContentParams = CreateContentParams.create().contentData(new PropertyTree()).displayName("This is my content").name(name).parent(ContentPath.ROOT).type(ContentTypeName.folder()).parent(parentPath == null ? ContentPath.ROOT : parentPath).build();
final Content content = this.contentService.create(createContentParams);
this.contentService.publish(PushContentParams.create().contentIds(ContentIds.from(content.getId())).target(WS_OTHER).includeDependencies(false).build());
this.nodeService.setNodeState(SetNodeStateParams.create().nodeId(NodeId.from(content.getId())).recursive(true).nodeState(NodeState.PENDING_DELETE).build());
return content;
}
Aggregations