use of com.enonic.xp.content.Content in project xp by enonic.
the class ParentContentSynchronizerTest method updateThumbnailCreated.
@Test
public void updateThumbnailCreated() throws Exception {
final Content sourceContent = sourceContext.callWith(() -> createContent(ContentPath.ROOT, "content"));
final Content targetContent = syncCreated(sourceContent.getId());
sourceContext.runWith(() -> {
try {
final UpdateContentParams updateContentParams = new UpdateContentParams();
updateContentParams.contentId(targetContent.getId()).editor(edit -> {
edit.displayName = "new display name";
}).createAttachments(CreateAttachments.from(CreateAttachment.create().byteSource(loadImage("darth-small.jpg")).name(AttachmentNames.THUMBNAIL).mimeType("image/jpeg").build()));
this.contentService.update(updateContentParams);
} catch (IOException e) {
throw new RuntimeException(e);
}
});
final Content targetContentUpdated = syncUpdated(sourceContent.getId());
assertNotNull(targetContentUpdated.getThumbnail());
}
use of com.enonic.xp.content.Content in project xp by enonic.
the class ParentContentSynchronizerTest method syncCreatedWithChildren.
@Test
public void syncCreatedWithChildren() throws Exception {
final CreateContentParams createContentParams = CreateContentParams.create().contentData(new PropertyTree()).displayName("This is my content").createAttachments(CreateAttachments.create().add(CreateAttachment.create().byteSource(ByteSource.wrap("bytes".getBytes())).label("attachment").name("attachmentName").mimeType("image/png").build()).build()).parent(ContentPath.ROOT).type(ContentTypeName.folder()).build();
final Content sourceContent = sourceContext.callWith(() -> this.contentService.create(createContentParams));
final Content targetContent = syncCreated(sourceContent.getId());
compareSynched(sourceContent, targetContent);
}
use of com.enonic.xp.content.Content in project xp by enonic.
the class ParentContentSynchronizerTest method updateThumbnailUpdated.
@Test
public void updateThumbnailUpdated() throws Exception {
final Content sourceContent = sourceContext.callWith(() -> createContent(ContentPath.ROOT, "content"));
final Content targetContent = syncCreated(sourceContent.getId());
sourceContext.runWith(() -> {
try {
final UpdateContentParams updateContentParams = new UpdateContentParams();
updateContentParams.contentId(targetContent.getId()).editor(edit -> {
edit.displayName = "new display name";
}).createAttachments(CreateAttachments.from(CreateAttachment.create().byteSource(loadImage("darth-small.jpg")).name(AttachmentNames.THUMBNAIL).mimeType("image/jpeg").build()));
this.contentService.update(updateContentParams);
} catch (IOException e) {
throw new RuntimeException(e);
}
});
final Content thumbnailCreated = syncUpdated(sourceContent.getId());
sourceContext.runWith(() -> {
try {
final UpdateContentParams updateContentParams = new UpdateContentParams();
updateContentParams.contentId(targetContent.getId()).editor(edit -> {
edit.displayName = "new display name";
}).createAttachments(CreateAttachments.from(CreateAttachment.create().byteSource(loadImage("cat-small.jpg")).name(AttachmentNames.THUMBNAIL).mimeType("image/jpeg").build()));
this.contentService.update(updateContentParams);
} catch (IOException e) {
throw new RuntimeException(e);
}
});
final Content thumbnailUpdated = syncUpdated(sourceContent.getId());
assertNotEquals(thumbnailCreated.getThumbnail().getSize(), thumbnailUpdated.getThumbnail().getSize());
}
use of com.enonic.xp.content.Content in project xp by enonic.
the class ParentContentSynchronizerTest method syncDeletedInParent.
@Test
public void syncDeletedInParent() throws Exception {
final Content sourceContent = sourceContext.callWith(() -> createContent(ContentPath.ROOT, "name"));
syncCreated(sourceContent.getId());
sourceContext.runWith(() -> contentService.deleteWithoutFetch(DeleteContentParams.create().contentPath(sourceContent.getPath()).build()));
refresh();
sync(sourceContent.getId(), false);
assertFalse(targetContext.callWith(() -> contentService.contentExists(sourceContent.getId())));
}
use of com.enonic.xp.content.Content in project xp by enonic.
the class ParentContentSynchronizerTest method renameNotSynched.
@Test
public void renameNotSynched() throws Exception {
final Content targetContent = targetContext.callWith(() -> createContent(ContentPath.ROOT, "name"));
assertThrows(IllegalArgumentException.class, () -> syncRenamed(targetContent.getId()), "sourceContent must be set.");
}
Aggregations