use of org.sonarsource.sonarlint.core.container.connected.SonarLintWsClient in project sonarlint-core by SonarSource.
the class IssueDownloaderImplTest method test_code404.
@Test
public void test_code404() throws IOException {
SonarLintWsClient wsClient = WsClientTestUtils.createMock();
String key = "dummyKey";
WsClientTestUtils.addFailedResponse(wsClient, "/batch/issues?key=" + key, 404, "");
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_download.
@Test
public void test_download() throws IOException {
ScannerInput.ServerIssue issue = ScannerInput.ServerIssue.newBuilder().build();
SonarLintWsClient wsClient = WsClientTestUtils.createMock();
String key = "dummyKey";
try (InputStream inputStream = new ByteArrayInputStream(toByteArray(issue))) {
WsClientTestUtils.addResponse(wsClient, "/batch/issues?key=" + key, inputStream);
}
IssueDownloader issueDownloader = new IssueDownloaderImpl(wsClient);
assertThat(issueDownloader.apply(key)).containsOnly(issue);
}
use of org.sonarsource.sonarlint.core.container.connected.SonarLintWsClient in project sonarlint-core by SonarSource.
the class ModuleListDownloaderTest method update_modules_before_6_dot_3.
@Test
public void update_modules_before_6_dot_3() throws Exception {
SonarLintWsClient wsClient = WsClientTestUtils.createMock();
WsClientTestUtils.addReaderResponse(wsClient, "api/projects/index?format=json&subprojects=true", "/update/all_projects.json");
File tempDir = temp.newFolder();
ModuleListDownloader moduleListUpdate = new ModuleListDownloader(wsClient);
moduleListUpdate.fetchModulesListTo(tempDir.toPath(), "6.2", new ProgressWrapper(null));
ModuleList moduleList = ProtobufUtil.readFile(tempDir.toPath().resolve(StoragePaths.MODULE_LIST_PB), ModuleList.parser());
assertThat(moduleList.getModulesByKeyMap()).hasSize(1559);
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 testParsingError.
@Test
public void testParsingError() throws IOException {
// wrong file
SonarLintWsClient wsClient = WsClientTestUtils.createMockWithStreamResponse("/api/qualityprofiles/search.protobuf", "/update/all_projects.json");
qProfilesDownloader = new QualityProfilesDownloader(wsClient);
exception.expect(IllegalStateException.class);
exception.expectMessage("Failed to load default quality profiles");
qProfilesDownloader.fetchQualityProfilesTo(temp.getRoot().toPath());
}
use of org.sonarsource.sonarlint.core.container.connected.SonarLintWsClient in project sonarlint-core by SonarSource.
the class RulesDownloaderTest method errorReadingStream.
@Test
public void errorReadingStream() throws IOException {
SonarLintWsClient wsClient = WsClientTestUtils.createMock();
InputStream stream = new ByteArrayInputStream("trash".getBytes(StandardCharsets.UTF_8));
WsClientTestUtils.addResponse(wsClient, RULES_SEARCH_URL + "&p=1&ps=500", stream);
RulesDownloader rulesUpdate = new RulesDownloader(wsClient);
File tempDir = temp.newFolder();
exception.expect(IllegalStateException.class);
exception.expectMessage("Failed to load rules");
rulesUpdate.fetchRulesTo(tempDir.toPath(), new ProgressWrapper(null));
}
Aggregations