Search in sources :

Example 1 with TestClientInputFile

use of org.sonarsource.sonarlint.core.client.api.TestClientInputFile in project sonarlint-core by SonarSource.

the class StandaloneAnalysisConfigurationTest method testToString.

@Test
public void testToString() throws Exception {
    Map<String, String> props = new HashMap<>();
    props.put("sonar.java.libraries", "foo bar");
    final Path srcFile1 = temp.newFile().toPath();
    final Path srcFile2 = temp.newFile().toPath();
    final Path srcFile3 = temp.newFile().toPath();
    ClientInputFile inputFile = new TestClientInputFile(temp.getRoot().toPath(), srcFile1, false, StandardCharsets.UTF_8, null);
    ClientInputFile inputFileWithLanguage = new TestClientInputFile(temp.getRoot().toPath(), srcFile2, false, StandardCharsets.UTF_8, "java");
    ClientInputFile testInputFile = new TestClientInputFile(temp.getRoot().toPath(), srcFile3, true, StandardCharsets.UTF_8, "php");
    Path baseDir = temp.newFolder().toPath();
    Path workDir = temp.newFolder().toPath();
    StandaloneAnalysisConfiguration config = new StandaloneAnalysisConfiguration(baseDir, workDir, Arrays.asList(inputFile, inputFileWithLanguage, testInputFile), props);
    assertThat(config.toString()).isEqualTo("[\n" + "  baseDir: " + baseDir.toString() + "\n" + "  workDir: " + workDir.toString() + "\n" + "  extraProperties: {sonar.java.libraries=foo bar}\n" + "  inputFiles: [\n" + "    " + srcFile1.toString() + " (UTF-8)\n" + "    " + srcFile2.toString() + " (UTF-8) [java]\n" + "    " + srcFile3.toString() + " (UTF-8) [test] [php]\n" + "  ]\n" + "]\n");
    assertThat(config.baseDir()).isEqualTo(baseDir);
    assertThat(config.workDir()).isEqualTo(workDir);
    assertThat(config.inputFiles()).containsExactly(inputFile, inputFileWithLanguage, testInputFile);
    assertThat(config.extraProperties()).containsExactly(entry("sonar.java.libraries", "foo bar"));
}
Also used : Path(java.nio.file.Path) HashMap(java.util.HashMap) TestClientInputFile(org.sonarsource.sonarlint.core.client.api.TestClientInputFile) ClientInputFile(org.sonarsource.sonarlint.core.client.api.common.analysis.ClientInputFile) TestClientInputFile(org.sonarsource.sonarlint.core.client.api.TestClientInputFile) Test(org.junit.Test)

Example 2 with TestClientInputFile

use of org.sonarsource.sonarlint.core.client.api.TestClientInputFile in project sonarlint-core by SonarSource.

the class ConnectedAnalysisConfigurationTest method testToString.

@Test
public void testToString() throws Exception {
    Map<String, String> props = new HashMap<>();
    props.put("sonar.java.libraries", "foo bar");
    final Path srcFile1 = temp.newFile().toPath();
    final Path srcFile2 = temp.newFile().toPath();
    ClientInputFile inputFile = new TestClientInputFile(temp.getRoot().toPath(), srcFile1, false, StandardCharsets.UTF_8, null);
    ClientInputFile testInputFile = new TestClientInputFile(temp.getRoot().toPath(), srcFile2, true, StandardCharsets.UTF_8, null);
    Path baseDir = temp.newFolder().toPath();
    Path workDir = temp.newFolder().toPath();
    ConnectedAnalysisConfiguration config = new ConnectedAnalysisConfiguration("foo", baseDir, workDir, Arrays.asList(inputFile, testInputFile), props);
    assertThat(config.toString()).isEqualTo("[\n" + "  moduleKey: foo\n" + "  baseDir: " + baseDir.toString() + "\n" + "  workDir: " + workDir.toString() + "\n" + "  extraProperties: {sonar.java.libraries=foo bar}\n" + "  inputFiles: [\n" + "    " + srcFile1.toString() + " (UTF-8)\n" + "    " + srcFile2.toString() + " (UTF-8) [test]\n" + "  ]\n" + "]\n");
    assertThat(config.baseDir()).isEqualTo(baseDir);
    assertThat(config.workDir()).isEqualTo(workDir);
    assertThat(config.inputFiles()).containsExactly(inputFile, testInputFile);
    assertThat(config.moduleKey()).isEqualTo("foo");
    assertThat(config.extraProperties()).containsExactly(entry("sonar.java.libraries", "foo bar"));
    config = new ConnectedAnalysisConfiguration(null, baseDir, workDir, Arrays.asList(inputFile, testInputFile), props);
    assertThat(config.toString()).isEqualTo("[\n" + "  baseDir: " + baseDir.toString() + "\n" + "  workDir: " + workDir.toString() + "\n" + "  extraProperties: {sonar.java.libraries=foo bar}\n" + "  inputFiles: [\n" + "    " + srcFile1.toString() + " (UTF-8)\n" + "    " + srcFile2.toString() + " (UTF-8) [test]\n" + "  ]\n" + "]\n");
}
Also used : Path(java.nio.file.Path) HashMap(java.util.HashMap) TestClientInputFile(org.sonarsource.sonarlint.core.client.api.TestClientInputFile) ClientInputFile(org.sonarsource.sonarlint.core.client.api.common.analysis.ClientInputFile) TestClientInputFile(org.sonarsource.sonarlint.core.client.api.TestClientInputFile) Test(org.junit.Test)

Aggregations

Path (java.nio.file.Path)2 HashMap (java.util.HashMap)2 Test (org.junit.Test)2 TestClientInputFile (org.sonarsource.sonarlint.core.client.api.TestClientInputFile)2 ClientInputFile (org.sonarsource.sonarlint.core.client.api.common.analysis.ClientInputFile)2