use of org.sonarqube.ws.client.GetRequest in project sonarqube by SonarSource.
the class WsLocalCallTest method propagates_authorization_rights.
@Test
public void propagates_authorization_rights() {
WsClient wsClient = WsClientFactories.getDefault().newClient(HttpConnector.newBuilder().url(orchestrator.getServer().getUrl()).credentials("admin", "admin").build());
WsResponse response = wsClient.wsConnector().call(new GetRequest("local_ws_call/require_permission"));
assertThat(response.isSuccessful()).isTrue();
}
use of org.sonarqube.ws.client.GetRequest in project sonarqube by SonarSource.
the class WsTest method gets_json.
@Test
public void gets_json() {
WsResponse response = newWsClient(orchestrator).wsConnector().call(new GetRequest("api/issues/search.json"));
assertThat(response.isSuccessful()).isTrue();
assertThat(response.contentType()).contains("application/json");
}
use of org.sonarqube.ws.client.GetRequest in project sonarqube by SonarSource.
the class WsTest method fail_on_unknown_extension.
/**
* SONAR-7484
*/
@Test
public void fail_on_unknown_extension() {
WsResponse response = newWsClient(orchestrator).wsConnector().call(new GetRequest("api/issues/search.unknown"));
assertThat(response.isSuccessful()).isFalse();
assertThat(response.code()).isEqualTo(HTTP_BAD_REQUEST);
}
use of org.sonarqube.ws.client.GetRequest in project sonarqube by SonarSource.
the class WsTest method gets_protobuf.
@Test
public void gets_protobuf() {
WsResponse response = newWsClient(orchestrator).wsConnector().call(new GetRequest("api/issues/search.protobuf"));
assertThat(response.isSuccessful()).isTrue();
assertThat(response.contentType()).contains("application/x-protobuf");
}
use of org.sonarqube.ws.client.GetRequest in project sonarqube by SonarSource.
the class DefaultMetricsRepositoryLoader method loadFromPaginatedWs.
private void loadFromPaginatedWs(List<Metric> metrics) throws IOException {
int page = 1;
WsMetricsResponse response;
do {
GetRequest getRequest = new GetRequest(METRICS_SEARCH_URL + page);
try (Reader reader = wsClient.call(getRequest).contentReader()) {
response = GsonHelper.create().fromJson(reader, WsMetricsResponse.class);
for (WsMetric metric : response.metrics) {
metrics.add(new Metric.Builder(metric.getKey(), metric.getName(), ValueType.valueOf(metric.getType())).create().setDirection(metric.getDirection()).setQualitative(metric.isQualitative()).setUserManaged(false).setDescription(metric.getDescription()).setUuid(metric.getUuid()));
}
}
page++;
} while (response.getP() < (response.getTotal() / response.getPs() + 1));
}
Aggregations