Search in sources :

Example 21 with Content

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

the class RemoveAttachmentHandlerTest method removeAttachmentMulti.

@Test
public void removeAttachmentMulti() throws Exception {
    final Content content = TestDataFixtures.newExampleContent();
    Mockito.when(this.contentService.getByPath(Mockito.any())).thenReturn(content);
    runFunction("/test/RemoveAttachmentHandlerTest.js", "removeAttachmentMulti");
}
Also used : Content(com.enonic.xp.content.Content) Test(org.junit.jupiter.api.Test)

Example 22 with Content

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

the class TestDataFixtures method newExampleContentBuilder.

public static Content.Builder newExampleContentBuilder() {
    final Content.Builder builder = Content.create();
    builder.id(ContentId.from("123456"));
    builder.name("mycontent");
    builder.displayName("My Content");
    builder.parentPath(ContentPath.from("/path/to"));
    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);
    final PropertyTree tree = new PropertyTree();
    tree.setString("myfield", "Hello World");
    builder.data(tree);
    builder.attachments(newAttachments());
    builder.valid(true);
    builder.childOrder(ChildOrder.from("_ts DESC, _name ASC"));
    return builder;
}
Also used : Content(com.enonic.xp.content.Content) PropertyTree(com.enonic.xp.data.PropertyTree)

Example 23 with Content

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

the class TestDataFixtures method newContents.

public static Contents newContents(final int num) {
    final List<Content> list = new ArrayList<>();
    for (int i = 0; i < num; i++) {
        final Content content = Content.create().id(ContentId.from("id" + (i + 1))).name("name" + (i + 1)).displayName("My Content " + (i + 1)).parentPath(ContentPath.from("/a/b")).modifier(PrincipalKey.from("user:system:admin")).modifiedTime(Instant.ofEpochSecond(0)).creator(PrincipalKey.from("user:system:admin")).createdTime(Instant.ofEpochSecond(0)).build();
        list.add(content);
    }
    return Contents.from(list);
}
Also used : Content(com.enonic.xp.content.Content) ArrayList(java.util.ArrayList) GeoPoint(com.enonic.xp.util.GeoPoint)

Example 24 with Content

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

the class MoveContentHandlerTest method testExample.

@Test
public void testExample() {
    // example 1
    final Content sourceContent = mockContent("/my-site/my-content-name");
    mockGetByPath("/my-site/my-content-name", sourceContent);
    mockRename(sourceContent.getId(), "new-name", mockContent("/my-site/new-name"));
    // example 2
    mockMove(sourceContent.getId(), "/my-site/folder/", mockContent("/my-site/folder/my-content-name"));
    // example 3
    mockGetById("8d933461-ede7-4dd5-80da-cb7de0cd7bba", sourceContent);
    final ContentPath cp = ContentPath.from("/my-site/folder/existing-content");
    when(contentService.contentExists(cp)).thenReturn(true);
    runScript("/lib/xp/examples/content/move.js");
}
Also used : Content(com.enonic.xp.content.Content) ContentPath(com.enonic.xp.content.ContentPath) Test(org.junit.jupiter.api.Test)

Example 25 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)

Aggregations

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