Search in sources :

Example 16 with HttpException

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

the class DefaultScannerWsClientTest method create_error_msg_from_html.

@Test
public void create_error_msg_from_html() {
    String content = "<!DOCTYPE html><html>something</html>";
    assertThat(DefaultScannerWsClient.createErrorMessage(new HttpException("url", 400, content))).isEqualTo("HTTP code 400");
}
Also used : HttpException(org.sonarqube.ws.client.HttpException) Test(org.junit.Test)

Example 17 with HttpException

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

the class DefaultScannerWsClientTest method create_error_msg_from_json.

@Test
public void create_error_msg_from_json() {
    String content = "{\"errors\":[{\"msg\":\"missing scan permission\"}, {\"msg\":\"missing another permission\"}]}";
    assertThat(DefaultScannerWsClient.createErrorMessage(new HttpException("url", 400, content))).isEqualTo("missing scan permission, missing another permission");
}
Also used : HttpException(org.sonarqube.ws.client.HttpException) Test(org.junit.Test)

Aggregations

HttpException (org.sonarqube.ws.client.HttpException)17 Test (org.junit.Test)11 WsResponse (org.sonarqube.ws.client.WsResponse)6 MessageException (org.sonar.api.utils.MessageException)5 GetRequest (org.sonarqube.ws.client.GetRequest)4 MockWsResponse (org.sonarqube.ws.client.MockWsResponse)3 WsRequest (org.sonarqube.ws.client.WsRequest)3 IOException (java.io.IOException)2 InputStream (java.io.InputStream)2 File (java.io.File)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 Profiler (org.sonar.api.utils.log.Profiler)1 Ce (org.sonarqube.ws.Ce)1 Settings (org.sonarqube.ws.Settings)1 PostRequest (org.sonarqube.ws.client.PostRequest)1 OrganizationService (org.sonarqube.ws.client.organization.OrganizationService)1