use of com.enonic.xp.content.ContentPath 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.ContentPath in project xp by enonic.
the class ContentServiceImplTest_findIdsByParent method params_from.
@Test
public void params_from() throws Exception {
final Content parentContent = createContent(ContentPath.ROOT);
createContent(parentContent.getPath());
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(2).parentPath(parentContentPath).build();
final FindContentIdsByParentResult result = contentService.findIdsByParent(params);
assertNotNull(result);
assertEquals(2, result.getHits());
assertEquals(4, result.getTotalHits());
assertEquals(2, result.getContentIds().getSize());
}
use of com.enonic.xp.content.ContentPath 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());
}
use of com.enonic.xp.content.ContentPath in project xp by enonic.
the class SyncContentServiceImplTest method resetWithRemovedSource.
@Test
public void resetWithRemovedSource() throws Exception {
final Content source = sourceContext.callWith(() -> createContent(ContentPath.ROOT));
syncCreated(source.getId());
targetContext.runWith(() -> {
contentService.update(new UpdateContentParams().contentId(source.getId()).editor(edit -> {
edit.workflowInfo = WorkflowInfo.ready();
edit.data = new PropertyTree();
}));
});
sourceContext.runWith(() -> contentService.deleteWithoutFetch(DeleteContentParams.create().contentPath(source.getPath()).build()));
assertThrows(IllegalArgumentException.class, () -> syncContentService.resetInheritance(ResetContentInheritParams.create().contentId(source.getId()).inherit(EnumSet.of(ContentInheritType.CONTENT)).projectName(targetProject.getName()).build()));
}
use of com.enonic.xp.content.ContentPath in project xp by enonic.
the class ContentNodeHelperTest method translateNodePathToContentPath.
@Test
public void translateNodePathToContentPath() {
final ContentPath contentPath = ContentNodeHelper.translateNodePathToContentPath(NodePath.create("/content/site/myContent").build());
assertEquals(ContentPath.from("/site/myContent"), contentPath);
}
Aggregations