Skip to content

Commit

Permalink
Fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
nquinquenel committed Dec 10, 2024
1 parent 63de5a6 commit daa151e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ public Optional<ServerApi> getServerApi(String connectionId) {
}

private boolean checkIfBearerIsSupported(EndpointParams params) {
if (params.isSonarCloud()) {
return true;
}
var httpClient = awareHttpClientProvider.getHttpClient();
var cancelMonitor = new SonarLintCancelMonitor();
var serverApi = new ServerApi(params, httpClient);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@ void getServerApi_for_sonarqube() {
void getServerApi_for_sonarqube_notConnected() {
var httpClient = mock(HttpClient.class);
when(httpClientProvider.getHttpClientWithPreemptiveAuth("token", false)).thenReturn(httpClient);
when(awareHttpClientProvider.getHttpClient()).thenReturn(httpClient);
var httpResponse = mock(HttpClient.Response.class);
when(httpResponse.isSuccessful()).thenReturn(true);
when(httpResponse.bodyAsString()).thenReturn("{\"id\": \"20160308094653\",\"version\": \"10.0\",\"status\": \"UP\"}");
when(httpClient.getAsync("sq_notConnected/api/system/status")).thenReturn(CompletableFuture.completedFuture(httpResponse));

var serverApi = underTest.getServerApi("sq_notConnected", null, "token");
assertThat(serverApi.isSonarCloud()).isFalse();
Expand Down

0 comments on commit daa151e

Please sign in to comment.