Search in sources :

Example 31 with Contents

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

the class ContentServiceImplTest_getByPaths method multiple.

@Test
public void multiple() throws Exception {
    final Content content1 = createContent(ContentPath.ROOT);
    final Content content2 = createContent(content1.getPath());
    final Content content3 = createContent(content2.getPath());
    final Contents contents = this.contentService.getByPaths(ContentPaths.from(content1.getPath(), content2.getPath(), content3.getPath()));
    assertNotNull(contents);
    assertEquals(3, contents.getSize());
}
Also used : Contents(com.enonic.xp.content.Contents) Content(com.enonic.xp.content.Content) Test(org.junit.jupiter.api.Test)

Example 32 with Contents

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

the class ContentServiceImplTest_getByIds method test_published_draft.

@Test
public void test_published_draft() throws Exception {
    final Content content1 = createContent(ContentPath.ROOT);
    final Content content2 = createContent(ContentPath.ROOT, ContentPublishInfo.create().from(Instant.now().minus(Duration.ofDays(1))).to(Instant.now().plus(Duration.ofDays(1))).build());
    final ContentIds ids = ContentIds.from(content1.getId(), content2.getId());
    final Contents contents = this.contentService.getByIds(new GetContentByIdsParams(ids));
    assertEquals(contents.getSize(), 2);
    assertTrue(contents.contains(content1));
    assertTrue(contents.contains(content2));
}
Also used : Contents(com.enonic.xp.content.Contents) GetContentByIdsParams(com.enonic.xp.content.GetContentByIdsParams) Content(com.enonic.xp.content.Content) ContentIds(com.enonic.xp.content.ContentIds) Test(org.junit.jupiter.api.Test)

Example 33 with Contents

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

the class ContentServiceImplTest_getByIds method test_pending_publish_master.

@Test
public void test_pending_publish_master() throws Exception {
    authorizedMasterContext().callWith(() -> {
        final Content content1 = createContent(ContentPath.ROOT);
        final Content content2 = createContent(ContentPath.ROOT, ContentPublishInfo.create().from(Instant.now().plus(Duration.ofDays(1))).build());
        final ContentIds ids = ContentIds.from(content1.getId(), content2.getId());
        final Contents contents = this.contentService.getByIds(new GetContentByIdsParams(ids));
        assertEquals(contents.getSize(), 1);
        assertTrue(contents.contains(content1));
        assertFalse(contents.contains(content2));
        return null;
    });
}
Also used : Contents(com.enonic.xp.content.Contents) GetContentByIdsParams(com.enonic.xp.content.GetContentByIdsParams) Content(com.enonic.xp.content.Content) ContentIds(com.enonic.xp.content.ContentIds) Test(org.junit.jupiter.api.Test)

Example 34 with Contents

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

the class ContentServiceImplTest_getByIds method test_published_master.

@Test
public void test_published_master() throws Exception {
    authorizedMasterContext().callWith(() -> {
        final Content content1 = createContent(ContentPath.ROOT);
        final Content content2 = createContent(ContentPath.ROOT, ContentPublishInfo.create().from(Instant.now().minus(Duration.ofDays(1))).to(Instant.now().plus(Duration.ofDays(1))).build());
        final ContentIds ids = ContentIds.from(content1.getId(), content2.getId());
        final Contents contents = this.contentService.getByIds(new GetContentByIdsParams(ids));
        assertEquals(contents.getSize(), 2);
        assertTrue(contents.contains(content1));
        assertTrue(contents.contains(content2));
        return null;
    });
}
Also used : Contents(com.enonic.xp.content.Contents) GetContentByIdsParams(com.enonic.xp.content.GetContentByIdsParams) Content(com.enonic.xp.content.Content) ContentIds(com.enonic.xp.content.ContentIds) Test(org.junit.jupiter.api.Test)

Example 35 with Contents

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

the class ContentServiceImplTest_getByIds method test_pending_publish_draft.

@Test
public void test_pending_publish_draft() throws Exception {
    final Content content1 = createContent(ContentPath.ROOT);
    final Content content2 = createContent(ContentPath.ROOT, ContentPublishInfo.create().from(Instant.now().plus(Duration.ofDays(1))).build());
    final ContentIds ids = ContentIds.from(content1.getId(), content2.getId());
    final Contents contents = this.contentService.getByIds(new GetContentByIdsParams(ids));
    assertEquals(contents.getSize(), 2);
    assertTrue(contents.contains(content1));
    assertTrue(contents.contains(content2));
}
Also used : Contents(com.enonic.xp.content.Contents) GetContentByIdsParams(com.enonic.xp.content.GetContentByIdsParams) Content(com.enonic.xp.content.Content) ContentIds(com.enonic.xp.content.ContentIds) Test(org.junit.jupiter.api.Test)

Aggregations

Contents (com.enonic.xp.content.Contents)41 Test (org.junit.jupiter.api.Test)30 Content (com.enonic.xp.content.Content)25 GetContentByIdsParams (com.enonic.xp.content.GetContentByIdsParams)16 ContentIds (com.enonic.xp.content.ContentIds)12 ContentPaths (com.enonic.xp.content.ContentPaths)7 PropertyTree (com.enonic.xp.data.PropertyTree)7 ContentId (com.enonic.xp.content.ContentId)5 ContentQuery (com.enonic.xp.content.ContentQuery)5 DeleteContentsResult (com.enonic.xp.content.DeleteContentsResult)5 FindContentByParentParams (com.enonic.xp.content.FindContentByParentParams)5 FindContentByParentResult (com.enonic.xp.content.FindContentByParentResult)5 FindContentIdsByQueryResult (com.enonic.xp.content.FindContentIdsByQueryResult)5 CreateContentParams (com.enonic.xp.content.CreateContentParams)4 Nodes (com.enonic.xp.node.Nodes)3 BucketAggregation (com.enonic.xp.aggregation.BucketAggregation)2 Buckets (com.enonic.xp.aggregation.Buckets)2 ApplicationKey (com.enonic.xp.app.ApplicationKey)2 ContentDependencies (com.enonic.xp.content.ContentDependencies)2 ContentIndexPath (com.enonic.xp.content.ContentIndexPath)2