Search in sources :

Example 51 with GetRequest

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

the class QualityProfilesServiceTest method search.

@Test
public void search() {
    underTest.search(new SearchWsRequest().setDefaults(true).setProjectKey("project").setLanguage("language").setProfileName("profile"));
    GetRequest getRequest = serviceTester.getGetRequest();
    assertThat(serviceTester.getGetParser()).isSameAs(QualityProfiles.SearchWsResponse.parser());
    serviceTester.assertThat(getRequest).hasParam(PARAM_DEFAULTS, true).hasParam(PARAM_PROJECT_KEY, "project").hasParam(PARAM_LANGUAGE, "language").hasParam(PARAM_PROFILE_NAME, "profile").andNoOtherParam();
}
Also used : GetRequest(org.sonarqube.ws.client.GetRequest) Test(org.junit.Test)

Example 52 with GetRequest

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

the class RulesServiceTest method search.

@Test
public void search() {
    underTest.search(new SearchWsRequest().setActivation(ACTIVATION_VALUE).setActiveSeverities(ACTIVE_SEVERITIES_VALUE).setAsc(ASC_VALUE).setAvailableSince(AVAILABLE_SINCE_VALUE).setFields(FIELDS_VALUE).setFacets(FACETS_VALUE).setInheritance(INHERITANCE_VALUE).setIsTemplate(IS_TEMPLATE_VALUE).setLanguages(LANGUAGES_VALUE).setPage(PAGE_VALUE).setPageSize(PAGE_SIZE_VALUE).setQuery(QUERY_VALUE).setQProfile(QPROFILE_VALUE).setRepositories(REPOSITORIES_VALUE).setRuleKey(RULE_KEY_VALUE).setSort(SORT_VALUE).setSeverities(SEVERITIES_VALUE).setStatuses(STATUSES_VALUE).setTags(TAGS_VALUE).setTemplateKey(TEMPLATE_KEY_VALUE).setTypes(TYPES_VALUE));
    assertThat(serviceTester.getGetParser()).isSameAs(SearchResponse.parser());
    GetRequest getRequest = serviceTester.getGetRequest();
    serviceTester.assertThat(getRequest).hasPath("search").hasParam(PARAM_ACTIVATION, ACTIVATION_VALUE).hasParam(PARAM_ACTIVE_SEVERITIES, ACTIVE_SEVERITIES_VALUE_INLINED).hasParam("asc", ASC_VALUE).hasParam(PARAM_AVAILABLE_SINCE, AVAILABLE_SINCE_VALUE).hasParam("f", FIELDS_VALUE_INLINED).hasParam("facets", FACETS_VALUE_INLINED).hasParam(PARAM_INHERITANCE, INHERITANCE_VALUE_INLINED).hasParam(PARAM_IS_TEMPLATE, IS_TEMPLATE_VALUE).hasParam("p", PAGE_VALUE).hasParam("ps", PAGE_SIZE_VALUE).hasParam("q", QUERY_VALUE).hasParam(PARAM_QPROFILE, QPROFILE_VALUE).hasParam(PARAM_REPOSITORIES, REPOSITORIES_VALUE_INLINED).hasParam(PARAM_RULE_KEY, RULE_KEY_VALUE).hasParam(PARAM_LANGUAGES, LANGUAGES_VALUE_INLINED).hasParam("s", SORT_VALUE).hasParam(PARAM_SEVERITIES, SEVERITIES_VALUE_INLINED).hasParam(PARAM_STATUSES, STATUSES_VALUE_INLINED).hasParam(PARAM_TAGS, TAGS_VALUE_INLINED).hasParam(PARAM_TEMPLATE_KEY, TEMPLATE_KEY_VALUE).hasParam(PARAM_TYPES, TYPES_VALUE_INLINED).andNoOtherParam();
}
Also used : GetRequest(org.sonarqube.ws.client.GetRequest) Test(org.junit.Test)

Example 53 with GetRequest

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

the class SettingsServiceTest method values.

@Test
public void values() {
    underTest.values(ValuesRequest.builder().setKeys("sonar.debt,sonar.issue").setComponent("KEY").build());
    GetRequest getRequest = serviceTester.getGetRequest();
    assertThat(serviceTester.getGetParser()).isSameAs(ValuesWsResponse.parser());
    serviceTester.assertThat(getRequest).hasParam(PARAM_KEYS, "sonar.debt,sonar.issue").hasParam(PARAM_COMPONENT, "KEY").andNoOtherParam();
}
Also used : GetRequest(org.sonarqube.ws.client.GetRequest) Test(org.junit.Test)

Example 54 with GetRequest

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

the class UpgradeTest method checkUrlIsReturningNotFound.

private void checkUrlIsReturningNotFound(String url) {
    WsResponse response = newWsClient(orchestrator).wsConnector().call(new GetRequest(url));
    assertThat(response.code()).isEqualTo(HttpURLConnection.HTTP_NOT_FOUND);
}
Also used : GetRequest(org.sonarqube.ws.client.GetRequest) WsResponse(org.sonarqube.ws.client.WsResponse)

Example 55 with GetRequest

use of org.sonarqube.ws.client.GetRequest in project sonar-scanner-jenkins by SonarSource.

the class HttpClient method getHttp.

public String getHttp(String url, @Nullable String token) {
    String baseUrl = StringUtils.substringBeforeLast(url, "/");
    String path = StringUtils.substringAfterLast(url, "/");
    HttpConnector httpConnector = HttpConnector.newBuilder().userAgent("Scanner for Jenkins").url(baseUrl).credentials(token, null).build();
    WsResponse response = httpConnector.call(new GetRequest(path));
    response.failIfNotSuccessful();
    return response.content();
}
Also used : HttpConnector(org.sonarqube.ws.client.HttpConnector) GetRequest(org.sonarqube.ws.client.GetRequest) WsResponse(org.sonarqube.ws.client.WsResponse)

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