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");
}
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;
}
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);
}
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");
}
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();
}
Aggregations