use of com.enonic.xp.issue.UpdateIssueCommentParams in project xp by enonic.
the class UpdateIssueCommentCommandTest method update.
@Test
public void update() {
final Node issueNode = Node.create().name("parent-issue").path(NodePath.ROOT.toString()).id(NodeId.from(UUID.randomUUID())).build();
final PrincipalKey creator = PrincipalKey.from("user:store:one");
final UpdateIssueCommentParams params = UpdateIssueCommentParams.create().comment(NodeId.from(UUID.randomUUID())).text("Comment text...").build();
PropertyTree data = new IssueCommentDataSerializer().toCreateNodeData(CreateIssueCommentParams.create().text(params.getText()).creator(creator).creatorDisplayName("Creator One").issue(IssueId.from(issueNode.id().toString())).build());
final Node commentNode = Node.create().parentPath(issueNode.path()).name("comment-node").data(data).build();
final UpdateIssueCommentCommand command = updateIssueCommentCommand(params);
Mockito.when(this.nodeService.getById(Mockito.any(NodeId.class))).thenReturn(issueNode);
Mockito.when(this.nodeService.update(Mockito.any(UpdateNodeParams.class))).thenReturn(commentNode);
final IssueComment comment = command.execute();
assertNotNull(comment);
assertEquals("Comment text...", comment.getText());
assertEquals(creator, comment.getCreator());
assertEquals("Creator One", comment.getCreatorDisplayName());
}
use of com.enonic.xp.issue.UpdateIssueCommentParams in project xp by enonic.
the class UpdateIssueCommentCommandTest method updateNoText.
@Test
public void updateNoText() {
final UpdateIssueCommentParams params = UpdateIssueCommentParams.create().comment(NodeId.from(UUID.randomUUID())).build();
final UpdateIssueCommentCommand command = updateIssueCommentCommand(params);
assertThrows(IllegalArgumentException.class, () -> command.execute());
}
use of com.enonic.xp.issue.UpdateIssueCommentParams in project xp by enonic.
the class UpdateIssueCommentCommandTest method updateCommentNotExists.
@Test
public void updateCommentNotExists() {
final UpdateIssueCommentParams params = UpdateIssueCommentParams.create().comment(NodeId.from(UUID.randomUUID())).text("Comment text...").build();
final UpdateIssueCommentCommand command = updateIssueCommentCommand(params);
Mockito.when(this.nodeService.update(Mockito.any(UpdateNodeParams.class))).thenThrow(new NodeNotFoundException("Node not found"));
assertThrows(NodeNotFoundException.class, () -> command.execute());
}
use of com.enonic.xp.issue.UpdateIssueCommentParams in project xp by enonic.
the class UpdateIssueCommentCommandTest method updateNoCommentId.
@Test
public void updateNoCommentId() {
final UpdateIssueCommentParams params = UpdateIssueCommentParams.create().text("text").build();
final UpdateIssueCommentCommand command = updateIssueCommentCommand(params);
assertThrows(IllegalArgumentException.class, () -> command.execute());
}
use of com.enonic.xp.issue.UpdateIssueCommentParams in project xp by enonic.
the class IssueServiceImplTest_updateComment method udpateComment_noComment.
@Test
public void udpateComment_noComment() throws Exception {
final UpdateIssueCommentParams params = UpdateIssueCommentParams.create().text("text").comment(NodeId.from(UUID.randomUUID())).build();
assertThrows(NodeNotFoundException.class, () -> this.issueService.updateComment(params));
}
Aggregations