Search in sources :

Example 56 with PullRequest

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

the class EngineResultResource method getResult.

@GET
@Path("")
@Produces(WORKFLOW_RESULT_MEDIA_TYPE)
@Operation(summary = "Workflow engine result", description = "Returns the result of the workflow checks for the given pull request.", tags = "Workflow Engine", operationId = "review_get_repository_workflow_result")
@ApiResponse(responseCode = "200", description = "success", content = @Content(mediaType = WORKFLOW_RESULT_MEDIA_TYPE, schema = @Schema(implementation = ResultListDto.class)))
@ApiResponse(responseCode = "401", description = "not authenticated / invalid credentials")
@ApiResponse(responseCode = "403", description = "not authorized, the current user does not have the \"repository:readWorkflowConfig\" privilege")
@ApiResponse(responseCode = "404", description = "either repository or pull request not found")
@ApiResponse(responseCode = "500", description = "internal server error", content = @Content(mediaType = VndMediaType.ERROR_TYPE, schema = @Schema(implementation = ErrorDto.class)))
public ResultListDto getResult(@Context UriInfo uriInfo, @PathParam("namespace") String namespace, @PathParam("name") String name, @PathParam("pullRequestId") String pullRequestId) {
    Repository repository = pullRequestService.getRepository(namespace, name);
    PullRequest pullRequest = pullRequestService.get(namespace, name, pullRequestId);
    final Links.Builder linksBuilder = new Links.Builder();
    linksBuilder.self(new PullRequestResourceLinks(uriInfo::getBaseUri).workflowEngineLinks().results(repository.getNamespace(), repository.getName(), pullRequestId));
    List<Result> ruleResults = engine.validate(repository, pullRequest).getRuleResults();
    return new ResultListDto(linksBuilder.build(), ruleResults.stream().map(this::createDto).collect(Collectors.toList()));
}
Also used : Repository(sonia.scm.repository.Repository) PullRequest(com.cloudogu.scm.review.pullrequest.service.PullRequest) Links(de.otto.edison.hal.Links) PullRequestResourceLinks(com.cloudogu.scm.review.PullRequestResourceLinks) PullRequestResourceLinks(com.cloudogu.scm.review.PullRequestResourceLinks) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) Operation(io.swagger.v3.oas.annotations.Operation) ApiResponse(io.swagger.v3.oas.annotations.responses.ApiResponse)

Example 57 with PullRequest

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

the class PullRequestInformationHookTest method createPullRequest.

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

Example 58 with PullRequest

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

the class TestData method createPullRequest.

public static PullRequest createPullRequest(String id, PullRequestStatus pullRequestStatus) {
    PullRequest pullRequest = new PullRequest();
    pullRequest.setSource("develop");
    pullRequest.setTarget("master");
    pullRequest.setTitle("PR");
    pullRequest.setId(id);
    pullRequest.setDescription("Hitchhiker's guide to the galaxy");
    pullRequest.setAuthor("dent");
    pullRequest.setCreationDate(Instant.MIN);
    pullRequest.setLastModified(Instant.MIN);
    pullRequest.setStatus(pullRequestStatus);
    return pullRequest;
}
Also used : PullRequest(com.cloudogu.scm.review.pullrequest.service.PullRequest)

Example 59 with PullRequest

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

the class StatusCheckHookTest method mockRejectedPullRequest.

private PullRequest mockRejectedPullRequest() {
    PullRequest pullRequest = new PullRequest();
    pullRequest.setStatus(PullRequestStatus.REJECTED);
    when(pullRequestService.getAll(NAMESPACE, NAME)).thenReturn(singletonList(pullRequest));
    return pullRequest;
}
Also used : PullRequest(com.cloudogu.scm.review.pullrequest.service.PullRequest)

Example 60 with PullRequest

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

the class CommentIndexerTest method shouldIndexCommentForReplyEvent.

@Test
void shouldIndexCommentForReplyEvent() {
    PullRequest pr = createPullRequest();
    Comment comment = Comment.createComment("1", "first one", "trillian", new Location());
    Reply reply = Reply.createReply("1", "first reply", "trillian");
    indexer.handleEvent(new ReplyEvent(repository, pr, reply, reply, comment, HandlerEventType.CREATE));
    verify(forType).update(any(SerializableIndexTask.class));
}
Also used : SerializableIndexTask(sonia.scm.search.SerializableIndexTask) 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