Search in sources :

Example 46 with UpdateContentParams

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

the class SyncContentServiceImplTest method testWorkflowInfo.

@Test
public void testWorkflowInfo() throws Exception {
    final Content source = sourceContext.callWith(() -> createContent(ContentPath.ROOT));
    syncCreated(source.getId());
    targetContext.runWith(() -> {
        contentService.update(new UpdateContentParams().contentId(source.getId()).editor(edit -> {
            edit.workflowInfo = WorkflowInfo.ready();
            edit.data = new PropertyTree();
        }));
    });
    syncContentService.resetInheritance(ResetContentInheritParams.create().contentId(source.getId()).inherit(EnumSet.of(ContentInheritType.CONTENT)).projectName(targetProject.getName()).build());
    targetContext.runWith(() -> {
        final Content changed = contentService.getById(source.getId());
        assertTrue(changed.getInherit().contains(ContentInheritType.CONTENT));
        assertTrue(changed.getData().hasProperty("stringField"));
    });
}
Also used : ChildOrder(com.enonic.xp.index.ChildOrder) Assertions.assertThrows(org.junit.jupiter.api.Assertions.assertThrows) BeforeEach(org.junit.jupiter.api.BeforeEach) WorkflowInfo(com.enonic.xp.content.WorkflowInfo) ContentPath(com.enonic.xp.content.ContentPath) ProjectSyncParams(com.enonic.xp.content.ProjectSyncParams) ContentInheritType(com.enonic.xp.content.ContentInheritType) Content(com.enonic.xp.content.Content) DeleteContentParams(com.enonic.xp.content.DeleteContentParams) UpdateContentParams(com.enonic.xp.content.UpdateContentParams) ContentSyncEventType(com.enonic.xp.core.impl.content.ContentSyncEventType) Test(org.junit.jupiter.api.Test) ParentContentSynchronizer(com.enonic.xp.core.impl.content.ParentContentSynchronizer) SyncContentServiceImpl(com.enonic.xp.core.impl.content.SyncContentServiceImpl) ContentId(com.enonic.xp.content.ContentId) ResetContentInheritParams(com.enonic.xp.content.ResetContentInheritParams) Assertions.assertFalse(org.junit.jupiter.api.Assertions.assertFalse) ProjectName(com.enonic.xp.project.ProjectName) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) SetContentChildOrderParams(com.enonic.xp.content.SetContentChildOrderParams) ContentEventsSyncParams(com.enonic.xp.core.impl.content.ContentEventsSyncParams) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) EnumSet(java.util.EnumSet) PropertyTree(com.enonic.xp.data.PropertyTree) UpdateContentParams(com.enonic.xp.content.UpdateContentParams) Content(com.enonic.xp.content.Content) PropertyTree(com.enonic.xp.data.PropertyTree) Test(org.junit.jupiter.api.Test)

Example 47 with UpdateContentParams

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

the class ContentServiceImplTest_publish_update_publishedTime method keep_original_published_time.

@Test
public void keep_original_published_time() throws Exception {
    final Content content = doCreateContent();
    doPublishContent(content);
    assertVersions(content.getId(), 2);
    final ContentPublishInfo publishInfo = this.contentService.getById(content.getId()).getPublishInfo();
    assertNotNull(publishInfo);
    assertNotNull(publishInfo.getFirst());
    assertNotNull(publishInfo.getFrom());
    final UpdateContentParams updateContentParams = new UpdateContentParams();
    updateContentParams.contentId(content.getId()).editor(edit -> edit.displayName = "new display name");
    this.contentService.update(updateContentParams);
    doPublishContent(content);
    assertVersions(content.getId(), 3);
    final ContentPublishInfo unUpdatedPublishInfo = this.contentService.getById(content.getId()).getPublishInfo();
    assertEquals(publishInfo, unUpdatedPublishInfo);
}
Also used : UpdateContentParams(com.enonic.xp.content.UpdateContentParams) Content(com.enonic.xp.content.Content) ContentPublishInfo(com.enonic.xp.content.ContentPublishInfo) Test(org.junit.jupiter.api.Test)

Example 48 with UpdateContentParams

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

the class ContentServiceImplTest_publish_update_publishedTime method set_publish_time_again_if_reset.

@Test
public void set_publish_time_again_if_reset() throws Exception {
    final Content content = doCreateContent();
    doPublishContent(content);
    final ContentPublishInfo publishInfo = this.contentService.getById(content.getId()).getPublishInfo();
    final UpdateContentParams updateContentParams = new UpdateContentParams();
    updateContentParams.contentId(content.getId()).editor(edit -> edit.publishInfo = null);
    this.contentService.update(updateContentParams);
    doPublishContent(content);
    final ContentPublishInfo updatedPublishInfo = this.contentService.getById(content.getId()).getPublishInfo();
    assertTrue(updatedPublishInfo.getFrom().isAfter(publishInfo.getFrom()));
}
Also used : UpdateContentParams(com.enonic.xp.content.UpdateContentParams) Content(com.enonic.xp.content.Content) ContentPublishInfo(com.enonic.xp.content.ContentPublishInfo) Test(org.junit.jupiter.api.Test)

Example 49 with UpdateContentParams

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

the class ApplyProjectLanguageCommand method doUpdateLanguage.

private Locale doUpdateLanguage() {
    return projectRepoContext.callWith(() -> {
        final Content root = this.contentService.getByPath(ContentPath.ROOT);
        final UpdateContentParams params = new UpdateContentParams().contentId(root.getId()).modifier(getCurrentUser().getKey()).editor(edit -> edit.language = this.language);
        return this.contentService.update(params).getLanguage();
    });
}
Also used : UpdateContentParams(com.enonic.xp.content.UpdateContentParams) Content(com.enonic.xp.content.Content)

Aggregations

UpdateContentParams (com.enonic.xp.content.UpdateContentParams)49 Content (com.enonic.xp.content.Content)43 Test (org.junit.jupiter.api.Test)35 PropertyTree (com.enonic.xp.data.PropertyTree)27 CreateContentParams (com.enonic.xp.content.CreateContentParams)14 ContentPath (com.enonic.xp.content.ContentPath)9 EditableContent (com.enonic.xp.content.EditableContent)9 Assertions.assertEquals (org.junit.jupiter.api.Assertions.assertEquals)9 Assertions.assertTrue (org.junit.jupiter.api.Assertions.assertTrue)9 ContentId (com.enonic.xp.content.ContentId)8 ContentInheritType (com.enonic.xp.content.ContentInheritType)7 WorkflowInfo (com.enonic.xp.content.WorkflowInfo)7 ByteSource (com.google.common.io.ByteSource)7 Assertions.assertNotNull (org.junit.jupiter.api.Assertions.assertNotNull)7 Assertions.assertThrows (org.junit.jupiter.api.Assertions.assertThrows)7 CreateAttachment (com.enonic.xp.attachment.CreateAttachment)6 CreateAttachments (com.enonic.xp.attachment.CreateAttachments)6 DeleteContentParams (com.enonic.xp.content.DeleteContentParams)6 ResetContentInheritParams (com.enonic.xp.content.ResetContentInheritParams)6 SetContentChildOrderParams (com.enonic.xp.content.SetContentChildOrderParams)6