Search in sources :

Example 11 with CreateContentParams

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);
}
Also used : CreateContentParams(com.enonic.xp.content.CreateContentParams) Content(com.enonic.xp.content.Content) PropertyTree(com.enonic.xp.data.PropertyTree) Test(org.junit.jupiter.api.Test)

Example 12 with CreateContentParams

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()));
}
Also used : UpdateContentParams(com.enonic.xp.content.UpdateContentParams) CreateContentParams(com.enonic.xp.content.CreateContentParams) Content(com.enonic.xp.content.Content) PropertyTree(com.enonic.xp.data.PropertyTree) Test(org.junit.jupiter.api.Test)

Example 13 with CreateContentParams

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());
}
Also used : UpdateContentParams(com.enonic.xp.content.UpdateContentParams) CreateContentParams(com.enonic.xp.content.CreateContentParams) Content(com.enonic.xp.content.Content) PropertyTree(com.enonic.xp.data.PropertyTree) Test(org.junit.jupiter.api.Test)

Example 14 with CreateContentParams

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());
}
Also used : CreateAttachments(com.enonic.xp.attachment.CreateAttachments) ContentType(com.enonic.xp.schema.content.ContentType) CreateContentParams(com.enonic.xp.content.CreateContentParams) ProcessCreateResult(com.enonic.xp.content.processor.ProcessCreateResult) ProcessCreateParams(com.enonic.xp.content.processor.ProcessCreateParams) Test(org.junit.jupiter.api.Test)

Example 15 with CreateContentParams

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);
}
Also used : GeoPoint(com.enonic.xp.util.GeoPoint) CreateContentParams(com.enonic.xp.content.CreateContentParams) ProcessCreateResult(com.enonic.xp.content.processor.ProcessCreateResult) XData(com.enonic.xp.schema.xdata.XData) ExtraData(com.enonic.xp.content.ExtraData) ProcessCreateParams(com.enonic.xp.content.processor.ProcessCreateParams) 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