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);
}
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"));
}
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);
}
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);
}
Aggregations