Search in sources :

Example 6 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 7 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 8 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 9 with PushContentParams

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

the class ContentServiceImplTest_publish method push_dependencies.

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

Example 10 with PushContentParams

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

the class ContentServiceImplTest_publish method push_exclude_empty.

@Disabled("This test is not correct; it should not be allowed to exclude parent if new")
@Test
public void push_exclude_empty() throws Exception {
    createContentTree();
    final PushContentParams pushParams = PushContentParams.create().contentIds(ContentIds.from(content1.getId())).excludedContentIds(ContentIds.from(content1.getId())).target(WS_OTHER).build();
    refresh();
    final PublishContentResult result = this.contentService.publish(pushParams);
    assertEquals(0, result.getPushedContents().getSize());
}
Also used : PublishContentResult(com.enonic.xp.content.PublishContentResult) PushContentParams(com.enonic.xp.content.PushContentParams) Test(org.junit.jupiter.api.Test) Disabled(org.junit.jupiter.api.Disabled)

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