use of com.github.sdorra.shiro.SubjectAware in project scm-review-plugin by scm-manager.
the class CommentServiceTest method shouldFailModifyWhenCommentDoesNotExist.
@Test
@SubjectAware(username = "dent")
public void shouldFailModifyWhenCommentDoesNotExist() {
Comment changedRootComment = EXISTING_COMMENT.clone();
changedRootComment.setComment("new comment");
Assertions.assertThrows(NotFoundException.class, () -> commentService.modifyComment(NAMESPACE, NAME, PULL_REQUEST_ID, "no such id", changedRootComment));
verify(store, never()).update(any(), any());
}
use of com.github.sdorra.shiro.SubjectAware in project scm-review-plugin by scm-manager.
the class CommentServiceTest method shouldAddComment.
@Test
@SubjectAware(username = "createCommentUser")
public void shouldAddComment() {
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(rootCommentCaptor.getAllValues()).hasSize(1);
Comment storedComment = rootCommentCaptor.getValue();
assertThat(storedComment.getAuthor()).isEqualTo("author");
assertThat(storedComment.getDate()).isEqualTo(NOW);
}
use of com.github.sdorra.shiro.SubjectAware in project scm-review-plugin by scm-manager.
the class CommentServiceTest method shouldAddReplyToParentComment.
@Test
@SubjectAware(username = "createCommentUser")
public void shouldAddReplyToParentComment() {
doNothing().when(store).update(eq(PULL_REQUEST_ID), rootCommentCaptor.capture());
Reply reply = createReply("new reply", "1. comment", author);
commentService.reply(NAMESPACE, NAME, PULL_REQUEST_ID, "1", reply);
assertThat(rootCommentCaptor.getAllValues()).hasSize(1);
Comment storedComment = rootCommentCaptor.getValue();
assertThat(storedComment.getReplies()).hasSize(2);
assertThat(storedComment.getReplies()).contains(reply);
assertThat(storedComment.getReplies().get(1).getId()).isNotEqualTo("new reply");
}
use of com.github.sdorra.shiro.SubjectAware in project scm-review-plugin by scm-manager.
the class CommentServiceTest method shouldKeepAuthorAndDateWhenModifyingRootComment.
@Test
@SubjectAware(username = "dent")
public void shouldKeepAuthorAndDateWhenModifyingRootComment() {
doNothing().when(store).update(eq(PULL_REQUEST_ID), rootCommentCaptor.capture());
Comment changedRootComment = EXISTING_COMMENT.clone();
changedRootComment.setAuthor("new author");
changedRootComment.setDate(ofEpochMilli(123));
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.getAuthor()).isEqualTo(EXISTING_COMMENT.getAuthor());
assertThat(storedComment.getDate()).isEqualTo(EXISTING_COMMENT.getDate());
}
use of com.github.sdorra.shiro.SubjectAware in project scm-review-plugin by scm-manager.
the class CommentServiceTest method shouldTriggerModifyEventForReplies.
@Test
@SubjectAware(username = "dent")
public void shouldTriggerModifyEventForReplies() {
Reply changedReply = EXISTING_REPLY.clone();
changedReply.setComment("new comment");
commentService.modifyReply(NAMESPACE, NAME, PULL_REQUEST_ID, EXISTING_REPLY.getId(), changedReply);
assertThat(eventCaptor.getAllValues()).hasSize(1);
assertThat(eventCaptor.getValue().getEventType()).isEqualTo(HandlerEventType.MODIFY);
}
Aggregations