use of org.sonarsource.sonarlint.core.util.ProgressWrapper in project sonarlint-core by SonarSource.
the class ModuleStorageUpdateCheckerTest method changedQualityProfile.
@Test
public void changedQualityProfile() {
when(moduleConfigurationDownloader.fetchModuleConfiguration(eq(SERVER_VERSION), eq(MODULE_KEY), any(GlobalProperties.class), any(ProgressWrapper.class))).thenReturn(ModuleConfiguration.newBuilder().putQprofilePerLanguage("java", "sonar-way-456").build());
when(storageReader.readModuleConfig(MODULE_KEY)).thenReturn(ModuleConfiguration.newBuilder().putQprofilePerLanguage("java", "sonar-way-123").build());
StorageUpdateCheckResult result = checker.checkForUpdates(MODULE_KEY, new ProgressWrapper(null));
assertThat(result.needUpdate()).isTrue();
assertThat(result.changelog()).containsOnly("Quality profiles configuration changed");
assertThat(logTester.logs(LoggerLevel.DEBUG)).containsOnly("Quality profile for language 'java' changed from 'sonar-way-123' to 'sonar-way-456'");
}
use of org.sonarsource.sonarlint.core.util.ProgressWrapper in project sonarlint-core by SonarSource.
the class ModuleStorageUpdateCheckerTest method addedProfile.
@Test
public void addedProfile() {
when(moduleConfigurationDownloader.fetchModuleConfiguration(eq(SERVER_VERSION), eq(MODULE_KEY), any(GlobalProperties.class), any(ProgressWrapper.class))).thenReturn(ModuleConfiguration.newBuilder().putQprofilePerLanguage("java", "sonar-way-123").build());
StorageUpdateCheckResult result = checker.checkForUpdates(MODULE_KEY, new ProgressWrapper(null));
assertThat(result.needUpdate()).isTrue();
assertThat(result.changelog()).containsOnly("Quality profiles configuration changed");
assertThat(logTester.logs(LoggerLevel.DEBUG)).containsOnly("Quality profile for language 'java' added with value 'sonar-way-123'");
}
use of org.sonarsource.sonarlint.core.util.ProgressWrapper in project sonarlint-core by SonarSource.
the class ModuleStorageUpdateCheckerTest method ignoreRemovedProfile.
@Test
public void ignoreRemovedProfile() {
when(storageReader.readModuleConfig(MODULE_KEY)).thenReturn(ModuleConfiguration.newBuilder().putQprofilePerLanguage("java", "sonar-way-123").build());
StorageUpdateCheckResult result = checker.checkForUpdates(MODULE_KEY, new ProgressWrapper(null));
assertThat(result.needUpdate()).isFalse();
assertThat(logTester.logs(LoggerLevel.DEBUG)).containsOnly("Quality profile for language 'java' removed");
}
use of org.sonarsource.sonarlint.core.util.ProgressWrapper in project sonarlint-core by SonarSource.
the class ModuleStorageUpdateExecutorTest method module_update.
@Test
public void module_update() throws Exception {
File destDir = temp.newFolder();
QProfiles.Builder builder = QProfiles.newBuilder();
builder.putQprofilesByKey("cs-sonar-way-58886", QProfiles.QProfile.newBuilder().build());
builder.putQprofilesByKey("java-empty-74333", QProfiles.QProfile.newBuilder().build());
builder.putQprofilesByKey("js-sonar-way-60746", QProfiles.QProfile.newBuilder().build());
builder.putQprofilesByKey("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);
moduleUpdate.update(MODULE_KEY_WITH_BRANCH, new ProgressWrapper(null));
ModuleConfiguration moduleConfiguration = ProtobufUtil.readFile(destDir.toPath().resolve(StoragePaths.MODULE_CONFIGURATION_PB), ModuleConfiguration.parser());
assertThat(moduleConfiguration.getQprofilePerLanguage()).containsOnly(entry("cs", "cs-sonar-way-58886"), entry("java", "java-empty-74333"), entry("js", "js-sonar-way-60746"));
assertThat(moduleConfiguration.getModulePathByKey()).containsOnly(entry(MODULE_KEY_WITH_BRANCH, ""), entry(MODULE_KEY_WITH_BRANCH + "child1", "child 1"));
}
use of org.sonarsource.sonarlint.core.util.ProgressWrapper in project sonarlint-core by SonarSource.
the class ConnectedSonarLintEngineImpl method updateModule.
@Override
public void updateModule(ServerConfiguration serverConfig, String moduleKey, @Nullable ProgressMonitor monitor) {
checkNotNull(serverConfig);
checkNotNull(moduleKey);
setLogging(null);
rwl.writeLock().lock();
checkUpdateStatus();
ConnectedContainer connectedContainer = new ConnectedContainer(globalConfig, serverConfig);
try {
changeState(State.UPDATING);
connectedContainer.startComponents();
connectedContainer.updateModule(moduleKey, new ProgressWrapper(monitor));
} catch (RuntimeException e) {
throw SonarLintWrappedException.wrap(e);
} finally {
try {
connectedContainer.stopComponents(false);
} catch (Exception e) {
// Ignore
}
changeState(getHandler().getGlobalStorageStatus() != null ? State.UPDATED : State.NEVER_UPDATED);
rwl.writeLock().unlock();
}
}
Aggregations