Search in sources :

Example 16 with FindContentByParentParams

use of com.enonic.xp.content.FindContentByParentParams in project xp by enonic.

the class ContentServiceImplTest_findByParent method hasChildResolved.

@Test
public void hasChildResolved() throws Exception {
    final Content parentContent = createContent(ContentPath.ROOT);
    final Content content1 = createContent(parentContent.getPath());
    createContent(content1.getPath());
    final ContentPath parentContentPath = parentContent.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(1, result.getTotalHits());
    final Content content1Result = result.getContents().getContentById(content1.getId());
    assertTrue(content1Result.hasChildren());
}
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 17 with FindContentByParentParams

use of com.enonic.xp.content.FindContentByParentParams in project xp by enonic.

the class ContentServiceImplTest_findByParent method params_from.

@Test
public void params_from() throws Exception {
    final Content parentContent = createContent(ContentPath.ROOT);
    createContent(parentContent.getPath());
    createContent(parentContent.getPath());
    createContent(parentContent.getPath());
    createContent(parentContent.getPath());
    final ContentPath parentContentPath = parentContent.getPath();
    this.nodeService.refresh(RefreshMode.SEARCH);
    final FindContentByParentParams params = FindContentByParentParams.create().from(2).parentPath(parentContentPath).build();
    final FindContentByParentResult result = contentService.findByParent(params);
    assertNotNull(result);
    assertEquals(2, result.getHits());
    assertEquals(4, result.getTotalHits());
    assertEquals(2, result.getContents().getSize());
}
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 18 with FindContentByParentParams

use of com.enonic.xp.content.FindContentByParentParams in project xp by enonic.

the class ContentServiceImplTest_findIdsByParent method hasChildResolved.

@Test
public void hasChildResolved() throws Exception {
    final Content parentContent = createContent(ContentPath.ROOT);
    final Content content1 = createContent(parentContent.getPath());
    createContent(content1.getPath());
    this.nodeService.refresh(RefreshMode.SEARCH);
    final FindContentByParentParams params = FindContentByParentParams.create().from(0).size(30).parentId(parentContent.getId()).build();
    final FindContentIdsByParentResult result = contentService.findIdsByParent(params);
    assertNotNull(result);
    assertEquals(1, result.getTotalHits());
    final Content content1Result = this.contentService.getById(result.getContentIds().first());
    assertTrue(content1Result.hasChildren());
}
Also used : FindContentByParentParams(com.enonic.xp.content.FindContentByParentParams) Content(com.enonic.xp.content.Content) FindContentIdsByParentResult(com.enonic.xp.content.FindContentIdsByParentResult) Test(org.junit.jupiter.api.Test)

Example 19 with FindContentByParentParams

use of com.enonic.xp.content.FindContentByParentParams in project xp by enonic.

the class ContentServiceImplTest_findByParent method createAndFindContent.

private FindContentByParentResult createAndFindContent(final ContentPublishInfo publishInfo) throws Exception {
    createContent(ContentPath.ROOT, publishInfo);
    this.nodeService.refresh(RefreshMode.SEARCH);
    final FindContentByParentParams params = FindContentByParentParams.create().parentPath(ContentPath.ROOT).build();
    return contentService.findByParent(params);
}
Also used : FindContentByParentParams(com.enonic.xp.content.FindContentByParentParams)

Example 20 with FindContentByParentParams

use of com.enonic.xp.content.FindContentByParentParams in project xp by enonic.

the class ContentServiceImplTest_findByParent method root_no_content.

@Test
public void root_no_content() throws Exception {
    final FindContentByParentParams params = FindContentByParentParams.create().from(0).size(30).parentPath(null).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) Test(org.junit.jupiter.api.Test)

Aggregations

FindContentByParentParams (com.enonic.xp.content.FindContentByParentParams)23 Content (com.enonic.xp.content.Content)18 Test (org.junit.jupiter.api.Test)18 FindContentByParentResult (com.enonic.xp.content.FindContentByParentResult)12 ContentPath (com.enonic.xp.content.ContentPath)10 FindContentIdsByParentResult (com.enonic.xp.content.FindContentIdsByParentResult)8 Contents (com.enonic.xp.content.Contents)1 PageTemplate (com.enonic.xp.page.PageTemplate)1 PageTemplates (com.enonic.xp.page.PageTemplates)1 ValueFilter (com.enonic.xp.query.filter.ValueFilter)1