Search in sources :

Example 6 with FindContentIdsByParentResult

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

the class ContentServiceImplTest_findIdsByParent 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 FindContentIdsByParentResult result = contentService.findIdsByParent(params);
    assertNotNull(result);
    assertEquals(0, result.getTotalHits());
}
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 7 with FindContentIdsByParentResult

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

the class ContentServiceImplTest_findIdsByParent 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 FindContentIdsByParentResult result = contentService.findIdsByParent(params);
    assertNotNull(result);
    assertEquals(0, result.getTotalHits());
}
Also used : FindContentByParentParams(com.enonic.xp.content.FindContentByParentParams) FindContentIdsByParentResult(com.enonic.xp.content.FindContentIdsByParentResult) Test(org.junit.jupiter.api.Test)

Example 8 with FindContentIdsByParentResult

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

the class ContentServiceImplTest_findIdsByParent 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 FindContentIdsByParentResult result = contentService.findIdsByParent(params);
    assertNotNull(result);
    assertEquals(3, result.getTotalHits());
}
Also used : FindContentByParentParams(com.enonic.xp.content.FindContentByParentParams) Content(com.enonic.xp.content.Content) FindContentIdsByParentResult(com.enonic.xp.content.FindContentIdsByParentResult) ContentPath(com.enonic.xp.content.ContentPath) Test(org.junit.jupiter.api.Test)

Example 9 with FindContentIdsByParentResult

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

the class ContentServiceImplTest_findIdsByParent 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 FindContentIdsByParentResult result = contentService.findIdsByParent(FindContentByParentParams.create().from(10).parentPath(parentContent.getPath()).build());
    assertNotNull(result);
    assertEquals(0, result.getHits());
    assertEquals(3, result.getTotalHits());
    assertTrue(result.getContentIds().isEmpty());
}
Also used : Content(com.enonic.xp.content.Content) FindContentIdsByParentResult(com.enonic.xp.content.FindContentIdsByParentResult) Test(org.junit.jupiter.api.Test)

Example 10 with FindContentIdsByParentResult

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

the class ContentServiceImplTest_findIdsByParent method test_published_master.

@Test
public void test_published_master() throws Exception {
    authorizedMasterContext().callWith(() -> {
        final FindContentIdsByParentResult 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 : FindContentIdsByParentResult(com.enonic.xp.content.FindContentIdsByParentResult) Test(org.junit.jupiter.api.Test)

Aggregations

FindContentIdsByParentResult (com.enonic.xp.content.FindContentIdsByParentResult)16 Test (org.junit.jupiter.api.Test)16 Content (com.enonic.xp.content.Content)8 FindContentByParentParams (com.enonic.xp.content.FindContentByParentParams)8 ContentPath (com.enonic.xp.content.ContentPath)4