Search in sources :

Example 31 with ContentPath

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());
}
Also used : FindContentByParentParams(com.enonic.xp.content.FindContentByParentParams) Content(com.enonic.xp.content.Content) FindContentIdsByParentResult(com.enonic.xp.content.FindContentIdsByParentResult) ContentPath(com.enonic.xp.content.ContentPath) Test(org.junit.jupiter.api.Test)

Example 32 with ContentPath

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());
}
Also used : FindContentByParentParams(com.enonic.xp.content.FindContentByParentParams) Content(com.enonic.xp.content.Content) FindContentIdsByParentResult(com.enonic.xp.content.FindContentIdsByParentResult) ContentPath(com.enonic.xp.content.ContentPath) Test(org.junit.jupiter.api.Test)

Example 33 with ContentPath

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());
}
Also used : FindContentByParentParams(com.enonic.xp.content.FindContentByParentParams) Content(com.enonic.xp.content.Content) FindContentIdsByParentResult(com.enonic.xp.content.FindContentIdsByParentResult) ContentPath(com.enonic.xp.content.ContentPath) Test(org.junit.jupiter.api.Test)

Example 34 with ContentPath

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()));
}
Also used : ChildOrder(com.enonic.xp.index.ChildOrder) Assertions.assertThrows(org.junit.jupiter.api.Assertions.assertThrows) BeforeEach(org.junit.jupiter.api.BeforeEach) WorkflowInfo(com.enonic.xp.content.WorkflowInfo) ContentPath(com.enonic.xp.content.ContentPath) ProjectSyncParams(com.enonic.xp.content.ProjectSyncParams) ContentInheritType(com.enonic.xp.content.ContentInheritType) Content(com.enonic.xp.content.Content) DeleteContentParams(com.enonic.xp.content.DeleteContentParams) UpdateContentParams(com.enonic.xp.content.UpdateContentParams) ContentSyncEventType(com.enonic.xp.core.impl.content.ContentSyncEventType) Test(org.junit.jupiter.api.Test) ParentContentSynchronizer(com.enonic.xp.core.impl.content.ParentContentSynchronizer) SyncContentServiceImpl(com.enonic.xp.core.impl.content.SyncContentServiceImpl) ContentId(com.enonic.xp.content.ContentId) ResetContentInheritParams(com.enonic.xp.content.ResetContentInheritParams) Assertions.assertFalse(org.junit.jupiter.api.Assertions.assertFalse) ProjectName(com.enonic.xp.project.ProjectName) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) SetContentChildOrderParams(com.enonic.xp.content.SetContentChildOrderParams) ContentEventsSyncParams(com.enonic.xp.core.impl.content.ContentEventsSyncParams) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) EnumSet(java.util.EnumSet) PropertyTree(com.enonic.xp.data.PropertyTree) UpdateContentParams(com.enonic.xp.content.UpdateContentParams) Content(com.enonic.xp.content.Content) PropertyTree(com.enonic.xp.data.PropertyTree) Test(org.junit.jupiter.api.Test)

Example 35 with ContentPath

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);
}
Also used : ContentPath(com.enonic.xp.content.ContentPath) Test(org.junit.jupiter.api.Test)

Aggregations

ContentPath (com.enonic.xp.content.ContentPath)56 Content (com.enonic.xp.content.Content)30 Test (org.junit.jupiter.api.Test)30 ContentNotFoundException (com.enonic.xp.content.ContentNotFoundException)13 ContentId (com.enonic.xp.content.ContentId)11 FindContentByParentParams (com.enonic.xp.content.FindContentByParentParams)10 WebException (com.enonic.xp.web.WebException)8 FindContentByParentResult (com.enonic.xp.content.FindContentByParentResult)6 ArrayList (java.util.ArrayList)5 FindContentIdsByParentResult (com.enonic.xp.content.FindContentIdsByParentResult)4 Node (com.enonic.xp.node.Node)4 PortalRequest (com.enonic.xp.portal.PortalRequest)4 ContentInheritType (com.enonic.xp.content.ContentInheritType)3 Context (com.enonic.xp.context.Context)3 Site (com.enonic.xp.site.Site)3 ContentAlreadyExistsException (com.enonic.xp.content.ContentAlreadyExistsException)2 CONTENT_ROOT_PATH_ATTRIBUTE (com.enonic.xp.content.ContentConstants.CONTENT_ROOT_PATH_ATTRIBUTE)2 ContentVersionId (com.enonic.xp.content.ContentVersionId)2 List (java.util.List)2 Set (java.util.Set)2