use of testutils.TestInputFileBuilder in project sonarlint-core by SonarSource.
the class SensorOptimizerTests method should_optimize_on_language.
@Test
void should_optimize_on_language() {
var descriptor = new DefaultSensorDescriptor().onlyOnLanguages("java", "php");
assertThat(optimizer.shouldExecute(descriptor)).isFalse();
inputFileCache.doAdd(new TestInputFileBuilder("src/Foo.java").setLanguage(Language.JAVA).build());
assertThat(optimizer.shouldExecute(descriptor)).isTrue();
}
use of testutils.TestInputFileBuilder in project sonarlint-core by SonarSource.
the class DefaultAnalysisErrorTests method setUp.
@BeforeEach
void setUp() {
inputFile = new TestInputFileBuilder("src/File.java").build();
textPointer = new DefaultTextPointer(5, 2);
storage = mock(SensorStorage.class);
}
use of testutils.TestInputFileBuilder in project sonarlint-core by SonarSource.
the class SonarLintFileSystemTests method files.
@Test
void files() {
assertThat(fs.inputFiles(fs.predicates().all())).isEmpty();
var inputFile = new TestInputFileBuilder("src/Foo.php").setBaseDir(basedir).setLanguage(Language.PHP).build();
inputFileCache.doAdd(inputFile);
inputFileCache.doAdd(new TestInputFileBuilder("src/Bar.java").setBaseDir(basedir).setLanguage(Language.JAVA).build());
inputFileCache.doAdd(new TestInputFileBuilder("src/Baz.java").setBaseDir(basedir).setLanguage(Language.JAVA).build());
// no language
inputFileCache.doAdd(new TestInputFileBuilder("src/readme.txt").setBaseDir(basedir).build());
// needed for CFamily
assertThat(fs.inputFile(fs.predicates().is(inputFile.file()))).isNotNull();
assertThat(fs.inputFile(fs.predicates().hasURI(new File(basedir.toFile(), "src/Bar.java").toURI()))).isNotNull();
assertThat(fs.inputFile(fs.predicates().hasURI(new File(basedir.toFile(), "does/not/exist").toURI()))).isNull();
assertThat(fs.inputFile(fs.predicates().hasURI(new File(basedir.toFile(), "../src/Bar.java").toURI()))).isNull();
assertThat(fs.files(fs.predicates().all())).hasSize(4);
assertThat(fs.files(fs.predicates().hasLanguage("java"))).hasSize(2);
assertThat(fs.files(fs.predicates().hasLanguage("cobol"))).isEmpty();
assertThat(fs.hasFiles(fs.predicates().all())).isTrue();
assertThat(fs.hasFiles(fs.predicates().hasLanguage("java"))).isTrue();
assertThat(fs.hasFiles(fs.predicates().hasLanguage("cobol"))).isFalse();
assertThat(fs.inputFiles(fs.predicates().all())).hasSize(4);
assertThat(fs.inputFiles(fs.predicates().hasLanguage("php"))).hasSize(1);
assertThat(fs.inputFiles(fs.predicates().hasLanguage("java"))).hasSize(2);
assertThat(fs.inputFiles(fs.predicates().hasLanguage("cobol"))).isEmpty();
assertThat(fs.languages()).containsOnly("java", "php");
}
use of testutils.TestInputFileBuilder in project sonarlint-core by SonarSource.
the class SonarLintFileSystemTests method add_languages.
@Test
void add_languages() {
assertThat(fs.languages()).isEmpty();
inputFileCache.doAdd(new TestInputFileBuilder("src/Foo.php").setLanguage(Language.PHP).build());
inputFileCache.doAdd(new TestInputFileBuilder("src/Bar.java").setLanguage(Language.JAVA).build());
assertThat(fs.languages()).containsOnly("java", "php");
}
use of testutils.TestInputFileBuilder in project sonarlint-core by SonarSource.
the class SonarLintFileSystemTests method input_file_supports_non_indexed_predicates.
@Test
void input_file_supports_non_indexed_predicates() {
inputFileCache.doAdd(new TestInputFileBuilder("src/Bar.java").setLanguage(Language.JAVA).build());
// it would fail if more than one java file
assertThat(fs.inputFile(fs.predicates().hasLanguage("java"))).isNotNull();
}
Aggregations