use of com.cloudogu.scm.review.comment.service.Comment in project scm-review-plugin by scm-manager.
the class CommentRootResourceTest method mockExistingComments.
private void mockExistingComments() {
Comment comment1 = createComment("1", "1. comment", "author", new Location("file.txt", "123", 0, 3));
Comment comment2 = createComment("2", "2. comment", "author", new Location("", "", 0, 0));
comment1.setContext(new InlineContext(ImmutableList.of(copy(new MockedDiffLine.Builder().newLineNumber(1).get()), copy(new MockedDiffLine.Builder().newLineNumber(2).get()), copy(new MockedDiffLine.Builder().newLineNumber(3).get()))));
Reply reply1 = createReply("2_1", "1. reply", "author");
Reply reply2 = createReply("2_2", "2. reply", "author");
comment2.setReplies(asList(reply1, reply2));
ArrayList<Comment> list = Lists.newArrayList(comment1, comment2);
when(service.getAll("space", "name", "1")).thenReturn(list);
when(service.get("space", "name", "1", "1")).thenReturn(comment1);
when(service.get("space", "name", "1", "2")).thenReturn(comment2);
}
use of com.cloudogu.scm.review.comment.service.Comment in project scm-review-plugin by scm-manager.
the class CommentResourceTest method shouldReply.
@Test
public void shouldReply() throws URISyntaxException {
String newComment = "haha ";
when(service.reply(eq("space"), eq("name"), eq("1"), eq("1"), argThat(t -> t.getComment().equals(newComment)))).thenReturn("new");
byte[] pullRequestCommentJson = ("{\"comment\" : \"" + newComment + "\"}").getBytes();
MockHttpRequest request = MockHttpRequest.post("/" + PullRequestRootResource.PULL_REQUESTS_PATH_V2 + "/space/name/1/comments/1/replies").content(pullRequestCommentJson).contentType(MediaType.APPLICATION_JSON);
dispatcher.invoke(request, response);
verify(service).reply(eq("space"), eq("name"), eq("1"), any(), any());
assertEquals(create("https://scm-manager.org/scm/api/v2/pull-requests/space/name/1/comments/1/replies/new"), response.getOutputHeaders().getFirst("Location"));
assertEquals(HttpServletResponse.SC_CREATED, response.getStatus());
}
use of com.cloudogu.scm.review.comment.service.Comment in project scm-review-plugin by scm-manager.
the class CommentResourceTest method shouldNotReplyIfPullRequestHasChanged.
@Test
public void shouldNotReplyIfPullRequestHasChanged() throws URISyntaxException, UnsupportedEncodingException {
String newComment = "haha ";
when(service.reply(eq("space"), eq("name"), eq("1"), eq("1"), argThat(t -> t.getComment().equals(newComment)))).thenReturn("new");
byte[] pullRequestCommentJson = ("{\"comment\" : \"" + newComment + "\"}").getBytes();
MockHttpRequest request = MockHttpRequest.post("/" + PullRequestRootResource.PULL_REQUESTS_PATH_V2 + "/space/name/1/comments/1/replies?sourceRevision=wrong").content(pullRequestCommentJson).contentType(MediaType.APPLICATION_JSON);
dispatcher.invoke(request, response);
verify(service, never()).reply(any(), any(), any(), any(), any());
Assertions.assertThat(response.getContentAsString()).contains("modified concurrently");
}
use of com.cloudogu.scm.review.comment.service.Comment in project scm-review-plugin by scm-manager.
the class EventListenerTest method createCommentEvent.
private CommentEvent createCommentEvent() {
Repository repository = RepositoryTestData.createHeartOfGold();
PullRequest pullRequest = TestData.createPullRequest();
mockChannel(repository, pullRequest);
Comment comment = new Comment();
comment.setId("c42");
return new CommentEvent(repository, pullRequest, null, comment, HandlerEventType.DELETE);
}
use of com.cloudogu.scm.review.comment.service.Comment in project scm-review-plugin by scm-manager.
the class EmailNotificationHookTest method shouldNotSendSystemEmails.
@Test
void shouldNotSendSystemEmails() throws Exception {
Comment systemComment = Comment.createSystemComment("1");
CommentEvent commentEvent = new CommentEvent(repository, pullRequest, systemComment, oldComment, HandlerEventType.CREATE);
emailNotificationHook.handleCommentEvents(commentEvent);
verify(service, never()).sendEmail(any(), any());
verify(service, never()).sendEmail(any(), any());
reset(service);
}
Aggregations