Search in sources :

Example 1 with DownloadException

use of org.sonarsource.sonarlint.core.client.api.exceptions.DownloadException in project sonarlint-core by SonarSource.

the class PartialUpdater method updateFileIssues.

public void updateFileIssues(String moduleKey, String filePath) {
    Path serverIssuesPath = storagePaths.getServerIssuesPath(moduleKey);
    IssueStore issueStore = issueStoreFactory.apply(serverIssuesPath);
    String fileKey = issueStoreReader.getFileKey(moduleKey, filePath);
    List<ServerIssue> issues;
    try {
        issues = downloader.apply(fileKey);
    } catch (Exception e) {
        // null as cause so that it doesn't get wrapped
        throw new DownloadException("Failed to update file issues: " + e.getMessage(), null);
    }
    issueStore.save(issues);
}
Also used : Path(java.nio.file.Path) DownloadException(org.sonarsource.sonarlint.core.client.api.exceptions.DownloadException) IssueStore(org.sonarsource.sonarlint.core.container.connected.IssueStore) ServerIssue(org.sonar.scanner.protocol.input.ScannerInput.ServerIssue) DownloadException(org.sonarsource.sonarlint.core.client.api.exceptions.DownloadException)

Example 2 with DownloadException

use of org.sonarsource.sonarlint.core.client.api.exceptions.DownloadException in project sonarlint-core by SonarSource.

the class ServerIssueTrackerTest method should_get_issues_from_engine_if_download_failed.

@Test
public void should_get_issues_from_engine_if_download_failed() {
    String moduleKey = "dummy module";
    String filePath = "dummy file";
    ConnectedSonarLintEngine engine = mock(ConnectedSonarLintEngine.class);
    ServerConfiguration serverConfiguration = mock(ServerConfiguration.class);
    ServerIssueTracker tracker = new ServerIssueTracker(mock(Logger.class), mock(Console.class), mock(CachingIssueTracker.class));
    when(engine.downloadServerIssues(serverConfiguration, moduleKey, filePath)).thenThrow(new DownloadException());
    tracker.update(serverConfiguration, engine, moduleKey, Collections.singleton(filePath));
    verify(engine).downloadServerIssues(serverConfiguration, moduleKey, filePath);
    verify(engine).getServerIssues(moduleKey, filePath);
    verifyNoMoreInteractions(engine);
}
Also used : ServerConfiguration(org.sonarsource.sonarlint.core.client.api.connected.ServerConfiguration) DownloadException(org.sonarsource.sonarlint.core.client.api.exceptions.DownloadException) ConnectedSonarLintEngine(org.sonarsource.sonarlint.core.client.api.connected.ConnectedSonarLintEngine) Test(org.junit.Test)

Aggregations

DownloadException (org.sonarsource.sonarlint.core.client.api.exceptions.DownloadException)2 Path (java.nio.file.Path)1 Test (org.junit.Test)1 ServerIssue (org.sonar.scanner.protocol.input.ScannerInput.ServerIssue)1 ConnectedSonarLintEngine (org.sonarsource.sonarlint.core.client.api.connected.ConnectedSonarLintEngine)1 ServerConfiguration (org.sonarsource.sonarlint.core.client.api.connected.ServerConfiguration)1 IssueStore (org.sonarsource.sonarlint.core.container.connected.IssueStore)1