use of org.sonarsource.sonarlint.core.client.api.connected.StorageUpdateCheckResult in project sonarlint-core by SonarSource.
the class ModuleStorageUpdateCheckerTest method removedProp.
@Test
public void removedProp() {
when(storageReader.readModuleConfig(MODULE_KEY)).thenReturn(ModuleConfiguration.newBuilder().putProperties("sonar.cobol.license.secured", "value").build());
StorageUpdateCheckResult result = checker.checkForUpdates(MODULE_KEY, new ProgressWrapper(null));
assertThat(result.needUpdate()).isTrue();
assertThat(result.changelog()).containsOnly("Project settings updated");
assertThat(logTester.logs(LoggerLevel.DEBUG)).containsOnly("Property 'sonar.cobol.license.secured' removed");
}
use of org.sonarsource.sonarlint.core.client.api.connected.StorageUpdateCheckResult in project sonarlint-core by SonarSource.
the class ModuleStorageUpdateCheckerTest method changedProp.
@Test
public void changedProp() {
when(storageReader.readModuleConfig(MODULE_KEY)).thenReturn(ModuleConfiguration.newBuilder().putProperties("sonar.inclusions", "old").build());
when(moduleConfigurationDownloader.fetchModuleConfiguration(eq(SERVER_VERSION), eq(MODULE_KEY), any(GlobalProperties.class), any(ProgressWrapper.class))).thenReturn(ModuleConfiguration.newBuilder().putProperties("sonar.inclusions", "new").build());
StorageUpdateCheckResult result = checker.checkForUpdates(MODULE_KEY, new ProgressWrapper(null));
assertThat(result.needUpdate()).isTrue();
assertThat(result.changelog()).containsOnly("Project settings updated");
assertThat(logTester.logs(LoggerLevel.DEBUG)).containsOnly("Value of property 'sonar.inclusions' changed from 'old' to 'new'");
}
use of org.sonarsource.sonarlint.core.client.api.connected.StorageUpdateCheckResult in project sonarlint-core by SonarSource.
the class ModuleStorageUpdateCheckerTest method addedProp.
@Test
public void addedProp() {
when(moduleConfigurationDownloader.fetchModuleConfiguration(eq(SERVER_VERSION), eq(MODULE_KEY), any(GlobalProperties.class), any(ProgressWrapper.class))).thenReturn(ModuleConfiguration.newBuilder().putProperties("sonar.issue.enforce.allFiles", "value").build());
StorageUpdateCheckResult result = checker.checkForUpdates(MODULE_KEY, new ProgressWrapper(null));
assertThat(result.needUpdate()).isTrue();
assertThat(result.changelog()).containsOnly("Project settings updated");
assertThat(logTester.logs(LoggerLevel.DEBUG)).containsOnly("Property 'sonar.issue.enforce.allFiles' added with value 'value'");
}
use of org.sonarsource.sonarlint.core.client.api.connected.StorageUpdateCheckResult in project sonarlint-core by SonarSource.
the class ConnectedModeTest method checkForUpdate.
@Test
public void checkForUpdate() throws Exception {
updateGlobal();
updateModule(PROJECT_KEY_JAVA);
ServerConfiguration serverConfig = getServerConfig(true);
StorageUpdateCheckResult result = engine.checkIfGlobalStorageNeedUpdate(serverConfig, null);
assertThat(result.needUpdate()).isFalse();
// restarting server should not lead to notify an update
ORCHESTRATOR.restartServer();
result = engine.checkIfGlobalStorageNeedUpdate(serverConfig, null);
assertThat(result.needUpdate()).isFalse();
// Change a global setting that is not in the whitelist
setSettings(null, "sonar.foo", "bar");
result = engine.checkIfGlobalStorageNeedUpdate(serverConfig, null);
assertThat(result.needUpdate()).isFalse();
// Change a global setting that *is* in the whitelist
setSettingsMultiValue(null, "sonar.inclusions", "**/*");
// Activate a new rule
SearchWsResponse response = newAdminWsClient(ORCHESTRATOR).qualityProfiles().search(new SearchWsRequest().setLanguage("java"));
String profileKey = response.getProfilesList().stream().filter(p -> p.getName().equals("SonarLint IT Java")).findFirst().get().getKey();
ORCHESTRATOR.getServer().adminWsClient().post("api/qualityprofiles/activate_rule", "profile_key", profileKey, "rule_key", "squid:S1228");
result = engine.checkIfGlobalStorageNeedUpdate(serverConfig, null);
assertThat(result.needUpdate()).isTrue();
assertThat(result.changelog()).containsOnly("Global settings updated", "Quality profile 'SonarLint IT Java' for language 'Java' updated");
result = engine.checkIfModuleStorageNeedUpdate(serverConfig, PROJECT_KEY_JAVA, null);
assertThat(result.needUpdate()).isFalse();
// Change a project setting that is not in the whitelist
setSettings(PROJECT_KEY_JAVA, "sonar.foo", "biz");
result = engine.checkIfModuleStorageNeedUpdate(serverConfig, PROJECT_KEY_JAVA, null);
assertThat(result.needUpdate()).isFalse();
// Change a project setting that *is* in the whitelist
setSettingsMultiValue(PROJECT_KEY_JAVA, "sonar.exclusions", "**/*.foo");
result = engine.checkIfModuleStorageNeedUpdate(serverConfig, PROJECT_KEY_JAVA, null);
assertThat(result.needUpdate()).isTrue();
assertThat(result.changelog()).containsOnly("Project settings updated");
}
use of org.sonarsource.sonarlint.core.client.api.connected.StorageUpdateCheckResult 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