use of org.sonarsource.sonarlint.core.util.ProgressWrapper in project sonarlint-core by SonarSource.
the class ModuleStorageUpdateExecutorTest method test_server_issues_are_downloaded_and_stored.
@Test
public void test_server_issues_are_downloaded_and_stored() throws IOException {
WsClientTestUtils.addResponse(wsClient, getQualityProfileUrl(), newEmptyStream());
when(storageReader.readQProfiles()).thenReturn(QProfiles.getDefaultInstance());
when(storagePaths.getModuleStorageRoot(MODULE_KEY_WITH_BRANCH)).thenReturn(temp.newFolder().toPath());
ScannerInput.ServerIssue fileIssue1 = ScannerInput.ServerIssue.newBuilder().setModuleKey("someModuleKey").setPath("some/path").setRuleKey("squid:x").build();
ScannerInput.ServerIssue fileIssue2 = ScannerInput.ServerIssue.newBuilder().setModuleKey("someModuleKey").setPath("some/path").setRuleKey("squid:y").build();
ScannerInput.ServerIssue anotherFileIssue = ScannerInput.ServerIssue.newBuilder().setModuleKey("someModuleKey").setPath("another/path").build();
ScannerInput.ServerIssue notDownloadedIssue = ScannerInput.ServerIssue.newBuilder().setModuleKey("someModuleKey").setPath("yet/another/path").build();
IssueDownloader issueDownloader = moduleKey -> Arrays.asList(fileIssue1, fileIssue2, anotherFileIssue);
moduleUpdate = new ModuleStorageUpdateExecutor(storageReader, storagePaths, wsClient, issueDownloader, issueStoreFactory, tempFolder, moduleConfigurationDownloader);
moduleUpdate.update(MODULE_KEY_WITH_BRANCH, new ProgressWrapper(null));
assertThat(issueStore.load(createFileKey(fileIssue1))).containsOnly(fileIssue1, fileIssue2);
assertThat(issueStore.load(createFileKey(anotherFileIssue))).containsOnly(anotherFileIssue);
assertThat(issueStore.load(createFileKey(notDownloadedIssue))).isEmpty();
}
use of org.sonarsource.sonarlint.core.util.ProgressWrapper in project sonarlint-core by SonarSource.
the class ModuleStorageUpdateExecutorTest method exception_ws_load_qps.
@Test
public void exception_ws_load_qps() throws IOException {
when(wsClient.get(getQualityProfileUrl())).thenThrow(IOException.class);
File destDir = temp.newFolder();
QProfiles.Builder builder = QProfiles.newBuilder();
builder.putQprofilesByKey("java-empty-74333", QProfiles.QProfile.newBuilder().build());
when(storageReader.readQProfiles()).thenReturn(builder.build());
when(storagePaths.getModuleStorageRoot(MODULE_KEY_WITH_BRANCH)).thenReturn(destDir.toPath());
moduleUpdate = new ModuleStorageUpdateExecutor(storageReader, storagePaths, wsClient, (key) -> Collections.emptyList(), issueStoreFactory, tempFolder, moduleConfigurationDownloader);
exception.expect(IllegalStateException.class);
exception.expectMessage("Failed to load module quality profiles");
moduleUpdate.update(MODULE_KEY_WITH_BRANCH, new ProgressWrapper(null));
}
use of org.sonarsource.sonarlint.core.util.ProgressWrapper in project sonarlint-core by SonarSource.
the class ModuleStorageUpdateExecutorTest method test_error_if_qp_doesnt_exist.
@Test
public void test_error_if_qp_doesnt_exist() throws IOException {
File destDir = temp.newFolder();
QProfiles.Builder builder = QProfiles.newBuilder();
Map<String, QProfiles.QProfile> mutableQprofilesByKey = builder.getMutableQprofilesByKey();
mutableQprofilesByKey.put("cs-sonar-way-58886", QProfiles.QProfile.newBuilder().build());
mutableQprofilesByKey.put("java-empty-74333", QProfiles.QProfile.newBuilder().build());
mutableQprofilesByKey.put("xoo2-basic-34035", QProfiles.QProfile.newBuilder().build());
when(storageReader.readQProfiles()).thenReturn(builder.build());
when(storagePaths.getModuleStorageRoot(MODULE_KEY_WITH_BRANCH)).thenReturn(destDir.toPath());
moduleUpdate = new ModuleStorageUpdateExecutor(storageReader, storagePaths, wsClient, (key) -> Collections.emptyList(), issueStoreFactory, tempFolder, moduleConfigurationDownloader);
exception.expect(IllegalStateException.class);
exception.expectMessage("is associated to quality profile 'js-sonar-way-60746' that is not in the storage");
moduleUpdate.update(MODULE_KEY_WITH_BRANCH, new ProgressWrapper(null));
}
use of org.sonarsource.sonarlint.core.util.ProgressWrapper in project sonarlint-core by SonarSource.
the class ConnectedSonarLintEngineImpl method update.
@Override
public UpdateResult update(ServerConfiguration serverConfig, @Nullable ProgressMonitor monitor) {
checkNotNull(serverConfig);
setLogging(null);
return withRwLock(() -> {
stop(false);
changeState(State.UPDATING);
List<SonarAnalyzer> analyzers;
try {
analyzers = runInConnectedContainer(serverConfig, container -> container.update(new ProgressWrapper(monitor)));
} finally {
start();
}
return new UpdateResult(getHandler().getGlobalStorageStatus(), analyzers);
});
}
use of org.sonarsource.sonarlint.core.util.ProgressWrapper in project sonarlint-core by SonarSource.
the class ConnectedSonarLintEngineImpl method checkIfModuleStorageNeedUpdate.
@Override
public StorageUpdateCheckResult checkIfModuleStorageNeedUpdate(ServerConfiguration serverConfig, String moduleKey, @Nullable ProgressMonitor monitor) {
checkNotNull(serverConfig);
checkNotNull(moduleKey);
return withReadLock(() -> runInConnectedContainer(serverConfig, container -> container.checkForUpdate(moduleKey, new ProgressWrapper(monitor))));
}
Aggregations