use of com.enonic.xp.content.CreateContentParams in project xp by enonic.
the class ContentServiceImplTest_undoPendingDelete method not_deleted_not_resurrected.
@Test
public void not_deleted_not_resurrected() throws Exception {
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);
int result = resurrect(ContentIds.from(ContentIds.from(content.getId())));
assertEquals(0, result);
}
use of com.enonic.xp.content.CreateContentParams in project xp by enonic.
the class ContentServiceImplTest_update method update_content_modified_time_updated.
@Test
public void update_content_modified_time_updated() throws Exception {
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);
final UpdateContentParams updateContentParams = new UpdateContentParams();
updateContentParams.contentId(content.getId()).editor(edit -> {
edit.displayName = "new display name";
});
this.contentService.update(updateContentParams);
final Content updatedContent = this.contentService.getById(content.getId());
assertEquals("new display name", updatedContent.getDisplayName());
assertNotNull(updatedContent.getCreator());
assertNotNull(updatedContent.getCreatedTime());
assertNotNull(updatedContent.getModifier());
assertNotNull(updatedContent.getModifiedTime());
assertTrue(updatedContent.getModifiedTime().isAfter(content.getModifiedTime()));
}
use of com.enonic.xp.content.CreateContentParams in project xp by enonic.
the class ContentServiceImplTest_update method update_workflow_info.
@Test
public void update_workflow_info() throws Exception {
final CreateContentParams createContentParams = CreateContentParams.create().contentData(new PropertyTree()).displayName("This is my content").parent(ContentPath.ROOT).type(ContentTypeName.folder()).workflowInfo(WorkflowInfo.inProgress()).build();
final Content content = this.contentService.create(createContentParams);
final UpdateContentParams updateContentParams = new UpdateContentParams();
updateContentParams.contentId(content.getId()).editor(edit -> {
edit.workflowInfo = WorkflowInfo.create().state(WorkflowState.PENDING_APPROVAL).checks(Map.of("Laywer review", WorkflowCheckState.PENDING)).build();
});
this.contentService.update(updateContentParams);
final Content storedContent = this.contentService.getById(content.getId());
assertNotNull(storedContent.getWorkflowInfo());
assertNotNull(storedContent.getWorkflowInfo().getState());
assertNotNull(storedContent.getWorkflowInfo().getChecks());
assertEquals(WorkflowState.PENDING_APPROVAL, storedContent.getWorkflowInfo().getState());
assertEquals(Map.of("Laywer review", WorkflowCheckState.PENDING), storedContent.getWorkflowInfo().getChecks());
}
use of com.enonic.xp.content.CreateContentParams in project xp by enonic.
the class ImageContentProcessorTest method testProcessCreate.
@Test
public void testProcessCreate() throws IOException {
Mockito.when(this.xDataService.getFromContentType(Mockito.any(ContentType.class))).thenReturn(XDatas.empty());
final CreateAttachments createAttachments = createAttachments();
final CreateContentParams params = createContentParams(createAttachments);
final ProcessCreateParams processCreateParams = new ProcessCreateParams(params, MediaInfo.create().build());
final ProcessCreateResult result = this.imageContentProcessor.processCreate(processCreateParams);
assertEquals(result.getCreateContentParams().getCreateAttachments().first(), createAttachments.first());
}
use of com.enonic.xp.content.CreateContentParams in project xp by enonic.
the class ImageContentProcessorTest method testProcessCreateWithGeoData.
@Test
public void testProcessCreateWithGeoData() throws IOException {
final XData gpsInfo = createXData(GPS_INFO_METADATA_NAME, "Gps Info", createGpsInfoMixinForm());
Mockito.when(this.xDataService.getFromContentType(Mockito.any())).thenReturn(XDatas.from(gpsInfo));
final CreateContentParams params = createContentParams(createAttachments());
final ProcessCreateParams processCreateParams = new ProcessCreateParams(params, MediaInfo.create().addMetadata("geo lat", "1").addMetadata("geo long", "2").build());
final GeoPoint geoPoint = new GeoPoint(1.0, 2.0);
final ProcessCreateResult result = this.imageContentProcessor.processCreate(processCreateParams);
final ExtraData geoExtraData = result.getCreateContentParams().getExtraDatas().first();
assertEquals(geoExtraData.getName(), GPS_INFO_METADATA_NAME);
assertEquals(geoExtraData.getData().getGeoPoint(MediaInfo.GPS_INFO_GEO_POINT, 0), geoPoint);
}
Aggregations