use of com.enonic.xp.content.ContentPath in project xp by enonic.
the class ContentPathsTest method addAndRemoveContentPath.
@Test
void addAndRemoveContentPath() {
Set<ContentPath> set = Set.of(CONTENT_PATH2, CONTENT_PATH3);
ContentPath[] array = { CONTENT_PATH2, CONTENT_PATH3 };
ContentPaths pathsFromSet = ContentPaths.from(CONTENT_PATH1).add(set);
ContentPaths pathsFromArray = ContentPaths.from(CONTENT_PATH1).add(array);
assertEquals(pathsFromSet, pathsFromArray);
pathsFromArray = pathsFromArray.remove(set);
pathsFromSet = pathsFromSet.remove(array);
assertEquals(pathsFromSet, pathsFromArray);
assertEquals(pathsFromSet.hashCode(), pathsFromArray.hashCode());
assertEquals(pathsFromSet.toString(), pathsFromArray.toString());
}
use of com.enonic.xp.content.ContentPath in project xp by enonic.
the class ContentServiceImplTest_findByParent method hasChildResolved.
@Test
public void hasChildResolved() throws Exception {
final Content parentContent = createContent(ContentPath.ROOT);
final Content content1 = createContent(parentContent.getPath());
createContent(content1.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(1, result.getTotalHits());
final Content content1Result = result.getContents().getContentById(content1.getId());
assertTrue(content1Result.hasChildren());
}
use of com.enonic.xp.content.ContentPath in project xp by enonic.
the class ContentServiceImplTest_findByParent 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 FindContentByParentResult result = contentService.findByParent(params);
assertNotNull(result);
assertEquals(2, result.getHits());
assertEquals(4, result.getTotalHits());
assertEquals(2, result.getContents().getSize());
}
use of com.enonic.xp.content.ContentPath in project xp by enonic.
the class ContentPathConverterTest method testSameType.
@Test
public void testSameType() {
final ContentPath path = ContentPath.from("/some/path");
assertSame(path, Converters.convert(path, ContentPath.class));
}
use of com.enonic.xp.content.ContentPath in project xp by enonic.
the class ContentServiceImpl method getRootPermissions.
@Override
public AccessControlList getRootPermissions() {
final ContentPath rootContentPath = ContentPath.ROOT;
final NodePath rootNodePath = ContentNodeHelper.translateContentPathToNodePath(rootContentPath);
final Node rootNode = nodeService.getByPath(rootNodePath);
return rootNode != null ? rootNode.getPermissions() : AccessControlList.empty();
}
Aggregations