Search in sources :

Example 26 with ContentPath

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

Example 27 with ContentPath

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

Example 28 with ContentPath

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

Example 29 with ContentPath

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

Example 30 with ContentPath

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());
}
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)

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