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