Search in sources :

Example 6 with ProgressWrapper

use of org.sonarsource.sonarlint.core.util.ProgressWrapper 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");
}
Also used : ProgressWrapper(org.sonarsource.sonarlint.core.util.ProgressWrapper) StorageUpdateCheckResult(org.sonarsource.sonarlint.core.client.api.connected.StorageUpdateCheckResult) Test(org.junit.Test)

Example 7 with ProgressWrapper

use of org.sonarsource.sonarlint.core.util.ProgressWrapper 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'");
}
Also used : ProgressWrapper(org.sonarsource.sonarlint.core.util.ProgressWrapper) StorageUpdateCheckResult(org.sonarsource.sonarlint.core.client.api.connected.StorageUpdateCheckResult) GlobalProperties(org.sonarsource.sonarlint.core.proto.Sonarlint.GlobalProperties) Test(org.junit.Test)

Example 8 with ProgressWrapper

use of org.sonarsource.sonarlint.core.util.ProgressWrapper 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'");
}
Also used : ProgressWrapper(org.sonarsource.sonarlint.core.util.ProgressWrapper) StorageUpdateCheckResult(org.sonarsource.sonarlint.core.client.api.connected.StorageUpdateCheckResult) GlobalProperties(org.sonarsource.sonarlint.core.proto.Sonarlint.GlobalProperties) Test(org.junit.Test)

Example 9 with ProgressWrapper

use of org.sonarsource.sonarlint.core.util.ProgressWrapper in project sonarlint-core by SonarSource.

the class GlobalStorageUpdateExecutorTest method dontCopyOnError.

@Test
public void dontCopyOnError() throws IOException {
    Files.createDirectories(destDir.toPath());
    Files.createFile(destDir.toPath().resolve("test"));
    doThrow(IllegalStateException.class).when(rulesDownloader).fetchRulesTo(any(Path.class), any(ProgressWrapper.class));
    try {
        globalUpdate.update(new ProgressWrapper(null));
        fail("Expected exception");
    } catch (IllegalStateException e) {
        // dest left untouched
        assertThat(Files.exists(destDir.toPath().resolve("test"))).isTrue();
        // tmp cleaned
        assertThat(Files.exists(tempDir.toPath())).isFalse();
    }
}
Also used : Path(java.nio.file.Path) ProgressWrapper(org.sonarsource.sonarlint.core.util.ProgressWrapper) Test(org.junit.Test)

Example 10 with ProgressWrapper

use of org.sonarsource.sonarlint.core.util.ProgressWrapper in project sonarlint-core by SonarSource.

the class GlobalStorageUpdateExecutorTest method testUpdate.

@Test
public void testUpdate() throws Exception {
    globalUpdate.update(new ProgressWrapper(null));
    StorageStatus updateStatus = ProtobufUtil.readFile(destDir.toPath().resolve(StoragePaths.STORAGE_STATUS_PB), StorageStatus.parser());
    assertThat(updateStatus.getClientUserAgent()).isEqualTo("UT");
    assertThat(updateStatus.getSonarlintCoreVersion()).isEqualTo(VersionUtils.getLibraryVersion());
    assertThat(updateStatus.getUpdateTimestamp()).isNotEqualTo(0);
    ServerInfos serverInfos = ProtobufUtil.readFile(destDir.toPath().resolve(StoragePaths.SERVER_INFO_PB), ServerInfos.parser());
    assertThat(serverInfos.getId()).isEqualTo("20160308094653");
    assertThat(serverInfos.getVersion()).isEqualTo("5.6-SNAPSHOT");
}
Also used : ProgressWrapper(org.sonarsource.sonarlint.core.util.ProgressWrapper) StorageStatus(org.sonarsource.sonarlint.core.proto.Sonarlint.StorageStatus) ServerInfos(org.sonarsource.sonarlint.core.proto.Sonarlint.ServerInfos) Test(org.junit.Test)

Aggregations

ProgressWrapper (org.sonarsource.sonarlint.core.util.ProgressWrapper)38 Test (org.junit.Test)31 SonarLintWsClient (org.sonarsource.sonarlint.core.container.connected.SonarLintWsClient)14 File (java.io.File)11 StorageUpdateCheckResult (org.sonarsource.sonarlint.core.client.api.connected.StorageUpdateCheckResult)9 GlobalProperties (org.sonarsource.sonarlint.core.proto.Sonarlint.GlobalProperties)8 Map (java.util.Map)6 Nullable (javax.annotation.Nullable)6 ServerInfos (org.sonarsource.sonarlint.core.proto.Sonarlint.ServerInfos)6 Path (java.nio.file.Path)5 IssueListener (org.sonarsource.sonarlint.core.client.api.common.analysis.IssueListener)5 IOException (java.io.IOException)4 Arrays (java.util.Arrays)4 Collections (java.util.Collections)4 HashMap (java.util.HashMap)4 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)4 Assertions.entry (org.assertj.core.api.Assertions.entry)4 Before (org.junit.Before)4 Rule (org.junit.Rule)4 ExpectedException (org.junit.rules.ExpectedException)4