Search in sources :

Example 26 with ProgressWrapper

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

the class ModuleListDownloaderTest method update_modules_after_6_dot_3.

@Test
public void update_modules_after_6_dot_3() throws Exception {
    SonarLintWsClient wsClient = WsClientTestUtils.createMock();
    WsClientTestUtils.addStreamResponse(wsClient, "api/components/search.protobuf?qualifiers=TRK,BRC&ps=500&p=1", "/update/searchmodulesp1.pb");
    File tempDir = temp.newFolder();
    ModuleListDownloader moduleListUpdate = new ModuleListDownloader(wsClient);
    moduleListUpdate.fetchModulesListTo(tempDir.toPath(), "6.3", new ProgressWrapper(null));
    ModuleList moduleList = ProtobufUtil.readFile(tempDir.toPath().resolve(StoragePaths.MODULE_LIST_PB), ModuleList.parser());
    assertThat(moduleList.getModulesByKeyMap()).hasSize(282);
    assertThat(moduleList.getModulesByKeyMap().values()).extracting("qu").contains("TRK", "BRC");
}
Also used : ProgressWrapper(org.sonarsource.sonarlint.core.util.ProgressWrapper) ModuleList(org.sonarsource.sonarlint.core.proto.Sonarlint.ModuleList) File(java.io.File) SonarLintWsClient(org.sonarsource.sonarlint.core.container.connected.SonarLintWsClient) Test(org.junit.Test)

Example 27 with ProgressWrapper

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

the class ModuleListDownloaderTest method update_modules_after_6_dot_3_with_org.

@Test
public void update_modules_after_6_dot_3_with_org() throws Exception {
    SonarLintWsClient wsClient = WsClientTestUtils.createMock();
    when(wsClient.getOrganizationKey()).thenReturn("myOrg");
    WsClientTestUtils.addStreamResponse(wsClient, "api/components/search.protobuf?qualifiers=TRK,BRC&organization=myOrg&ps=500&p=1", "/update/searchmodulesp1.pb");
    File tempDir = temp.newFolder();
    ModuleListDownloader moduleListUpdate = new ModuleListDownloader(wsClient);
    moduleListUpdate.fetchModulesListTo(tempDir.toPath(), "6.3", new ProgressWrapper(null));
    ModuleList moduleList = ProtobufUtil.readFile(tempDir.toPath().resolve(StoragePaths.MODULE_LIST_PB), ModuleList.parser());
    assertThat(moduleList.getModulesByKeyMap()).hasSize(282);
    assertThat(moduleList.getModulesByKeyMap().values()).extracting("qu").contains("TRK", "BRC");
}
Also used : ProgressWrapper(org.sonarsource.sonarlint.core.util.ProgressWrapper) ModuleList(org.sonarsource.sonarlint.core.proto.Sonarlint.ModuleList) File(java.io.File) SonarLintWsClient(org.sonarsource.sonarlint.core.container.connected.SonarLintWsClient) Test(org.junit.Test)

Example 28 with ProgressWrapper

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

the class RulesDownloaderTest method rules_update_protobuf.

@Test
public void rules_update_protobuf() throws Exception {
    SonarLintWsClient wsClient = WsClientTestUtils.createMockWithStreamResponse(RULES_SEARCH_URL + "&p=1&ps=500", "/update/rulesp1.pb");
    WsClientTestUtils.addStreamResponse(wsClient, RULES_SEARCH_URL + "&p=2&ps=500", "/update/rulesp2.pb");
    RulesDownloader rulesUpdate = new RulesDownloader(wsClient);
    File tempDir = temp.newFolder();
    rulesUpdate.fetchRulesTo(tempDir.toPath(), new ProgressWrapper(null));
    Rules rules = ProtobufUtil.readFile(tempDir.toPath().resolve(StoragePaths.RULES_PB), Rules.parser());
    assertThat(rules.getRulesByKeyMap()).hasSize(939);
    ActiveRules jsActiveRules = ProtobufUtil.readFile(tempDir.toPath().resolve(StoragePaths.ACTIVE_RULES_FOLDER).resolve("js-sonar-way-62960.pb"), ActiveRules.parser());
    assertThat(jsActiveRules.getActiveRulesByKeyMap()).hasSize(85);
}
Also used : ProgressWrapper(org.sonarsource.sonarlint.core.util.ProgressWrapper) ActiveRules(org.sonarsource.sonarlint.core.proto.Sonarlint.ActiveRules) File(java.io.File) Rules(org.sonarsource.sonarlint.core.proto.Sonarlint.Rules) ActiveRules(org.sonarsource.sonarlint.core.proto.Sonarlint.ActiveRules) SonarLintWsClient(org.sonarsource.sonarlint.core.container.connected.SonarLintWsClient) Test(org.junit.Test)

Example 29 with ProgressWrapper

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

the class RulesDownloaderTest method rules_update_protobuf_with_org.

@Test
public void rules_update_protobuf_with_org() throws Exception {
    SonarLintWsClient wsClient = WsClientTestUtils.createMockWithStreamResponse(RULES_SEARCH_URL + "&organization=myOrg&p=1&ps=500", "/update/rulesp1.pb");
    WsClientTestUtils.addStreamResponse(wsClient, RULES_SEARCH_URL + "&organization=myOrg&p=2&ps=500", "/update/rulesp2.pb");
    when(wsClient.getOrganizationKey()).thenReturn("myOrg");
    RulesDownloader rulesUpdate = new RulesDownloader(wsClient);
    File tempDir = temp.newFolder();
    rulesUpdate.fetchRulesTo(tempDir.toPath(), new ProgressWrapper(null));
    Rules rules = ProtobufUtil.readFile(tempDir.toPath().resolve(StoragePaths.RULES_PB), Rules.parser());
    assertThat(rules.getRulesByKeyMap()).hasSize(939);
    ActiveRules jsActiveRules = ProtobufUtil.readFile(tempDir.toPath().resolve(StoragePaths.ACTIVE_RULES_FOLDER).resolve("js-sonar-way-62960.pb"), ActiveRules.parser());
    assertThat(jsActiveRules.getActiveRulesByKeyMap()).hasSize(85);
}
Also used : ProgressWrapper(org.sonarsource.sonarlint.core.util.ProgressWrapper) ActiveRules(org.sonarsource.sonarlint.core.proto.Sonarlint.ActiveRules) File(java.io.File) Rules(org.sonarsource.sonarlint.core.proto.Sonarlint.Rules) ActiveRules(org.sonarsource.sonarlint.core.proto.Sonarlint.ActiveRules) SonarLintWsClient(org.sonarsource.sonarlint.core.container.connected.SonarLintWsClient) Test(org.junit.Test)

Example 30 with ProgressWrapper

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

the class ModuleStorageUpdateCheckerTest method testNoChanges.

@Test
public void testNoChanges() {
    StorageUpdateCheckResult result = checker.checkForUpdates(MODULE_KEY, new ProgressWrapper(null));
    assertThat(result.needUpdate()).isFalse();
    assertThat(result.changelog()).isEmpty();
}
Also used : ProgressWrapper(org.sonarsource.sonarlint.core.util.ProgressWrapper) StorageUpdateCheckResult(org.sonarsource.sonarlint.core.client.api.connected.StorageUpdateCheckResult) 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