Search in sources :

Example 1 with IssueCommentDataSerializer

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());
}
Also used : Node(com.enonic.xp.node.Node) PropertyTree(com.enonic.xp.data.PropertyTree) UpdateNodeParams(com.enonic.xp.node.UpdateNodeParams) IssueCommentDataSerializer(com.enonic.xp.core.impl.issue.serializer.IssueCommentDataSerializer) NodeId(com.enonic.xp.node.NodeId) IssueComment(com.enonic.xp.issue.IssueComment) PrincipalKey(com.enonic.xp.security.PrincipalKey) UpdateIssueCommentParams(com.enonic.xp.issue.UpdateIssueCommentParams) Test(org.junit.jupiter.api.Test)

Aggregations

IssueCommentDataSerializer (com.enonic.xp.core.impl.issue.serializer.IssueCommentDataSerializer)1 PropertyTree (com.enonic.xp.data.PropertyTree)1 IssueComment (com.enonic.xp.issue.IssueComment)1 UpdateIssueCommentParams (com.enonic.xp.issue.UpdateIssueCommentParams)1 Node (com.enonic.xp.node.Node)1 NodeId (com.enonic.xp.node.NodeId)1 UpdateNodeParams (com.enonic.xp.node.UpdateNodeParams)1 PrincipalKey (com.enonic.xp.security.PrincipalKey)1 Test (org.junit.jupiter.api.Test)1