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();
}
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);
}
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");
}
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");
}
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"));
}
Aggregations