use of org.sonarsource.sonarlint.core.client.api.connected.ValidationResult in project sonarlint-core by SonarSource.
the class WsHelperImplTest method testConnectionOrganizationNotFound.
@Test
public void testConnectionOrganizationNotFound() throws Exception {
WsClientTestUtils.addResponse(client, "api/system/status", "{\"id\": \"20160308094653\",\"version\": \"6.3\",\"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}");
WsClientTestUtils.addStreamResponse(client, "api/organizations/search.protobuf?organizations=myOrg&ps=500&p=1", "/orgs/empty.pb");
ValidationResult validation = WsHelperImpl.validateConnection(client, "myOrg");
assertThat(validation.success()).isFalse();
assertThat(validation.message()).isEqualTo("No organizations found for key: myOrg");
}
use of org.sonarsource.sonarlint.core.client.api.connected.ValidationResult in project sonarlint-core by SonarSource.
the class WsHelperImplTest method testConnection_ok_with_org.
@Test
public void testConnection_ok_with_org() throws Exception {
WsClientTestUtils.addResponse(client, "api/system/status", "{\"id\": \"20160308094653\",\"version\": \"6.3\",\"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}");
WsClientTestUtils.addStreamResponse(client, "api/organizations/search.protobuf?organizations=henryju-github&ps=500&p=1", "/orgs/single.pb");
WsClientTestUtils.addStreamResponse(client, "api/organizations/search.protobuf?organizations=henryju-github&ps=500&p=2", "/orgs/empty.pb");
ValidationResult validation = WsHelperImpl.validateConnection(client, "henryju-github");
assertThat(validation.success()).isTrue();
}
use of org.sonarsource.sonarlint.core.client.api.connected.ValidationResult in project sonarlint-core by SonarSource.
the class AuthenticationCheckerTest method test_connection_issue.
@Test
public void test_connection_issue() {
SonarLintWsClient wsClient = WsClientTestUtils.createMock();
WsClientTestUtils.addFailedResponse(wsClient, "api/authentication/validate?format=json", 500, "Foo");
AuthenticationChecker checker = new AuthenticationChecker(wsClient);
ValidationResult validationResult = checker.validateCredentials();
assertThat(validationResult.success()).isFalse();
assertThat(validationResult.message()).isEqualTo("HTTP Connection failed (500): Foo");
}
use of org.sonarsource.sonarlint.core.client.api.connected.ValidationResult in project sonarlint-core by SonarSource.
the class AuthenticationCheckerTest method test_authentication_ko.
@Test
public void test_authentication_ko() {
SonarLintWsClient wsClient = WsClientTestUtils.createMockWithResponse("api/authentication/validate?format=json", "{\"valid\": false}");
AuthenticationChecker checker = new AuthenticationChecker(wsClient);
ValidationResult validationResult = checker.validateCredentials();
assertThat(validationResult.success()).isFalse();
assertThat(validationResult.message()).isEqualTo("Authentication failed");
}
use of org.sonarsource.sonarlint.core.client.api.connected.ValidationResult in project sonarlint-core by SonarSource.
the class ServerVersionAndStatusCheckerTest method incompatibleVersion.
@Test
public void incompatibleVersion() throws Exception {
SonarLintWsClient wsClient = WsClientTestUtils.createMockWithResponse("api/system/status", "{\"id\": \"20160308094653\",\"version\": \"4.5\",\"status\": \"UP\"}");
ServerVersionAndStatusChecker checker = new ServerVersionAndStatusChecker(wsClient);
ValidationResult validateStatusAndVersion = checker.validateStatusAndVersion();
assertThat(validateStatusAndVersion.success()).isFalse();
assertThat(validateStatusAndVersion.message()).isEqualTo("SonarQube server has version 4.5. Version should be greater or equal to 5.6");
}
Aggregations