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();
}
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");
}
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");
}
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();
}
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");
}
Aggregations