Search in sources :

Example 41 with GetRequest

use of org.sonarqube.ws.client.GetRequest in project sonarqube by SonarSource.

the class WsLocalCallTest method gets_protobuf.

@Test
public void gets_protobuf() {
    WsResponse response = newWsClient(orchestrator).wsConnector().call(new GetRequest("local_ws_call/protobuf_data"));
    assertThat(response.isSuccessful()).isTrue();
}
Also used : GetRequest(org.sonarqube.ws.client.GetRequest) WsResponse(org.sonarqube.ws.client.WsResponse) Test(org.junit.Test)

Example 42 with GetRequest

use of org.sonarqube.ws.client.GetRequest in project sonarqube by SonarSource.

the class ScannerPluginInstaller method loadPluginIndex.

private String loadPluginIndex() {
    Profiler profiler = Profiler.create(LOG).startInfo("Load plugins index");
    GetRequest getRequest = new GetRequest(PLUGINS_INDEX_URL);
    String str;
    try (Reader reader = wsClient.call(getRequest).contentReader()) {
        str = IOUtils.toString(reader);
    } catch (IOException e) {
        throw new IllegalStateException(e);
    }
    profiler.stopInfo();
    return str;
}
Also used : Profiler(org.sonar.api.utils.log.Profiler) GetRequest(org.sonarqube.ws.client.GetRequest) Reader(java.io.Reader) IOException(java.io.IOException)

Example 43 with GetRequest

use of org.sonarqube.ws.client.GetRequest in project sonarqube by SonarSource.

the class DefaultSettingsLoader method load.

@Override
public Map<String, String> load(@Nullable String componentKey) {
    String url = "api/settings/values.protobuf";
    Profiler profiler = Profiler.create(LOG);
    if (componentKey != null) {
        url += "?component=" + ScannerUtils.encodeForUrl(componentKey);
        profiler.startInfo("Load settings for component '" + componentKey + "'");
    } else {
        profiler.startInfo("Load global settings");
    }
    try (InputStream is = wsClient.call(new GetRequest(url)).contentStream()) {
        ValuesWsResponse values = ValuesWsResponse.parseFrom(is);
        profiler.stopInfo();
        return toMap(values.getSettingsList());
    } catch (IOException e) {
        throw new IllegalStateException("Failed to load server settings", e);
    }
}
Also used : ValuesWsResponse(org.sonarqube.ws.Settings.ValuesWsResponse) Profiler(org.sonar.api.utils.log.Profiler) InputStream(java.io.InputStream) GetRequest(org.sonarqube.ws.client.GetRequest) IOException(java.io.IOException)

Example 44 with GetRequest

use of org.sonarqube.ws.client.GetRequest in project sonarqube by SonarSource.

the class ComponentsService method searchProjects.

public SearchProjectsWsResponse searchProjects(SearchProjectsRequest request) {
    List<String> additionalFields = request.getAdditionalFields();
    GetRequest get = new GetRequest(path(ACTION_SEARCH_PROJECTS)).setParam(PARAM_ORGANIZATION, request.getOrganization()).setParam(PARAM_FILTER, request.getFilter()).setParam(Param.FACETS, request.getFacets()).setParam(Param.SORT, request.getSort()).setParam(Param.ASCENDING, request.getAsc()).setParam(Param.PAGE, request.getPage()).setParam(Param.PAGE_SIZE, request.getPageSize()).setParam(Param.FIELDS, !additionalFields.isEmpty() ? inlineMultipleParamValue(additionalFields) : null);
    return call(get, SearchProjectsWsResponse.parser());
}
Also used : GetRequest(org.sonarqube.ws.client.GetRequest)

Example 45 with GetRequest

use of org.sonarqube.ws.client.GetRequest in project sonarqube by SonarSource.

the class MeasuresServiceTest method component_tree.

@Test
public void component_tree() {
    ComponentTreeWsRequest componentTreeRequest = new ComponentTreeWsRequest().setBaseComponentId(VALUE_BASE_COMPONENT_ID).setBaseComponentKey(VALUE_BASE_COMPONENT_KEY).setMetricKeys(VALUE_METRIC_KEYS).setStrategy(VALUE_STRATEGY).setQualifiers(VALUE_QUALIFIERS).setAdditionalFields(VALUE_ADDITIONAL_FIELDS).setSort(VALUE_SORT).setAsc(VALUE_ASC).setMetricSort(VALUE_METRIC_SORT).setPage(VALUE_PAGE).setPageSize(VALUE_PAGE_SIZE).setQuery(VALUE_QUERY).setDeveloperId(VALUE_DEVELOPER_ID).setDeveloperKey(VALUE_DEVELOPER_KEY).setMetricSortFilter(VALUE_METRIC_SORT_FILTER);
    underTest.componentTree(componentTreeRequest);
    GetRequest getRequest = serviceTester.getGetRequest();
    assertThat(serviceTester.getGetParser()).isSameAs(ComponentTreeWsResponse.parser());
    serviceTester.assertThat(getRequest).hasParam(PARAM_BASE_COMPONENT_ID, VALUE_BASE_COMPONENT_ID).hasParam(PARAM_BASE_COMPONENT_KEY, VALUE_BASE_COMPONENT_KEY).hasParam(PARAM_METRIC_KEYS, "ncloc,complexity").hasParam(PARAM_STRATEGY, VALUE_STRATEGY).hasParam(PARAM_QUALIFIERS, "FIL,PRJ").hasParam(PARAM_ADDITIONAL_FIELDS, "metrics").hasParam("s", "qualifier,metric").hasParam("asc", VALUE_ASC).hasParam(PARAM_METRIC_SORT, VALUE_METRIC_SORT).hasParam("p", VALUE_PAGE).hasParam("ps", VALUE_PAGE_SIZE).hasParam("q", VALUE_QUERY).hasParam(PARAM_DEVELOPER_ID, VALUE_DEVELOPER_ID).hasParam(PARAM_DEVELOPER_KEY, VALUE_DEVELOPER_KEY).hasParam(PARAM_METRIC_SORT_FILTER, VALUE_METRIC_SORT_FILTER).andNoOtherParam();
}
Also used : GetRequest(org.sonarqube.ws.client.GetRequest) Test(org.junit.Test)

Aggregations

GetRequest (org.sonarqube.ws.client.GetRequest)59 Test (org.junit.Test)34 WsResponse (org.sonarqube.ws.client.WsResponse)27 IOException (java.io.IOException)5 InputStream (java.io.InputStream)5 Profiler (org.sonar.api.utils.log.Profiler)5 Reader (java.io.Reader)4 HttpException (org.sonarqube.ws.client.HttpException)4 WsClient (org.sonarqube.ws.client.WsClient)4 ItUtils.newAdminWsClient (util.ItUtils.newAdminWsClient)3 File (java.io.File)2 PipedInputStream (java.io.PipedInputStream)2 PipedOutputStream (java.io.PipedOutputStream)2 ShowWsResponse (org.sonarqube.ws.ServerId.ShowWsResponse)2 ItUtils.newWsClient (util.ItUtils.newWsClient)2 Gson (com.google.gson.Gson)1 LinkedList (java.util.LinkedList)1 CheckForNull (javax.annotation.CheckForNull)1 LoadedActiveRule (org.sonar.api.batch.rule.LoadedActiveRule)1 Metric (org.sonar.api.measures.Metric)1