use of com.enonic.xp.content.ContentPath in project xp by enonic.
the class GetNearestSiteCommandTest method get_nearest_site_no_nearest_site.
@Test
public void get_nearest_site_no_nearest_site() throws Exception {
final Node node = Node.create().id(NodeId.from("test")).name("myContent").parentPath(ContentConstants.CONTENT_ROOT_PATH).build();
final ContentId contentId = ContentId.from("aaa");
final Content content = Content.create().id(contentId).name("name").parentPath(ContentPath.from("/aaa")).build();
final ContentPath contentPath = ContentPath.from("/mycontent");
final Content parent = Content.create().path(contentPath).id(ContentId.from("bbb")).build();
Mockito.when(this.nodeService.getById(Mockito.any(NodeId.class))).thenReturn(node);
Mockito.when(this.nodeService.getByPath(Mockito.isA(NodePath.class))).thenReturn(node);
Mockito.when(this.translator.fromNode(node, true)).thenReturn(content, parent);
assertNull(createCommand(contentId).execute());
}
use of com.enonic.xp.content.ContentPath in project xp by enonic.
the class ContentServiceImplTest_findByParent 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 FindContentByParentResult result = contentService.findByParent(params);
assertNotNull(result);
assertEquals(3, result.getTotalHits());
}
use of com.enonic.xp.content.ContentPath 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());
}
use of com.enonic.xp.content.ContentPath 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());
}
use of com.enonic.xp.content.ContentPath in project xp by enonic.
the class ContentServiceImplTest_findIdsByParent 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 FindContentIdsByParentResult result = contentService.findIdsByParent(params);
assertNotNull(result);
assertEquals(3, result.getTotalHits());
}
Aggregations