use of com.enonic.xp.content.Content in project xp by enonic.
the class ParentContentSynchronizerTest method updateDataChanged.
@Test
public void updateDataChanged() throws Exception {
final Content sourceContent = sourceContext.callWith(() -> createContent(ContentPath.ROOT, "content1"));
final Content targetContent = syncCreated(sourceContent.getId());
sourceContext.runWith(() -> {
contentService.update(new UpdateContentParams().contentId(sourceContent.getId()).editor((edit -> edit.data = new PropertyTree())));
});
final Content targetContentUpdated = syncUpdated(sourceContent.getId());
assertNotEquals(targetContent.getData(), targetContentUpdated.getData());
assertNotEquals(targetContent.getModifiedTime(), targetContentUpdated.getModifiedTime());
}
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 syncByRoot.
@Test
public void syncByRoot() throws Exception {
final Content sourceContent = sourceContext.callWith(() -> createContent(ContentPath.ROOT, "name"));
final Content sourceChild1 = sourceContext.callWith(() -> createContent(sourceContent.getPath(), "child1"));
final Content sourceChild1_1 = sourceContext.callWith(() -> createContent(sourceContent.getPath(), "child1_1"));
sync(null, false);
assertTrue(targetContext.callWith(() -> contentService.contentExists(sourceContent.getId())));
assertTrue(targetContext.callWith(() -> contentService.contentExists(sourceChild1.getId())));
assertTrue(targetContext.callWith(() -> contentService.contentExists(sourceChild1_1.getId())));
}
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 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())));
}
Aggregations