Search in sources :

Example 36 with PullRequest

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

the class OpenPullRequestProviderTest method createPullRequest.

private static PullRequest createPullRequest(String id, PullRequestStatus status) {
    PullRequest existingPullRequest = new PullRequest();
    existingPullRequest.setId(id);
    existingPullRequest.setTitle("title " + id);
    existingPullRequest.setSource("source");
    existingPullRequest.setTarget("target");
    existingPullRequest.setStatus(status);
    return existingPullRequest;
}
Also used : PullRequest(com.cloudogu.scm.review.pullrequest.service.PullRequest)

Example 37 with PullRequest

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

the class AllReviewerApprovedRuleTest method shouldReturnFailedIfReviewerHaveNotApproved.

@Test
void shouldReturnFailedIfReviewerHaveNotApproved() {
    PullRequest pullRequest = TestData.createPullRequest();
    pullRequest.addReviewer("trillian");
    pullRequest.addReviewer("dent");
    Context context = new Context(REPOSITORY, pullRequest);
    Result result = rule.validate(context);
    assertThat(result.isFailed()).isTrue();
}
Also used : PullRequest(com.cloudogu.scm.review.pullrequest.service.PullRequest) Test(org.junit.jupiter.api.Test)

Example 38 with PullRequest

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

the class MergeObstacleCheckHook method checkForObstacles.

@Subscribe(async = false)
public void checkForObstacles(PreReceiveRepositoryHookEvent event) {
    HookContext context = event.getContext();
    Repository repository = event.getRepository();
    if (ignoreHook(context, repository)) {
        return;
    }
    List<PullRequest> pullRequests = pullRequestService.getAll(repository.getNamespace(), repository.getName());
    new Worker(event).process(pullRequests);
}
Also used : Repository(sonia.scm.repository.Repository) PullRequest(com.cloudogu.scm.review.pullrequest.service.PullRequest) HookContext(sonia.scm.repository.api.HookContext) Subscribe(com.github.legman.Subscribe)

Example 39 with PullRequest

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

the class StatusCheckHook method checkStatus.

@Subscribe(async = false)
public void checkStatus(PostReceiveRepositoryHookEvent event) {
    Repository repository = event.getRepository();
    if (ignoreHook(event.getContext(), repository)) {
        return;
    }
    List<PullRequest> pullRequests = pullRequestService.getAll(repository.getNamespace(), repository.getName());
    new Worker(event).process(pullRequests);
}
Also used : Repository(sonia.scm.repository.Repository) PullRequest(com.cloudogu.scm.review.pullrequest.service.PullRequest) Subscribe(com.github.legman.Subscribe)

Example 40 with PullRequest

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

the class CommentService method addCommentOnEmergencyMerge.

@Subscribe
public void addCommentOnEmergencyMerge(PullRequestEmergencyMergedEvent mergedEvent) {
    PullRequest pullRequest = mergedEvent.getPullRequest();
    Comment comment = new Comment();
    comment.setEmergencyMerged(true);
    comment.setComment(pullRequest.getOverrideMessage());
    addWithoutPermissionCheck(mergedEvent.getRepository(), pullRequest.getId(), comment);
}
Also used : PullRequest(com.cloudogu.scm.review.pullrequest.service.PullRequest) Subscribe(com.github.legman.Subscribe)

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