use of com.enonic.xp.content.Content in project xp by enonic.
the class ParentContentSynchronizerTest method testCreateExisted.
@Test
public void testCreateExisted() throws Exception {
final Content sourceContent = sourceContext.callWith(() -> createContent(ContentPath.ROOT));
final Content targetContent1 = syncCreated(sourceContent.getId());
assertThrows(IllegalArgumentException.class, () -> syncCreated(sourceContent.getId()), "targetContent must be set.");
final Content targetContent2 = targetContext.callWith(() -> contentService.getById(sourceContent.getId()));
assertEquals(targetContent1, targetContent2);
compareSynched(sourceContent, targetContent1);
}
use of com.enonic.xp.content.Content in project xp by enonic.
the class ParentContentSynchronizerTest method sortNotSynched.
@Test
public void sortNotSynched() throws Exception {
final Content sourceContent = sourceContext.callWith(() -> createContent(ContentPath.ROOT, "name"));
assertThrows(IllegalArgumentException.class, () -> syncSorted(sourceContent.getId()));
}
use of com.enonic.xp.content.Content in project xp by enonic.
the class ParentContentSynchronizerTest method renameChanged.
@Test
public void renameChanged() throws Exception {
final Content sourceContent = sourceContext.callWith(() -> createContent(ContentPath.ROOT));
final Content targetContent = syncCreated(sourceContent.getId());
sourceContext.runWith(() -> contentService.rename(RenameContentParams.create().contentId(sourceContent.getId()).newName(ContentName.from("newName")).build()));
final Content targetContentRenamed = syncRenamed(sourceContent.getId());
assertNotEquals(targetContent.getName(), targetContentRenamed.getName());
assertEquals("newName", targetContentRenamed.getName().toString());
}
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 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());
}
Aggregations