Search in sources :

Example 1 with GetRequest

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

the class DefaultServerLineHashesLoader method loadHashesFromWs.

private String loadHashesFromWs(String fileKey) {
    Profiler profiler = Profiler.createIfDebug(Loggers.get(getClass())).addContext("file", fileKey).startDebug("Load line hashes");
    GetRequest getRequest = new GetRequest("/api/sources/hash?key=" + ScannerUtils.encodeForUrl(fileKey));
    Reader reader = wsClient.call(getRequest).contentReader();
    try {
        return IOUtils.toString(reader);
    } catch (IOException e) {
        throw new IllegalStateException(e);
    } finally {
        profiler.stopDebug();
    }
}
Also used : Profiler(org.sonar.api.utils.log.Profiler) GetRequest(org.sonarqube.ws.client.GetRequest) Reader(java.io.Reader) IOException(java.io.IOException)

Example 2 with GetRequest

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

the class DefaultQualityProfileLoader method loadResource.

private List<QualityProfile> loadResource(String url) {
    GetRequest getRequest = new GetRequest(url);
    InputStream is = wsClient.call(getRequest).contentStream();
    SearchWsResponse profiles = null;
    try {
        profiles = SearchWsResponse.parseFrom(is);
    } catch (IOException e) {
        throw new IllegalStateException("Failed to load quality profiles", e);
    } finally {
        IOUtils.closeQuietly(is);
    }
    List<QualityProfile> profilesList = profiles.getProfilesList();
    if (profilesList == null || profilesList.isEmpty()) {
        throw MessageException.of("No quality profiles have been found, you probably don't have any language plugin installed.");
    }
    return profilesList;
}
Also used : InputStream(java.io.InputStream) GetRequest(org.sonarqube.ws.client.GetRequest) QualityProfile(org.sonarqube.ws.QualityProfiles.SearchWsResponse.QualityProfile) SearchWsResponse(org.sonarqube.ws.QualityProfiles.SearchWsResponse) IOException(java.io.IOException)

Example 3 with GetRequest

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

the class DefaultServerIssuesLoader method load.

@Override
public void load(String componentKey, Function<ServerIssue, Void> consumer) {
    GetRequest getRequest = new GetRequest("/batch/issues.protobuf?key=" + ScannerUtils.encodeForUrl(componentKey));
    InputStream is = wsClient.call(getRequest).contentStream();
    parseIssues(is, consumer);
}
Also used : InputStream(java.io.InputStream) GetRequest(org.sonarqube.ws.client.GetRequest)

Example 4 with GetRequest

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

the class IssuesServiceTest method changelog.

@Test
public void changelog() {
    underTest.changelog("ABCD");
    GetRequest getRequest = serviceTester.getGetRequest();
    assertThat(serviceTester.getGetParser()).isSameAs(Issues.ChangelogWsResponse.parser());
    serviceTester.assertThat(getRequest).hasParam("issue", "ABCD").andNoOtherParam();
}
Also used : GetRequest(org.sonarqube.ws.client.GetRequest) Test(org.junit.Test)

Example 5 with GetRequest

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

the class PermissionsServiceTest method searchProjectPermissions_does_GET_on_Ws_search_project_permissions.

@Test
public void searchProjectPermissions_does_GET_on_Ws_search_project_permissions() {
    underTest.searchProjectPermissions(new SearchProjectPermissionsWsRequest().setProjectId(PROJECT_ID_VALUE).setProjectKey(PROJECT_KEY_VALUE).setQualifier(QUALIFIER_VALUE).setPage(PAGE_VALUE).setPageSize(PAGE_SIZE_VALUE).setQuery(QUERY_VALUE));
    assertThat(serviceTester.getGetParser()).isSameAs(WsPermissions.SearchProjectPermissionsWsResponse.parser());
    GetRequest getRequest = serviceTester.getGetRequest();
    serviceTester.assertThat(getRequest).hasPath("search_project_permissions").hasParam(PARAM_PROJECT_ID, PROJECT_ID_VALUE).hasParam(PARAM_PROJECT_KEY, PROJECT_KEY_VALUE).hasParam(PARAM_QUALIFIER, QUALIFIER_VALUE).hasParam(PARAM_P, PAGE_VALUE).hasParam(PARAM_PS, PAGE_SIZE_VALUE).hasParam(PARAM_Q, QUERY_VALUE).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