use of com.github.sdorra.shiro.SubjectAware in project scm-review-plugin by scm-manager.
the class CommentServiceTest method shouldDeleteExistingReply.
@Test
@SubjectAware(username = "dent")
public void shouldDeleteExistingReply() {
doNothing().when(store).update(eq(PULL_REQUEST_ID), rootCommentCaptor.capture());
commentService.delete(NAMESPACE, NAME, PULL_REQUEST_ID, EXISTING_REPLY.getId());
assertThat(rootCommentCaptor.getAllValues()).hasSize(1);
Comment storedComment = rootCommentCaptor.getValue();
assertThat(storedComment.getReplies()).isEmpty();
}
use of com.github.sdorra.shiro.SubjectAware in project scm-review-plugin by scm-manager.
the class CommentServiceTest method shouldTriggerMentionEventOnModifyReplyText.
@Test
@SubjectAware(username = "dent")
public void shouldTriggerMentionEventOnModifyReplyText() {
doNothing().when(store).update(eq(PULL_REQUEST_ID), rootCommentCaptor.capture());
when(mentionMapper.extractMentionsFromComment("new comment @[dent]")).thenReturn(ImmutableSet.of("dent"));
Reply changedReply = EXISTING_REPLY.clone();
changedReply.setMentionUserIds(ImmutableSet.of("dent"));
changedReply.setComment("new comment @[dent]");
String parsedCommentText = "2. comment @Arthur Dent";
Reply parsedReply = createReply("2", parsedCommentText, author);
when(mentionMapper.parseMentionsUserIdsToDisplayNames(any(Reply.class))).thenReturn(parsedReply);
commentService.modifyReply(NAMESPACE, NAME, PULL_REQUEST_ID, EXISTING_REPLY.getId(), changedReply);
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 shouldModifyReplyText.
@Test
@SubjectAware(username = "dent")
public void shouldModifyReplyText() {
doNothing().when(store).update(eq(PULL_REQUEST_ID), rootCommentCaptor.capture());
Reply changedReply = EXISTING_REPLY.clone();
changedReply.setComment("new comment");
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");
}
use of com.github.sdorra.shiro.SubjectAware in project scm-review-plugin by scm-manager.
the class PullRequestRootResourceTest method shouldGetUnauthorizedExceptionWhenMissingPermissionOnGetAllPR.
@Test
@SubjectAware(username = "trillian")
public void shouldGetUnauthorizedExceptionWhenMissingPermissionOnGetAllPR() throws URISyntaxException {
MockHttpRequest request = MockHttpRequest.get("/" + PullRequestRootResource.PULL_REQUESTS_PATH_V2 + "/" + REPOSITORY_NAMESPACE + "/" + REPOSITORY_NAME + "");
dispatcher.invoke(request, response);
assertEquals(HttpServletResponse.SC_FORBIDDEN, response.getStatus());
}
use of com.github.sdorra.shiro.SubjectAware in project scm-review-plugin by scm-manager.
the class PullRequestRootResourceTest method shouldGetUnauthorizedExceptionWhenMissingPermissionOnGetPR.
@Test
@SubjectAware(username = "trillian")
public void shouldGetUnauthorizedExceptionWhenMissingPermissionOnGetPR() throws URISyntaxException {
MockHttpRequest request = MockHttpRequest.get("/" + PullRequestRootResource.PULL_REQUESTS_PATH_V2 + "/" + REPOSITORY_NAMESPACE + "/" + REPOSITORY_NAME + "/123");
dispatcher.invoke(request, response);
assertEquals(HttpServletResponse.SC_FORBIDDEN, response.getStatus());
}
Aggregations