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");
}
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");
}
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");
}
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());
}
}
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());
}
Aggregations