Search in sources :

Example 11 with FindContentByParentResult

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);
    }
}
Also used : FindContentByParentResult(com.enonic.xp.content.FindContentByParentResult) Content(com.enonic.xp.content.Content)

Example 12 with FindContentByParentResult

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());
}
Also used : FindContentByParentResult(com.enonic.xp.content.FindContentByParentResult) Test(org.junit.jupiter.api.Test)

Example 13 with FindContentByParentResult

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());
}
Also used : FindContentByParentParams(com.enonic.xp.content.FindContentByParentParams) FindContentByParentResult(com.enonic.xp.content.FindContentByParentResult) Content(com.enonic.xp.content.Content) Test(org.junit.jupiter.api.Test)

Example 14 with FindContentByParentResult

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());
}
Also used : FindContentByParentParams(com.enonic.xp.content.FindContentByParentParams) FindContentByParentResult(com.enonic.xp.content.FindContentByParentResult) Content(com.enonic.xp.content.Content) ContentPath(com.enonic.xp.content.ContentPath) Test(org.junit.jupiter.api.Test)

Example 15 with FindContentByParentResult

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());
}
Also used : FindContentByParentResult(com.enonic.xp.content.FindContentByParentResult) Content(com.enonic.xp.content.Content) Test(org.junit.jupiter.api.Test)

Aggregations

FindContentByParentResult (com.enonic.xp.content.FindContentByParentResult)33 Test (org.junit.jupiter.api.Test)26 Content (com.enonic.xp.content.Content)18 FindContentByParentParams (com.enonic.xp.content.FindContentByParentParams)18 ContentPath (com.enonic.xp.content.ContentPath)7 Contents (com.enonic.xp.content.Contents)4 ArrayDeque (java.util.ArrayDeque)2 ArchiveConstants (com.enonic.xp.archive.ArchiveConstants)1 ContentConstants (com.enonic.xp.content.ContentConstants)1 BRANCH_DRAFT (com.enonic.xp.content.ContentConstants.BRANCH_DRAFT)1 CONTENT_ROOT_PATH_ATTRIBUTE (com.enonic.xp.content.ContentConstants.CONTENT_ROOT_PATH_ATTRIBUTE)1 ContentId (com.enonic.xp.content.ContentId)1 ContentService (com.enonic.xp.content.ContentService)1 Context (com.enonic.xp.context.Context)1 ContextAccessor (com.enonic.xp.context.ContextAccessor)1 ContextBuilder (com.enonic.xp.context.ContextBuilder)1 MediaInfoService (com.enonic.xp.media.MediaInfoService)1 NodePath (com.enonic.xp.node.NodePath)1 PageTemplate (com.enonic.xp.page.PageTemplate)1 PageTemplates (com.enonic.xp.page.PageTemplates)1