use of com.enonic.xp.content.FindContentByParentResult in project xp by enonic.
the class AbstractContentServiceTest method doPrintChildren.
private void doPrintChildren(int ident, final Content root) {
System.out.println(createString(root, ident));
ident += 3;
final FindContentByParentResult result = this.contentService.findByParent(FindContentByParentParams.create().parentId(root.getId()).size(-1).build());
for (final Content content : result.getContents()) {
doPrintChildren(ident, content);
}
}
use of com.enonic.xp.content.FindContentByParentResult in project xp by enonic.
the class ContentServiceImplTest_findByParent method test_published_draft.
@Test
public void test_published_draft() throws Exception {
final FindContentByParentResult result = createAndFindContent(ContentPublishInfo.create().from(Instant.now().minus(Duration.ofDays(1))).to(Instant.now().plus(Duration.ofDays(1))).build());
assertEquals(1, result.getTotalHits());
}
use of com.enonic.xp.content.FindContentByParentResult in project xp by enonic.
the class ContentServiceImplTest_findByParent method invalid_parent_path.
@Test
public void invalid_parent_path() throws Exception {
final Content rootContent = createContent(ContentPath.ROOT);
final Content childrenLevel1 = createContent(rootContent.getPath());
this.nodeService.refresh(RefreshMode.SEARCH);
final FindContentByParentParams params = FindContentByParentParams.create().from(0).size(30).parentPath(ContentPath.from("/test_invalid_path")).build();
final FindContentByParentResult result = contentService.findByParent(params);
assertNotNull(result);
assertEquals(0, result.getTotalHits());
}
use of com.enonic.xp.content.FindContentByParentResult in project xp by enonic.
the class ContentServiceImplTest_findByParent method deep_children.
@Test
public void deep_children() throws Exception {
final Content rootContent = createContent(ContentPath.ROOT);
final Content childrenLevel1 = createContent(rootContent.getPath());
final Content childrenLevel2_1 = createContent(childrenLevel1.getPath());
final Content childrenLevel2_2 = createContent(childrenLevel1.getPath());
final Content childrenLevel2_3 = createContent(childrenLevel1.getPath());
final ContentPath parentContentPath = childrenLevel1.getPath();
this.nodeService.refresh(RefreshMode.SEARCH);
final FindContentByParentParams params = FindContentByParentParams.create().from(0).size(30).parentPath(parentContentPath).build();
final FindContentByParentResult result = contentService.findByParent(params);
assertNotNull(result);
assertEquals(3, result.getTotalHits());
}
use of com.enonic.xp.content.FindContentByParentResult in project xp by enonic.
the class ContentServiceImplTest_findByParent method params_from_beyond.
@Test
public void params_from_beyond() throws Exception {
final Content parentContent = createContent(ContentPath.ROOT);
createContent(parentContent.getPath());
createContent(parentContent.getPath());
createContent(parentContent.getPath());
refresh();
this.nodeService.refresh(RefreshMode.SEARCH);
final FindContentByParentResult result = contentService.findByParent(FindContentByParentParams.create().from(10).parentPath(parentContent.getPath()).build());
assertNotNull(result);
assertEquals(0, result.getHits());
assertEquals(3, result.getTotalHits());
assertTrue(result.getContents().isEmpty());
}
Aggregations