Search in sources :

Example 21 with Contents

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

the class QueryContentHandler method convert.

private ContentsResultMapper convert(final FindContentIdsByQueryResult findQueryResult) {
    final ContentIds contentIds = findQueryResult.getContentIds();
    final Contents contents;
    if (contentIds.isEmpty()) {
        contents = Contents.empty();
    } else {
        contents = this.contentService.getByIds(new GetContentByIdsParams(contentIds));
    }
    return new ContentsResultMapper(contents, findQueryResult.getTotalHits(), findQueryResult.getAggregations(), findQueryResult.getHighlight(), findQueryResult.getSort(), findQueryResult.getScore());
}
Also used : Contents(com.enonic.xp.content.Contents) GetContentByIdsParams(com.enonic.xp.content.GetContentByIdsParams) ContentsResultMapper(com.enonic.xp.lib.content.mapper.ContentsResultMapper) ContentIds(com.enonic.xp.content.ContentIds)

Example 22 with Contents

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

the class GetChildContentHandlerTest method getChildrenByPath_allParameters.

@Test
public void getChildrenByPath_allParameters() throws Exception {
    final Contents contents = TestDataFixtures.newContents(3);
    final FindContentByParentResult findResult = FindContentByParentResult.create().hits(contents.getSize()).totalHits(20).contents(contents).build();
    final FindContentByParentParams expectedFindParams = FindContentByParentParams.create().parentPath(ContentPath.from("/a/b/mycontent")).from(5).size(3).childOrder(ChildOrder.from("_modifiedTime ASC")).build();
    Mockito.when(this.contentService.findByParent(Mockito.eq(expectedFindParams))).thenReturn(findResult);
    runFunction("/test/GetChildContentHandlerTest.js", "getChildrenByPath_allParameters");
}
Also used : FindContentByParentParams(com.enonic.xp.content.FindContentByParentParams) Contents(com.enonic.xp.content.Contents) FindContentByParentResult(com.enonic.xp.content.FindContentByParentResult) Test(org.junit.jupiter.api.Test)

Example 23 with Contents

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

the class GetChildContentHandlerTest method getChildrenById.

@Test
public void getChildrenById() throws Exception {
    final Contents contents = TestDataFixtures.newContents(3);
    final FindContentByParentResult findResult = FindContentByParentResult.create().hits(contents.getSize()).totalHits(20).contents(contents).build();
    Mockito.when(this.contentService.findByParent(Mockito.isA(FindContentByParentParams.class))).thenReturn(findResult);
    runFunction("/test/GetChildContentHandlerTest.js", "getChildrenById");
}
Also used : FindContentByParentParams(com.enonic.xp.content.FindContentByParentParams) Contents(com.enonic.xp.content.Contents) FindContentByParentResult(com.enonic.xp.content.FindContentByParentResult) Test(org.junit.jupiter.api.Test)

Example 24 with Contents

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

the class GetChildContentHandlerTest method getChildrenByPath.

@Test
public void getChildrenByPath() throws Exception {
    final Contents contents = TestDataFixtures.newContents(3);
    final FindContentByParentResult findResult = FindContentByParentResult.create().hits(contents.getSize()).totalHits(20).contents(contents).build();
    Mockito.when(this.contentService.findByParent(Mockito.isA(FindContentByParentParams.class))).thenReturn(findResult);
    runFunction("/test/GetChildContentHandlerTest.js", "getChildrenByPath");
}
Also used : FindContentByParentParams(com.enonic.xp.content.FindContentByParentParams) Contents(com.enonic.xp.content.Contents) FindContentByParentResult(com.enonic.xp.content.FindContentByParentResult) Test(org.junit.jupiter.api.Test)

Example 25 with Contents

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

the class ApplicationInfoServiceImplTest method mockReferences.

private void mockReferences(final ApplicationKey applicationKey) {
    final Content content1 = Content.create().id(ContentId.from("id1")).name("name1").displayName("My Content 1").parentPath(ContentPath.from("/a/b")).modifier(PrincipalKey.from("user:system:admin")).modifiedTime(Instant.ofEpochSecond(0)).creator(PrincipalKey.from("user:system:admin")).createdTime(Instant.ofEpochSecond(0)).build();
    final Content content2 = Content.create().id(ContentId.from("id2")).name("name2").displayName("My Content 2").parentPath(ContentPath.from("/a/c")).modifier(PrincipalKey.from("user:system:admin")).modifiedTime(Instant.ofEpochSecond(0)).creator(PrincipalKey.from("user:system:admin")).createdTime(Instant.ofEpochSecond(0)).build();
    final Contents contents = Contents.from(content1, content2);
    Mockito.when(this.contentService.findByApplicationKey(applicationKey)).thenReturn(contents);
}
Also used : Contents(com.enonic.xp.content.Contents) Content(com.enonic.xp.content.Content)

Aggregations

Contents (com.enonic.xp.content.Contents)41 Test (org.junit.jupiter.api.Test)30 Content (com.enonic.xp.content.Content)25 GetContentByIdsParams (com.enonic.xp.content.GetContentByIdsParams)16 ContentIds (com.enonic.xp.content.ContentIds)12 ContentPaths (com.enonic.xp.content.ContentPaths)7 PropertyTree (com.enonic.xp.data.PropertyTree)7 ContentId (com.enonic.xp.content.ContentId)5 ContentQuery (com.enonic.xp.content.ContentQuery)5 DeleteContentsResult (com.enonic.xp.content.DeleteContentsResult)5 FindContentByParentParams (com.enonic.xp.content.FindContentByParentParams)5 FindContentByParentResult (com.enonic.xp.content.FindContentByParentResult)5 FindContentIdsByQueryResult (com.enonic.xp.content.FindContentIdsByQueryResult)5 CreateContentParams (com.enonic.xp.content.CreateContentParams)4 Nodes (com.enonic.xp.node.Nodes)3 BucketAggregation (com.enonic.xp.aggregation.BucketAggregation)2 Buckets (com.enonic.xp.aggregation.Buckets)2 ApplicationKey (com.enonic.xp.app.ApplicationKey)2 ContentDependencies (com.enonic.xp.content.ContentDependencies)2 ContentIndexPath (com.enonic.xp.content.ContentIndexPath)2