use of com.enonic.xp.content.Content in project xp by enonic.
the class ContentServiceImplTest_update method update_thumbnail.
@Test
public void update_thumbnail() throws Exception {
final ByteSource thumbnail = loadImage("cat-small.jpg");
final CreateContentParams createContentParams = CreateContentParams.create().displayName("This is my content").parent(ContentPath.ROOT).type(ContentTypeName.folder()).contentData(new PropertyTree()).build();
final Content content = this.contentService.create(createContentParams);
final UpdateContentParams updateContentParams = new UpdateContentParams();
updateContentParams.contentId(content.getId()).editor(edit -> {
edit.displayName = "new display name";
}).createAttachments(CreateAttachments.from(CreateAttachment.create().byteSource(thumbnail).name(AttachmentNames.THUMBNAIL).mimeType("image/jpeg").build()));
this.contentService.update(updateContentParams);
final Content updatedContent = this.contentService.getById(content.getId());
assertNotNull(updatedContent.getThumbnail());
assertEquals(thumbnail.size(), updatedContent.getThumbnail().getSize());
final ByteSource newThumbnail = loadImage("darth-small.jpg");
final UpdateContentParams updateContentParams2 = new UpdateContentParams();
updateContentParams2.contentId(content.getId()).editor(edit -> {
edit.displayName = "yet another display name";
}).createAttachments(CreateAttachments.from(CreateAttachment.create().byteSource(newThumbnail).name(AttachmentNames.THUMBNAIL).mimeType("image/jpeg").build()));
this.contentService.update(updateContentParams2);
final Content reUpdatedContent = this.contentService.getById(content.getId());
assertNotNull(reUpdatedContent.getThumbnail());
final Thumbnail thumbnailAttachment = reUpdatedContent.getThumbnail();
assertEquals(newThumbnail.size(), thumbnailAttachment.getSize());
}
use of com.enonic.xp.content.Content in project xp by enonic.
the class ParentContentSynchronizerTest method updateManualOrderNotSynched.
@Test
public void updateManualOrderNotSynched() throws Exception {
final Content sourceContent = sourceContext.callWith(() -> createContent(ContentPath.ROOT, "name"));
assertThrows(IllegalArgumentException.class, () -> syncManualOrderUpdated(sourceContent.getId()), "sourceContent must be set.");
}
use of com.enonic.xp.content.Content in project xp by enonic.
the class ParentContentSynchronizerTest method testCreatedChild.
@Test
public void testCreatedChild() throws Exception {
final Content sourceParent = sourceContext.callWith(() -> createContent(ContentPath.ROOT));
final Content sourceChild = sourceContext.callWith(() -> createContent(sourceParent.getPath()));
syncCreated(sourceParent.getId());
final Content targetChild = syncCreated(sourceChild.getId());
targetContext.runWith(() -> {
assertEquals(contentService.getById(sourceChild.getId()).getParentPath(), contentService.getById(sourceParent.getId()).getPath());
compareSynched(sourceChild, targetChild);
});
}
use of com.enonic.xp.content.Content in project xp by enonic.
the class ParentContentSynchronizerTest method syncWithoutChildren.
@Test
public void syncWithoutChildren() throws Exception {
final Content sourceContent = sourceContext.callWith(() -> createContent(ContentPath.ROOT, "name"));
final Content sourceChild1 = sourceContext.callWith(() -> createContent(sourceContent.getPath(), "child1"));
sync(sourceContent.getId(), false);
assertTrue(targetContext.callWith(() -> contentService.contentExists(sourceContent.getId())));
assertFalse(targetContext.callWith(() -> contentService.contentExists(sourceChild1.getId())));
}
use of com.enonic.xp.content.Content in project xp by enonic.
the class ParentContentSynchronizerTest method deleteDeletedInParent.
@Test
public void deleteDeletedInParent() throws Exception {
final Content sourceContent = sourceContext.callWith(() -> createContent(ContentPath.ROOT, "name"));
final Content targetContent = syncCreated(sourceContent.getId());
sourceContext.runWith(() -> contentService.deleteWithoutFetch(DeleteContentParams.create().contentPath(sourceContent.getPath()).build()));
assertTrue(syncDeleted(targetContent.getId()));
}
Aggregations