Search in sources :

Example 1 with ValidationResult

use of org.sonarsource.sonarlint.core.client.api.connected.ValidationResult in project sonarlint-core by SonarSource.

the class WsHelperImplTest method testConnection_ok.

@Test
public void testConnection_ok() throws Exception {
    WsClientTestUtils.addResponse(client, "api/system/status", "{\"id\": \"20160308094653\",\"version\": \"5.6\",\"status\": \"UP\"}");
    String content = Resources.toString(this.getClass().getResource(RESPONSE_FILE_LTS), StandardCharsets.UTF_8);
    WsClientTestUtils.addResponse(client, PluginListDownloader.WS_PATH_LTS, content);
    WsClientTestUtils.addResponse(client, "api/authentication/validate?format=json", "{\"valid\": true}");
    ValidationResult validation = WsHelperImpl.validateConnection(client, null);
    assertThat(validation.success()).isTrue();
}
Also used : ValidationResult(org.sonarsource.sonarlint.core.client.api.connected.ValidationResult) Test(org.junit.Test)

Example 2 with ValidationResult

use of org.sonarsource.sonarlint.core.client.api.connected.ValidationResult in project sonarlint-core by SonarSource.

the class WsHelperImplTest method testConnectionUnsupportedOrganizations.

@Test
public void testConnectionUnsupportedOrganizations() throws Exception {
    WsClientTestUtils.addResponse(client, "api/system/status", "{\"id\": \"20160308094653\",\"version\": \"5.6\",\"status\": \"UP\"}");
    String content = Resources.toString(this.getClass().getResource(RESPONSE_FILE_LTS), StandardCharsets.UTF_8);
    WsClientTestUtils.addResponse(client, PluginListDownloader.WS_PATH_LTS, content);
    WsClientTestUtils.addResponse(client, "api/authentication/validate?format=json", "{\"valid\": true}");
    ValidationResult validation = WsHelperImpl.validateConnection(client, "myOrg");
    assertThat(validation.success()).isFalse();
    assertThat(validation.message()).isEqualTo("No organization support for this server version: 5.6");
}
Also used : ValidationResult(org.sonarsource.sonarlint.core.client.api.connected.ValidationResult) Test(org.junit.Test)

Example 3 with ValidationResult

use of org.sonarsource.sonarlint.core.client.api.connected.ValidationResult in project sonarlint-core by SonarSource.

the class AuthenticationCheckerTest method test_authentication_ok.

@Test
public void test_authentication_ok() {
    SonarLintWsClient wsClient = WsClientTestUtils.createMockWithResponse("api/authentication/validate?format=json", "{\"valid\": true}");
    AuthenticationChecker checker = new AuthenticationChecker(wsClient);
    ValidationResult validationResult = checker.validateCredentials();
    assertThat(validationResult.success()).isTrue();
    assertThat(validationResult.message()).isEqualTo("Authentication successful");
}
Also used : ValidationResult(org.sonarsource.sonarlint.core.client.api.connected.ValidationResult) SonarLintWsClient(org.sonarsource.sonarlint.core.container.connected.SonarLintWsClient) Test(org.junit.Test)

Example 4 with ValidationResult

use of org.sonarsource.sonarlint.core.client.api.connected.ValidationResult in project sonarlint-core by SonarSource.

the class ConnectedModeRequirementsTest method dontCheckMinimalPluginVersionWhenValidatingConnection.

@Test
public void dontCheckMinimalPluginVersionWhenValidatingConnection() throws IOException {
    ValidationResult result = new WsHelperImpl().validateConnection(config());
    assertThat(result.success()).isTrue();
}
Also used : WsHelperImpl(org.sonarsource.sonarlint.core.WsHelperImpl) ValidationResult(org.sonarsource.sonarlint.core.client.api.connected.ValidationResult) Test(org.junit.Test)

Example 5 with ValidationResult

use of org.sonarsource.sonarlint.core.client.api.connected.ValidationResult in project sonarlint-core by SonarSource.

the class WsHelperImplTest method testUnsupportedServer.

@Test
public void testUnsupportedServer() {
    WsClientTestUtils.addResponse(client, "api/system/status", "{\"id\": \"20160308094653\",\"version\": \"4.5\",\"status\": \"UP\"}");
    when(serverChecker.checkVersionAndStatus()).thenThrow(UnsupportedServerException.class);
    ValidationResult validation = WsHelperImpl.validateConnection(client, null);
    assertThat(validation.success()).isFalse();
    assertThat(validation.message()).isEqualTo("SonarQube server has version 4.5. Version should be greater or equal to 5.6");
}
Also used : ValidationResult(org.sonarsource.sonarlint.core.client.api.connected.ValidationResult) Test(org.junit.Test)

Aggregations

ValidationResult (org.sonarsource.sonarlint.core.client.api.connected.ValidationResult)13 Test (org.junit.Test)11 SonarLintWsClient (org.sonarsource.sonarlint.core.container.connected.SonarLintWsClient)5 CommitStepException (com.intellij.ide.wizard.CommitStepException)1 SonarQubeServer (org.sonarlint.intellij.config.global.SonarQubeServer)1 ConnectionTestTask (org.sonarlint.intellij.tasks.ConnectionTestTask)1 WsHelperImpl (org.sonarsource.sonarlint.core.WsHelperImpl)1 UnsupportedServerException (org.sonarsource.sonarlint.core.client.api.exceptions.UnsupportedServerException)1 AuthenticationChecker (org.sonarsource.sonarlint.core.container.connected.validate.AuthenticationChecker)1 DefaultValidationResult (org.sonarsource.sonarlint.core.container.connected.validate.DefaultValidationResult)1 ServerVersionAndStatusChecker (org.sonarsource.sonarlint.core.container.connected.validate.ServerVersionAndStatusChecker)1 Version (org.sonarsource.sonarlint.core.plugin.Version)1 ServerInfos (org.sonarsource.sonarlint.core.proto.Sonarlint.ServerInfos)1 ProgressWrapper (org.sonarsource.sonarlint.core.util.ProgressWrapper)1