Search in sources :

Example 16 with PullRequest

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

the class CommentServiceTest method mockPullRequest.

private PullRequest mockPullRequest() {
    PullRequest mock = mock(PullRequest.class);
    when(mock.getId()).thenReturn(PULL_REQUEST_ID);
    return mock;
}
Also used : PullRequest(com.cloudogu.scm.review.pullrequest.service.PullRequest)

Example 17 with PullRequest

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

the class CommentServiceTest method shouldAddCommentOnEmergencyMergeEvent.

@Test
public void shouldAddCommentOnEmergencyMergeEvent() {
    String overrideMessage = "really urgent";
    PullRequest pullRequest = mockPullRequest();
    when(store.add(eq(PULL_REQUEST_ID), rootCommentCaptor.capture())).thenReturn("newId");
    when(pullRequest.getOverrideMessage()).thenReturn(overrideMessage);
    commentService.addCommentOnEmergencyMerge(new PullRequestEmergencyMergedEvent(REPOSITORY, pullRequest));
    assertThat(rootCommentCaptor.getAllValues()).hasSize(1);
    Comment storedComment = rootCommentCaptor.getValue();
    assertThat(storedComment.getComment()).isEqualTo(overrideMessage);
    assertThat(storedComment.isEmergencyMerged()).isTrue();
    assertThat(storedComment.getAuthor()).isEqualTo("author");
}
Also used : Comment.createComment(com.cloudogu.scm.review.comment.service.Comment.createComment) PullRequest(com.cloudogu.scm.review.pullrequest.service.PullRequest) PullRequestEmergencyMergedEvent(com.cloudogu.scm.review.pullrequest.service.PullRequestEmergencyMergedEvent) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.junit.Test)

Example 18 with PullRequest

use of com.cloudogu.scm.review.pullrequest.service.PullRequest 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 19 with PullRequest

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

the class EventListenerTest method createPullRequestEvent.

private PullRequestEvent createPullRequestEvent() {
    Repository repository = RepositoryTestData.createHeartOfGold();
    PullRequest pullRequest = TestData.createPullRequest();
    mockChannel(repository, pullRequest);
    return new PullRequestEvent(repository, pullRequest, null, HandlerEventType.CREATE);
}
Also used : BasicPullRequestEvent(com.cloudogu.scm.review.pullrequest.service.BasicPullRequestEvent) PullRequestEvent(com.cloudogu.scm.review.pullrequest.service.PullRequestEvent) Repository(sonia.scm.repository.Repository) PullRequest(com.cloudogu.scm.review.pullrequest.service.PullRequest)

Example 20 with PullRequest

use of com.cloudogu.scm.review.pullrequest.service.PullRequest 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);
}
Also used : Comment(com.cloudogu.scm.review.comment.service.Comment) CommentEvent(com.cloudogu.scm.review.comment.service.CommentEvent) Repository(sonia.scm.repository.Repository) PullRequest(com.cloudogu.scm.review.pullrequest.service.PullRequest)

Aggregations

PullRequest (com.cloudogu.scm.review.pullrequest.service.PullRequest)82 Repository (sonia.scm.repository.Repository)27 Test (org.junit.jupiter.api.Test)20 Test (org.junit.Test)18 TestData.createPullRequest (com.cloudogu.scm.review.TestData.createPullRequest)17 MockHttpRequest (org.jboss.resteasy.mock.MockHttpRequest)16 Subscribe (com.github.legman.Subscribe)13 SubjectAware (com.github.sdorra.shiro.SubjectAware)13 NamespaceAndName (sonia.scm.repository.NamespaceAndName)13 User (sonia.scm.user.User)11 DisplayUser (sonia.scm.user.DisplayUser)10 JsonNode (com.fasterxml.jackson.databind.JsonNode)8 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)8 Optional (java.util.Optional)7 Comment (com.cloudogu.scm.review.comment.service.Comment)6 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)6 PermissionCheck (com.cloudogu.scm.review.PermissionCheck)5 PullRequestService (com.cloudogu.scm.review.pullrequest.service.PullRequestService)5 Operation (io.swagger.v3.oas.annotations.Operation)5 List (java.util.List)5