use of com.enonic.xp.content.FindContentByParentParams in project xp by enonic.
the class ContentServiceImplTest_findByParent 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 FindContentByParentResult result = contentService.findByParent(params);
assertNotNull(result);
assertEquals(0, result.getTotalHits());
}
use of com.enonic.xp.content.FindContentByParentParams in project xp by enonic.
the class ContentServiceImplTest_findIdsByParent 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 FindContentIdsByParentResult result = contentService.findIdsByParent(params);
assertNotNull(result);
assertEquals(1, result.getHits());
assertEquals(3, result.getTotalHits());
assertEquals(1, result.getContentIds().getSize());
}
use of com.enonic.xp.content.FindContentByParentParams in project xp by enonic.
the class ContentServiceImplTest_findIdsByParent method createAndFindContent.
private FindContentIdsByParentResult 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.findIdsByParent(params);
}
use of com.enonic.xp.content.FindContentByParentParams 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.FindContentByParentParams in project xp by enonic.
the class ContentResourceTest method reprocess_child_with_error.
@Test
public void reprocess_child_with_error() throws Exception {
Content content = createContent("content-id", ContentPath.from("/path/to/content"));
Content reprocessedContent = Content.create(content).displayName("new name").build();
Content child = createContent("child-id", ContentPath.from(content.getPath(), "child"));
Mockito.when(this.contentService.getByPath(content.getPath())).thenReturn(content);
Mockito.when(this.contentService.reprocess(content.getId())).thenReturn(reprocessedContent);
Mockito.when(this.contentService.reprocess(child.getId())).thenThrow(new RuntimeException("errorMessage"));
final FindContentByParentParams findParams = FindContentByParentParams.create().parentId(content.getId()).from(0).size(5).build();
Mockito.when(this.contentService.findByParent(findParams)).thenReturn(FindContentByParentResult.create().contents(Contents.create().add(child).build()).build());
final String result = request().path("content/reprocess").entity(readFromFile("reprocess_params.json"), MediaType.APPLICATION_JSON_TYPE).post().getAsString();
assertEquals("{\"errors\":[\"Content '/path/to/content/child' - java.lang.RuntimeException: errorMessage\"],\"updatedContent\":[\"/path/to/content\"]}", result);
}
Aggregations