Search in sources :

Example 26 with Content

use of com.enonic.xp.content.Content in project xp by enonic.

the class ContentServiceImplTest_getNearestSite method deep_child_of_site_pending_publish_master.

@Test
public void deep_child_of_site_pending_publish_master() {
    final Content site = createSite();
    final Content childLevel1 = createContent(site.getPath());
    final Content childLevel2 = createContent(childLevel1.getPath(), ContentPublishInfo.create().from(Instant.now().plus(Duration.ofDays(1))).build());
    final Content childLevel3 = createContent(childLevel2.getPath());
    this.contentService.publish(PushContentParams.create().target(ContentConstants.BRANCH_MASTER).contentIds(ContentIds.from(site.getId())).build());
    final Site fetchedSite = authorizedMasterContext().callWith(() -> this.contentService.getNearestSite(childLevel3.getId()));
    assertNull(fetchedSite);
}
Also used : Site(com.enonic.xp.site.Site) Content(com.enonic.xp.content.Content) Test(org.junit.jupiter.api.Test)

Example 27 with Content

use of com.enonic.xp.content.Content in project xp by enonic.

the class ContentServiceImplTest_getNearestSite method child_of_site_published_master.

@Test
public void child_of_site_published_master() {
    final Content site = createSite();
    final Content child = createContent(site.getPath(), ContentPublishInfo.create().from(Instant.now().plus(Duration.ofDays(1))).to(Instant.now().plus(Duration.ofDays(1))).build());
    this.contentService.publish(PushContentParams.create().target(ContentConstants.BRANCH_MASTER).contentIds(ContentIds.from(site.getId())).build());
    final Site fetchedSite = authorizedMasterContext().callWith(() -> this.contentService.getNearestSite(child.getId()));
    assertNull(fetchedSite);
}
Also used : Site(com.enonic.xp.site.Site) Content(com.enonic.xp.content.Content) Test(org.junit.jupiter.api.Test)

Example 28 with Content

use of com.enonic.xp.content.Content 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)

Example 29 with Content

use of com.enonic.xp.content.Content 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 30 with Content

use of com.enonic.xp.content.Content 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)

Aggregations

Content (com.enonic.xp.content.Content)560 Test (org.junit.jupiter.api.Test)432 PropertyTree (com.enonic.xp.data.PropertyTree)130 CreateContentParams (com.enonic.xp.content.CreateContentParams)57 ContentId (com.enonic.xp.content.ContentId)50 UpdateContentParams (com.enonic.xp.content.UpdateContentParams)48 ContentPath (com.enonic.xp.content.ContentPath)47 ValidationErrors (com.enonic.xp.content.ValidationErrors)47 Site (com.enonic.xp.site.Site)43 PropertySet (com.enonic.xp.data.PropertySet)30 GetContentTypeParams (com.enonic.xp.schema.content.GetContentTypeParams)27 Page (com.enonic.xp.page.Page)26 Contents (com.enonic.xp.content.Contents)25 Node (com.enonic.xp.node.Node)25 ContentIds (com.enonic.xp.content.ContentIds)24 FindContentByParentParams (com.enonic.xp.content.FindContentByParentParams)24 ContentQuery (com.enonic.xp.content.ContentQuery)23 FindContentByParentResult (com.enonic.xp.content.FindContentByParentResult)23 DataValidationError (com.enonic.xp.content.DataValidationError)21 ContentType (com.enonic.xp.schema.content.ContentType)20