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);
});
}
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);
});
}
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);
}
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));
}
Aggregations