use of com.enonic.xp.content.GetContentByIdsParams 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.GetContentByIdsParams 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));
}
use of com.enonic.xp.content.GetContentByIdsParams in project xp by enonic.
the class ContentServiceImplTest_delete method create_delete_content_with_children.
@Test
public void create_delete_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);
refresh();
// Deletes the content
final DeleteContentsResult deletedContents = this.contentService.deleteWithoutFetch(DeleteContentParams.create().contentPath(content.getPath()).build());
assertNotNull(deletedContents);
assertEquals(4, deletedContents.getDeletedContents().getSize());
// Checks that the content and the children are deleted
final GetContentByIdsParams getContentByIdsParams = new GetContentByIdsParams(ContentIds.from(content.getId(), child1Content.getId(), child2Content.getId(), subChildContent.getId()));
final Contents foundContents = this.contentService.getByIds(getContentByIdsParams);
assertEquals(0, foundContents.getSize());
}
use of com.enonic.xp.content.GetContentByIdsParams in project xp by enonic.
the class ContentServiceImplTest_getByIds 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 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.GetContentByIdsParams in project xp by enonic.
the class ContentServiceImplTest_getByIds 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 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));
return null;
});
}
Aggregations