use of com.github.sdorra.shiro.SubjectAware in project scm-review-plugin by scm-manager.
the class CommentServiceTest method shouldPostEventForNewRootComment.
@Test
@SubjectAware(username = "createCommentUser")
public void shouldPostEventForNewRootComment() {
when(store.add(eq(PULL_REQUEST_ID), rootCommentCaptor.capture())).thenReturn("newId");
Comment comment = createComment("2", "2. comment", author, new Location());
commentService.add(NAMESPACE, NAME, PULL_REQUEST_ID, comment);
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 shouldTriggerMentionEventIfNewMentionAddedOnCreateComment.
@Test
@SubjectAware(username = "dent")
public void shouldTriggerMentionEventIfNewMentionAddedOnCreateComment() {
when(store.add(eq(PULL_REQUEST_ID), rootCommentCaptor.capture())).thenReturn("newId");
when(mentionMapper.extractMentionsFromComment("2. comment @[dent]")).thenReturn(ImmutableSet.of("dent"));
Comment comment = createComment("2", "2. comment @[dent]", author, new Location());
String parsedCommentText = "2. comment @Arthur Dent";
Comment parsedComment = createComment("2", parsedCommentText, author, new Location());
when(mentionMapper.parseMentionsUserIdsToDisplayNames(comment)).thenReturn(parsedComment);
commentService.add(NAMESPACE, NAME, PULL_REQUEST_ID, comment);
assertThat(eventCaptor.getAllValues().size()).isEqualTo(2);
assertMentionEventFiredAndMentionsParsedToDisplayNames(parsedCommentText);
}
use of com.github.sdorra.shiro.SubjectAware in project scm-review-plugin by scm-manager.
the class CommentServiceTest method shouldExtractMentionsOnAddComment.
@Test
@SubjectAware(username = "createCommentUser")
public void shouldExtractMentionsOnAddComment() {
when(store.add(eq(PULL_REQUEST_ID), rootCommentCaptor.capture())).thenReturn("newId");
when(mentionMapper.extractMentionsFromComment(anyString())).thenReturn(ImmutableSet.of("trillian"));
Comment comment = createComment("2", "2. comment @[trillian]", author, new Location());
commentService.add(NAMESPACE, NAME, PULL_REQUEST_ID, comment);
assertThat(rootCommentCaptor.getAllValues()).hasSize(1);
Comment storedComment = rootCommentCaptor.getValue();
assertThat(storedComment.getMentionUserIds()).contains("trillian");
}
use of com.github.sdorra.shiro.SubjectAware in project scm-review-plugin by scm-manager.
the class CommentServiceTest method shouldAddCommentOnMergeEvent.
@Test
@SubjectAware(username = "dent")
public void shouldAddCommentOnMergeEvent() {
when(store.add(eq(PULL_REQUEST_ID), rootCommentCaptor.capture())).thenReturn("newId");
commentService.addCommentOnMerge(new PullRequestMergedEvent(REPOSITORY, mockPullRequest()));
assertThat(rootCommentCaptor.getAllValues()).hasSize(1);
Comment storedComment = rootCommentCaptor.getValue();
assertThat(storedComment.getComment()).isEqualTo("merged");
}
use of com.github.sdorra.shiro.SubjectAware in project scm-review-plugin by scm-manager.
the class CommentServiceTest method shouldExtractMentionsOnModifyRootCommentText.
@Test
@SubjectAware(username = "dent")
public void shouldExtractMentionsOnModifyRootCommentText() {
doNothing().when(store).update(eq(PULL_REQUEST_ID), rootCommentCaptor.capture());
when(mentionMapper.extractMentionsFromComment(anyString())).thenReturn(ImmutableSet.of("trillian"));
Comment changedRootComment = EXISTING_COMMENT.clone();
changedRootComment.setComment("new comment @[trillian]");
changedRootComment.setMentionUserIds(EMPTY_SET);
commentService.modifyComment(NAMESPACE, NAME, PULL_REQUEST_ID, EXISTING_COMMENT.getId(), changedRootComment);
assertThat(rootCommentCaptor.getAllValues()).hasSize(1);
Comment storedComment = rootCommentCaptor.getValue();
assertThat(storedComment.getComment()).isEqualTo("new comment @[trillian]");
assertThat(storedComment.getMentionUserIds()).contains("trillian");
}
Aggregations