use of org.sonarsource.sonarlint.core.proto.Sonarlint.ModuleConfiguration.Builder in project sonarlint-core by SonarSource.
the class IssueStoreReaderTest method testMultiModule2.
@Test
public void testMultiModule2() {
// setup module hierarchy
Map<String, String> modulePaths = new HashMap<>();
modulePaths.put(MODULE_KEY, "");
modulePaths.put("root:module1", "module1");
modulePaths.put("root:module12", "module12");
Builder moduleConfigBuilder = ModuleConfiguration.newBuilder();
moduleConfigBuilder.getMutableModulePathByKey().putAll(modulePaths);
when(storage.readModuleConfig(MODULE_KEY)).thenReturn(moduleConfigBuilder.build());
// setup issues
issueStore.save(Arrays.asList(createServerIssue("root:module1", "path1"), createServerIssue("root:module12", "path12")));
// test
// matches module12 path
assertThat(issueStoreReader.getServerIssues(MODULE_KEY, "module12/path12")).usingElementComparator(simpleComparator).containsOnly(createApiIssue(MODULE_KEY, "module12/path12"));
}
use of org.sonarsource.sonarlint.core.proto.Sonarlint.ModuleConfiguration.Builder in project sonarlint-core by SonarSource.
the class IssueStoreReaderTest method testSingleModule.
@Test
public void testSingleModule() {
// setup module hierarchy
Map<String, String> modulePaths = new HashMap<>();
modulePaths.put(MODULE_KEY, "");
Builder moduleConfigBuilder = ModuleConfiguration.newBuilder();
moduleConfigBuilder.getMutableModulePathByKey().putAll(modulePaths);
when(storage.readModuleConfig(MODULE_KEY)).thenReturn(moduleConfigBuilder.build());
// setup issues
issueStore.save(Arrays.asList(createServerIssue(MODULE_KEY, "src/path1")));
// test
// matches path
assertThat(issueStoreReader.getServerIssues(MODULE_KEY, "src/path1")).usingElementComparator(simpleComparator).containsOnly(createApiIssue(MODULE_KEY, "src/path1"));
// no file found
assertThat(issueStoreReader.getServerIssues(MODULE_KEY, "src/path3")).isEmpty();
// module not in storage
exception.expect(IllegalStateException.class);
exception.expectMessage("module not in storage");
assertThat(issueStoreReader.getServerIssues("root:module1", "path2")).usingElementComparator(simpleComparator).containsOnly(createApiIssue("module1", "path2"));
}
use of org.sonarsource.sonarlint.core.proto.Sonarlint.ModuleConfiguration.Builder in project sonarlint-core by SonarSource.
the class IssueStoreReaderTest method testDontSetTypeIfDoesntExist.
@Test
public void testDontSetTypeIfDoesntExist() {
// setup module hierarchy
Map<String, String> modulePaths = new HashMap<>();
modulePaths.put(MODULE_KEY, "");
Builder moduleConfigBuilder = ModuleConfiguration.newBuilder();
moduleConfigBuilder.getMutableModulePathByKey().putAll(modulePaths);
when(storage.readModuleConfig(MODULE_KEY)).thenReturn(moduleConfigBuilder.build());
ScannerInput.ServerIssue serverIssue = ScannerInput.ServerIssue.newBuilder().setModuleKey(MODULE_KEY).setPath("path").build();
issueStore.save(Collections.singletonList(serverIssue));
ServerIssue issue = issueStoreReader.getServerIssues(MODULE_KEY, "path").iterator().next();
assertThat(issue.type()).isNull();
}
use of org.sonarsource.sonarlint.core.proto.Sonarlint.ModuleConfiguration.Builder in project sonarlint-core by SonarSource.
the class SettingsDownloaderTest method testFetchProjectProperties.
@Test
public void testFetchProjectProperties() throws Exception {
SonarLintWsClient wsClient = WsClientTestUtils.createMockWithReaderResponse("/api/properties?format=json&resource=foo", new StringReader("[{\"key\": \"sonar.inclusions\",\"value\": \"**/*.java\"}," + "{\"key\": \"sonar.java.fileSuffixes\",\"value\": \"*.java\"}]"));
Builder builder = ModuleConfiguration.newBuilder();
new SettingsDownloader(wsClient).fetchProjectSettings("6.2", "foo", GlobalProperties.newBuilder().build(), builder);
assertThat(builder.getPropertiesMap()).containsOnly(entry("sonar.inclusions", "**/*.java"), entry("sonar.java.fileSuffixes", "*.java"));
}
Aggregations