Search in sources :

Example 1 with RenameContentParams

use of com.enonic.xp.content.RenameContentParams in project xp by enonic.

the class MoveContentHandlerTest method mockRename.

private void mockRename(final ContentId contentId, final String newName, final Content contentResult) {
    final RenameContentParams renameParams = RenameContentParams.create().contentId(contentId).newName(ContentName.from(newName)).build();
    when(this.contentService.rename(Mockito.eq(renameParams))).thenReturn(contentResult);
}
Also used : RenameContentParams(com.enonic.xp.content.RenameContentParams)

Example 2 with RenameContentParams

use of com.enonic.xp.content.RenameContentParams in project xp by enonic.

the class RenameContentCommandTest method test_valid_changed.

@Test
void test_valid_changed() {
    final Content content = createContent(true);
    when(this.nodeService.getById(any(NodeId.class))).thenReturn(mockNode);
    when(translator.fromNode(mockNode, false)).thenReturn(content);
    when(translator.fromNode(mockNode, true)).thenReturn(content);
    final RenameContentParams params = RenameContentParams.create().contentId(content.getId()).newName(ContentName.unnamed()).build();
    createCommand(params).execute();
    verify(nodeService, times(1)).update(isA(UpdateNodeParams.class));
}
Also used : RenameContentParams(com.enonic.xp.content.RenameContentParams) Content(com.enonic.xp.content.Content) UpdateNodeParams(com.enonic.xp.node.UpdateNodeParams) NodeId(com.enonic.xp.node.NodeId) Test(org.junit.jupiter.api.Test)

Example 3 with RenameContentParams

use of com.enonic.xp.content.RenameContentParams in project xp by enonic.

the class RenameContentCommandTest method test_valid_not_changed.

@Test
void test_valid_not_changed() {
    final Content content = createContent(false);
    when(translator.fromNode(mockNode, false)).thenReturn(content);
    when(translator.fromNode(mockNode, true)).thenReturn(content);
    final RenameContentParams params = RenameContentParams.create().contentId(content.getId()).newName(ContentName.unnamed()).build();
    createCommand(params).execute();
    verify(contentService, never()).update(isA(UpdateContentParams.class));
}
Also used : RenameContentParams(com.enonic.xp.content.RenameContentParams) UpdateContentParams(com.enonic.xp.content.UpdateContentParams) Content(com.enonic.xp.content.Content) Test(org.junit.jupiter.api.Test)

Example 4 with RenameContentParams

use of com.enonic.xp.content.RenameContentParams in project xp by enonic.

the class RenameContentCommandTest method test_valid_not_changed_but_fiwer_errors.

@Test
void test_valid_not_changed_but_fiwer_errors() {
    final Content content = createContent(false);
    when(translator.fromNode(mockNode, false)).thenReturn(content);
    when(translator.fromNode(mockNode, true)).thenReturn(content);
    final RenameContentParams params = RenameContentParams.create().contentId(content.getId()).newName(ContentName.unnamed()).build();
    createCommand(params).execute();
    verify(contentService, never()).update(isA(UpdateContentParams.class));
}
Also used : RenameContentParams(com.enonic.xp.content.RenameContentParams) UpdateContentParams(com.enonic.xp.content.UpdateContentParams) Content(com.enonic.xp.content.Content) Test(org.junit.jupiter.api.Test)

Example 5 with RenameContentParams

use of com.enonic.xp.content.RenameContentParams in project xp by enonic.

the class MoveContentHandler method rename.

private Content rename(final ContentId sourceId, final String newName) {
    final ContentName newContentName = ContentName.from(newName);
    final RenameContentParams renameParams = RenameContentParams.create().contentId(sourceId).newName(newContentName).build();
    return contentService.rename(renameParams);
}
Also used : ContentName(com.enonic.xp.content.ContentName) RenameContentParams(com.enonic.xp.content.RenameContentParams)

Aggregations

RenameContentParams (com.enonic.xp.content.RenameContentParams)5 Content (com.enonic.xp.content.Content)3 Test (org.junit.jupiter.api.Test)3 UpdateContentParams (com.enonic.xp.content.UpdateContentParams)2 ContentName (com.enonic.xp.content.ContentName)1 NodeId (com.enonic.xp.node.NodeId)1 UpdateNodeParams (com.enonic.xp.node.UpdateNodeParams)1