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