Search in sources :

Example 26 with SonarLintWsClient

use of org.sonarsource.sonarlint.core.container.connected.SonarLintWsClient in project sonarlint-core by SonarSource.

the class IssueDownloaderImplTest method test_code403.

@Test
public void test_code403() throws IOException {
    SonarLintWsClient wsClient = WsClientTestUtils.createMock();
    String key = "dummyKey";
    WsClientTestUtils.addFailedResponse(wsClient, "/batch/issues?key=" + key, 403, "");
    IssueDownloader issueDownloader = new IssueDownloaderImpl(wsClient);
    assertThat(issueDownloader.apply(key)).isEmpty();
}
Also used : SonarLintWsClient(org.sonarsource.sonarlint.core.container.connected.SonarLintWsClient) Test(org.junit.Test)

Example 27 with SonarLintWsClient

use of org.sonarsource.sonarlint.core.container.connected.SonarLintWsClient in project sonarlint-core by SonarSource.

the class IssueDownloaderImplTest method test_fail_other_codes.

@Test
public void test_fail_other_codes() throws IOException {
    SonarLintWsClient wsClient = WsClientTestUtils.createMock();
    String key = "dummyKey";
    WsClientTestUtils.addFailedResponse(wsClient, "/batch/issues?key=" + key, 503, "");
    IssueDownloader issueDownloader = new IssueDownloaderImpl(wsClient);
    exception.expect(IllegalStateException.class);
    exception.expectMessage("Error 503");
    issueDownloader.apply(key);
}
Also used : SonarLintWsClient(org.sonarsource.sonarlint.core.container.connected.SonarLintWsClient) Test(org.junit.Test)

Example 28 with SonarLintWsClient

use of org.sonarsource.sonarlint.core.container.connected.SonarLintWsClient 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 29 with SonarLintWsClient

use of org.sonarsource.sonarlint.core.container.connected.SonarLintWsClient 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 30 with SonarLintWsClient

use of org.sonarsource.sonarlint.core.container.connected.SonarLintWsClient in project sonarlint-core by SonarSource.

the class QualityProfilesDownloaderTest method test.

@Test
public void test() {
    SonarLintWsClient wsClient = WsClientTestUtils.createMockWithStreamResponse("/api/qualityprofiles/search.protobuf", "/update/qualityprofiles.pb");
    qProfilesDownloader = new QualityProfilesDownloader(wsClient);
    qProfilesDownloader.fetchQualityProfilesTo(temp.getRoot().toPath());
    QProfiles qProfiles = ProtobufUtil.readFile(temp.getRoot().toPath().resolve(StoragePaths.QUALITY_PROFILES_PB), QProfiles.parser());
    assertThat(qProfiles.getQprofilesByKeyMap()).containsOnlyKeys("cs-sonar-way-58886", "java-sonar-way-74592", "java-empty-74333", "js-sonar-security-way-70539", "js-sonar-way-60746");
    assertThat(qProfiles.getDefaultQProfilesByLanguageMap()).containsOnly(entry("cs", "cs-sonar-way-58886"), entry("java", "java-sonar-way-74592"), entry("js", "js-sonar-way-60746"));
}
Also used : SonarLintWsClient(org.sonarsource.sonarlint.core.container.connected.SonarLintWsClient) QProfiles(org.sonarsource.sonarlint.core.proto.Sonarlint.QProfiles) Test(org.junit.Test)

Aggregations

SonarLintWsClient (org.sonarsource.sonarlint.core.container.connected.SonarLintWsClient)40 Test (org.junit.Test)37 ProgressWrapper (org.sonarsource.sonarlint.core.util.ProgressWrapper)8 File (java.io.File)7 UnsupportedServerException (org.sonarsource.sonarlint.core.client.api.exceptions.UnsupportedServerException)6 NotFoundException (org.sonarsource.sonarlint.core.container.connected.exceptions.NotFoundException)6 ValidationResult (org.sonarsource.sonarlint.core.client.api.connected.ValidationResult)5 StringReader (java.io.StringReader)4 ByteArrayInputStream (java.io.ByteArrayInputStream)3 ZonedDateTime (java.time.ZonedDateTime)3 SonarQubeNotification (org.sonarsource.sonarlint.core.client.api.notifications.SonarQubeNotification)3 ActiveRules (org.sonarsource.sonarlint.core.proto.Sonarlint.ActiveRules)3 Builder (org.sonarsource.sonarlint.core.proto.Sonarlint.ModuleConfiguration.Builder)3 ModuleList (org.sonarsource.sonarlint.core.proto.Sonarlint.ModuleList)3 Rules (org.sonarsource.sonarlint.core.proto.Sonarlint.Rules)3 InputStream (java.io.InputStream)2 PipedInputStream (java.io.PipedInputStream)2 PipedOutputStream (java.io.PipedOutputStream)2 ValuesWsResponse (org.sonarqube.ws.Settings.ValuesWsResponse)2 GlobalProperties (org.sonarsource.sonarlint.core.proto.Sonarlint.GlobalProperties)2