use of com.enonic.xp.content.MoveContentParams in project xp by enonic.
the class MoveContentCommandTest method move_non_existing_content.
@Test
public void move_non_existing_content() throws Exception {
PropertyTree existingContentData = new PropertyTree();
existingContentData.addString("myData", "aaa");
ContentId contentId = ContentId.from("mycontent");
MoveContentParams params = MoveContentParams.create().contentId(contentId).parentContentPath(ContentPath.ROOT).build();
MoveContentCommand command = MoveContentCommand.create(params).contentTypeService(this.contentTypeService).nodeService(this.nodeService).translator(this.translator).eventPublisher(this.eventPublisher).build();
Mockito.when(nodeService.getById(Mockito.isA(NodeId.class))).thenThrow(new NodeNotFoundException("Node not found"));
// exercise
assertThrows(ContentNotFoundException.class, () -> command.execute());
}
use of com.enonic.xp.content.MoveContentParams in project xp by enonic.
the class MoveContentCommandTest method move_to_the_same_parent.
@Test
public void move_to_the_same_parent() throws Exception {
final PropertyTree existingContentData = new PropertyTree();
existingContentData.addString("myData", "aaa");
final Content existingContent = createContent(existingContentData, ContentPath.ROOT, ContentTypeName.folder());
final MoveContentParams params = MoveContentParams.create().contentId(existingContent.getId()).parentContentPath(ContentPath.ROOT).build();
final MoveContentCommand command = MoveContentCommand.create(params).contentTypeService(this.contentTypeService).nodeService(this.nodeService).translator(this.translator).eventPublisher(this.eventPublisher).build();
final Node mockNode = Node.create().name(existingContent.getName().toString()).parentPath(ContentNodeHelper.translateContentParentToNodeParentPath(existingContent.getParentPath())).build();
Mockito.when(nodeService.getById(NodeId.from(existingContent.getId()))).thenReturn(mockNode);
Mockito.when(nodeService.nodeExists(mockNode.path())).thenReturn(true);
Mockito.when(translator.fromNode(mockNode, true)).thenReturn(existingContent);
Mockito.when(translator.fromNode(mockNode, false)).thenReturn(existingContent);
// exercise
assertThrows(ContentAlreadyMovedException.class, command::execute);
}
use of com.enonic.xp.content.MoveContentParams in project xp by enonic.
the class ContentServiceImplTest_delete method move_to_folder_starting_with_same_name_and_delete.
@Test
public void move_to_folder_starting_with_same_name_and_delete() throws Exception {
final Content site = createContent(ContentPath.ROOT, "site");
final Content child1 = createContent(site.getPath(), "child1");
createContent(child1.getPath(), "child1_1");
createContent(child1.getPath(), "child2_1");
final Content site2 = createContent(ContentPath.ROOT, "site2");
refresh();
final MoveContentParams params = MoveContentParams.create().contentId(child1.getId()).parentContentPath(site2.getPath()).build();
this.contentService.move(params);
final DeleteContentsResult result = this.contentService.deleteWithoutFetch(DeleteContentParams.create().contentPath(site.getPath()).build());
assertEquals(1, result.getDeletedContents().getSize());
}
use of com.enonic.xp.content.MoveContentParams in project xp by enonic.
the class ContentServiceImplTest_publish method publish_move_delete_old_parent.
/**
* /content1
* /content1_1
* /content2
* /content2_1 -> ref:content1_1
*/
@Test
public void publish_move_delete_old_parent() throws Exception {
createContentTree();
this.contentService.publish(PushContentParams.create().contentIds(ContentIds.from(content1.getId())).target(WS_OTHER).excludeChildrenIds(ContentIds.from(content1.getId())).build());
final MoveContentParams params = MoveContentParams.create().contentId(content2_1.getId()).parentContentPath(content1.getPath()).build();
this.contentService.move(params);
this.contentService.deleteWithoutFetch(DeleteContentParams.create().contentPath(content2.getPath()).build());
final Content movedContent = this.contentService.getByPath(ContentPath.from(content1.getPath(), content2_1.getName().toString()));
assertNotNull(movedContent);
}
use of com.enonic.xp.content.MoveContentParams in project xp by enonic.
the class ContentServiceImplTest_publish method doMove.
private void doMove(final ContentId contentId, final String newParent) {
final MoveContentParams params = MoveContentParams.create().contentId(contentId).parentContentPath(ContentPath.from(newParent)).build();
this.contentService.move(params);
}
Aggregations