Search in sources :

Example 6 with ProcessUpdateParams

use of com.enonic.xp.content.processor.ProcessUpdateParams in project xp by enonic.

the class ProjectAccessSiteProcessorTest method testProcessUpdateByContentAdmin.

@Test
public void testProcessUpdateByContentAdmin() {
    final Context context = ContextBuilder.from(ContextAccessor.current()).authInfo(AuthenticationInfo.create().user(TEST_USER).principals(RoleKeys.CONTENT_MANAGER_ADMIN).build()).build();
    context.runWith(() -> {
        final ProcessUpdateParams params = createProcessUpdateParams("white", "blue");
        final ProcessUpdateResult result = this.projectAccessSiteProcessor.processUpdate(params);
        assertNull(result);
    });
}
Also used : Context(com.enonic.xp.context.Context) ProcessUpdateParams(com.enonic.xp.content.processor.ProcessUpdateParams) ProcessUpdateResult(com.enonic.xp.content.processor.ProcessUpdateResult) Test(org.junit.jupiter.api.Test)

Example 7 with ProcessUpdateParams

use of com.enonic.xp.content.processor.ProcessUpdateParams in project xp by enonic.

the class ProjectAccessSiteProcessorTest method testProcessUpdateByAdmin.

@Test
public void testProcessUpdateByAdmin() {
    final Context context = ContextBuilder.from(ContextAccessor.current()).authInfo(AuthenticationInfo.create().user(TEST_USER).principals(RoleKeys.ADMIN).build()).build();
    context.runWith(() -> {
        final ProcessUpdateParams params = createProcessUpdateParams("white", "blue");
        final ProcessUpdateResult result = this.projectAccessSiteProcessor.processUpdate(params);
        assertNull(result);
    });
}
Also used : Context(com.enonic.xp.context.Context) ProcessUpdateParams(com.enonic.xp.content.processor.ProcessUpdateParams) ProcessUpdateResult(com.enonic.xp.content.processor.ProcessUpdateResult) Test(org.junit.jupiter.api.Test)

Example 8 with ProcessUpdateParams

use of com.enonic.xp.content.processor.ProcessUpdateParams in project xp by enonic.

the class HtmlAreaContentProcessorTest method setUp.

@BeforeEach
public void setUp() throws Exception {
    this.siteService = Mockito.mock(SiteService.class);
    this.xDataService = Mockito.mock(XDataService.class);
    this.contentTypeService = Mockito.mock(ContentTypeService.class);
    this.pageDescriptorService = Mockito.mock(PageDescriptorService.class);
    this.partDescriptorService = Mockito.mock(PartDescriptorService.class);
    this.layoutDescriptorService = Mockito.mock(LayoutDescriptorService.class);
    contentTypeName = ContentTypeName.from("myContentType");
    final GetContentTypeParams params = GetContentTypeParams.from(contentTypeName);
    contentType = ContentType.create().name(contentTypeName).superType(ContentTypeName.folder()).form(Form.create().addFormItem(Input.create().name("htmlData").label("htmlData").inputType(InputTypeName.HTML_AREA).build()).build()).build();
    final ProcessUpdateParams processUpdateParams = ProcessUpdateParams.create().contentType(contentType).build();
    Mockito.when(contentTypeService.getByName(params)).thenReturn(contentType);
    Mockito.when(xDataService.getByNames(Mockito.isA(XDataNames.class))).thenReturn(XDatas.empty());
    htmlAreaContentProcessor = new HtmlAreaContentProcessor();
    htmlAreaContentProcessor.setContentTypeService(contentTypeService);
    htmlAreaContentProcessor.setSiteService(siteService);
    htmlAreaContentProcessor.setXDataService(xDataService);
    htmlAreaContentProcessor.setPageDescriptorService(pageDescriptorService);
    htmlAreaContentProcessor.setPartDescriptorService(partDescriptorService);
    htmlAreaContentProcessor.setLayoutDescriptorService(layoutDescriptorService);
    result = htmlAreaContentProcessor.processUpdate(processUpdateParams);
}
Also used : PartDescriptorService(com.enonic.xp.region.PartDescriptorService) GetContentTypeParams(com.enonic.xp.schema.content.GetContentTypeParams) PageDescriptorService(com.enonic.xp.page.PageDescriptorService) SiteService(com.enonic.xp.site.SiteService) XDataNames(com.enonic.xp.schema.xdata.XDataNames) XDataService(com.enonic.xp.schema.xdata.XDataService) ProcessUpdateParams(com.enonic.xp.content.processor.ProcessUpdateParams) ContentTypeService(com.enonic.xp.schema.content.ContentTypeService) LayoutDescriptorService(com.enonic.xp.region.LayoutDescriptorService) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 9 with ProcessUpdateParams

use of com.enonic.xp.content.processor.ProcessUpdateParams in project xp by enonic.

the class ImageContentProcessorTest method testProcessUpdateWithMediaInfo.

@Test
public void testProcessUpdateWithMediaInfo() throws IOException {
    final Form.Builder form = Form.create();
    form.addFormItem(createTextLine("shutterTime", "Exposure Time").occurrences(0, 1).build());
    form.addFormItem(createTextLine("altitude", "Gps Altitude").occurrences(0, 1).build());
    final XData xDataInfo = createXData(MediaInfo.IMAGE_INFO_METADATA_NAME, "Extra Info", form.build());
    Mockito.when(this.xDataService.getFromContentType(Mockito.any())).thenReturn(XDatas.from(xDataInfo));
    final CreateAttachments createAttachments = createAttachments();
    final ProcessUpdateParams processUpdateParams = ProcessUpdateParams.create().contentType(ContentType.create().superType(ContentTypeName.imageMedia()).name("myContent").build()).mediaInfo(MediaInfo.create().addMetadata("exposure time", "1").addMetadata("gps altitude ", "2").build()).createAttachments(createAttachments).build();
    final ProcessUpdateResult result = this.imageContentProcessor.processUpdate(processUpdateParams);
    final PropertyTree data = new PropertyTree();
    final EditableContent editableContent = new EditableContent(Content.create().name("myContentName").parentPath(ContentPath.ROOT).data(data).build());
    result.getEditor().edit(editableContent);
    assertEquals(editableContent.extraDatas.first().getData().getString("shutterTime", 0), "1");
    assertEquals(editableContent.extraDatas.first().getData().getString("altitude", 0), "2");
    assertEquals(13, editableContent.extraDatas.first().getData().getLong(MediaInfo.MEDIA_INFO_BYTE_SIZE, 0));
}
Also used : CreateAttachments(com.enonic.xp.attachment.CreateAttachments) Form(com.enonic.xp.form.Form) ProcessUpdateParams(com.enonic.xp.content.processor.ProcessUpdateParams) PropertyTree(com.enonic.xp.data.PropertyTree) EditableContent(com.enonic.xp.content.EditableContent) ProcessUpdateResult(com.enonic.xp.content.processor.ProcessUpdateResult) XData(com.enonic.xp.schema.xdata.XData) Test(org.junit.jupiter.api.Test)

Aggregations

ProcessUpdateParams (com.enonic.xp.content.processor.ProcessUpdateParams)9 ProcessUpdateResult (com.enonic.xp.content.processor.ProcessUpdateResult)7 Test (org.junit.jupiter.api.Test)7 Context (com.enonic.xp.context.Context)5 EditableContent (com.enonic.xp.content.EditableContent)3 PropertyTree (com.enonic.xp.data.PropertyTree)3 CreateAttachments (com.enonic.xp.attachment.CreateAttachments)2 ExtraData (com.enonic.xp.content.ExtraData)2 ContentTypeService (com.enonic.xp.schema.content.ContentTypeService)2 GetContentTypeParams (com.enonic.xp.schema.content.GetContentTypeParams)2 XData (com.enonic.xp.schema.xdata.XData)2 XDataService (com.enonic.xp.schema.xdata.XDataService)2 Attachment (com.enonic.xp.attachment.Attachment)1 CreateAttachment (com.enonic.xp.attachment.CreateAttachment)1 ContentEditor (com.enonic.xp.content.ContentEditor)1 ContentService (com.enonic.xp.content.ContentService)1 CreateContentParams (com.enonic.xp.content.CreateContentParams)1 ExtraDatas (com.enonic.xp.content.ExtraDatas)1 Media (com.enonic.xp.content.Media)1 ContentProcessor (com.enonic.xp.content.processor.ContentProcessor)1