use of com.github.sdorra.shiro.SubjectAware in project scm-review-plugin by scm-manager.
the class CommentServiceTest method shouldModifyRootCommentDoneFlag.
@Test
@SubjectAware(username = "dent")
public void shouldModifyRootCommentDoneFlag() {
doNothing().when(store).update(eq(PULL_REQUEST_ID), rootCommentCaptor.capture());
EXISTING_COMMENT.setType(CommentType.TASK_TODO);
commentService.transform(NAMESPACE, NAME, PULL_REQUEST_ID, EXISTING_COMMENT.getId(), SET_DONE);
assertThat(rootCommentCaptor.getAllValues()).hasSize(1);
Comment storedComment = rootCommentCaptor.getValue();
assertThat(storedComment.getType()).isEqualTo(TASK_DONE);
}
use of com.github.sdorra.shiro.SubjectAware in project scm-review-plugin by scm-manager.
the class CommentServiceTest method shouldAddChangedStatusComment.
@Test
@SubjectAware(username = "trillian")
public void shouldAddChangedStatusComment() {
when(store.add(eq(PULL_REQUEST_ID), rootCommentCaptor.capture())).thenReturn("newId");
commentService.addStatusChangedComment(REPOSITORY, PULL_REQUEST_ID, SystemCommentType.MERGED);
assertThat(rootCommentCaptor.getAllValues()).hasSize(1);
Comment storedComment = rootCommentCaptor.getValue();
assertThat(storedComment.getComment()).isEqualTo("merged");
assertThat(storedComment.isSystemComment()).isTrue();
}
use of com.github.sdorra.shiro.SubjectAware in project scm-review-plugin by scm-manager.
the class CommentServiceTest method shouldAddCommentOnRejectEventByUser.
@Test
@SubjectAware(username = "dent")
public void shouldAddCommentOnRejectEventByUser() {
when(store.add(eq(PULL_REQUEST_ID), rootCommentCaptor.capture())).thenReturn("newId");
commentService.addCommentOnReject(new PullRequestRejectedEvent(REPOSITORY, mockPullRequest(), PullRequestRejectedEvent.RejectionCause.REJECTED_BY_USER));
assertThat(rootCommentCaptor.getAllValues()).hasSize(1);
Comment storedComment = rootCommentCaptor.getValue();
assertThat(storedComment.getComment()).isEqualTo("rejected");
}
use of com.github.sdorra.shiro.SubjectAware in project scm-review-plugin by scm-manager.
the class CommentServiceTest method shouldPostEventForNewReply.
@Test
@SubjectAware(username = "createCommentUser")
public void shouldPostEventForNewReply() {
doNothing().when(store).update(eq(PULL_REQUEST_ID), rootCommentCaptor.capture());
Reply reply = createReply("1", "1. comment", author);
commentService.reply(NAMESPACE, NAME, PULL_REQUEST_ID, "1", reply);
assertThat(eventCaptor.getAllValues()).hasSize(1);
assertThat(eventCaptor.getValue().getEventType()).isEqualTo(HandlerEventType.CREATE);
}
use of com.github.sdorra.shiro.SubjectAware in project scm-review-plugin by scm-manager.
the class CommentServiceTest method shouldExtractMentionsOnModifyReplyText.
@Test
@SubjectAware(username = "dent")
public void shouldExtractMentionsOnModifyReplyText() {
doNothing().when(store).update(eq(PULL_REQUEST_ID), rootCommentCaptor.capture());
when(mentionMapper.extractMentionsFromComment(anyString())).thenReturn(ImmutableSet.of("trillian", "dent"));
Reply changedReply = EXISTING_REPLY.clone();
changedReply.setComment("new comment @[trillian] @[dent]");
commentService.modifyReply(NAMESPACE, NAME, PULL_REQUEST_ID, EXISTING_REPLY.getId(), changedReply);
assertThat(rootCommentCaptor.getAllValues()).hasSize(1);
Comment storedComment = rootCommentCaptor.getValue();
assertThat(storedComment.getReplies()).hasSize(1);
assertThat(storedComment.getReplies().get(0).getComment()).isEqualTo("new comment @[trillian] @[dent]");
assertThat(storedComment.getReplies().get(0).getMentionUserIds()).contains("trillian", "dent");
}
Aggregations