use of org.sonarqube.ws.client.HttpException in project sonarqube by SonarSource.
the class DefaultProjectRepositoriesLoaderTest method continueOnHttp404Exception.
@Test
public void continueOnHttp404Exception() {
when(wsClient.call(any(WsRequest.class))).thenThrow(new HttpException("/batch/project.protobuf?key=foo%3F", HttpURLConnection.HTTP_NOT_FOUND, ""));
ProjectRepositories proj = loader.load(PROJECT_KEY, null);
assertThat(proj.exists()).isFalse();
}
use of org.sonarqube.ws.client.HttpException in project sonarqube by SonarSource.
the class DefaultQualityProfileLoaderTest method load_tries_default_if_no_profiles_found_for_project.
@Test
public void load_tries_default_if_no_profiles_found_for_project() throws IOException {
HttpException e = new HttpException("", 404, "{\"errors\":[{\"msg\":\"No project found with key 'foo'\"}]}");
WsTestUtil.mockException(wsClient, "/api/qualityprofiles/search.protobuf?project=foo", e);
WsTestUtil.mockStream(wsClient, "/api/qualityprofiles/search.protobuf?defaults=true", createStreamOfProfiles("qp"));
underTest.load("foo");
verifyCalledPath("/api/qualityprofiles/search.protobuf?project=foo");
verifyCalledPath("/api/qualityprofiles/search.protobuf?defaults=true");
}
use of org.sonarqube.ws.client.HttpException in project sonarqube by SonarSource.
the class QualityGateCheckTest method should_fail_if_cant_call_ws_for_task.
@Test
public void should_fail_if_cant_call_ws_for_task() {
when(properties.shouldWaitForQualityGate()).thenReturn(true);
when(properties.qualityGateWaitTimeout()).thenReturn(5);
when(wsClient.call(newGetCeTaskRequest())).thenThrow(new HttpException("task-url", 400, "content"));
underTest.start();
assertThatThrownBy(() -> underTest.await()).isInstanceOf(MessageException.class).hasMessage("Failed to get CE Task status - HTTP code 400: content");
}
use of org.sonarqube.ws.client.HttpException in project sonarqube by SonarSource.
the class QualityGateCheckTest method should_fail_if_cant_call_ws_for_quality_gate.
@Test
public void should_fail_if_cant_call_ws_for_quality_gate() {
when(properties.shouldWaitForQualityGate()).thenReturn(true);
when(properties.qualityGateWaitTimeout()).thenReturn(5);
MockWsResponse ceTaskWsResponse = getCeTaskWsResponse(TaskStatus.SUCCESS);
doReturn(ceTaskWsResponse).when(wsClient).call(newGetCeTaskRequest());
doThrow(new HttpException("quality-gate-url", 400, "content")).when(wsClient).call(newGetQualityGateRequest());
underTest.start();
assertThatThrownBy(() -> underTest.await()).isInstanceOf(MessageException.class).hasMessage("Failed to get Quality Gate status - HTTP code 400: content");
}
use of org.sonarqube.ws.client.HttpException in project sonarqube by SonarSource.
the class DefaultScannerWsClientTest method create_error_msg_from_long_content.
@Test
public void create_error_msg_from_long_content() {
String content = StringUtils.repeat("mystring", 1000);
assertThat(DefaultScannerWsClient.createErrorMessage(new HttpException("url", 400, content))).hasSize(15 + 128);
}
Aggregations