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());
}
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");
}
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");
}
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");
}
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);
}
Aggregations