use of org.sonarsource.sonarlint.core.container.connected.SonarLintWsClient 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("");
}
use of org.sonarsource.sonarlint.core.container.connected.SonarLintWsClient in project sonarlint-core by SonarSource.
the class SettingsDownloaderTest method invalidResponseSettings.
@Test(expected = IllegalStateException.class)
public void invalidResponseSettings() throws Exception {
SonarLintWsClient wsClient = WsClientTestUtils.createMock();
WsClientTestUtils.addResponse(wsClient, "/api/settings/values.protobuf", new ByteArrayInputStream("foo bar".getBytes()));
new SettingsDownloader(wsClient).fetchGlobalSettingsTo("6.3", destDir);
}
use of org.sonarsource.sonarlint.core.container.connected.SonarLintWsClient in project sonarlint-core by SonarSource.
the class SettingsDownloaderTest method testFetchGlobalProperties.
@Test
public void testFetchGlobalProperties() throws Exception {
SonarLintWsClient wsClient = WsClientTestUtils.createMockWithReaderResponse("/api/properties?format=json", new StringReader("[{\"key\": \"sonar.core.treemap.colormetric\",\"value\": \"violations_density\"}," + "{\"key\": \"sonar.core.treemap.sizemetric\",\"value\": \"ncloc\"}," + "{\"key\": \"views.servers\",\"value\": \"135817900907501\",\"values\": [\"135817900907501\"]}]"));
new SettingsDownloader(wsClient).fetchGlobalSettingsTo("6.2", destDir);
GlobalProperties properties = ProtobufUtil.readFile(destDir.resolve(StoragePaths.PROPERTIES_PB), GlobalProperties.parser());
assertThat(properties.getPropertiesMap()).containsOnly(entry("sonar.core.treemap.colormetric", "violations_density"), entry("sonar.core.treemap.sizemetric", "ncloc"), entry("views.servers", "135817900907501"));
}
use of org.sonarsource.sonarlint.core.container.connected.SonarLintWsClient in project sonarlint-core by SonarSource.
the class SettingsDownloaderTest method testFetchGlobalSettings.
@Test
public void testFetchGlobalSettings() throws Exception {
SonarLintWsClient wsClient = WsClientTestUtils.createMock();
ValuesWsResponse response = ValuesWsResponse.newBuilder().addSettings(Setting.newBuilder().setKey("sonar.core.treemap.colormetric").setValue("violations_density").setInherited(true)).addSettings(Setting.newBuilder().setKey("sonar.core.treemap.sizemetric").setValue("ncloc")).addSettings(Setting.newBuilder().setKey("views.servers").setValues(Values.newBuilder().addValues("135817900907501"))).build();
PipedInputStream in = new PipedInputStream();
final PipedOutputStream out = new PipedOutputStream(in);
response.writeTo(out);
out.close();
WsClientTestUtils.addResponse(wsClient, "/api/settings/values.protobuf", in);
new SettingsDownloader(wsClient).fetchGlobalSettingsTo("6.3", destDir);
GlobalProperties properties = ProtobufUtil.readFile(destDir.resolve(StoragePaths.PROPERTIES_PB), GlobalProperties.parser());
assertThat(properties.getPropertiesMap()).containsOnly(entry("sonar.core.treemap.sizemetric", "ncloc"), entry("views.servers", "135817900907501"));
}
use of org.sonarsource.sonarlint.core.container.connected.SonarLintWsClient in project sonarlint-core by SonarSource.
the class SettingsDownloaderTest method invalidResponseProperties.
@Test(expected = IllegalStateException.class)
public void invalidResponseProperties() throws Exception {
SonarLintWsClient wsClient = WsClientTestUtils.createMockWithReaderResponse("/api/properties?format=json", new StringReader("foo bar"));
new SettingsDownloader(wsClient).fetchGlobalSettingsTo("6.2", destDir);
}
Aggregations