Search in sources :

Example 6 with TestInputFileBuilder

use of testutils.TestInputFileBuilder in project sonarlint-core by SonarSource.

the class SonarLintFileSystemTests method input_file_fails_if_too_many_results.

@Test
void input_file_fails_if_too_many_results() {
    inputFileCache.doAdd(new TestInputFileBuilder("src/Bar.java").setLanguage(Language.JAVA).build());
    inputFileCache.doAdd(new TestInputFileBuilder("src/Baz.java").setLanguage(Language.JAVA).build());
    var thrown = assertThrows(IllegalArgumentException.class, () -> fs.inputFile(fs.predicates().all()));
    assertThat(thrown).hasMessageStartingWith("expected one element");
}
Also used : TestInputFileBuilder(testutils.TestInputFileBuilder) Test(org.junit.jupiter.api.Test)

Example 7 with TestInputFileBuilder

use of testutils.TestInputFileBuilder in project sonarlint-core by SonarSource.

the class SensorOptimizerTests method should_optimize_on_type.

@Test
void should_optimize_on_type() {
    var descriptor = new DefaultSensorDescriptor().onlyOnFileType(InputFile.Type.MAIN);
    assertThat(optimizer.shouldExecute(descriptor)).isFalse();
    inputFileCache.doAdd(new TestInputFileBuilder("tests/FooTest.java").setType(InputFile.Type.TEST).build());
    assertThat(optimizer.shouldExecute(descriptor)).isFalse();
    inputFileCache.doAdd(new TestInputFileBuilder("src/Foo.java").setType(InputFile.Type.MAIN).build());
    assertThat(optimizer.shouldExecute(descriptor)).isTrue();
}
Also used : TestInputFileBuilder(testutils.TestInputFileBuilder) DefaultSensorDescriptor(org.sonarsource.sonarlint.core.analysis.sonarapi.DefaultSensorDescriptor) Test(org.junit.jupiter.api.Test)

Aggregations

TestInputFileBuilder (testutils.TestInputFileBuilder)7 Test (org.junit.jupiter.api.Test)6 DefaultSensorDescriptor (org.sonarsource.sonarlint.core.analysis.sonarapi.DefaultSensorDescriptor)2 File (java.io.File)1 BeforeEach (org.junit.jupiter.api.BeforeEach)1 SensorStorage (org.sonar.api.batch.sensor.internal.SensorStorage)1 DefaultTextPointer (org.sonarsource.sonarlint.core.analysis.container.analysis.filesystem.DefaultTextPointer)1