use of org.sonarsource.sonarlint.core.util.ProgressWrapper in project sonarlint-core by SonarSource.
the class WsHelperImplTest method testListOrganizations.
@Test
public void testListOrganizations() {
WsClientTestUtils.addStreamResponse(client, "api/organizations/search.protobuf?ps=500&p=1", "/orgs/orgsp1.pb");
WsClientTestUtils.addStreamResponse(client, "api/organizations/search.protobuf?ps=500&p=2", "/orgs/orgsp2.pb");
WsClientTestUtils.addStreamResponse(client, "api/organizations/search.protobuf?ps=500&p=3", "/orgs/orgsp3.pb");
List<RemoteOrganization> orgs = WsHelperImpl.listOrganizations(client, serverChecker, new ProgressWrapper(null));
assertThat(orgs).hasSize(4);
verify(serverChecker).checkVersionAndStatus("6.3");
when(serverChecker.checkVersionAndStatus("6.3")).thenThrow(UnsupportedServerException.class);
try {
WsHelperImpl.listOrganizations(client, serverChecker, new ProgressWrapper(null));
fail("Expected exception");
} catch (UnsupportedServerException e) {
// Success
}
}
use of org.sonarsource.sonarlint.core.util.ProgressWrapper in project sonarlint-core by SonarSource.
the class ModuleHierarchyDownloaderTest method simpleTest.
@Test
public void simpleTest() {
WsClientTestUtils.addStreamResponse(wsClient, "api/components/tree.protobuf?qualifiers=BRC&baseComponentKey=testRoot&ps=500&p=1", "/update/tree.pb");
WsClientTestUtils.addStreamResponse(wsClient, "api/components/show.protobuf?id=AVeumyM5SDj1uJJMtck2", "/update/show_module1.pb");
WsClientTestUtils.addStreamResponse(wsClient, "api/components/show.protobuf?id=AVeumyM5SDj1uJJMtck3", "/update/show_module1_module11.pb");
WsClientTestUtils.addStreamResponse(wsClient, "api/components/show.protobuf?id=AVeumyM5SDj1uJJMtck6", "/update/show_module1_module12.pb");
WsClientTestUtils.addStreamResponse(wsClient, "api/components/show.protobuf?id=AVeumyM5SDj1uJJMtck9", "/update/show_module2.pb");
Map<String, String> fetchModuleHierarchy = downloader.fetchModuleHierarchy("testRoot", new ProgressWrapper(null));
assertThat(fetchModuleHierarchy).contains(entry("testRoot", ""), entry("testRoot:module1", "module1"), entry("testRoot:module2", "module2"), entry("testRoot:module1:module12", "module1/module12"), entry("testRoot:module1:module11", "module1/module11"));
}
use of org.sonarsource.sonarlint.core.util.ProgressWrapper 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.util.ProgressWrapper 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));
}
use of org.sonarsource.sonarlint.core.util.ProgressWrapper in project sonarlint-core by SonarSource.
the class RulesDownloaderTest method unknown_type.
@Test
public void unknown_type() throws IOException {
org.sonarqube.ws.Rules.SearchResponse response = org.sonarqube.ws.Rules.SearchResponse.newBuilder().addRules(org.sonarqube.ws.Rules.Rule.newBuilder().setKey("S:101").build()).build();
SonarLintWsClient wsClient = WsClientTestUtils.createMock();
WsClientTestUtils.addResponse(wsClient, RULES_SEARCH_URL + "&p=1&ps=500", response);
RulesDownloader rulesUpdate = new RulesDownloader(wsClient);
File tempDir = temp.newFolder();
rulesUpdate.fetchRulesTo(tempDir.toPath(), new ProgressWrapper(null));
Rules saved = ProtobufUtil.readFile(tempDir.toPath().resolve(StoragePaths.RULES_PB), Rules.parser());
assertThat(saved.getRulesByKeyMap()).hasSize(1);
assertThat(saved.getRulesByKeyMap().get("S:101").getType()).isEqualTo("");
}
Aggregations