use of org.sonarlint.intellij.tasks.ConnectionTestTask in project sonarlint-intellij by SonarSource.
the class AuthStep method checkConnection.
private void checkConnection() throws CommitStepException {
SonarQubeServer tmpServer = model.createServerWithoutOrganization();
ConnectionTestTask test = new ConnectionTestTask(tmpServer);
ProgressManager.getInstance().run(test);
ValidationResult r = test.result();
String msg = "Failed to connect to the server. Please check the configuration.";
if (test.getException() != null) {
if (test.getException().getMessage() != null) {
msg = msg + " Error: " + test.getException().getMessage();
}
throw new CommitStepException(msg);
} else if (!r.success()) {
throw new CommitStepException(msg + " Cause: " + r.message());
}
}
use of org.sonarlint.intellij.tasks.ConnectionTestTask in project sonarlint-intellij by SonarSource.
the class ConnectionTestTaskTest method fail_if_no_connection.
@Test
public void fail_if_no_connection() {
SonarQubeServer server = SonarQubeServer.newBuilder().setHostUrl("invalid_url").build();
ConnectionTestTask task = new ConnectionTestTask(server);
ProgressIndicator progress = mock(ProgressIndicator.class);
task.run(progress);
verify(progress).setIndeterminate(true);
assertThat(task.getException()).isNotNull();
assertThat(task.result()).isNull();
verify(globalLogOutput).logError(eq("Connection test failed"), any(Throwable.class));
}
Aggregations