use of com.enonic.xp.content.Content in project xp by enonic.
the class ProjectContentEventListenerTest method testCreatedInMaster.
@Test
public void testCreatedInMaster() throws InterruptedException {
final Content sourceContent = ContextBuilder.from(sourceContext).branch(ContentConstants.BRANCH_MASTER).build().callWith(() -> createContent(ContentPath.ROOT, "name"));
handleEvents();
assertThrows(ContentNotFoundException.class, () -> targetContext.callWith(() -> contentService.getById(sourceContent.getId())));
}
use of com.enonic.xp.content.Content in project xp by enonic.
the class ProjectContentEventListenerTest method testSyncDuplicateWithExistedLocalName.
@Test
public void testSyncDuplicateWithExistedLocalName() throws InterruptedException {
targetContext.callWith(() -> createContent(ContentPath.ROOT, "localName-copy"));
targetContext.callWith(() -> createContent(ContentPath.ROOT, "localName-copy-1"));
final Content sourceContent = sourceContext.callWith(() -> createContent(ContentPath.ROOT, "localName"));
handleEvents();
final ContentId duplicatedContentId = sourceContext.callWith(() -> contentService.duplicate(DuplicateContentParams.create().contentId(sourceContent.getId()).build()).getDuplicatedContents().first());
handleEvents();
targetContext.runWith(() -> {
final Content duplicatedTargetContent = contentService.getById(duplicatedContentId);
assertEquals("localName-copy-1-1", duplicatedTargetContent.getName().toString());
assertEquals(3, duplicatedTargetContent.getInherit().size());
assertFalse(duplicatedTargetContent.getInherit().contains(ContentInheritType.NAME));
});
}
use of com.enonic.xp.content.Content in project xp by enonic.
the class ProjectContentEventListenerTest method testManualOrderLocally.
@Test
public void testManualOrderLocally() throws InterruptedException {
final Content sourceContent = sourceContext.callWith(() -> createContent(ContentPath.ROOT, "content"));
final Content sourceChild1 = sourceContext.callWith(() -> createContent(sourceContent.getPath(), "child1"));
final Content sourceChild2 = sourceContext.callWith(() -> createContent(sourceContent.getPath(), "child2"));
final Content sourceChild3 = sourceContext.callWith(() -> createContent(sourceContent.getPath(), "child3"));
handleEvents();
sourceContext.runWith(() -> contentService.setChildOrder(SetContentChildOrderParams.create().contentId(sourceContent.getId()).childOrder(ChildOrder.from("_name DESC")).build()));
handleEvents();
targetContext.runWith(() -> contentService.setChildOrder(SetContentChildOrderParams.create().contentId(sourceContent.getId()).childOrder(ChildOrder.manualOrder()).build()));
targetContext.runWith(() -> contentService.reorderChildren(ReorderChildContentsParams.create().contentId(sourceContent.getId()).add(ReorderChildParams.create().contentToMove(sourceChild2.getId()).contentToMoveBefore(sourceChild3.getId()).build()).add(ReorderChildParams.create().contentToMove(sourceChild1.getId()).contentToMoveBefore(sourceChild3.getId()).build()).build()));
sourceContext.runWith(() -> contentService.setChildOrder(SetContentChildOrderParams.create().contentId(sourceContent.getId()).childOrder(ChildOrder.from("_name DESC")).build()));
handleEvents();
targetContext.runWith(() -> {
final FindContentByParentResult result = contentService.findByParent(FindContentByParentParams.create().parentId(sourceContent.getId()).build());
final Iterator<Content> iterator = result.getContents().iterator();
assertEquals(sourceChild2.getId(), iterator.next().getId());
assertEquals(sourceChild1.getId(), iterator.next().getId());
assertEquals(sourceChild3.getId(), iterator.next().getId());
assertTrue(contentService.getById(sourceContent.getId()).getChildOrder().isManualOrder());
});
}
use of com.enonic.xp.content.Content in project xp by enonic.
the class ProjectContentEventListenerTest method testMovedToExistedPath.
@Test
public void testMovedToExistedPath() throws InterruptedException {
final Content sourceContent1 = sourceContext.callWith(() -> createContent(ContentPath.ROOT, "content"));
final Content sourceContent2 = sourceContext.callWith(() -> createContent(ContentPath.ROOT, "content2"));
handleEvents();
targetContext.callWith(() -> createContent(sourceContent2.getPath(), "content"));
sourceContext.runWith(() -> contentService.move(MoveContentParams.create().contentId(sourceContent1.getId()).parentContentPath(sourceContent2.getPath()).build()));
handleEvents();
final Content targetMovedContent = targetContext.callWith(() -> contentService.getById(sourceContent1.getId()));
assertEquals("/content2/content-1", targetMovedContent.getPath().toString());
}
use of com.enonic.xp.content.Content in project xp by enonic.
the class ProjectContentEventListenerTest method testSortedLocally.
@Test
public void testSortedLocally() throws InterruptedException {
final Content sourceContent = sourceContext.callWith(() -> createContent(ContentPath.ROOT, "content"));
handleEvents();
final Content sortedInChild = targetContext.callWith(() -> contentService.setChildOrder(SetContentChildOrderParams.create().contentId(sourceContent.getId()).childOrder(ChildOrder.from("_name DESC")).build()));
assertEquals(3, sortedInChild.getInherit().size());
assertFalse(sortedInChild.getInherit().contains(ContentInheritType.SORT));
final Content sortedInParent = sourceContext.callWith(() -> contentService.setChildOrder(SetContentChildOrderParams.create().contentId(sourceContent.getId()).childOrder(ChildOrder.from("_name ASC")).build()));
handleEvents();
assertNotEquals(sortedInParent.getChildOrder(), targetContext.callWith(() -> contentService.getById(sortedInChild.getId())));
}
Aggregations