Search in sources :

Example 61 with PullRequest

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

Example 62 with PullRequest

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

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

the class EventListenerTest method createPullRequestMergedEvent.

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

Example 64 with PullRequest

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

the class EventListenerTest method createPullRequestUpdatedEvent.

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

Example 65 with PullRequest

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

the class BranchRevisionResolverTest method shouldGetRevisionsForPullRequest.

@Test
void shouldGetRevisionsForPullRequest() throws IOException {
    when(repositoryServiceFactory.create(NAMESPACE_AND_NAME)).thenReturn(repositoryService);
    PullRequest pullRequest = TestData.createPullRequest();
    setUpBranches(pullRequest);
    mockSingleChangeset(pullRequest.getSource());
    mockSingleChangeset(pullRequest.getTarget());
    BranchRevisionResolver.RevisionResult revisions = branchRevisionResolver.getRevisions(NAMESPACE_AND_NAME, pullRequest);
    Assertions.assertThat(revisions.getSourceRevision()).isEqualTo(pullRequest.getSource() + "Id");
    Assertions.assertThat(revisions.getTargetRevision()).isEqualTo(pullRequest.getTarget() + "Id");
}
Also used : PullRequest(com.cloudogu.scm.review.pullrequest.service.PullRequest) Test(org.junit.jupiter.api.Test)

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