use of sonia.scm.repository.Repository in project scm-review-plugin by scm-manager.
the class RepositoryEngineConfigResource method getRepositoryEngineConfig.
@GET
@Path("{namespace}/{name}/config")
@Produces(WORKFLOW_MEDIA_TYPE)
@Operation(summary = "Workflow engine configuration", description = "Returns the repository specific workflow engine configuration.", tags = "Workflow Engine", operationId = "review_get_repository_workflow_configuration")
@ApiResponse(responseCode = "200", description = "success", content = @Content(mediaType = MediaType.APPLICATION_JSON, 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 \"repository:readWorkflowConfig\" privilege")
@ApiResponse(responseCode = "500", description = "internal server error", content = @Content(mediaType = VndMediaType.ERROR_TYPE, schema = @Schema(implementation = ErrorDto.class)))
public RepositoryEngineConfigDto getRepositoryEngineConfig(@Context UriInfo uriInfo, @PathParam("namespace") String namespace, @PathParam("name") String name) {
Repository repository = loadRepository(namespace, name);
PermissionCheck.checkReadWorkflowConfig(repository);
return mapper.map(configurator.getEngineConfiguration(repository), repository, uriInfo);
}
use of sonia.scm.repository.Repository 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()));
}
use of sonia.scm.repository.Repository in project scm-review-plugin by scm-manager.
the class RepositoryResolverTest method testResolveForUnsupportedType.
@Test
public void testResolveForUnsupportedType() {
Repository repository = RepositoryTestData.createHeartOfGold("svn");
repository.setId("42");
when(repositoryManager.get(namespaceAndName)).thenReturn(repository);
when(repositoryServiceFactory.create(repository)).thenReturn(repositoryService);
when(repositoryService.isSupported(Command.MERGE)).thenReturn(Boolean.FALSE);
PullRequestNotSupportedException exception = assertThrows(PullRequestNotSupportedException.class, () -> resolver.resolve(namespaceAndName));
ContextEntry contextEntry = exception.getContext().get(0);
assertThat(contextEntry.getType()).isEqualTo("Repository");
assertThat(contextEntry.getId()).isEqualTo("hitchhiker/HeartOfGold");
}
use of sonia.scm.repository.Repository in project scm-review-plugin by scm-manager.
the class RepositoryResolverTest method testResolve.
@Test
public void testResolve() {
Repository repository = RepositoryTestData.createHeartOfGold("git");
repository.setId("42");
when(repositoryManager.get(namespaceAndName)).thenReturn(repository);
when(repositoryServiceFactory.create(repository)).thenReturn(repositoryService);
when(repositoryService.isSupported(Command.MERGE)).thenReturn(Boolean.TRUE);
Repository resolvedRepository = resolver.resolve(namespaceAndName);
assertThat(resolvedRepository).isSameAs(repository);
}
use of sonia.scm.repository.Repository in project scm-review-plugin by scm-manager.
the class CommentStoreFactoryTest method shouldCreateCommentStore.
@Test
public void shouldCreateCommentStore() {
Repository repository = RepositoryTestData.createHeartOfGold("git");
repository.setId("repo");
when(dataStoreFactory.getStore(any())).thenReturn((DataStore) store);
when(dataStoreFactory.withType(any())).thenCallRealMethod();
CommentStore commentStore = storeFactory.create(repository);
assertThat(commentStore).isNotNull();
}
Aggregations