Search in sources :

Example 1 with PushContentParams

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

the class PublishContentHandlerTest method testExample.

@Test
public void testExample() {
    final Content content = exampleContent(PUB_ID_1, "mycontent", "My Content", "/mysite/somepage", "myfield", "Hello World");
    Mockito.when(this.contentService.getByPath(ContentPath.from("/mysite/somepage"))).thenReturn(content);
    ContentIds ids = ContentIds.from(PUB_ID_1, FAIL_ID);
    PushContentParams pushParams = PushContentParams.create().contentIds(ids).target(Branch.from("master")).includeDependencies(false).message("My first publish").build();
    Mockito.when(this.contentService.publish(pushParams)).thenReturn(exampleResult());
    runScript("/lib/xp/examples/content/publish.js");
}
Also used : Content(com.enonic.xp.content.Content) ContentIds(com.enonic.xp.content.ContentIds) PushContentParams(com.enonic.xp.content.PushContentParams) Test(org.junit.jupiter.api.Test)

Example 2 with PushContentParams

use of com.enonic.xp.content.PushContentParams 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)

Example 3 with PushContentParams

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

the class PublishContentHandlerTest method publishWithMessage.

@Test
public void publishWithMessage() {
    ContentIds ids = ContentIds.from(PUB_ID_2, DEL_ID, FAIL_ID);
    PushContentParams pushParams = PushContentParams.create().contentIds(ids).target(Branch.from("draft")).message("My first publish").build();
    Mockito.when(this.contentService.publish(pushParams)).thenReturn(exampleResult());
    runFunction("/test/PublishContentHandlerTest.js", "publishWithMessage");
}
Also used : ContentIds(com.enonic.xp.content.ContentIds) PushContentParams(com.enonic.xp.content.PushContentParams) Test(org.junit.jupiter.api.Test)

Example 4 with PushContentParams

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

the class ContentServiceImplTest_delete method create_delete_published_content_with_children.

@Test
public void create_delete_published_content_with_children() throws Exception {
    // Creates a content with children
    final CreateContentParams createContentParams = CreateContentParams.create().contentData(new PropertyTree()).displayName("Root Content").parent(ContentPath.ROOT).type(ContentTypeName.folder()).build();
    final Content content = this.contentService.create(createContentParams);
    final CreateContentParams createChild1ContentParams = CreateContentParams.create().contentData(new PropertyTree()).displayName("Child1 Content").parent(content.getPath()).type(ContentTypeName.folder()).build();
    final Content child1Content = this.contentService.create(createChild1ContentParams);
    final CreateContentParams createChild2ContentParams = CreateContentParams.create().contentData(new PropertyTree()).displayName("Child2 Content").parent(content.getPath()).type(ContentTypeName.folder()).build();
    final Content child2Content = this.contentService.create(createChild2ContentParams);
    final CreateContentParams createSubChildContentParams = CreateContentParams.create().contentData(new PropertyTree()).displayName("SubChild Content").parent(child1Content.getPath()).type(ContentTypeName.folder()).build();
    final Content subChildContent = this.contentService.create(createSubChildContentParams);
    // Publishes the content
    final PushContentParams pushParams = PushContentParams.create().contentIds(ContentIds.from(content.getId())).target(WS_OTHER).build();
    refresh();
    this.contentService.publish(pushParams);
    // Deletes the content
    final DeleteContentParams deleteContentParams = DeleteContentParams.create().contentPath(content.getPath()).build();
    final DeleteContentsResult deletedContents = this.contentService.deleteWithoutFetch(deleteContentParams);
    assertNotNull(deletedContents);
    assertEquals(4, deletedContents.getPendingContents().getSize());
    // Checks that the content and children are marked for deletion
    final ContentIds contentIds = ContentIds.from(content.getId(), child1Content.getId(), child2Content.getId(), subChildContent.getId());
    final GetContentByIdsParams getContentByIdsParams = new GetContentByIdsParams(contentIds);
    final Contents foundContents = this.contentService.getByIds(getContentByIdsParams);
    assertEquals(4, foundContents.getSize());
    for (Content foundContent : foundContents) {
        assertTrue(ContentState.PENDING_DELETE == foundContent.getContentState());
    }
}
Also used : DeleteContentParams(com.enonic.xp.content.DeleteContentParams) GetContentByIdsParams(com.enonic.xp.content.GetContentByIdsParams) Contents(com.enonic.xp.content.Contents) CreateContentParams(com.enonic.xp.content.CreateContentParams) Content(com.enonic.xp.content.Content) PropertyTree(com.enonic.xp.data.PropertyTree) ContentIds(com.enonic.xp.content.ContentIds) DeleteContentsResult(com.enonic.xp.content.DeleteContentsResult) PushContentParams(com.enonic.xp.content.PushContentParams) Test(org.junit.jupiter.api.Test)

Example 5 with PushContentParams

use of com.enonic.xp.content.PushContentParams 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)

Aggregations

PushContentParams (com.enonic.xp.content.PushContentParams)14 Test (org.junit.jupiter.api.Test)14 PublishContentResult (com.enonic.xp.content.PublishContentResult)9 ContentIds (com.enonic.xp.content.ContentIds)6 Content (com.enonic.xp.content.Content)4 PropertyTree (com.enonic.xp.data.PropertyTree)3 Contents (com.enonic.xp.content.Contents)2 Disabled (org.junit.jupiter.api.Disabled)2 CreateContentParams (com.enonic.xp.content.CreateContentParams)1 DeleteContentParams (com.enonic.xp.content.DeleteContentParams)1 DeleteContentsResult (com.enonic.xp.content.DeleteContentsResult)1 GetContentByIdsParams (com.enonic.xp.content.GetContentByIdsParams)1