Search in sources :

Example 1 with SearchProjectsRequest

use of org.sonarqube.ws.client.component.SearchProjectsRequest 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);
    }
}
Also used : SearchProjectsRequest(org.sonarqube.ws.client.component.SearchProjectsRequest) IOException(java.io.IOException) TestRequest(org.sonar.server.ws.TestRequest)

Aggregations

IOException (java.io.IOException)1 TestRequest (org.sonar.server.ws.TestRequest)1 SearchProjectsRequest (org.sonarqube.ws.client.component.SearchProjectsRequest)1