Search in sources :

Example 6 with PublishContentResult

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

the class ContentServiceImplTest_publish method push_exclude_without_children.

@Test
public void push_exclude_without_children() throws Exception {
    createContentTree();
    final PushContentParams pushParams = PushContentParams.create().contentIds(ContentIds.from(content1.getId())).excludedContentIds(ContentIds.from(content1_1.getId())).excludeChildrenIds(ContentIds.from(content1.getId())).target(WS_OTHER).build();
    refresh();
    final PublishContentResult result = this.contentService.publish(pushParams);
    assertEquals(1, result.getPushedContents().getSize());
}
Also used : PublishContentResult(com.enonic.xp.content.PublishContentResult) PushContentParams(com.enonic.xp.content.PushContentParams) Test(org.junit.jupiter.api.Test)

Example 7 with PublishContentResult

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

the class ContentServiceImplTest_publish method push_without_dependencies.

/**
 * ./content1
 * ../content1_1 -> Ref:content2_1_1
 * ./content2
 * ../content2_1
 * ../../content2_1_1
 * ./content3
 */
@Test
public void push_without_dependencies() throws Exception {
    createContentTree2();
    final PushContentParams pushParams = PushContentParams.create().contentIds(ContentIds.from(content1.getId())).includeDependencies(false).target(WS_OTHER).build();
    final PublishContentResult result = this.contentService.publish(pushParams);
    assertEquals(2, result.getPushedContents().getSize());
    assertTrue(result.getPushedContents().contains(content1.getId()));
    assertTrue(result.getPushedContents().contains(content1_1.getId()));
}
Also used : PublishContentResult(com.enonic.xp.content.PublishContentResult) PushContentParams(com.enonic.xp.content.PushContentParams) Test(org.junit.jupiter.api.Test)

Example 8 with PublishContentResult

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

the class ContentServiceImplTest_publish method push_parent_of_dependencies.

/**
 * ./content1
 * ../content1_1 -> Ref:content2_1_1
 * ./content2
 * ../content2_1
 * ../../content2_1_1
 * ./content3
 */
@Test
public void push_parent_of_dependencies() throws Exception {
    createContentTree2();
    final PushContentParams pushParams = PushContentParams.create().contentIds(ContentIds.from(content1_1.getId())).excludeChildrenIds(ContentIds.from(content1_1.getId())).target(WS_OTHER).build();
    final PublishContentResult result = this.contentService.publish(pushParams);
    assertEquals(5, result.getPushedContents().getSize());
    assertEquals(0, result.getFailedContents().getSize());
}
Also used : PublishContentResult(com.enonic.xp.content.PublishContentResult) PushContentParams(com.enonic.xp.content.PushContentParams) Test(org.junit.jupiter.api.Test)

Example 9 with PublishContentResult

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

the class ContentServiceImplTest_delete method delete_published_content_with_unpublished_children.

@Test
public void delete_published_content_with_unpublished_children() throws Exception {
    final Content parent = this.contentService.create(CreateContentParams.create().contentData(new PropertyTree()).displayName("Root Content").parent(ContentPath.ROOT).type(ContentTypeName.folder()).build());
    final Content child = this.contentService.create(CreateContentParams.create().contentData(new PropertyTree()).displayName("Published Child Content").parent(parent.getPath()).type(ContentTypeName.folder()).build());
    refresh();
    final PublishContentResult result = this.contentService.publish(PushContentParams.create().contentIds(ContentIds.from(parent.getId())).target(WS_OTHER).build());
    assertEquals(2, result.getPushedContents().getSize());
    refresh();
    // Creates an child that we wont publish
    final Content unpublishedChildContent = this.contentService.create(CreateContentParams.create().contentData(new PropertyTree()).displayName("Unpublished Child Content").parent(parent.getPath()).type(ContentTypeName.folder()).build());
    refresh();
    // Deletes the root content
    final DeleteContentsResult deletedContents = this.contentService.deleteWithoutFetch(DeleteContentParams.create().contentPath(parent.getPath()).build());
    assertNotNull(deletedContents);
    assertEquals(1, deletedContents.getDeletedContents().getSize());
    assertEquals(2, deletedContents.getPendingContents().getSize());
    DeleteContentParams.create().contentPath(parent.getPath()).build();
    assertTrue(deletedContents.getDeletedContents().contains(unpublishedChildContent.getId()));
    assertTrue(deletedContents.getPendingContents().contains(parent.getId()));
    assertTrue(deletedContents.getPendingContents().contains(child.getId()));
    // Checks that the content and published child are marked for deletion and that the unpublished child is deleted
    final ContentIds contentIds = ContentIds.from(parent.getId(), child.getId(), unpublishedChildContent.getId());
    final GetContentByIdsParams getContentByIdsParams = new GetContentByIdsParams(contentIds);
    final Contents foundContents = this.contentService.getByIds(getContentByIdsParams);
    assertEquals(2, foundContents.getSize());
    for (Content foundContent : foundContents) {
        assertTrue(ContentState.PENDING_DELETE == foundContent.getContentState());
        assertTrue(parent.getId().equals(foundContent.getId()) || child.getId().equals(foundContent.getId()));
    }
}
Also used : PublishContentResult(com.enonic.xp.content.PublishContentResult) GetContentByIdsParams(com.enonic.xp.content.GetContentByIdsParams) Contents(com.enonic.xp.content.Contents) Content(com.enonic.xp.content.Content) PropertyTree(com.enonic.xp.data.PropertyTree) ContentIds(com.enonic.xp.content.ContentIds) DeleteContentsResult(com.enonic.xp.content.DeleteContentsResult) Test(org.junit.jupiter.api.Test)

Example 10 with PublishContentResult

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

the class PublishContentHandlerTest method publishWithoutChildrenOrDependencies.

@Test
public void publishWithoutChildrenOrDependencies() {
    Contents published = Contents.from(exampleContent(PUB_ID_3, "mycontent", "My Content", "/mysite/somepage", "myfield", "Hello World"));
    PublishContentResult exampleResult = PublishContentResult.create().setPushed(published.getIds()).build();
    ContentIds ids = ContentIds.from(PUB_ID_3);
    PushContentParams pushParams = PushContentParams.create().contentIds(ids).target(Branch.from("master")).excludeChildrenIds(ids).includeDependencies(false).build();
    Mockito.when(this.contentService.publish(pushParams)).thenReturn(exampleResult);
    runFunction("/test/PublishContentHandlerTest.js", "publishWithoutChildrenOrDependencies");
}
Also used : PublishContentResult(com.enonic.xp.content.PublishContentResult) Contents(com.enonic.xp.content.Contents) ContentIds(com.enonic.xp.content.ContentIds) PushContentParams(com.enonic.xp.content.PushContentParams) Test(org.junit.jupiter.api.Test)

Aggregations

PublishContentResult (com.enonic.xp.content.PublishContentResult)21 Test (org.junit.jupiter.api.Test)19 Content (com.enonic.xp.content.Content)12 PropertyTree (com.enonic.xp.data.PropertyTree)11 PushContentParams (com.enonic.xp.content.PushContentParams)10 CreateContentParams (com.enonic.xp.content.CreateContentParams)7 DeleteContentsResult (com.enonic.xp.content.DeleteContentsResult)5 Disabled (org.junit.jupiter.api.Disabled)3 ContentId (com.enonic.xp.content.ContentId)2 ContentIds (com.enonic.xp.content.ContentIds)2 Contents (com.enonic.xp.content.Contents)2 LogAuditLogParams (com.enonic.xp.audit.LogAuditLogParams)1 ContentPath (com.enonic.xp.content.ContentPath)1 ContentPublishInfo (com.enonic.xp.content.ContentPublishInfo)1 DeleteContentParams (com.enonic.xp.content.DeleteContentParams)1 GetContentByIdsParams (com.enonic.xp.content.GetContentByIdsParams)1 PropertySet (com.enonic.xp.data.PropertySet)1 PublishContentResultMapper (com.enonic.xp.lib.content.mapper.PublishContentResultMapper)1 ContentType (com.enonic.xp.schema.content.ContentType)1 ArrayList (java.util.ArrayList)1