Search in sources :

Example 6 with FindContentVersionsResult

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

the class AbstractContentServiceTest method assertVersions.

protected void assertVersions(final ContentId contentId, final int expected) {
    FindContentVersionsResult versions = this.contentService.getVersions(FindContentVersionsParams.create().contentId(contentId).build());
    assertEquals(expected, versions.getHits());
    final Iterator<ContentVersion> iterator = versions.getContentVersions().iterator();
    Instant lastModified = null;
    while (iterator.hasNext()) {
        final ContentVersion next = iterator.next();
        if (lastModified != null) {
            assertFalse(next.getModified().isAfter(lastModified));
        }
        lastModified = next.getModified();
    }
}
Also used : ContentVersion(com.enonic.xp.content.ContentVersion) FindContentVersionsResult(com.enonic.xp.content.FindContentVersionsResult) Instant(java.time.Instant)

Example 7 with FindContentVersionsResult

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

the class ContentServiceImplTest_versions method get_archived_versions.

@Test
public void get_archived_versions() throws Exception {
    final Content content = this.contentService.create(CreateContentParams.create().contentData(new PropertyTree()).displayName("content").parent(ContentPath.ROOT).name("myContent").type(ContentTypeName.folder()).build());
    this.contentService.archive(ArchiveContentParams.create().contentId(content.getId()).build());
    this.contentService.restore(RestoreContentParams.create().contentId(content.getId()).build());
    final FindContentVersionsResult result = this.contentService.getVersions(FindContentVersionsParams.create().contentId(content.getId()).build());
    assertEquals(5, result.getHits());
    assertEquals(5, result.getTotalHits());
    final ImmutableList<ContentVersion> versions = ImmutableList.copyOf(result.getContentVersions().iterator());
    assertEquals(ContentVersionPublishInfo.CommitType.RESTORED, versions.get(0).getPublishInfo().getType());
    assertEquals(ContentVersionPublishInfo.CommitType.ARCHIVED, versions.get(2).getPublishInfo().getType());
}
Also used : Content(com.enonic.xp.content.Content) ContentVersion(com.enonic.xp.content.ContentVersion) PropertyTree(com.enonic.xp.data.PropertyTree) FindContentVersionsResult(com.enonic.xp.content.FindContentVersionsResult) Test(org.junit.jupiter.api.Test)

Example 8 with FindContentVersionsResult

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

the class ContentServiceImplTest_publish method publish_with_message.

@Test
public void publish_with_message() {
    final Content content = createContent(ContentPath.ROOT, "a");
    this.contentService.publish(PushContentParams.create().contentIds(ContentIds.from(content.getId())).target(WS_OTHER).message("My message").build());
    FindContentVersionsResult versions = this.contentService.getVersions(FindContentVersionsParams.create().contentId(content.getId()).build());
    Iterator<ContentVersion> iterator = versions.getContentVersions().iterator();
    assertTrue(iterator.hasNext());
    ContentVersion version = iterator.next();
    assertNotNull(version.getPublishInfo().getTimestamp());
    assertEquals("user:system:test-user", version.getPublishInfo().getPublisher().toString());
    assertEquals("My message", version.getPublishInfo().getMessage());
}
Also used : Content(com.enonic.xp.content.Content) ContentVersion(com.enonic.xp.content.ContentVersion) FindContentVersionsResult(com.enonic.xp.content.FindContentVersionsResult) Test(org.junit.jupiter.api.Test)

Aggregations

FindContentVersionsResult (com.enonic.xp.content.FindContentVersionsResult)8 Content (com.enonic.xp.content.Content)6 ContentVersion (com.enonic.xp.content.ContentVersion)6 Test (org.junit.jupiter.api.Test)6 PropertyTree (com.enonic.xp.data.PropertyTree)4 ContentVersions (com.enonic.xp.content.ContentVersions)1 UpdateContentParams (com.enonic.xp.content.UpdateContentParams)1 WorkflowCheckState (com.enonic.xp.content.WorkflowCheckState)1 WorkflowInfo (com.enonic.xp.content.WorkflowInfo)1 NodeId (com.enonic.xp.node.NodeId)1 NodeVersionQueryResult (com.enonic.xp.node.NodeVersionQueryResult)1 Instant (java.time.Instant)1