Search in sources :

Example 1 with BranchRevisionResolver

use of com.cloudogu.scm.review.pullrequest.dto.BranchRevisionResolver in project scm-review-plugin by scm-manager.

the class CommentResource method getReply.

@GET
@Path("replies/{replyId}")
@Produces(MediaType.APPLICATION_JSON)
@Operation(summary = "Pull request comment reply", description = "Returns a single pull request comment reply.", tags = "Pull Request Comment")
@ApiResponse(responseCode = "200", description = "success", content = @Content(mediaType = MediaType.APPLICATION_JSON, schema = @Schema(implementation = ReplyDto.class)))
@ApiResponse(responseCode = "401", description = "not authenticated / invalid credentials")
@ApiResponse(responseCode = "403", description = "not authorized, the current user does not have the \"commentPullRequest\" privilege")
@ApiResponse(responseCode = "404", description = "not found, a reply with the given id is not available for this pull request")
@ApiResponse(responseCode = "500", description = "internal server error", content = @Content(mediaType = VndMediaType.ERROR_TYPE, schema = @Schema(implementation = ErrorDto.class)))
public ReplyDto getReply(@PathParam("namespace") String namespace, @PathParam("name") String name, @PathParam("pullRequestId") String pullRequestId, @PathParam("commentId") String commentId, @PathParam("replyId") String replyId, @QueryParam("sourceRevision") String expectedSourceRevision, @QueryParam("targetRevision") String expectedTargetRevision) {
    checkRevision(branchRevisionResolver, namespace, name, pullRequestId, expectedSourceRevision, expectedTargetRevision);
    Repository repository = repositoryResolver.resolve(new NamespaceAndName(namespace, name));
    BranchRevisionResolver.RevisionResult revisions = branchRevisionResolver.getRevisions(namespace, name, pullRequestId);
    Comment comment = service.get(namespace, name, pullRequestId, commentId);
    Reply reply = service.getReply(namespace, name, pullRequestId, commentId, replyId);
    return replyMapper.map(reply, repository, pullRequestId, comment, revisions);
}
Also used : Comment(com.cloudogu.scm.review.comment.service.Comment) Repository(sonia.scm.repository.Repository) NamespaceAndName(sonia.scm.repository.NamespaceAndName) BranchRevisionResolver(com.cloudogu.scm.review.pullrequest.dto.BranchRevisionResolver) Reply(com.cloudogu.scm.review.comment.service.Reply) 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 2 with BranchRevisionResolver

use of com.cloudogu.scm.review.pullrequest.dto.BranchRevisionResolver in project scm-review-plugin by scm-manager.

the class CommentRootResourceTest method init.

@Before
public void init() {
    when(repositoryResolver.resolve(any())).thenReturn(repository);
    commentMapper.setReplyMapper(replyMapper);
    commentMapper.setExecutedTransitionMapper(executedTransitionMapper);
    commentMapper.setPossibleTransitionMapper(possibleTransitionMapper);
    replyMapper.setExecutedTransitionMapper(executedTransitionMapper);
    CommentRootResource resource = new CommentRootResource(commentMapper, repositoryResolver, service, commentResourceProvider, commentPathBuilder, pullRequestService, branchRevisionResolver);
    when(uriInfo.getAbsolutePathBuilder()).thenReturn(UriBuilder.fromPath("/scm"));
    dispatcher = new RestDispatcher();
    PullRequestRootResource pullRequestRootResource = new PullRequestRootResource(new PullRequestMapperImpl(), null, serviceFactory, Providers.of(new PullRequestResource(new PullRequestMapperImpl(), null, Providers.of(resource), null, channelRegistry)));
    dispatcher.addSingletonResource(pullRequestRootResource);
    when(branchRevisionResolver.getRevisions(any(), any(), any())).thenReturn(new BranchRevisionResolver.RevisionResult("source", "target"));
    when(branchRevisionResolver.getRevisions(any(), any())).thenReturn(new BranchRevisionResolver.RevisionResult("source", "target"));
}
Also used : PullRequestResource(com.cloudogu.scm.review.pullrequest.api.PullRequestResource) BranchRevisionResolver(com.cloudogu.scm.review.pullrequest.dto.BranchRevisionResolver) PullRequestMapperImpl(com.cloudogu.scm.review.pullrequest.dto.PullRequestMapperImpl) RestDispatcher(sonia.scm.web.RestDispatcher) PullRequestRootResource(com.cloudogu.scm.review.pullrequest.api.PullRequestRootResource) Before(org.junit.Before)

Example 3 with BranchRevisionResolver

use of com.cloudogu.scm.review.pullrequest.dto.BranchRevisionResolver in project scm-review-plugin by scm-manager.

the class CommentResource method getComment.

@GET
@Path("")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(PullRequestMediaType.PULL_REQUEST)
@Operation(summary = "Pull request comment", description = "Returns a single pull request comment.", tags = "Pull Request Comment")
@ApiResponse(responseCode = "200", description = "success", content = @Content(mediaType = MediaType.APPLICATION_JSON, schema = @Schema(implementation = CommentDto.class)))
@ApiResponse(responseCode = "401", description = "not authenticated / invalid credentials")
@ApiResponse(responseCode = "403", description = "not authorized, the current user does not have the \"commentPullRequest\" privilege")
@ApiResponse(responseCode = "404", description = "not found, a comment with the given id is not available for this pull request")
@ApiResponse(responseCode = "500", description = "internal server error", content = @Content(mediaType = VndMediaType.ERROR_TYPE, schema = @Schema(implementation = ErrorDto.class)))
public CommentDto getComment(@PathParam("namespace") String namespace, @PathParam("name") String name, @PathParam("pullRequestId") String pullRequestId, @PathParam("commentId") String commentId, @QueryParam("sourceRevision") String expectedSourceRevision, @QueryParam("targetRevision") String expectedTargetRevision) {
    checkRevision(branchRevisionResolver, namespace, name, pullRequestId, expectedSourceRevision, expectedTargetRevision);
    Repository repository = repositoryResolver.resolve(new NamespaceAndName(namespace, name));
    BranchRevisionResolver.RevisionResult revisions = branchRevisionResolver.getRevisions(namespace, name, pullRequestId);
    Comment comment = service.get(namespace, name, pullRequestId, commentId);
    Collection<CommentTransition> possibleTransitions = service.possibleTransitions(namespace, name, pullRequestId, comment.getId());
    return commentMapper.map(comment, repository, pullRequestId, possibleTransitions, revisions);
}
Also used : CommentTransition(com.cloudogu.scm.review.comment.service.CommentTransition) Comment(com.cloudogu.scm.review.comment.service.Comment) Repository(sonia.scm.repository.Repository) NamespaceAndName(sonia.scm.repository.NamespaceAndName) BranchRevisionResolver(com.cloudogu.scm.review.pullrequest.dto.BranchRevisionResolver) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) Consumes(javax.ws.rs.Consumes) GET(javax.ws.rs.GET) Operation(io.swagger.v3.oas.annotations.Operation) ApiResponse(io.swagger.v3.oas.annotations.responses.ApiResponse)

Example 4 with BranchRevisionResolver

use of com.cloudogu.scm.review.pullrequest.dto.BranchRevisionResolver in project scm-review-plugin by scm-manager.

the class CommentResourceTest method init.

@Before
public void init() {
    when(branchRevisionResolver.getRevisions("space", "name", "1")).thenReturn(new BranchRevisionResolver.RevisionResult("source", "target"));
    when(repositoryResolver.resolve(any())).thenReturn(repository);
    CommentResource resource = new CommentResource(service, repositoryResolver, new CommentMapperImpl(), new ReplyMapperImpl(), commentPathBuilder, new ExecutedTransitionMapperImpl(), branchRevisionResolver);
    when(uriInfo.getAbsolutePathBuilder()).thenReturn(UriBuilder.fromPath("/scm"));
    dispatcher = new RestDispatcher();
    PullRequestRootResource pullRequestRootResource = new PullRequestRootResource(new PullRequestMapperImpl(), null, serviceFactory, Providers.of(new PullRequestResource(new PullRequestMapperImpl(), null, Providers.of(new CommentRootResource(new CommentMapperImpl(), repositoryResolver, service, Providers.of(resource), commentPathBuilder, pullRequestService, branchRevisionResolver)), null, channelRegistry)));
    dispatcher.addSingletonResource(pullRequestRootResource);
    when(service.get("space", "name", "1", "1")).thenReturn(EXISTING_ROOT_COMMENT);
}
Also used : PullRequestResource(com.cloudogu.scm.review.pullrequest.api.PullRequestResource) BranchRevisionResolver(com.cloudogu.scm.review.pullrequest.dto.BranchRevisionResolver) PullRequestMapperImpl(com.cloudogu.scm.review.pullrequest.dto.PullRequestMapperImpl) RestDispatcher(sonia.scm.web.RestDispatcher) PullRequestRootResource(com.cloudogu.scm.review.pullrequest.api.PullRequestRootResource) Before(org.junit.Before)

Aggregations

BranchRevisionResolver (com.cloudogu.scm.review.pullrequest.dto.BranchRevisionResolver)4 Comment (com.cloudogu.scm.review.comment.service.Comment)2 PullRequestResource (com.cloudogu.scm.review.pullrequest.api.PullRequestResource)2 PullRequestRootResource (com.cloudogu.scm.review.pullrequest.api.PullRequestRootResource)2 PullRequestMapperImpl (com.cloudogu.scm.review.pullrequest.dto.PullRequestMapperImpl)2 Operation (io.swagger.v3.oas.annotations.Operation)2 ApiResponse (io.swagger.v3.oas.annotations.responses.ApiResponse)2 GET (javax.ws.rs.GET)2 Path (javax.ws.rs.Path)2 Produces (javax.ws.rs.Produces)2 Before (org.junit.Before)2 NamespaceAndName (sonia.scm.repository.NamespaceAndName)2 Repository (sonia.scm.repository.Repository)2 RestDispatcher (sonia.scm.web.RestDispatcher)2 CommentTransition (com.cloudogu.scm.review.comment.service.CommentTransition)1 Reply (com.cloudogu.scm.review.comment.service.Reply)1 Consumes (javax.ws.rs.Consumes)1