use of org.sonar.server.ws.TestRequest in project sonarqube by SonarSource.
the class ProvisionedActionTest method provisioned_projects_with_correct_pagination.
@Test
public void provisioned_projects_with_correct_pagination() throws Exception {
OrganizationDto org = db.organizations().insert();
for (int i = 1; i <= 10; i++) {
db.components().insertComponent(newProvisionedProject(org, String.valueOf(i)));
}
userSessionRule.logIn().addPermission(PROVISION_PROJECTS, org);
TestRequest request = underTest.newRequest().setParam(PARAM_ORGANIZATION, org.getKey()).setParam(Param.PAGE, "3").setParam(Param.PAGE_SIZE, "4");
String jsonOutput = request.execute().getInput();
assertThat(StringUtils.countMatches(jsonOutput, "provisioned-uuid-")).isEqualTo(2);
}
use of org.sonar.server.ws.TestRequest in project sonarqube by SonarSource.
the class CreateEventActionTest method call.
private CreateEventResponse call(CreateEventRequest.Builder requestBuilder) {
CreateEventRequest request = requestBuilder.build();
TestRequest httpRequest = ws.newRequest().setMethod(POST.name()).setMediaType(MediaTypes.PROTOBUF);
httpRequest.setParam(PARAM_CATEGORY, request.getCategory().name()).setParam(PARAM_NAME, request.getName()).setParam(PARAM_ANALYSIS, request.getAnalysis());
try {
return CreateEventResponse.parseFrom(httpRequest.execute().getInputStream());
} catch (IOException e) {
throw Throwables.propagate(e);
}
}
use of org.sonar.server.ws.TestRequest in project sonarqube by SonarSource.
the class SearchActionTest method call.
private SearchWsResponse call(SearchWsRequest wsRequest) {
TestRequest request = ws.newRequest().setMediaType(PROTOBUF);
setNullable(wsRequest.getOrganization(), organization -> request.setParam(PARAM_ORGANIZATION, organization));
List<String> qualifiers = wsRequest.getQualifiers();
if (!qualifiers.isEmpty()) {
request.setParam(ComponentsWsParameters.PARAM_QUALIFIERS, Joiner.on(",").join(qualifiers));
}
setNullable(wsRequest.getQuery(), query -> request.setParam(TEXT_QUERY, query));
setNullable(wsRequest.getPage(), page -> request.setParam(PAGE, String.valueOf(page)));
setNullable(wsRequest.getPageSize(), pageSize -> request.setParam(PAGE_SIZE, String.valueOf(pageSize)));
try {
return SearchWsResponse.parseFrom(request.execute().getInputStream());
} catch (IOException e) {
throw Throwables.propagate(e);
}
}
use of org.sonar.server.ws.TestRequest in project sonarqube by SonarSource.
the class SearchActionTest method call.
private SearchResponse call(@Nullable String textQuery, @Nullable Integer pageSize) {
TestRequest request = ws.newRequest().setMediaType(PROTOBUF);
setNullable(textQuery, s -> request.setParam("q", s));
setNullable(pageSize, ps -> request.setParam("ps", ps.toString()));
try {
return SearchResponse.parseFrom(request.execute().getInputStream());
} catch (IOException e) {
throw Throwables.propagate(e);
}
}
use of org.sonar.server.ws.TestRequest in project sonarqube by SonarSource.
the class SearchActionTest method call.
private SearchResponse call(SearchRequest wsRequest) {
TestRequest request = ws.newRequest().setMediaType(PROTOBUF).setMethod(POST.name());
setNullable(wsRequest.getProject(), project -> request.setParam(PARAM_PROJECT, project));
setNullable(wsRequest.getCategory(), category -> request.setParam(PARAM_CATEGORY, category.name()));
setNullable(wsRequest.getPage(), page -> request.setParam(Param.PAGE, String.valueOf(page)));
setNullable(wsRequest.getPageSize(), pageSize -> request.setParam(Param.PAGE_SIZE, String.valueOf(pageSize)));
try {
return SearchResponse.parseFrom(request.execute().getInputStream());
} catch (IOException e) {
throw Throwables.propagate(e);
}
}
Aggregations