Search in sources :

Example 6 with GetContentByIdsParams

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

the class ContentServiceImplTest_getByIds method test_publish_expired_master.

@Test
public void test_publish_expired_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().minus(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 7 with GetContentByIdsParams

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

the class ContentServiceImplTest_getByIds method test_publish_expired_draft.

@Test
public void test_publish_expired_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().minus(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 8 with GetContentByIdsParams

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

the class ContentServiceImplTest_delete method create_delete_content_with_children.

@Test
public void create_delete_content_with_children() throws Exception {
    // Creates a content with children
    final CreateContentParams createContentParams = CreateContentParams.create().contentData(new PropertyTree()).displayName("Root Content").parent(ContentPath.ROOT).type(ContentTypeName.folder()).build();
    final Content content = this.contentService.create(createContentParams);
    final CreateContentParams createChild1ContentParams = CreateContentParams.create().contentData(new PropertyTree()).displayName("Child1 Content").parent(content.getPath()).type(ContentTypeName.folder()).build();
    final Content child1Content = this.contentService.create(createChild1ContentParams);
    final CreateContentParams createChild2ContentParams = CreateContentParams.create().contentData(new PropertyTree()).displayName("Child2 Content").parent(content.getPath()).type(ContentTypeName.folder()).build();
    final Content child2Content = this.contentService.create(createChild2ContentParams);
    final CreateContentParams createSubChildContentParams = CreateContentParams.create().contentData(new PropertyTree()).displayName("SubChild Content").parent(child1Content.getPath()).type(ContentTypeName.folder()).build();
    final Content subChildContent = this.contentService.create(createSubChildContentParams);
    refresh();
    // Deletes the content
    final DeleteContentsResult deletedContents = this.contentService.deleteWithoutFetch(DeleteContentParams.create().contentPath(content.getPath()).build());
    assertNotNull(deletedContents);
    assertEquals(4, deletedContents.getDeletedContents().getSize());
    // Checks that the content and the children are deleted
    final GetContentByIdsParams getContentByIdsParams = new GetContentByIdsParams(ContentIds.from(content.getId(), child1Content.getId(), child2Content.getId(), subChildContent.getId()));
    final Contents foundContents = this.contentService.getByIds(getContentByIdsParams);
    assertEquals(0, foundContents.getSize());
}
Also used : GetContentByIdsParams(com.enonic.xp.content.GetContentByIdsParams) Contents(com.enonic.xp.content.Contents) CreateContentParams(com.enonic.xp.content.CreateContentParams) Content(com.enonic.xp.content.Content) PropertyTree(com.enonic.xp.data.PropertyTree) DeleteContentsResult(com.enonic.xp.content.DeleteContentsResult) Test(org.junit.jupiter.api.Test)

Example 9 with GetContentByIdsParams

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

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

Aggregations

Contents (com.enonic.xp.content.Contents)13 GetContentByIdsParams (com.enonic.xp.content.GetContentByIdsParams)13 Content (com.enonic.xp.content.Content)11 ContentIds (com.enonic.xp.content.ContentIds)11 Test (org.junit.jupiter.api.Test)10 DeleteContentsResult (com.enonic.xp.content.DeleteContentsResult)5 PropertyTree (com.enonic.xp.data.PropertyTree)5 CreateContentParams (com.enonic.xp.content.CreateContentParams)4 DeleteContentParams (com.enonic.xp.content.DeleteContentParams)3 ContentDependencies (com.enonic.xp.content.ContentDependencies)2 ContentId (com.enonic.xp.content.ContentId)2 ContentQuery (com.enonic.xp.content.ContentQuery)2 ContentService (com.enonic.xp.content.ContentService)2 BucketAggregation (com.enonic.xp.aggregation.BucketAggregation)1 ApplicationKey (com.enonic.xp.app.ApplicationKey)1 ArchiveContentParams (com.enonic.xp.archive.ArchiveContentParams)1 ArchiveContentsResult (com.enonic.xp.archive.ArchiveContentsResult)1 RestoreContentParams (com.enonic.xp.archive.RestoreContentParams)1 RestoreContentsResult (com.enonic.xp.archive.RestoreContentsResult)1 Branches (com.enonic.xp.branch.Branches)1