use of com.enonic.xp.core.impl.issue.serializer.IssueCommentDataSerializer 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());
}
Aggregations