Search in sources :

Example 16 with FindContentByParentResult

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

the class ContentServiceImplTest_findByParent method test_pending_publish_draft.

@Test
public void test_pending_publish_draft() throws Exception {
    final FindContentByParentResult result = createAndFindContent(ContentPublishInfo.create().from(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 17 with FindContentByParentResult

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

the class ContentServiceImplTest_findByParent method params_size_one.

@Test
public void params_size_one() throws Exception {
    final Content parentContent = createContent(ContentPath.ROOT);
    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(0).size(1).parentPath(parentContentPath).build();
    final FindContentByParentResult result = contentService.findByParent(params);
    assertNotNull(result);
    assertEquals(1, result.getHits());
    assertEquals(3, result.getTotalHits());
    assertEquals(1, 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 FindContentByParentResult

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

the class ContentServiceImplTest_findByParent method root_children.

@Test
public void root_children() throws Exception {
    final Content parentContent = createContent(ContentPath.ROOT);
    final Content content1 = createContent(parentContent.getPath());
    final Content content2 = createContent(parentContent.getPath());
    final Content content3 = createContent(parentContent.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(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 19 with FindContentByParentResult

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

the class ContentServiceImplTest_findByParent method test_published_master.

@Test
public void test_published_master() throws Exception {
    authorizedMasterContext().callWith(() -> {
        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());
        return null;
    });
}
Also used : FindContentByParentResult(com.enonic.xp.content.FindContentByParentResult) Test(org.junit.jupiter.api.Test)

Example 20 with FindContentByParentResult

use of com.enonic.xp.content.FindContentByParentResult 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

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