use of org.sonar.server.ws.TestRequest in project sonarqube by SonarSource.
the class SearchProjectsActionTest method call.
private SearchProjectsWsResponse call(RequestBuilder requestBuilder) {
SearchProjectsRequest wsRequest = requestBuilder.build();
TestRequest httpRequest = ws.newRequest();
ofNullable(wsRequest.getFilter()).ifPresent(filter -> httpRequest.setParam(PARAM_FILTER, filter));
ofNullable(wsRequest.getSort()).ifPresent(sort -> httpRequest.setParam(SORT, sort));
ofNullable(wsRequest.getAsc()).ifPresent(asc -> httpRequest.setParam(ASCENDING, Boolean.toString(asc)));
httpRequest.setParam(PAGE, String.valueOf(wsRequest.getPage()));
httpRequest.setParam(PAGE_SIZE, String.valueOf(wsRequest.getPageSize()));
httpRequest.setParam(FACETS, Joiner.on(",").join(wsRequest.getFacets()));
httpRequest.setParam(FIELDS, Joiner.on(",").join(wsRequest.getAdditionalFields()));
return httpRequest.executeProtobuf(SearchProjectsWsResponse.class);
}
use of org.sonar.server.ws.TestRequest in project sonarqube by SonarSource.
the class AppActionTest method fail_when_branch_not_found.
@Test
public void fail_when_branch_not_found() {
ComponentDto project = db.components().insertPrivateProject();
ComponentDto branch = db.components().insertProjectBranch(project);
ComponentDto file = db.components().insertComponent(newFileDto(branch));
TestRequest request = ws.newRequest().setParam("component", file.getKey()).setParam("branch", "unknown");
assertThatThrownBy(request::execute).isInstanceOf(NotFoundException.class);
}
use of org.sonar.server.ws.TestRequest in project sonarqube by SonarSource.
the class AppActionTest method fail_when_missing_permission.
@Test
public void fail_when_missing_permission() {
ComponentDto project = db.components().insertPrivateProject();
ComponentDto file = db.components().insertComponent(newFileDto(project));
TestRequest request = ws.newRequest().setParam("component", file.getKey());
assertThatThrownBy(request::execute).isInstanceOf(ForbiddenException.class);
}
use of org.sonar.server.ws.TestRequest in project sonarqube by SonarSource.
the class ActivityActionTest method return_401_if_user_is_not_logged_in.
@Test
public void return_401_if_user_is_not_logged_in() {
ComponentDto project = db.components().insertPrivateProject();
userSession.anonymous();
TestRequest request = ws.newRequest().setParam("componentId", project.uuid());
assertThatThrownBy(() -> call(request)).isInstanceOf(UnauthorizedException.class).hasMessage("Authentication is required");
}
use of org.sonar.server.ws.TestRequest in project sonarqube by SonarSource.
the class AnalysisStatusActionTest method fail_if_both_branch_and_pullRequest_are_specified.
@Test
public void fail_if_both_branch_and_pullRequest_are_specified() {
TestRequest request = ws.newRequest().setParam(PARAM_COMPONENT, "dummy").setParam(PARAM_BRANCH, "feature1").setParam(PARAM_PULL_REQUEST, "pr1");
assertThatThrownBy(request::execute).isInstanceOf(BadRequestException.class);
}
Aggregations