Search in sources :

Example 6 with TestClientInputFile

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

the class InputFileBuilderTest method testCreateWithLanguageSet.

@Test
public void testCreateWithLanguageSet() throws IOException {
    Path path = temp.getRoot().toPath().resolve("file");
    Files.write(path, "test".getBytes(StandardCharsets.ISO_8859_1));
    ClientInputFile file = new TestClientInputFile(path, "file", true, StandardCharsets.ISO_8859_1, "cpp");
    InputFileBuilder builder = new InputFileBuilder(langDetection, metadata);
    SonarLintInputFile inputFile = builder.create(file);
    assertThat(inputFile.language()).isEqualTo("cpp");
    verifyZeroInteractions(langDetection);
}
Also used : FileUtils.toSonarQubePath(org.sonarsource.sonarlint.core.client.api.util.FileUtils.toSonarQubePath) Path(java.nio.file.Path) ClientInputFile(org.sonarsource.sonarlint.core.client.api.common.analysis.ClientInputFile) TestClientInputFile(org.sonarsource.sonarlint.core.TestClientInputFile) TestClientInputFile(org.sonarsource.sonarlint.core.TestClientInputFile) Test(org.junit.Test)

Example 7 with TestClientInputFile

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

the class SonarLintInputFileTest method setUp.

@Before
public void setUp() throws IOException {
    path = temp.newFile().toPath();
    Files.write(path, "test string".getBytes(StandardCharsets.UTF_8));
    inputFile = new TestClientInputFile(path, "file", false, StandardCharsets.UTF_8);
    file = new SonarLintInputFile(inputFile);
}
Also used : TestClientInputFile(org.sonarsource.sonarlint.core.TestClientInputFile) Before(org.junit.Before)

Aggregations

TestClientInputFile (org.sonarsource.sonarlint.core.TestClientInputFile)7 ClientInputFile (org.sonarsource.sonarlint.core.client.api.common.analysis.ClientInputFile)5 Test (org.junit.Test)4 File (java.io.File)2 Path (java.nio.file.Path)2 Before (org.junit.Before)2 InputFile (org.sonar.api.batch.fs.InputFile)2 FileUtils.toSonarQubePath (org.sonarsource.sonarlint.core.client.api.util.FileUtils.toSonarQubePath)2 ArrayList (java.util.ArrayList)1 Issue (org.sonarsource.sonarlint.core.client.api.common.analysis.Issue)1 StandaloneAnalysisConfiguration (org.sonarsource.sonarlint.core.client.api.standalone.StandaloneAnalysisConfiguration)1