use of org.sonarsource.sonarlint.core.client.api.common.analysis.ClientInputFile in project sonarlint-core by SonarSource.
the class BrokenStorageMissingPluginMediumTest method prepareInputFile.
private ClientInputFile prepareInputFile(String relativePath, String content, final boolean isTest) throws IOException {
final File file = new File(baseDir, relativePath);
FileUtils.write(file, content);
ClientInputFile inputFile = TestUtils.createInputFile(file.toPath(), relativePath, isTest);
return inputFile;
}
use of org.sonarsource.sonarlint.core.client.api.common.analysis.ClientInputFile in project sonarlint-core by SonarSource.
the class BrokenStorageMissingPluginMediumTest method require_update.
@Test
public void require_update() throws Exception {
assertThat(sonarlint.getState()).isEqualTo(ConnectedSonarLintEngine.State.NEED_UPDATE);
ClientInputFile inputFile = prepareJavaInputFile();
final List<Issue> issues = new ArrayList<>();
try {
sonarlint.analyze(new ConnectedAnalysisConfiguration(null, baseDir.toPath(), temp.newFolder().toPath(), Arrays.asList(inputFile), ImmutableMap.<String, String>of()), new StoreIssueListener(issues), null, null);
fail("Expected exception");
} catch (Exception e) {
assertThat(e).isExactlyInstanceOf(GlobalUpdateRequiredException.class);
}
}
use of org.sonarsource.sonarlint.core.client.api.common.analysis.ClientInputFile in project sonarlint-core by SonarSource.
the class ConnectedEmptyStorageMediumTest method test_no_storage.
@Test
public void test_no_storage() throws Exception {
assertThat(sonarlint.getState()).isEqualTo(State.NEVER_UPDATED);
assertThat(sonarlint.getGlobalStorageStatus()).isNull();
assertThat(sonarlint.getModuleStorageStatus("foo")).isNull();
try {
sonarlint.allModulesByKey();
fail("Expected exception");
} catch (Exception e) {
assertThat(e).isInstanceOf(GlobalUpdateRequiredException.class).hasMessage("Please update server 'localhost'");
}
try {
sonarlint.getRuleDetails("rule");
fail("Expected exception");
} catch (Exception e) {
assertThat(e).isInstanceOf(GlobalUpdateRequiredException.class).hasMessage("Please update server 'localhost'");
}
try {
sonarlint.analyze(new ConnectedAnalysisConfiguration(null, baseDir.toPath(), temp.newFolder().toPath(), Collections.<ClientInputFile>emptyList(), ImmutableMap.<String, String>of()), mock(IssueListener.class), null, null);
fail("Expected exception");
} catch (Exception e) {
assertThat(e).isInstanceOf(GlobalUpdateRequiredException.class).hasMessage("Please update server 'localhost'");
}
}
use of org.sonarsource.sonarlint.core.client.api.common.analysis.ClientInputFile in project sonarlint-core by SonarSource.
the class ConnectedFileExclusionsMediumTest method prepareInputFile.
private ClientInputFile prepareInputFile(String relativePath, String content, final boolean isTest) throws IOException {
final File file = new File(baseDir, relativePath);
FileUtils.write(file, content);
ClientInputFile inputFile = TestUtils.createInputFile(file.toPath(), relativePath, isTest);
return inputFile;
}
use of org.sonarsource.sonarlint.core.client.api.common.analysis.ClientInputFile in project sonarlint-core by SonarSource.
the class ConnectedFileExclusionsMediumTest method fileInclusionsExclusions.
@Test
public void fileInclusionsExclusions() throws Exception {
ClientInputFile mainFile1 = prepareInputFile("foo.xoo", "function xoo() {}", false);
ClientInputFile mainFile2 = prepareInputFile("src/foo2.xoo", "function xoo() {}", false);
ClientInputFile testFile1 = prepareInputFile("fooTest.xoo", "function xoo() {}", true);
ClientInputFile testFile2 = prepareInputFile("test/foo2Test.xoo", "function xoo() {}", true);
StoragePaths storagePaths = sonarlint.getGlobalContainer().getComponentByType(StoragePaths.class);
StorageReader storageReader = sonarlint.getGlobalContainer().getComponentByType(StorageReader.class);
ModuleConfiguration originalModuleConfig = storageReader.readModuleConfig(MODULE_KEY);
int result = count(mainFile1, mainFile2, testFile1, testFile2);
assertThat(result).isEqualTo(4);
updateModuleConfig(storagePaths, originalModuleConfig, ImmutableMap.of("sonar.inclusions", "src/**"));
result = count(mainFile1, mainFile2, testFile1, testFile2);
assertThat(result).isEqualTo(3);
updateModuleConfig(storagePaths, originalModuleConfig, ImmutableMap.of("sonar.inclusions", "file:**/src/**"));
result = count(mainFile1, mainFile2, testFile1, testFile2);
assertThat(result).isEqualTo(3);
updateModuleConfig(storagePaths, originalModuleConfig, ImmutableMap.of("sonar.exclusions", "src/**"));
result = count(mainFile1, mainFile2, testFile1, testFile2);
assertThat(result).isEqualTo(3);
updateModuleConfig(storagePaths, originalModuleConfig, ImmutableMap.of("sonar.test.inclusions", "test/**"));
result = count(mainFile1, mainFile2, testFile1, testFile2);
assertThat(result).isEqualTo(3);
updateModuleConfig(storagePaths, originalModuleConfig, ImmutableMap.of("sonar.test.exclusions", "test/**"));
result = count(mainFile1, mainFile2, testFile1, testFile2);
assertThat(result).isEqualTo(3);
updateModuleConfig(storagePaths, originalModuleConfig, ImmutableMap.of("sonar.inclusions", "file:**/src/**", "sonar.test.exclusions", "**/*Test.*"));
result = count(mainFile1, mainFile2, testFile1, testFile2);
assertThat(result).isEqualTo(1);
}
Aggregations