Search in sources :

Example 1 with IssueComment

use of com.enonic.xp.issue.IssueComment in project xp by enonic.

the class IssueServiceImplTest_updateComment method updateComment.

@Test
public void updateComment() throws Exception {
    Issue issue = this.createIssue(CreateIssueParams.create().title("issue-1"));
    final Instant created = Instant.now().minus(1, ChronoUnit.MINUTES);
    final PrincipalKey creator = PrincipalKey.from("user:store:me");
    final String creatorDisplayName = "Me Myself";
    final CreateIssueCommentParams params = CreateIssueCommentParams.create().text("text").issue(issue.getId()).creator(creator).creatorDisplayName(creatorDisplayName).created(created).build();
    final IssueComment comment = this.issueService.createComment(params);
    final IssueComment updatedComment = this.issueService.updateComment(UpdateIssueCommentParams.create().comment(comment.getId()).text("updated text").build());
    assertNotNull(updatedComment);
    assertEquals("updated text", updatedComment.getText());
    assertEquals(creator, updatedComment.getCreator());
    assertEquals(creatorDisplayName, updatedComment.getCreatorDisplayName());
    assertEquals(created, updatedComment.getCreated());
}
Also used : Issue(com.enonic.xp.issue.Issue) Instant(java.time.Instant) IssueComment(com.enonic.xp.issue.IssueComment) PrincipalKey(com.enonic.xp.security.PrincipalKey) CreateIssueCommentParams(com.enonic.xp.issue.CreateIssueCommentParams) Test(org.junit.jupiter.api.Test)

Example 2 with IssueComment

use of com.enonic.xp.issue.IssueComment in project xp by enonic.

the class CreateIssueCommentCommandTest method create.

@Test
public void create() {
    final Node issueNode = Node.create().name("parent-issue").build();
    final PrincipalKey creator = PrincipalKey.from("user:store:one");
    final CreateIssueCommentParams params = CreateIssueCommentParams.create().issue(IssueId.create()).creator(creator).creatorDisplayName("Creator One").text("Comment text...").build();
    final CreateIssueCommentCommand command = createIssueCommentCommand(params);
    Mockito.when(this.nodeService.findByQuery(Mockito.any(NodeQuery.class))).thenReturn(FindNodesByQueryResult.create().build());
    Mockito.when(this.nodeService.getById(Mockito.any(NodeId.class))).thenReturn(issueNode);
    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) NodeQuery(com.enonic.xp.node.NodeQuery) NodeId(com.enonic.xp.node.NodeId) IssueComment(com.enonic.xp.issue.IssueComment) PrincipalKey(com.enonic.xp.security.PrincipalKey) CreateIssueCommentParams(com.enonic.xp.issue.CreateIssueCommentParams) Test(org.junit.jupiter.api.Test)

Example 3 with IssueComment

use of com.enonic.xp.issue.IssueComment 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 4 with IssueComment

use of com.enonic.xp.issue.IssueComment in project xp by enonic.

the class IssueCommentNodeTranslatorTest method testFromNodeNotResolvingChildren.

@Test
public void testFromNodeNotResolvingChildren() throws Exception {
    final Instant created = Instant.now().minus(1, ChronoUnit.MINUTES);
    final Node node = createNode(created);
    final IssueComment comment = IssueCommentNodeTranslator.fromNode(node);
    assertNotNull(comment);
    assertEquals(node.id(), comment.getId());
    assertEquals("title", comment.getText());
    assertEquals(PrincipalKey.from("user:myStore:me"), comment.getCreator());
    assertEquals("Me Myself", comment.getCreatorDisplayName());
    assertEquals(created, comment.getCreated());
}
Also used : Instant(java.time.Instant) Node(com.enonic.xp.node.Node) IssueComment(com.enonic.xp.issue.IssueComment) Test(org.junit.jupiter.api.Test)

Example 5 with IssueComment

use of com.enonic.xp.issue.IssueComment in project xp by enonic.

the class IssueCommentDataSerializerTest method testDeserialize.

@Test
public void testDeserialize() {
    PropertyTree data = new PropertyTree();
    data.addString(TEXT, "Comment text...");
    data.addString(CREATOR_DISPLAY_NAME, "Creator One");
    data.addString(CREATOR, creator.toString());
    data.addInstant(CREATED_TIME, createdTime);
    IssueComment comment = serializer.fromData(data).build();
    assertNotNull(comment);
    assertEquals("Comment text...", comment.getText());
    assertEquals("Creator One", comment.getCreatorDisplayName());
    assertEquals(creator, comment.getCreator());
    assertEquals(createdTime, comment.getCreated());
}
Also used : PropertyTree(com.enonic.xp.data.PropertyTree) IssueComment(com.enonic.xp.issue.IssueComment) Test(org.junit.jupiter.api.Test)

Aggregations

IssueComment (com.enonic.xp.issue.IssueComment)7 Test (org.junit.jupiter.api.Test)6 Node (com.enonic.xp.node.Node)4 PrincipalKey (com.enonic.xp.security.PrincipalKey)4 CreateIssueCommentParams (com.enonic.xp.issue.CreateIssueCommentParams)3 Instant (java.time.Instant)3 PropertyTree (com.enonic.xp.data.PropertyTree)2 Issue (com.enonic.xp.issue.Issue)2 NodeId (com.enonic.xp.node.NodeId)2 NodeQuery (com.enonic.xp.node.NodeQuery)2 IssueCommentDataSerializer (com.enonic.xp.core.impl.issue.serializer.IssueCommentDataSerializer)1 UpdateIssueCommentParams (com.enonic.xp.issue.UpdateIssueCommentParams)1 FindNodesByQueryResult (com.enonic.xp.node.FindNodesByQueryResult)1 Nodes (com.enonic.xp.node.Nodes)1 UpdateNodeParams (com.enonic.xp.node.UpdateNodeParams)1