Search in sources :

Example 1 with ReplyEvent

use of com.cloudogu.scm.review.comment.service.ReplyEvent in project scm-review-plugin by scm-manager.

the class RemoveReviewMarksOnChangedCommentsHookTest method shouldRemoveMarksOnNewReplyOnCommentWithSameLocation.

@Test
void shouldRemoveMarksOnNewReplyOnCommentWithSameLocation() {
    Reply reply = Reply.createReply("321", "reply", "trillian");
    comment.setLocation(new Location("some/file"));
    comment.setReplies(singletonList(reply));
    pullRequest.setReviewMarks(of(new ReviewMark("some/file", "dent")));
    when(commentService.getAll(repository.getNamespace(), repository.getName(), pullRequest.getId())).thenReturn(singletonList(comment));
    ReplyEvent event = new ReplyEvent(repository, pullRequest, reply, null, comment, HandlerEventType.CREATE);
    hook.handleReplyEvents(event);
    verify(pullRequestService).removeReviewMarks(repository, pullRequest.getId(), singletonList(new ReviewMark("some/file", "dent")));
}
Also used : ReplyEvent(com.cloudogu.scm.review.comment.service.ReplyEvent) Reply(com.cloudogu.scm.review.comment.service.Reply) Location(com.cloudogu.scm.review.comment.service.Location) Test(org.junit.jupiter.api.Test)

Example 2 with ReplyEvent

use of com.cloudogu.scm.review.comment.service.ReplyEvent in project scm-review-plugin by scm-manager.

the class RemoveReviewMarksOnChangedCommentsHookTest method shouldIgnoreReplyOnCommentWithoutLocation.

@Test
void shouldIgnoreReplyOnCommentWithoutLocation() {
    Reply reply = Reply.createReply("321", "reply", "trillian");
    comment.setReplies(singletonList(reply));
    pullRequest.setReviewMarks(of(new ReviewMark("some/file", "dent")));
    when(commentService.getAll(repository.getNamespace(), repository.getName(), pullRequest.getId())).thenReturn(singletonList(comment));
    ReplyEvent event = new ReplyEvent(repository, pullRequest, reply, null, comment, HandlerEventType.CREATE);
    hook.handleReplyEvents(event);
    verify(pullRequestService, never()).removeReviewMarks(any(), any(), any());
}
Also used : ReplyEvent(com.cloudogu.scm.review.comment.service.ReplyEvent) Reply(com.cloudogu.scm.review.comment.service.Reply) Test(org.junit.jupiter.api.Test)

Example 3 with ReplyEvent

use of com.cloudogu.scm.review.comment.service.ReplyEvent in project scm-review-plugin by scm-manager.

the class RemoveReviewMarksOnChangedCommentsHookTest method shouldIgnoreDeletedReply.

@Test
void shouldIgnoreDeletedReply() {
    Reply reply = Reply.createReply("321", "reply", "trillian");
    ReplyEvent event = new ReplyEvent(repository, pullRequest, null, reply, comment, HandlerEventType.DELETE);
    hook.handleReplyEvents(event);
    verify(pullRequestService, never()).removeReviewMarks(any(), any(), any());
}
Also used : ReplyEvent(com.cloudogu.scm.review.comment.service.ReplyEvent) Reply(com.cloudogu.scm.review.comment.service.Reply) Test(org.junit.jupiter.api.Test)

Example 4 with ReplyEvent

use of com.cloudogu.scm.review.comment.service.ReplyEvent in project scm-review-plugin by scm-manager.

the class EventListenerTest method createReplyEvent.

private ReplyEvent createReplyEvent() {
    Repository repository = RepositoryTestData.createHeartOfGold();
    PullRequest pullRequest = TestData.createPullRequest();
    mockChannel(repository, pullRequest);
    Reply reply = new Reply();
    reply.setId("c42");
    return new ReplyEvent(repository, pullRequest, reply, reply, null, HandlerEventType.MODIFY);
}
Also used : Repository(sonia.scm.repository.Repository) PullRequest(com.cloudogu.scm.review.pullrequest.service.PullRequest) ReplyEvent(com.cloudogu.scm.review.comment.service.ReplyEvent) Reply(com.cloudogu.scm.review.comment.service.Reply)

Example 5 with ReplyEvent

use of com.cloudogu.scm.review.comment.service.ReplyEvent in project scm-review-plugin by scm-manager.

the class EventListenerTest method shouldBroadcastMessageForReplyEvent.

@Test
void shouldBroadcastMessageForReplyEvent() {
    SessionId sessionId = bindSessionId("4-2");
    ReplyEvent event = createReplyEvent();
    listener.handle(event);
    verify(channel).broadcast(captor.capture());
    assertMessageHasCorrectTypeAndName(ReplyEvent.class);
}
Also used : ReplyEvent(com.cloudogu.scm.review.comment.service.ReplyEvent) SessionId(sonia.scm.security.SessionId) Test(org.junit.jupiter.api.Test)

Aggregations

ReplyEvent (com.cloudogu.scm.review.comment.service.ReplyEvent)6 Reply (com.cloudogu.scm.review.comment.service.Reply)5 Test (org.junit.jupiter.api.Test)4 Location (com.cloudogu.scm.review.comment.service.Location)1 PullRequest (com.cloudogu.scm.review.pullrequest.service.PullRequest)1 TestFactory (org.junit.jupiter.api.TestFactory)1 Repository (sonia.scm.repository.Repository)1 SessionId (sonia.scm.security.SessionId)1