use of org.sonar.server.ws.TestRequest in project sonarqube by SonarSource.
the class AddProjectActionTest method executeRequest.
private void executeRequest(ComponentDto project, QualityProfileDto qualityProfile) {
TestRequest request = ws.newRequest().setParam("projectUuid", project.uuid()).setParam("profileKey", qualityProfile.getKey());
request.execute();
}
use of org.sonar.server.ws.TestRequest in project sonarqube by SonarSource.
the class RuleQueryFactoryTest method execute.
private RuleQuery execute(String... paramsKeyAndValue) {
WsActionTester ws = new WsActionTester(fakeAction);
TestRequest request = ws.newRequest();
for (int i = 0; i < paramsKeyAndValue.length; i += 2) {
request.setParam(paramsKeyAndValue[i], paramsKeyAndValue[i + 1]);
}
request.execute();
return fakeAction.getRuleQuery();
}
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(), p -> request.setParam(PARAM_ORGANIZATION, p));
setNullable(wsRequest.getLanguage(), p -> request.setParam(PARAM_LANGUAGE, p));
setNullable(wsRequest.getQualifiers(), p -> request.setParam(PARAM_QUALIFIERS, Joiner.on(",").join(p)));
setNullable(wsRequest.getQuery(), p -> request.setParam(TEXT_QUERY, p));
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 SearchProjectsActionTest method call.
private SearchProjectsWsResponse call(SearchProjectsRequest.Builder requestBuilder) {
SearchProjectsRequest wsRequest = requestBuilder.build();
TestRequest httpRequest = ws.newRequest().setMediaType(MediaTypes.PROTOBUF);
ofNullable(wsRequest.getOrganization()).ifPresent(organization -> httpRequest.setParam(PARAM_ORGANIZATION, organization));
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()));
try {
return SearchProjectsWsResponse.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 EditCommentActionTest method call.
private TestResponse call(@Nullable String commentKey, @Nullable String commentText) {
TestRequest request = tester.newRequest();
setNullable(commentKey, comment -> request.setParam("comment", comment));
setNullable(commentText, comment -> request.setParam("text", comment));
return request.execute();
}
Aggregations