public WsResponse call(WsRequest request) {
    checkState(!globalMode.isMediumTest(), "No WS call should be made in medium test mode");
    WsResponse response = target.wsConnector().call(request);
    failIfUnauthorized(response);
    checkAuthenticationWarnings(response);
    return response;
  }
@Test
  public void call_whenInvalidCredentials_shouldFailWithMsg() {
    WsRequest request = newRequest();
    server.stubFor(get(urlEqualTo(URL_ENDPOINT))
      .willReturn(aResponse()
        .withStatus(401)
        .withBody("Invalid credentials")));

    DefaultScannerWsClient client = new DefaultScannerWsClient(wsClient, /* credentials are configured */true,
      new GlobalAnalysisMode(new ScannerProperties(Collections.emptyMap())), analysisWarnings);
    assertThatThrownBy(() -> client.call(request))
      .isInstanceOf(MessageException.class)
      .hasMessage("Not authorized. Please check the user token in the property 'sonar.token' or the credentials in the properties 'sonar.login' and 'sonar.password'.");
  }