Search in sources :

Example 61 with Content

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

the class ContentServiceImplTest_publish_update_publishedTime method set_published_time.

@Test
public void set_published_time() throws Exception {
    final Content content = doCreateContent();
    assertNull(content.getPublishInfo());
    assertVersions(content.getId(), 1);
    doPublishContent(content);
    assertVersions(content.getId(), 2);
    final Content storedContent = this.contentService.getById(content.getId());
    assertNotNull(storedContent.getPublishInfo());
    assertNotNull(storedContent.getPublishInfo().getFirst());
    assertNotNull(storedContent.getPublishInfo().getFrom());
    final Content publishedContent = ContextBuilder.from(ContextAccessor.current()).branch(WS_OTHER).build().callWith(() -> this.contentService.getById(content.getId()));
    assertEquals(storedContent.getPublishInfo(), publishedContent.getPublishInfo());
}
Also used : Content(com.enonic.xp.content.Content) Test(org.junit.jupiter.api.Test)

Example 62 with Content

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

the class ContentServiceImplTest_publish_update_publishedTime method publish_info_is_removed_on_duplicate.

@Test
public void publish_info_is_removed_on_duplicate() throws Exception {
    final Content rootContent = createContent(ContentPath.ROOT);
    this.contentService.publish(PushContentParams.create().contentIds(ContentIds.from(rootContent.getId())).target(WS_OTHER).build());
    final Content duplicateContent = doDuplicateContent(rootContent);
    assertNull(duplicateContent.getPublishInfo());
}
Also used : Content(com.enonic.xp.content.Content) Test(org.junit.jupiter.api.Test)

Example 63 with Content

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

the class TestDataFixtures method newContent.

public static Content newContent() {
    final Content.Builder builder = Content.create();
    builder.id(ContentId.from("123456"));
    builder.name("mycontent");
    builder.displayName("My Content");
    builder.parentPath(ContentPath.from("/a/b"));
    builder.modifier(PrincipalKey.from("user:system:admin"));
    builder.modifiedTime(Instant.ofEpochSecond(0));
    builder.creator(PrincipalKey.from("user:system:admin"));
    builder.createdTime(Instant.ofEpochSecond(0));
    builder.language(Locale.ENGLISH);
    builder.data(newPropertyTree());
    builder.addExtraData(new ExtraData(XDataName.from("com.enonic.myapplication:myschema"), newTinyPropertyTree()));
    builder.page(newPage());
    return builder.build();
}
Also used : Content(com.enonic.xp.content.Content) ExtraData(com.enonic.xp.content.ExtraData)

Example 64 with Content

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

the class GetCurrentContentScriptTest method testExample.

@Test
public void testExample() {
    final Content content = TestDataFixtures.newExampleContent();
    this.portalRequest.setContent(content);
    runScript("/lib/xp/examples/portal/getContent.js");
}
Also used : Content(com.enonic.xp.content.Content) Test(org.junit.jupiter.api.Test)

Example 65 with Content

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

the class GetCurrentContentScriptTest method currentContentByContentPath.

@Test
public void currentContentByContentPath() {
    final Content content = TestDataFixtures.newContent();
    this.portalRequest.setContent(null);
    this.portalRequest.setContentPath(content.getPath());
    runFunction("/test/getCurrentContent-test.js", "noCurrentContent");
}
Also used : Content(com.enonic.xp.content.Content) Test(org.junit.jupiter.api.Test)

Aggregations

Content (com.enonic.xp.content.Content)563 Test (org.junit.jupiter.api.Test)435 PropertyTree (com.enonic.xp.data.PropertyTree)131 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)31 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 ContentQuery (com.enonic.xp.content.ContentQuery)24 FindContentByParentParams (com.enonic.xp.content.FindContentByParentParams)24 FindContentByParentResult (com.enonic.xp.content.FindContentByParentResult)23 DataValidationError (com.enonic.xp.content.DataValidationError)21 ContentType (com.enonic.xp.schema.content.ContentType)20