Search in sources :

Example 1 with PullRequestDto

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

the class PullRequestRootResource method getAll.

@GET
@Path("{namespace}/{name}")
@Produces(PullRequestMediaType.PULL_REQUEST_COLLECTION)
@Operation(summary = "Collection of pull requests", description = "Returns a list of pull requests by status.", tags = "Pull Request", operationId = "review_get_pull_request_collection")
@ApiResponse(responseCode = "200", description = "success", content = @Content(mediaType = PullRequestMediaType.PULL_REQUEST_COLLECTION, schema = @Schema(implementation = HalRepresentation.class)))
@ApiResponse(responseCode = "401", description = "not authenticated / invalid credentials")
@ApiResponse(responseCode = "403", description = "not authorized, the current user does not have the \"readPullRequest\" privilege")
@ApiResponse(responseCode = "500", description = "internal server error", content = @Content(mediaType = VndMediaType.ERROR_TYPE, schema = @Schema(implementation = ErrorDto.class)))
public HalRepresentation getAll(@Context UriInfo uriInfo, @PathParam("namespace") String namespace, @PathParam("name") String name, @QueryParam("status") @DefaultValue("OPEN") PullRequestSelector pullRequestSelector) {
    Repository repository = service.getRepository(namespace, name);
    PermissionCheck.checkRead(repository);
    List<PullRequestDto> pullRequestDtos = service.getAll(namespace, name).stream().filter(pullRequestSelector).map(pr -> mapper.using(uriInfo).map(pr, repository)).sorted(Comparator.comparing(this::getLastModification).reversed()).collect(Collectors.toList());
    PullRequestResourceLinks resourceLinks = new PullRequestResourceLinks(uriInfo::getBaseUri);
    boolean permission = PermissionCheck.mayCreate(repository);
    return createCollection(permission, resourceLinks.pullRequestCollection().all(namespace, name), resourceLinks.pullRequestCollection().create(namespace, name), pullRequestDtos, "pullRequests");
}
Also used : PullRequestDto(com.cloudogu.scm.review.pullrequest.dto.PullRequestDto) Repository(sonia.scm.repository.Repository) 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 2 with PullRequestDto

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

the class MyOpenTasksTest method mockMapper.

@BeforeEach
void mockMapper() {
    when(mapper.map(any(), any())).thenAnswer(invocationOnMock -> {
        PullRequestDto dto = new PullRequestDto();
        dto.setId(invocationOnMock.getArgument(0, PullRequest.class).getId());
        return dto;
    });
}
Also used : PullRequestDto(com.cloudogu.scm.review.pullrequest.dto.PullRequestDto) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 3 with PullRequestDto

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

the class MyOpenReviewsTest method mockMapper.

@BeforeEach
void mockMapper() {
    when(mapper.map(any(), any())).thenAnswer(invocationOnMock -> {
        PullRequestDto dto = new PullRequestDto();
        dto.setId(invocationOnMock.getArgument(0, PullRequest.class).getId());
        return dto;
    });
}
Also used : PullRequestDto(com.cloudogu.scm.review.pullrequest.dto.PullRequestDto) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 4 with PullRequestDto

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

the class MyPullRequestsTest method mockMapper.

@BeforeEach
void mockMapper() {
    when(mapper.map(any(), any())).thenAnswer(invocationOnMock -> {
        PullRequestDto dto = new PullRequestDto();
        dto.setId(invocationOnMock.getArgument(0, PullRequest.class).getId());
        return dto;
    });
}
Also used : PullRequestDto(com.cloudogu.scm.review.pullrequest.dto.PullRequestDto) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

PullRequestDto (com.cloudogu.scm.review.pullrequest.dto.PullRequestDto)4 BeforeEach (org.junit.jupiter.api.BeforeEach)3 PullRequestResourceLinks (com.cloudogu.scm.review.PullRequestResourceLinks)1 Operation (io.swagger.v3.oas.annotations.Operation)1 ApiResponse (io.swagger.v3.oas.annotations.responses.ApiResponse)1 GET (javax.ws.rs.GET)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1 Repository (sonia.scm.repository.Repository)1