Search in sources :

Example 76 with CreateContentParams

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

the class CreateFragmentCommandTest method captorFragmentCreation.

private ArgumentCaptor<CreateContentParams> captorFragmentCreation() {
    final Content fragment = Mockito.mock(Content.class);
    Mockito.when(fragment.getId()).thenReturn(ContentId.from("fragment-id"));
    final ArgumentCaptor<CreateContentParams> argument = ArgumentCaptor.forClass(CreateContentParams.class);
    Mockito.when(contentService.create(argument.capture())).thenReturn(fragment);
    return argument;
}
Also used : Content(com.enonic.xp.content.Content) CreateContentParams(com.enonic.xp.content.CreateContentParams)

Example 77 with CreateContentParams

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

the class CreateFragmentCommandTest method testLayoutComponentName.

private String testLayoutComponentName(final String name) {
    final ArgumentCaptor<CreateContentParams> captor = captorFragmentCreation();
    final DescriptorKey layoutKey = DescriptorKey.from(ApplicationKey.from("application"), "layout1");
    Mockito.when(this.layoutDescriptorService.getByKey(layoutKey)).thenReturn(layoutDescriptor(layoutKey, name));
    createFragmentCommand(createFragmentParams(layoutComponent(layoutKey))).execute();
    return captor.getValue().getDisplayName();
}
Also used : CreateContentParams(com.enonic.xp.content.CreateContentParams) DescriptorKey(com.enonic.xp.page.DescriptorKey)

Example 78 with CreateContentParams

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

the class ContentServiceImplTest_publish 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").name("myContent").parent(ContentPath.ROOT).type(ContentTypeName.folder()).build();
    final Content content = this.contentService.create(createContentParams);
    final PublishContentResult push = this.contentService.publish(PushContentParams.create().contentIds(ContentIds.from(content.getId())).target(WS_OTHER).includeDependencies(false).build());
    Mockito.verify(auditLogService, Mockito.timeout(5000).atLeast(16)).log(captor.capture());
    final PropertySet logResultSet = captor.getAllValues().stream().filter(log -> log.getType().equals("system.content.publish")).findFirst().get().getData().getSet("result");
    assertEquals(content.getId().toString(), logResultSet.getStrings("pushedContents").iterator().next());
    assertFalse(logResultSet.getStrings("deletedContents").iterator().hasNext());
    assertFalse(logResultSet.getStrings("pendingContents").iterator().hasNext());
}
Also used : PublishContentResult(com.enonic.xp.content.PublishContentResult) LogAuditLogParams(com.enonic.xp.audit.LogAuditLogParams) CreateContentParams(com.enonic.xp.content.CreateContentParams) Content(com.enonic.xp.content.Content) PropertyTree(com.enonic.xp.data.PropertyTree) PropertySet(com.enonic.xp.data.PropertySet) Test(org.junit.jupiter.api.Test)

Example 79 with CreateContentParams

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

the class ContentServiceImplTest_resolvePublishDependencies method resolve_single.

@Test
public void resolve_single() throws Exception {
    nodeService.push(NodeIds.from(ROOT_UUID), WS_OTHER);
    refresh();
    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);
    refresh();
    final CompareContentResults result = this.contentService.resolvePublishDependencies(ResolvePublishDependenciesParams.create().contentIds(ContentIds.from(content.getId())).excludeChildrenIds(ContentIds.from(content.getId())).target(WS_OTHER).build());
    assertEquals(1, result.contentIds().getSize());
}
Also used : CreateContentParams(com.enonic.xp.content.CreateContentParams) Content(com.enonic.xp.content.Content) CompareContentResults(com.enonic.xp.content.CompareContentResults) PropertyTree(com.enonic.xp.data.PropertyTree) Test(org.junit.jupiter.api.Test)

Example 80 with CreateContentParams

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

the class CreateContentHandlerTest method createContentWithWorkflow.

@Test
public void createContentWithWorkflow() throws Exception {
    when(this.contentService.create(any(CreateContentParams.class))).thenAnswer(mock -> createContent((CreateContentParams) mock.getArguments()[0]));
    final ContentType contentType = ContentType.create().name("test:myContentType").superType(ContentTypeName.structured()).build();
    GetContentTypeParams getContentType = GetContentTypeParams.from(ContentTypeName.from("test:myContentType"));
    when(this.contentTypeService.getByName(Mockito.eq(getContentType))).thenReturn(contentType);
    runFunction("/test/CreateContentHandlerTest.js", "createContentWithWorkflow");
}
Also used : GetContentTypeParams(com.enonic.xp.schema.content.GetContentTypeParams) ContentType(com.enonic.xp.schema.content.ContentType) CreateContentParams(com.enonic.xp.content.CreateContentParams) 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