Search in sources :

Example 1 with PullRequestRejectedEvent

use of com.cloudogu.scm.review.pullrequest.service.PullRequestRejectedEvent in project scm-review-plugin by scm-manager.

the class CommentServiceTest method shouldAddCommentOnRejectEventByUser.

@Test
@SubjectAware(username = "dent")
public void shouldAddCommentOnRejectEventByUser() {
    when(store.add(eq(PULL_REQUEST_ID), rootCommentCaptor.capture())).thenReturn("newId");
    commentService.addCommentOnReject(new PullRequestRejectedEvent(REPOSITORY, mockPullRequest(), PullRequestRejectedEvent.RejectionCause.REJECTED_BY_USER));
    assertThat(rootCommentCaptor.getAllValues()).hasSize(1);
    Comment storedComment = rootCommentCaptor.getValue();
    assertThat(storedComment.getComment()).isEqualTo("rejected");
}
Also used : PullRequestRejectedEvent(com.cloudogu.scm.review.pullrequest.service.PullRequestRejectedEvent) Comment.createComment(com.cloudogu.scm.review.comment.service.Comment.createComment) Test(org.junit.Test) SubjectAware(com.github.sdorra.shiro.SubjectAware)

Example 2 with PullRequestRejectedEvent

use of com.cloudogu.scm.review.pullrequest.service.PullRequestRejectedEvent in project scm-review-plugin by scm-manager.

the class EventListenerTest method createPullRequestRejectedEvent.

private PullRequestRejectedEvent createPullRequestRejectedEvent() {
    Repository repository = RepositoryTestData.createHeartOfGold();
    PullRequest pullRequest = TestData.createPullRequest();
    mockChannel(repository, pullRequest);
    return new PullRequestRejectedEvent(repository, pullRequest, PullRequestRejectedEvent.RejectionCause.BRANCH_DELETED);
}
Also used : PullRequestRejectedEvent(com.cloudogu.scm.review.pullrequest.service.PullRequestRejectedEvent) Repository(sonia.scm.repository.Repository) PullRequest(com.cloudogu.scm.review.pullrequest.service.PullRequest)

Example 3 with PullRequestRejectedEvent

use of com.cloudogu.scm.review.pullrequest.service.PullRequestRejectedEvent in project scm-review-plugin by scm-manager.

the class EventListenerTest method shouldBroadcastPullRequestRejectedEvent.

@Test
void shouldBroadcastPullRequestRejectedEvent() {
    bindSessionId("1-2-3");
    PullRequestRejectedEvent event = createPullRequestRejectedEvent();
    listener.handle(event);
    verify(channel).broadcast(captor.capture());
    assertMessageHasCorrectTypeAndName(PullRequestRejectedEvent.class);
}
Also used : PullRequestRejectedEvent(com.cloudogu.scm.review.pullrequest.service.PullRequestRejectedEvent) Test(org.junit.jupiter.api.Test)

Example 4 with PullRequestRejectedEvent

use of com.cloudogu.scm.review.pullrequest.service.PullRequestRejectedEvent in project scm-review-plugin by scm-manager.

the class EmailNotificationHookTest method shouldSendEmailsAfterRejectingPullRequest.

@Test
void shouldSendEmailsAfterRejectingPullRequest() throws Exception {
    PullRequestRejectedEvent event = new PullRequestRejectedEvent(repository, pullRequest, PullRequestRejectedEvent.RejectionCause.REJECTED_BY_USER);
    emailNotificationHook.handleRejectedPullRequest(event);
    verify(service).sendEmail(eq(of(subscribedButNotReviewer, subscribedAndReviewer)), isA(PullRequestRejectedMailTextResolver.class));
}
Also used : PullRequestRejectedEvent(com.cloudogu.scm.review.pullrequest.service.PullRequestRejectedEvent) Test(org.junit.jupiter.api.Test) DynamicTest(org.junit.jupiter.api.DynamicTest)

Example 5 with PullRequestRejectedEvent

use of com.cloudogu.scm.review.pullrequest.service.PullRequestRejectedEvent in project scm-review-plugin by scm-manager.

the class CommentServiceTest method shouldAddCommentOnRejectEventByDeletedBranch.

@Test
@SubjectAware(username = "dent")
public void shouldAddCommentOnRejectEventByDeletedBranch() {
    PullRequest pullRequest = mockPullRequest();
    when(store.add(eq(PULL_REQUEST_ID), rootCommentCaptor.capture())).thenReturn("newId");
    commentService.addCommentOnReject(new PullRequestRejectedEvent(REPOSITORY, pullRequest, PullRequestRejectedEvent.RejectionCause.BRANCH_DELETED));
    assertThat(rootCommentCaptor.getAllValues()).hasSize(1);
    Comment storedComment = rootCommentCaptor.getValue();
    assertThat(storedComment.getComment()).isEqualTo("sourceDeleted");
}
Also used : PullRequestRejectedEvent(com.cloudogu.scm.review.pullrequest.service.PullRequestRejectedEvent) Comment.createComment(com.cloudogu.scm.review.comment.service.Comment.createComment) PullRequest(com.cloudogu.scm.review.pullrequest.service.PullRequest) Test(org.junit.Test) SubjectAware(com.github.sdorra.shiro.SubjectAware)

Aggregations

PullRequestRejectedEvent (com.cloudogu.scm.review.pullrequest.service.PullRequestRejectedEvent)6 Test (org.junit.jupiter.api.Test)3 Comment.createComment (com.cloudogu.scm.review.comment.service.Comment.createComment)2 PullRequest (com.cloudogu.scm.review.pullrequest.service.PullRequest)2 SubjectAware (com.github.sdorra.shiro.SubjectAware)2 Test (org.junit.Test)2 DynamicTest (org.junit.jupiter.api.DynamicTest)1 Repository (sonia.scm.repository.Repository)1