Search in sources :

Example 6 with Contents

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

the class ContentServiceImplTest_delete method create_delete_published_content_with_children.

@Test
public void create_delete_published_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);
    // Publishes the content
    final PushContentParams pushParams = PushContentParams.create().contentIds(ContentIds.from(content.getId())).target(WS_OTHER).build();
    refresh();
    this.contentService.publish(pushParams);
    // Deletes the content
    final DeleteContentParams deleteContentParams = DeleteContentParams.create().contentPath(content.getPath()).build();
    final DeleteContentsResult deletedContents = this.contentService.deleteWithoutFetch(deleteContentParams);
    assertNotNull(deletedContents);
    assertEquals(4, deletedContents.getPendingContents().getSize());
    // Checks that the content and children are marked for deletion
    final ContentIds contentIds = ContentIds.from(content.getId(), child1Content.getId(), child2Content.getId(), subChildContent.getId());
    final GetContentByIdsParams getContentByIdsParams = new GetContentByIdsParams(contentIds);
    final Contents foundContents = this.contentService.getByIds(getContentByIdsParams);
    assertEquals(4, foundContents.getSize());
    for (Content foundContent : foundContents) {
        assertTrue(ContentState.PENDING_DELETE == foundContent.getContentState());
    }
}
Also used : DeleteContentParams(com.enonic.xp.content.DeleteContentParams) 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) ContentIds(com.enonic.xp.content.ContentIds) DeleteContentsResult(com.enonic.xp.content.DeleteContentsResult) PushContentParams(com.enonic.xp.content.PushContentParams) Test(org.junit.jupiter.api.Test)

Example 7 with Contents

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

the class ContentServiceImplTest_getByPaths 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 ContentPaths paths = ContentPaths.from(content1.getPath(), content2.getPath());
        final Contents contents = this.contentService.getByPaths(paths);
        assertEquals(contents.getSize(), 2);
        assertTrue(contents.contains(content1));
        assertTrue(contents.contains(content2));
        return null;
    });
}
Also used : ContentPaths(com.enonic.xp.content.ContentPaths) Contents(com.enonic.xp.content.Contents) Content(com.enonic.xp.content.Content) Test(org.junit.jupiter.api.Test)

Example 8 with Contents

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

the class ContentServiceImplTest_getByPaths 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 ContentPaths paths = ContentPaths.from(content1.getPath(), content2.getPath());
        final Contents contents = this.contentService.getByPaths(paths);
        assertEquals(contents.getSize(), 1);
        assertTrue(contents.contains(content1));
        assertFalse(contents.contains(content2));
        return null;
    });
}
Also used : ContentPaths(com.enonic.xp.content.ContentPaths) Contents(com.enonic.xp.content.Contents) Content(com.enonic.xp.content.Content) Test(org.junit.jupiter.api.Test)

Example 9 with Contents

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

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

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