use of org.sonarsource.sonarlint.core.serverapi.ServerApiHelper in project sonarlint-core by SonarSource.
the class ConnectionValidatorTests method testConnection_ok_with_org.
@Test
void testConnection_ok_with_org() throws Exception {
var underTest = new ConnectionValidator(new ServerApiHelper(mockServer.endpointParams("henryju-github"), MockWebServerExtension.httpClient()));
mockServer.addStringResponse("/api/system/status", "{\"id\": \"20160308094653\",\"version\": \"7.9\",\"status\": \"UP\"}");
mockServer.addStringResponse("/api/authentication/validate?format=json", "{\"valid\": true}");
mockServer.addResponseFromResource("/api/organizations/search.protobuf?organizations=henryju-github&ps=500&p=1", "/orgs/single.pb");
mockServer.addResponseFromResource("/api/organizations/search.protobuf?organizations=henryju-github&ps=500&p=2", "/orgs/empty.pb");
var futureValidation = underTest.validateConnection();
var validation = futureValidation.get();
assertThat(validation.success()).isTrue();
}
use of org.sonarsource.sonarlint.core.serverapi.ServerApiHelper in project sonarlint-core by SonarSource.
the class ConnectionValidatorTests method testUnsupportedServer.
@Test
void testUnsupportedServer() throws ExecutionException, InterruptedException {
var underTest = new ConnectionValidator(new ServerApiHelper(mockServer.endpointParams(), MockWebServerExtension.httpClient()));
mockServer.addStringResponse("/api/system/status", "{\"id\": \"20160308094653\",\"version\": \"6.7\",\"status\": \"UP\"}");
when(serverChecker.checkVersionAndStatus()).thenThrow(UnsupportedServerException.class);
var futureValidation = underTest.validateConnection();
var validation = futureValidation.get();
assertThat(validation.success()).isFalse();
assertThat(validation.message()).isEqualTo("SonarQube server has version 6.7. Version should be greater or equal to 7.9");
}
use of org.sonarsource.sonarlint.core.serverapi.ServerApiHelper in project sonarlint-core by SonarSource.
the class ConnectionValidatorTests method testResponseError.
@Test
void testResponseError() throws ExecutionException, InterruptedException {
var underTest = new ConnectionValidator(new ServerApiHelper(mockServer.endpointParams(), MockWebServerExtension.httpClient()));
mockServer.addStringResponse("/api/system/status", "{\"id\": }");
var futureValidation = underTest.validateConnection();
var validation = futureValidation.get();
assertThat(validation.success()).isFalse();
assertThat(validation.message()).isEqualTo("Unable to parse server infos from: {\"id\": }");
}
use of org.sonarsource.sonarlint.core.serverapi.ServerApiHelper in project sonarlint-core by SonarSource.
the class ConnectedSonarLintEngineImpl method downloadServerIssues.
private List<ServerIssue> downloadServerIssues(EndpointParams endpoint, HttpClient client, ProjectBinding projectBinding, String ideFilePath, boolean fetchTaintVulnerabilities, @Nullable String branchName, ProgressMonitor progress) {
var updater = partialUpdaterFactory.create();
var configuration = storageReader.readProjectConfig(projectBinding.projectKey());
updater.updateFileIssues(new ServerApiHelper(endpoint, client), projectBinding, configuration, ideFilePath, fetchTaintVulnerabilities, branchName, progress);
return getServerIssues(projectBinding, ideFilePath);
}
use of org.sonarsource.sonarlint.core.serverapi.ServerApiHelper in project sonarlint-core by SonarSource.
the class ConnectedSonarLintEngineImpl method updateProject.
@Override
public void updateProject(EndpointParams endpoint, HttpClient client, String projectKey, boolean fetchTaintVulnerabilities, @Nullable String branchName, @Nullable ClientProgressMonitor monitor) {
requireNonNull(endpoint);
requireNonNull(projectKey);
setLogging(null);
var globalStorageStatus = globalStatusReader.read();
if (globalStorageStatus == null || globalStorageStatus.isStale()) {
throw new StorageException("Missing or outdated storage for connection '" + globalConfig.getConnectionId() + "'");
}
projectStorageUpdateExecutor.update(new ServerApiHelper(endpoint, client), projectKey, fetchTaintVulnerabilities, branchName, new ProgressMonitor(monitor));
}
Aggregations