Search in sources :

Example 1 with UpdateIssueCommentParams

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());
}
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)

Example 2 with UpdateIssueCommentParams

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());
}
Also used : UpdateIssueCommentParams(com.enonic.xp.issue.UpdateIssueCommentParams) Test(org.junit.jupiter.api.Test)

Example 3 with UpdateIssueCommentParams

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());
}
Also used : NodeNotFoundException(com.enonic.xp.node.NodeNotFoundException) UpdateNodeParams(com.enonic.xp.node.UpdateNodeParams) UpdateIssueCommentParams(com.enonic.xp.issue.UpdateIssueCommentParams) Test(org.junit.jupiter.api.Test)

Example 4 with UpdateIssueCommentParams

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());
}
Also used : UpdateIssueCommentParams(com.enonic.xp.issue.UpdateIssueCommentParams) Test(org.junit.jupiter.api.Test)

Example 5 with UpdateIssueCommentParams

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));
}
Also used : UpdateIssueCommentParams(com.enonic.xp.issue.UpdateIssueCommentParams) Test(org.junit.jupiter.api.Test)

Aggregations

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