use of com.enonic.xp.content.Contents 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.Contents in project xp by enonic.
the class ContentServiceImplTest_getByPaths method test_published_master.
@Test
public void test_published_master() throws Exception {
authorizedMasterContext().callWith(() -> {
final Content content1 = createContent(ContentPath.ROOT);
final Content content2 = createContent(ContentPath.ROOT, ContentPublishInfo.create().from(Instant.now().minus(Duration.ofDays(1))).to(Instant.now().plus(Duration.ofDays(1))).build());
final ContentPaths paths = ContentPaths.from(content1.getPath(), content2.getPath());
final Contents contents = this.contentService.getByPaths(paths);
assertEquals(contents.getSize(), 2);
assertTrue(contents.contains(content1));
assertTrue(contents.contains(content2));
return null;
});
}
use of com.enonic.xp.content.Contents in project xp by enonic.
the class ContentServiceImplTest_getByPaths method test_pending_publish_master.
@Test
public void test_pending_publish_master() throws Exception {
authorizedMasterContext().callWith(() -> {
final Content content1 = createContent(ContentPath.ROOT);
final Content content2 = createContent(ContentPath.ROOT, ContentPublishInfo.create().from(Instant.now().plus(Duration.ofDays(1))).build());
final ContentPaths paths = ContentPaths.from(content1.getPath(), content2.getPath());
final Contents contents = this.contentService.getByPaths(paths);
assertEquals(contents.getSize(), 1);
assertTrue(contents.contains(content1));
assertFalse(contents.contains(content2));
return null;
});
}
use of com.enonic.xp.content.Contents in project xp by enonic.
the class ContentServiceImplTest_getByIds method test_publish_expired_master.
@Test
public void test_publish_expired_master() throws Exception {
authorizedMasterContext().callWith(() -> {
final Content content1 = createContent(ContentPath.ROOT);
final Content content2 = createContent(ContentPath.ROOT, ContentPublishInfo.create().from(Instant.now().minus(Duration.ofDays(1))).to(Instant.now().minus(Duration.ofDays(1))).build());
final ContentIds ids = ContentIds.from(content1.getId(), content2.getId());
final Contents contents = this.contentService.getByIds(new GetContentByIdsParams(ids));
assertEquals(contents.getSize(), 1);
assertTrue(contents.contains(content1));
assertFalse(contents.contains(content2));
return null;
});
}
use of com.enonic.xp.content.Contents in project xp by enonic.
the class ContentServiceImplTest_getByIds method test_publish_expired_draft.
@Test
public void test_publish_expired_draft() throws Exception {
final Content content1 = createContent(ContentPath.ROOT);
final Content content2 = createContent(ContentPath.ROOT, ContentPublishInfo.create().from(Instant.now().minus(Duration.ofDays(1))).to(Instant.now().minus(Duration.ofDays(1))).build());
final ContentIds ids = ContentIds.from(content1.getId(), content2.getId());
final Contents contents = this.contentService.getByIds(new GetContentByIdsParams(ids));
assertEquals(contents.getSize(), 2);
assertTrue(contents.contains(content1));
assertTrue(contents.contains(content2));
}
Aggregations